spee.ch/views/partials/publishForm-Channel.handlebars

65 lines
2.6 KiB
Handlebars
Raw Normal View History

2017-09-27 00:12:47 +02:00
<div class="row">
<div class="column column--3">
2017-09-27 00:12:47 +02:00
<label class="label" for="channel-name-select">Channel:</label>
</div><div class="column column--7">
2017-09-21 01:04:58 +02:00
<div id="input-error-channel-select" class="info-message info-message--failure"></div>
2017-10-03 01:23:09 +02:00
<select type="text" id="channel-name-select" class="select select--primary select--arrow" value="channel" onchange="toggleChannel(event)">
2017-09-27 00:12:47 +02:00
<optgroup>
2017-09-21 01:04:58 +02:00
{{#if user}}
2017-09-29 00:47:55 +02:00
<option value="{{user.channelName}}" >@{{user.userName}}</option>
2017-09-21 01:04:58 +02:00
{{/if}}
2017-09-22 01:03:45 +02:00
<option value="none" >None</option>
2017-09-27 00:12:47 +02:00
</optgroup>
<optgroup>
2017-09-21 01:04:58 +02:00
<option value="login">Login</option>
<option value="new" >New</option>
2017-09-27 00:12:47 +02:00
</optgroup>
2017-09-21 01:04:58 +02:00
</select>
</div>
2017-09-27 00:12:47 +02:00
</div>
2017-09-21 01:04:58 +02:00
<div id="channel-login-details" class="row row--short" hidden="true">
2017-09-27 00:12:47 +02:00
{{> channelLoginForm}}
2017-09-21 01:04:58 +02:00
</div>
<div id="channel-create-details" class="row row--short" hidden="true">
2017-09-27 00:12:47 +02:00
{{> channelCreationForm}}
</div>
2017-09-21 01:04:58 +02:00
<script src="/assets/js/authFunctions.js"></script>
<script type="text/javascript">
2017-09-29 00:47:55 +02:00
function toggleChannel (event) {
const createChannelTool = document.getElementById('channel-create-details');
const loginToChannelTool = document.getElementById('channel-login-details');
const selectedOption = event.target.selectedOptions[0].value;
const urlChannel = document.getElementById('url-channel');
console.log('toggle event triggered');
if (selectedOption === 'new') {
// show/hide the login and new channel forms
createChannelTool.hidden = false;
loginToChannelTool.hidden = true;
// update URL
urlChannel.innerText = '';
} else if (selectedOption === 'login') {
// show/hide the login and new channel forms
loginToChannelTool.hidden = false;
createChannelTool.hidden = true;
// update URL
urlChannel.innerText = '';
} else {
2017-09-29 00:47:55 +02:00
// hide the login and new channel forms
loginToChannelTool.hidden = true;
createChannelTool.hidden = true;
hideError(document.getElementById('input-error-channel-select'));
// update URL
if (selectedOption === 'none'){
console.log('selected option: none');
urlChannel.innerText = '';
} else {
console.log('selected option:', selectedOption);
// retrieve short url from db
urlChannel.innerText = `{{user.channelName}}:{{user.shortChannelId}}/`;
2017-09-29 00:47:55 +02:00
}
}
2017-09-29 00:47:55 +02:00
}
2017-09-21 01:04:58 +02:00
</script>