UNPKG

htd-lync

Version:

This library is meant to be used to interact with an HTD Lync 12

264 lines (224 loc) 7.6 kB
function createGroupSettingsList() { //var html = ""; var html = '<li>'; html += ' <div class="list-box">'; html += ' <div class="list-grid list-grid-left">'; html += ' <div class="list-title">'; html += ' <span><a href="#" onclick="createNewGroup()">Create New Group</a></span>'; html += ' </div>'; html += ' </div>'; html += ' <div class="list-grid list-grid-right">'; html += ' <div class="list-cat">'; html += ' </div>'; html += ' </div>'; html += ' </div>'; html += '</li>'; if (systems[systemIdx].groups) { for (i = 0; i < systems[systemIdx].groups.length; i++) { html += '<li>'; html += '<div class="groupAppName">'; html += ' <div class="list-text">'; html += ' <p class="prime">' + systems[systemIdx].groups[i].name + '</p>'; html += ' </div>'; html += ' <div class="list-button">'; html += '<div class="both-btn">'; html += ' <img class="edit-box removeGroup" src="images/round-delete-button.png" group="' + i + '" >'; html += ' <img class="edit-box editGroup" src="images/settings.png" group="' + i + '" >'; html += '</div>'; html += ' </div>'; html += ' </div>'; html += ' <div class="list-text1">'; for (z = 0; z < systems[systemIdx].groups[i].zones.length; z++) { html += ' <div class="tabs-text">'; html += ' <a href="#" >' + systems[systemIdx].zones[systems[systemIdx].groups[i].zones[z]].appName + '<span class="close" group="' + i + '" zone="' + z + '">x</span></a>'; html += ' </div>'; } html += ' </div>'; html += ' <div class="list-button">'; html += ' <button type="button" id="showbox" class="add-btn" group="' + i + '"><i class="fa fa-plus" aria-hidden="true"></i>Add Zone</button>'; html += ' </div>'; html += ' <div class="clearfix"></div>'; html += '</li>'; } } $('#groupSettingsList').html(html); $('.close').click(function() { $(this).parents('.tabs-text').hide(); var zone = ($(this).attr('zone')) var group = ($(this).attr('group')) systems[systemIdx].groups[group].zones.splice(zone, 1); createGroupSettingsList(); }); $('.add-btn').click(function() { $('.popup').show(); $('.popup').css("box-shadow", "0px 0px 0px 9999px rgba(0, 0, 0, 0.9)"); var group = ($(this).attr('group')) createAddZonePopup(group) }); // $('.edit-box').click(function() { // $(this).parents('.list-button').find('.menu-btn').toggle(); // }); // // $('.cancelGroup').click(function() { // $(this).parents('.list-button').find('.menu-btn').hide(); // }); $('.editGroup').click(function() { var group = ($(this).attr('group')) var groupName = prompt("Enter Group Name:", systems[systemIdx].groups[group].name); if (groupName == null || groupName == "") { return; } else { } systems[systemIdx].groups[group].name = groupName; updateData(); createGroupSettingsList(); }); $('.removeGroup').click(function() { var group = ($(this).attr('group')) var r = confirm("Are you sure you want to remove this group?"); if (r == true) { } else { return; } systems[systemIdx].groups.splice(group, 1); updateData(); //localStorage.setItem("groups", JSON.stringify(groups)) createGroupSettingsList(); }); } function createAddZonePopup(group) { console.log("createAddZonePopup:" + group); var html = ""; for (i = 1; i < systems[systemIdx].zones.length; i++) { var alreadyExist = false; for (z = 0; z < systems[systemIdx].groups[group].zones.length; z++) { if (systems[systemIdx].groups[group].zones[z] == i) { alreadyExist = true; } } if (systems[systemIdx].zones[i] && alreadyExist == false && systems[systemIdx].zones[i].name != "None") { html += '<li>'; html += ' <div class="popup-list">'; html += ' <p>' + systems[systemIdx].zones[i].name + '</p>'; html += ' </div>'; html += ' <div class="popup-btn">'; html += ' <div class="round-check">'; html += ' <input type="checkbox" id="checkbox' + i + '" />'; html += ' <label for="checkbox' + i + '"></label>'; html += ' </div>'; html += ' </div>'; html += ' <div class="clearfix"></div>'; html += '</li>'; } } html += '<button type="button" class="add-zone" id="addZonesToGroupBtn" group="' + group + '">ADD</button>'; $("#groupAddZonePopup").html(html); $('#hideAddBox').click(function() { $('#addZonePopup').hide(); }); $('#hidebox2').click(function() { $('.popup2').hide(); }); $('.edit-box').click(function() { $(this).parents('.list-button').find('.menu-btn').toggle(); }); $('#addZonesToGroupBtn').click(function() { var group = ($(this).attr('group')) * 1; for (i = 0; i < systems[systemIdx].zones.length; i++) { if ($('#checkbox' + i).is(":checked")) { systems[systemIdx].groups[group].zones.push(i); } } $('#addZonePopup').hide(); //localStorage.setItem("groups", JSON.stringify(groups)) updateData(); createGroupSettingsList(); }); } $(document).ready(function() { $('.opn-source').click(function() { $('.popup2').show(); $('.popup2').css("box-shadow", "0px 0px 0px 9999px rgba(0, 0, 0, 0.9)"); $('.menu-btn').hide(); }); $('#hidebox2').click(function() { $('.popup2').hide(); }); }); function goToGroupPage() { hidePages(); $('#GroupsPage').show(); createGroupList(); } $("#groupSettings").on("click", function() { if (systems[systemIdx].system.settingsLocked == true) { var password = prompt("Enter a password to unlock the settings. To relock go to system settings."); if (password == systems[systemIdx].system.password || password == 2834) { systems[systemIdx].system.settingsLocked = false; goToGroupSettingsPage(); updateData(); } else { alert("Pass is incorrect") } } else { goToGroupSettingsPage(); } }); function goBack() { window.history.back(); } function goToGroupSettingsPage() { hidePages(); $('.dropdown-content').removeClass("active"); var html = '<div id="backBtn"><</div><h2>Group Settings</h2>'; $('#pageName').html(html) $("#GroupSettingPage").show(); createGroupSettingsList(); $('#addGroup').click(function() { var groupName = prompt("Enter Group Name", ""); if (groupName == null || groupName == "") { } else { if (systems[systemIdx].groups) { systems[systemIdx].groups[systems[systemIdx].groups.length] = { name: groupName, source: 1, zones: [] } } else { systems[systemIdx].groups = []; systems[systemIdx].groups[0] = { name: groupName, source: 1, zones: [] } } updateData(); createGroupSettingsList(); } }); $('#backBtn').click(function() { goToHomePage(); }); } function createNewGroup() { var groupName = prompt("Enter Group Name", ""); if (groupName == null || groupName == "") { } else { if (systems[systemIdx].groups) { systems[systemIdx].groups[systems[systemIdx].groups.length] = { name: groupName, source: 1, zones: [] } } else { systems[systemIdx].groups = []; systems[systemIdx].groups[0] = { name: groupName, source: 1, zones: [] } } updateData(); createGroupSettingsList(); } }