diff options
author | Jannik Schönartz | 2017-03-15 12:54:29 +0100 |
---|---|---|
committer | Jannik Schönartz | 2017-03-15 12:54:29 +0100 |
commit | e92e4a11cd2771338db823e8aadb5a9c74957808 (patch) | |
tree | 4010849d0a02961e903843733a54013259624459 /modules-available | |
parent | frontend: fixed loading bar in mode 4, mode 4 now supports up to 4 rooms, fon... (diff) | |
download | slx-admin-e92e4a11cd2771338db823e8aadb5a9c74957808.tar.gz slx-admin-e92e4a11cd2771338db823e8aadb5a9c74957808.tar.xz slx-admin-e92e4a11cd2771338db823e8aadb5a9c74957808.zip |
Locationinfo: Reformat code.
Diffstat (limited to 'modules-available')
8 files changed, 708 insertions, 672 deletions
diff --git a/modules-available/locationinfo/api.inc.php b/modules-available/locationinfo/api.inc.php index a0f65cdb..caa9a6ec 100644 --- a/modules-available/locationinfo/api.inc.php +++ b/modules-available/locationinfo/api.inc.php @@ -2,7 +2,8 @@ HandleParameters(); -function HandleParameters() { +function HandleParameters() +{ $getAction = Request::get('action', 0, 'string'); if ($getAction == "roominfo") { @@ -35,16 +36,18 @@ function HandleParameters() { } } -function filterIdList($roomids) { +function filterIdList($roomids) +{ $idList = explode(',', $roomids); $filteredIdList = array_filter($idList, 'is_numeric'); - $filteredIdList = array_unique($filteredIdList); + $filteredIdList = array_unique($filteredIdList); $filteredIdList = filterHiddenRoom($filteredIdList); return $filteredIdList; } -function filterHiddenRoom($idArray) { +function filterHiddenRoom($idArray) +{ $filteredArray = array(); if (!empty($idArray)) { $query = "SELECT locationid, hidden FROM `location_info` WHERE locationid IN ("; @@ -53,7 +56,7 @@ function filterHiddenRoom($idArray) { $dbquery = Database::simpleQuery($query); - while($dbresult=$dbquery->fetch(PDO::FETCH_ASSOC)) { + while ($dbresult = $dbquery->fetch(PDO::FETCH_ASSOC)) { if ($dbresult['hidden'] == false) { $filteredArray[] = $dbresult['locationid']; } @@ -65,14 +68,15 @@ function filterHiddenRoom($idArray) { // ########## <Roominfo> ########## -function getRoomInfo($idList, $coords = false) { +function getRoomInfo($idList, $coords = false) +{ $coordinates = (string)$coords; $dbresult = array(); if (!empty($idList)) { // Build SQL Query for multiple ids. - $query = "SELECT m.locationid, machineuuid, position, logintime, lastseen, lastboot FROM `machine` as m LEFT JOIN location_info AS l ON l.locationid = m.locationid WHERE l.hidden = 0 AND m.locationid IN ("; + $query = "SELECT m.locationid, machineuuid, position, logintime, lastseen, lastboot FROM `machine` AS m LEFT JOIN location_info AS l ON l.locationid = m.locationid WHERE l.hidden = 0 AND m.locationid IN ("; $query .= implode(",", $idList); $query .= ")"; @@ -87,7 +91,7 @@ function getRoomInfo($idList, $coords = false) { $pclist = array(); // Fetch db data. - while($dbdata=$dbquery->fetch(PDO::FETCH_ASSOC)) { + while ($dbdata = $dbquery->fetch(PDO::FETCH_ASSOC)) { // Set the id if the locationid changed. if (!isset($dbresult[$dbdata['locationid']])) { @@ -103,8 +107,7 @@ function getRoomInfo($idList, $coords = false) { if (isset($position['overlays'])) { $pc['overlay'] = $position['overlays']; - } - else { + } else { $pc['overlay'] = array(); } } @@ -118,11 +121,13 @@ function getRoomInfo($idList, $coords = false) { // The array keys are only used for the isset -> Return only the values. return json_encode(array_values($dbresult), true); } + // ########## </Roominfo> ########### // ########## <Openingtime> ########## -function getOpeningTime($idList) { +function getOpeningTime($idList) +{ $dbresult = array(); if (!empty($idList)) { @@ -134,7 +139,7 @@ function getOpeningTime($idList) { // Execute query. $dbquery = Database::simpleQuery($query); $handledIds = array(); - while($dbdata=$dbquery->fetch(PDO::FETCH_ASSOC)) { + while ($dbdata = $dbquery->fetch(PDO::FETCH_ASSOC)) { $data['id'] = $dbdata['locationid']; $data['openingtime'] = json_decode($dbdata['openingtime'], true); $handledIds[] = $data['id']; @@ -151,7 +156,7 @@ function getOpeningTime($idList) { } // Go through the db entrys [id] = id; [openingtime] = e.g. [{"days":["Saturday","Sunday"],"openingtime":"12:32","closingtime":"14:35"}] - foreach($dbresult as $entry) { + foreach ($dbresult as $entry) { $tmp = array(); // Get the parents time if there is no openingtime defined. if (count($entry['openingtime']) == 0) { @@ -168,12 +173,13 @@ function getOpeningTime($idList) { } // Format the openingtime in the frontend needed format. -function formatOpeningtime($openingtime) { - $weekarray = array ("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"); +function formatOpeningtime($openingtime) +{ + $weekarray = array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"); foreach ($weekarray as $d) { $array = array(); foreach ($openingtime as $opt) { - foreach($opt['days'] as $val) { + foreach ($opt['days'] as $val) { if ($val == $d) { $arr = array(); @@ -188,7 +194,7 @@ function formatOpeningtime($openingtime) { $array[] = $arr; } } - if(!empty($array)) { + if (!empty($array)) { $result[$d] = $array; } } @@ -196,7 +202,8 @@ function formatOpeningtime($openingtime) { return $result; } -function getOpeningTimesFromParent($locationID) { +function getOpeningTimesFromParent($locationID) +{ // Get parent location id. $dbquery = Database::queryFirst("SELECT parentlocationid FROM `location` WHERE locationid = :locationID", array('locationID' => $locationID)); $parentlocationid = 0; @@ -216,8 +223,9 @@ function getOpeningTimesFromParent($locationID) { } } -function createBasicClosingTime() { - $weekarray = array ("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"); +function createBasicClosingTime() +{ + $weekarray = array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"); $array = array(); foreach ($weekarray as $d) { $a = array(); @@ -234,8 +242,9 @@ function createBasicClosingTime() { // ########## </Openingtime> ########## -function getConfig($locationID) { - $dbresult = Database::queryFirst("SELECT l.locationname, li.config, li.serverroomid, s.servertype, s.serverurl FROM `location_info` AS li +function getConfig($locationID) +{ + $dbresult = Database::queryFirst("SELECT l.locationname, li.config, li.serverroomid, s.servertype, s.serverurl FROM `location_info` AS li RIGHT JOIN `location` AS l ON l.locationid=li.locationid LEFT JOIN `setting_location_info` AS s ON s.serverid=li.serverid WHERE l.locationid=:locationID", array('locationID' => $locationID)); @@ -246,18 +255,19 @@ function getConfig($locationID) { $date = getdate(); $config['time'] = $date['year'] . "-" . $date['mon'] . "-" . $date['mday'] . " " . $date['hours'] . ":" . $date['minutes'] . ":" . $date['seconds']; - if($dbresult['servertype'] === "Frontend") { + if ($dbresult['servertype'] === "Frontend") { $config['calendarqueryurl'] = $dbresult['serverurl'] . "/" . $dbresult['serverroomid'] . ".json"; } if (empty($config)) { echo json_encode(array()); } else { - echo json_encode($config, JSON_UNESCAPED_SLASHES); + echo json_encode($config, JSON_UNESCAPED_SLASHES); } } -function getPcStates($idList) { +function getPcStates($idList) +{ $pcStates = array(); $roominfoList = json_decode(getRoomInfo($idList), true); @@ -271,11 +281,11 @@ function getPcStates($idList) { foreach ($roomInfo['computer'] as $computer) { if ($computer['pcState'] == 0) { $idle++; - } elseif($computer['pcState'] == 1) { + } elseif ($computer['pcState'] == 1) { $occupied++; - } elseif($computer['pcState'] == 2) { + } elseif ($computer['pcState'] == 2) { $off++; - } elseif($computer['pcState'] == 3) { + } elseif ($computer['pcState'] == 3) { $broken++; } } @@ -289,7 +299,8 @@ function getPcStates($idList) { return json_encode($pcStates); } -function getRoomTree($idList) { +function getRoomTree($idList) +{ $roomTree = array(); $filteredIdList = array(); foreach ($idList as $id) { @@ -307,12 +318,13 @@ function getRoomTree($idList) { return json_encode($roomTree); } -function getChildsRecursive($id, &$filteredIdList) { +function getChildsRecursive($id, &$filteredIdList) +{ $dbquery = Database::simpleQuery("SELECT locationid, locationname FROM `location` WHERE parentlocationid=:locationID", array('locationID' => $id)); $array = array(); $dbarray = array(); - while($dbresult=$dbquery->fetch(PDO::FETCH_ASSOC)) { + while ($dbresult = $dbquery->fetch(PDO::FETCH_ASSOC)) { $dbarray[] = $dbresult; } foreach ($dbarray as $db) { @@ -332,13 +344,14 @@ function getChildsRecursive($id, &$filteredIdList) { } // ########## <Calendar> ########### -function getCalendar($idList) { +function getCalendar($idList) +{ $serverList = array(); if (!empty($idList)) { //// Build SQL query for multiple ids. - $query = "SELECT locationid, l.serverid AS serverid, serverurl, servertype, credentials FROM `location_info` as l LEFT JOIN setting_location_info as s ON s.serverid = l.serverid WHERE locationid IN ("; + $query = "SELECT locationid, l.serverid AS serverid, serverurl, servertype, credentials FROM `location_info` AS l LEFT JOIN setting_location_info AS s ON s.serverid = l.serverid WHERE locationid IN ("; $query .= implode(",", $idList); @@ -348,7 +361,7 @@ function getCalendar($idList) { $first = true; $lastservertype = ""; - while($dbresult=$dbquery->fetch(PDO::FETCH_ASSOC)) { + while ($dbresult = $dbquery->fetch(PDO::FETCH_ASSOC)) { if (!isset($serverList[$dbresult['serverid']])) { $serverList[$dbresult['serverid']] = array('credentials' => json_decode($dbresult['credentials'], true), 'url' => $dbresult['serverurl'], 'type' => $dbresult['servertype'], 'idlist' => array()); } @@ -367,9 +380,9 @@ function getCalendar($idList) { if ($calendarFromBackend === false || $setCred === false) { $error['timestamp'] = time(); $error['error'] = $serverInstance->getError(); - Database::exec("UPDATE `setting_location_info` Set error=:error WHERE serverid=:id", array('id' => $serverid, 'error' => json_encode($error, true))); + Database::exec("UPDATE `setting_location_info` SET error=:error WHERE serverid=:id", array('id' => $serverid, 'error' => json_encode($error, true))); } else { - Database::exec("UPDATE `setting_location_info` Set error=NULL WHERE serverid=:id", array('id' => $serverid)); + Database::exec("UPDATE `setting_location_info` SET error=NULL WHERE serverid=:id", array('id' => $serverid)); } if (is_array($calendarFromBackend)) { foreach ($calendarFromBackend as $key => $value) { diff --git a/modules-available/locationinfo/inc/locationinfo.inc.php b/modules-available/locationinfo/inc/locationinfo.inc.php index 7ef06f8b..02a7e2c1 100644 --- a/modules-available/locationinfo/inc/locationinfo.inc.php +++ b/modules-available/locationinfo/inc/locationinfo.inc.php @@ -11,14 +11,14 @@ class LocationInfo * [2] = OFF * [3] = 10 days offline (BROKEN?) */ - // TODO USE STATE NAME instead of numbers + // TODO USE STATE NAME instead of numbers $logintime = (int)$pc['logintime']; $lastseen = (int)$pc['lastseen']; $lastboot = (int)$pc['lastboot']; $NOW = time(); - if ($NOW - $lastseen > 14*86400) { + if ($NOW - $lastseen > 14 * 86400) { return 3; } elseif (($NOW - $lastseen > 610) || $lastboot === 0) { return 2; diff --git a/modules-available/locationinfo/install.inc.php b/modules-available/locationinfo/install.inc.php index a371ad02..88d69d3a 100644 --- a/modules-available/locationinfo/install.inc.php +++ b/modules-available/locationinfo/install.inc.php @@ -3,13 +3,13 @@ $res = array(); $res[] = tableCreate('location_info', ' - `locationid` INT(11) NOT NULL, - `serverid` INT(11) NOT NULL, + `locationid` INT(11) NOT NULL, + `serverid` INT(11) NOT NULL, `serverroomid` VARCHAR(2000), `hidden` BOOLEAN NOT NULL DEFAULT 0, `openingtime` VARCHAR(2000), `config` VARCHAR(2000), - `calendar` VARCHAR(2000), + `calendar` VARCHAR(2000), `lastcalendarupdate` INT(11) NOT NULL DEFAULT 0, PRIMARY KEY (`locationid`) '); @@ -19,85 +19,85 @@ $res[] = tableCreate('setting_location_info', ' `servername` VARCHAR(2000) NOT NULL, `serverurl` VARCHAR(2000) NOT NULL, `servertype` VARCHAR(100) NOT NULL, - `credentials` VARCHAR(2000), + `credentials` VARCHAR(2000), `error` VARCHAR(2000), PRIMARY KEY (`serverid`) '); // Create response for browser if (!tableHasColumn('setting_location_info', 'error')) { - $ret = Database::exec("ALTER TABLE `setting_location_info` ADD `error` VARCHAR(2000) AFTER `credentials`"); - if ($ret === false) { - finalResponse(UPDATE_FAILED, 'Adding column error failed: ' . Database::lastError()); - } - $res[] = UPDATE_DONE; + $ret = Database::exec("ALTER TABLE `setting_location_info` ADD `error` VARCHAR(2000) AFTER `credentials`"); + if ($ret === false) { + finalResponse(UPDATE_FAILED, 'Adding column error failed: ' . Database::lastError()); + } + $res[] = UPDATE_DONE; } if (!tableHasColumn('setting_location_info', 'credentials')) { - $ret = Database::exec("ALTER TABLE `setting_location_info` ADD `credentials` VARCHAR(2000) AFTER `servertype`"); - if ($ret === false) { - finalResponse(UPDATE_FAILED, 'Adding column credentials failed: ' . Database::lastError()); - } - $res[] = UPDATE_DONE; + $ret = Database::exec("ALTER TABLE `setting_location_info` ADD `credentials` VARCHAR(2000) AFTER `servertype`"); + if ($ret === false) { + finalResponse(UPDATE_FAILED, 'Adding column credentials failed: ' . Database::lastError()); + } + $res[] = UPDATE_DONE; } if (tableHasColumn('setting_location_info', 'login')) { - $ret = Database::exec("ALTER TABLE `setting_location_info` DROP COLUMN login"); - if ($ret === false) { - finalResponse(UPDATE_FAILED, 'Dropping column login failed: ' . Database::lastError()); - } - $res[] = UPDATE_DONE; + $ret = Database::exec("ALTER TABLE `setting_location_info` DROP COLUMN login"); + if ($ret === false) { + finalResponse(UPDATE_FAILED, 'Dropping column login failed: ' . Database::lastError()); + } + $res[] = UPDATE_DONE; } if (tableHasColumn('setting_location_info', 'passwd')) { - $ret = Database::exec("ALTER TABLE `setting_location_info` DROP COLUMN passwd"); - if ($ret === false) { - finalResponse(UPDATE_FAILED, 'Dropping column passwd failed: ' . Database::lastError()); - } - $res[] = UPDATE_DONE; + $ret = Database::exec("ALTER TABLE `setting_location_info` DROP COLUMN passwd"); + if ($ret === false) { + finalResponse(UPDATE_FAILED, 'Dropping column passwd failed: ' . Database::lastError()); + } + $res[] = UPDATE_DONE; } if (tableHasColumn('location_info', 'serverroomid')) { - $ret = Database::exec("ALTER TABLE `location_info` MODIFY serverroomid VARCHAR(2000)"); - if ($ret === false) { - finalResponse(UPDATE_FAILED, 'Updateing column serverroomid failed: ' . Database::lastError()); - } - $res[] = UPDATE_DONE; + $ret = Database::exec("ALTER TABLE `location_info` MODIFY serverroomid VARCHAR(2000)"); + if ($ret === false) { + finalResponse(UPDATE_FAILED, 'Updateing column serverroomid failed: ' . Database::lastError()); + } + $res[] = UPDATE_DONE; } if (tableHasColumn('location_info', 'openingtime')) { - $ret = Database::exec("ALTER TABLE `location_info` MODIFY openingtime VARCHAR(2000)"); - if ($ret === false) { - finalResponse(UPDATE_FAILED, 'Updateing column openingtime failed: ' . Database::lastError()); - } - $res[] = UPDATE_DONE; + $ret = Database::exec("ALTER TABLE `location_info` MODIFY openingtime VARCHAR(2000)"); + if ($ret === false) { + finalResponse(UPDATE_FAILED, 'Updateing column openingtime failed: ' . Database::lastError()); + } + $res[] = UPDATE_DONE; } if (tableHasColumn('location_info', 'config')) { - $ret = Database::exec("ALTER TABLE `location_info` MODIFY config VARCHAR(2000)"); - if ($ret === false) { - finalResponse(UPDATE_FAILED, 'Updateing column config failed: ' . Database::lastError()); - } - $res[] = UPDATE_DONE; + $ret = Database::exec("ALTER TABLE `location_info` MODIFY config VARCHAR(2000)"); + if ($ret === false) { + finalResponse(UPDATE_FAILED, 'Updateing column config failed: ' . Database::lastError()); + } + $res[] = UPDATE_DONE; } if (tableHasColumn('location_info', 'calendar')) { - $ret = Database::exec("ALTER TABLE `location_info` MODIFY calendar VARCHAR(2000)"); - if ($ret === false) { - finalResponse(UPDATE_FAILED, 'Updateing column calendar failed: ' . Database::lastError()); - } - $res[] = UPDATE_DONE; + $ret = Database::exec("ALTER TABLE `location_info` MODIFY calendar VARCHAR(2000)"); + if ($ret === false) { + finalResponse(UPDATE_FAILED, 'Updateing column calendar failed: ' . Database::lastError()); + } + $res[] = UPDATE_DONE; } if (tableHasColumn('location_info', 'lastcalendarupdate')) { - $ret = Database::exec("ALTER TABLE `location_info` MODIFY lastcalendarupdate INT(11) NOT NULL DEFAULT 0"); - if ($ret === false) { - finalResponse(UPDATE_FAILED, 'Updateing column lastcalendarupdate failed: ' . Database::lastError()); - } - $res[] = UPDATE_DONE; + $ret = Database::exec("ALTER TABLE `location_info` MODIFY lastcalendarupdate INT(11) NOT NULL DEFAULT 0"); + if ($ret === false) { + finalResponse(UPDATE_FAILED, 'Updateing column lastcalendarupdate failed: ' . Database::lastError()); + } + $res[] = UPDATE_DONE; } -if(tableExists('locationinfo')) { +if (tableExists('locationinfo')) { $ret = Database::exec("DROP TABLE `locationinfo`"); if ($ret === false) { finalResponse(UPDATE_FAILED, 'Droping table locationinfo failed: ' . Database::lastError()); diff --git a/modules-available/locationinfo/lang/de/template-tags.json b/modules-available/locationinfo/lang/de/template-tags.json index f7094cee..5525dec2 100644 --- a/modules-available/locationinfo/lang/de/template-tags.json +++ b/modules-available/locationinfo/lang/de/template-tags.json @@ -1,24 +1,20 @@ { "lang_mainHeader": "Infoscreen", - "lang_locationName": "Name", "lang_locationID": "ID", "lang_locationIsHidden": "Versteckt", "lang_locationInUse": "In Benutzung / Gesamt", "lang_locationSettings": "Einstellungen", "lang_locationConfig": "Config", - "lang_pcID": "ID", "lang_pcIP": "IP", "lang_pcX": "X", "lang_pcY": "Y", "lang_pcState": "PC Status", - "lang_day": "Tag", "lang_openingTime": "Öffnungszeit", "lang_closingTime": "Schließungszeit", "lang_deleteAll": "Alles Löschen", - "lang_shortMonday": "Mo", "lang_shortTuesday": "Di", "lang_shortWednesday": "Mi", @@ -31,7 +27,6 @@ "lang_saturday": "Samstag", "lang_sunday": "Sonntag", "lang_expertMode": "Experten Modus", - "lang_language": "Sprache", "lang_languageEn": "en", "lang_languageDe": "de", diff --git a/modules-available/locationinfo/templates/config.html b/modules-available/locationinfo/templates/config.html index 5e221756..79d6f085 100644 --- a/modules-available/locationinfo/templates/config.html +++ b/modules-available/locationinfo/templates/config.html @@ -1,192 +1,199 @@ <div> - <form method="post" action="?do=locationinfo" id="configForm"> - <input type="hidden" name="token" value="{{token}}"> - <input type="hidden" name="action" value="updateConfig"> - <input type="hidden" name="id" value="{{id}}"> - - - <div style="float: left;"> - <Label>{{lang_server}}</Label><br> - <select name="serverid"> - {{#serverlist}} - <option id="serverOption-{{sid}}" value="{{sid}}">{{sname}}</option> - {{/serverlist}} - </select> - </div> - - <div style="float: left; margin-left: 15px;"> - <Label>{{lang_serverRoomId}}</Label><br> - <input name="serverroomid" id="serverroomid" value="{{serverroomid}}" style="width: 250px; text-align: center;"></input> - </div> - - - <br><br><br><br> - - <div style="float: left;"> - <Label>{{lang_language}}</Label><br> - <select name="language"> - <option value="en" id="en">{{lang_languageEn}}</option> - <option value="de" id="de">{{lang_languageDe}}</option> - <option value="pt" id="pt">{{lang_languagePt}}</option> - </select> - </div> - <div style="float: left; margin-left: 15px;"> - <Label>{{lang_mode}}</Label><br> - <select name="mode" onchange="vertical_cb(this.value);"> - <option value="1" id="mode1">{{lang_mode1}}</option> - <option value="2" id="mode2">{{lang_mode2}}</option> - <option value="3" id="mode3">{{lang_mode3}}</option> - <option value="4" id="mode4">{{lang_mode4}}</option> - </select> - </div> - <div style="float: left; margin-left: 15px;"> - <input name="vertical" id="cb_vertical" type="checkbox"/> {{lang_vertical}}<br> - <input name="eco" id="cb_eco" type="checkbox"/> {{lang_ecoMode}}<br> - <input name="autoscale" id="cb_autoScale" type="checkbox"/> {{lang_autoScale}} - </div> - - <div style="float: left; margin-left: 15px;"> - <Label data-toggle="tooltip" title="{{lang_daysToShowTooltip}}">{{lang_daysToShow}}</Label><br> - <select name="daystoshow"> - <option value="1" id="day1">1</option> - <option value="2" id="day2">2</option> - <option value="3" id="day3">3</option> - <option value="4" id="day4">4</option> - <option value="5" id="day5">5</option> - <option value="6" id="day6">6</option> - <option value="7" id="day7">7</option> - </select> - </div> - - <div style="float: left; margin-left: 15px;"> - <Label>{{lang_rotation}}</Label><br> - <select name="rotation"> - <option value="0" id="rotation0">{{lang_rotation0}}</option> - <option value="3" id="rotation3">{{lang_rotation3}}</option> - <option value="2" id="rotation2">{{lang_rotation2}}</option> - <option value="1" id="rotation1">{{lang_rotation1}}</option> - </select> - </div> - - <br><br><br><br> - - <Label data-toggle="tooltip" title="{{lang_scaleTooltip}}">{{lang_scale}}</Label><br> - <span id="scale">50 %</span><input name="scale" id="sl_scale" type="range" step="1" min="10" max="90" value="50" style="width: 300px;" oninput="showScaleValue(this.value)"/> - - <br><br> - - <Label data-toggle="tooltip" title="{{lang_switchTimeTooltip}}">{{lang_switchTime}}</Label><br> - <span id="switch">20 {{lang_sec}}</span><input name="switchtime" id="sl_switch" type="range" step="1" min="1" max="120" value="20" style="width: 300px;" oninput="showSwitchValue(this.value)"/> - - <br><br> - - <div> - <div style="float: left;"> - <Label data-toggle="tooltip" title="{{lang_calupdateTooltip}}">{{lang_calupdate}}</Label><br> - <input id="updateCalendar" name="calupdate" type="number" style="width: 50px; text-align: center;" min="0" max="1440"/> {{lang_min}} - </div> - <div style="float: left; margin-left: 15px;"> - <Label data-toggle="tooltip" title="{{lang_roomupdateTooltip}}">{{lang_roomupdate}}</Label><br> - <input id="updateRoom" name="roomupdate" type="number" style="width: 50px; text-align: center;" min="0" max="86400"/> {{lang_sec}} - </div> - <div style="float: left; margin-left: 15px;"> - <Label data-toggle="tooltip" title="{{lang_configupdateTooltip}}">{{lang_configupdate}}</Label><br> - <input id="updateConfig" name="configupdate" type="number" style="width: 50px; text-align: center;" min="0" max="1440"/> {{lang_min}} - </div> - </div> - - <br><br><br><br> - - <button type="submit" class="btn btn-primary">{{lang_save}}</button> - - </form> + <form method="post" action="?do=locationinfo" id="configForm"> + <input type="hidden" name="token" value="{{token}}"> + <input type="hidden" name="action" value="updateConfig"> + <input type="hidden" name="id" value="{{id}}"> + + + <div style="float: left;"> + <Label>{{lang_server}}</Label><br> + <select name="serverid"> + {{#serverlist}} + <option id="serverOption-{{sid}}" value="{{sid}}">{{sname}}</option> + {{/serverlist}} + </select> + </div> + + <div style="float: left; margin-left: 15px;"> + <Label>{{lang_serverRoomId}}</Label><br> + <input name="serverroomid" id="serverroomid" value="{{serverroomid}}" + style="width: 250px; text-align: center;"></input> + </div> + + + <br><br><br><br> + + <div style="float: left;"> + <Label>{{lang_language}}</Label><br> + <select name="language"> + <option value="en" id="en">{{lang_languageEn}}</option> + <option value="de" id="de">{{lang_languageDe}}</option> + <option value="pt" id="pt">{{lang_languagePt}}</option> + </select> + </div> + <div style="float: left; margin-left: 15px;"> + <Label>{{lang_mode}}</Label><br> + <select name="mode" onchange="vertical_cb(this.value);"> + <option value="1" id="mode1">{{lang_mode1}}</option> + <option value="2" id="mode2">{{lang_mode2}}</option> + <option value="3" id="mode3">{{lang_mode3}}</option> + <option value="4" id="mode4">{{lang_mode4}}</option> + </select> + </div> + <div style="float: left; margin-left: 15px;"> + <input name="vertical" id="cb_vertical" type="checkbox"/> {{lang_vertical}}<br> + <input name="eco" id="cb_eco" type="checkbox"/> {{lang_ecoMode}}<br> + <input name="autoscale" id="cb_autoScale" type="checkbox"/> {{lang_autoScale}} + </div> + + <div style="float: left; margin-left: 15px;"> + <Label data-toggle="tooltip" title="{{lang_daysToShowTooltip}}">{{lang_daysToShow}}</Label><br> + <select name="daystoshow"> + <option value="1" id="day1">1</option> + <option value="2" id="day2">2</option> + <option value="3" id="day3">3</option> + <option value="4" id="day4">4</option> + <option value="5" id="day5">5</option> + <option value="6" id="day6">6</option> + <option value="7" id="day7">7</option> + </select> + </div> + + <div style="float: left; margin-left: 15px;"> + <Label>{{lang_rotation}}</Label><br> + <select name="rotation"> + <option value="0" id="rotation0">{{lang_rotation0}}</option> + <option value="3" id="rotation3">{{lang_rotation3}}</option> + <option value="2" id="rotation2">{{lang_rotation2}}</option> + <option value="1" id="rotation1">{{lang_rotation1}}</option> + </select> + </div> + + <br><br><br><br> + + <Label data-toggle="tooltip" title="{{lang_scaleTooltip}}">{{lang_scale}}</Label><br> + <span id="scale">50 %</span><input name="scale" id="sl_scale" type="range" step="1" min="10" max="90" value="50" + style="width: 300px;" oninput="showScaleValue(this.value)"/> + + <br><br> + + <Label data-toggle="tooltip" title="{{lang_switchTimeTooltip}}">{{lang_switchTime}}</Label><br> + <span id="switch">20 {{lang_sec}}</span><input name="switchtime" id="sl_switch" type="range" step="1" min="1" + max="120" value="20" style="width: 300px;" + oninput="showSwitchValue(this.value)"/> + + <br><br> + + <div> + <div style="float: left;"> + <Label data-toggle="tooltip" title="{{lang_calupdateTooltip}}">{{lang_calupdate}}</Label><br> + <input id="updateCalendar" name="calupdate" type="number" style="width: 50px; text-align: center;" min="0" + max="1440"/> {{lang_min}} + </div> + <div style="float: left; margin-left: 15px;"> + <Label data-toggle="tooltip" title="{{lang_roomupdateTooltip}}">{{lang_roomupdate}}</Label><br> + <input id="updateRoom" name="roomupdate" type="number" style="width: 50px; text-align: center;" min="0" + max="86400"/> {{lang_sec}} + </div> + <div style="float: left; margin-left: 15px;"> + <Label data-toggle="tooltip" title="{{lang_configupdateTooltip}}">{{lang_configupdate}}</Label><br> + <input id="updateConfig" name="configupdate" type="number" style="width: 50px; text-align: center;" min="0" + max="1440"/> {{lang_min}} + </div> + </div> + + <br><br><br><br> + + <button type="submit" class="btn btn-primary">{{lang_save}}</button> + + </form> </div> <script type="text/javascript"> -loadValues(); - -function loadValues() { - $("#{{language}}").attr("selected","selected"); - - $('#serverOption-{{serverid}}').attr("selected", "selected"); - - var mode = $("#{{mode}}"); - if (!mode.length) { - mode = $("#mode1"); - } - mode.attr("selected","selected"); - vertical_cb(mode.val()); - if('{{vertical}}' == true){ - $("#cb_vertical").prop("checked", true); - } - if('{{eco}}' == true){ - $("#cb_eco").prop("checked", true); - } - - if('{{scaledaysauto}}' == true){ - $("#cb_autoScale").prop("checked", true); - } - - var day = $("#{{daystoshow}}"); - if (!day.length) { - day = $("#day7"); - } - day.attr("selected","selected"); - - var rotation = $("#{{rotation}}"); - if (!rotation.length) { - rotation = $("#rotation0"); - } - rotation.attr("selected","selected"); - - var scaleVal = '{{scale}}'; - if (scaleVal == '') { - scaleVal = 50; - } - $('#sl_scale').attr('value', '{{scale}}'); - showScaleValue(scaleVal); - - var switchVal = '{{switchtime}}'; - if (switchVal == '') { - switchVal = 20; - } - $("#sl_switch").attr('value', switchVal); - showSwitchValue(switchVal); - - var calupdate = '{{calupdate}}'; - if (!calupdate.length) { - calupdate = 30; - } - $("#updateCalendar").attr("value", calupdate); - - var roomupdate = '{{roomupdate}}'; - if (!roomupdate.length) { - roomupdate = 30; - } - $("#updateRoom").attr("value", roomupdate); - - var configupdate = '{{configupdate}}'; - if (!configupdate.length) { - configupdate = 180; - } - $("#updateConfig").attr("value", configupdate); -} - -function showScaleValue(newValue) { - $("#scale").text(newValue + " %"); -} - -function showSwitchValue(newValue) { - $("#switch").text(newValue + " " + '{{lang_sec}}'); -} - -function vertical_cb(value) { - var cb = $("#cb_vertical"); - if (value == 1) { - cb.prop("disabled", false); - } else { - cb.prop("disabled", true); - cb.prop("checked", false); - } -} + loadValues(); + + function loadValues() { + $("#{{language}}").attr("selected", "selected"); + + $('#serverOption-{{serverid}}').attr("selected", "selected"); + + var mode = $("#{{mode}}"); + if (!mode.length) { + mode = $("#mode1"); + } + mode.attr("selected", "selected"); + vertical_cb(mode.val()); + if ('{{vertical}}' == true) { + $("#cb_vertical").prop("checked", true); + } + if ('{{eco}}' == true) { + $("#cb_eco").prop("checked", true); + } + + if ('{{scaledaysauto}}' == true) { + $("#cb_autoScale").prop("checked", true); + } + + var day = $("#{{daystoshow}}"); + if (!day.length) { + day = $("#day7"); + } + day.attr("selected", "selected"); + + var rotation = $("#{{rotation}}"); + if (!rotation.length) { + rotation = $("#rotation0"); + } + rotation.attr("selected", "selected"); + + var scaleVal = '{{scale}}'; + if (scaleVal == '') { + scaleVal = 50; + } + $('#sl_scale').attr('value', '{{scale}}'); + showScaleValue(scaleVal); + + var switchVal = '{{switchtime}}'; + if (switchVal == '') { + switchVal = 20; + } + $("#sl_switch").attr('value', switchVal); + showSwitchValue(switchVal); + + var calupdate = '{{calupdate}}'; + if (!calupdate.length) { + calupdate = 30; + } + $("#updateCalendar").attr("value", calupdate); + + var roomupdate = '{{roomupdate}}'; + if (!roomupdate.length) { + roomupdate = 30; + } + $("#updateRoom").attr("value", roomupdate); + + var configupdate = '{{configupdate}}'; + if (!configupdate.length) { + configupdate = 180; + } + $("#updateConfig").attr("value", configupdate); + } + + function showScaleValue(newValue) { + $("#scale").text(newValue + " %"); + } + + function showSwitchValue(newValue) { + $("#switch").text(newValue + " " + '{{lang_sec}}'); + } + + function vertical_cb(value) { + var cb = $("#cb_vertical"); + if (value == 1) { + cb.prop("disabled", false); + } else { + cb.prop("disabled", true); + cb.prop("checked", false); + } + } </script> diff --git a/modules-available/locationinfo/templates/credentials.html b/modules-available/locationinfo/templates/credentials.html index 70e96982..f8c04bcb 100644 --- a/modules-available/locationinfo/templates/credentials.html +++ b/modules-available/locationinfo/templates/credentials.html @@ -1,31 +1,31 @@ <div> - <form method="post" action="?do=locationinfo" id="credentialsForm"> - <input type="hidden" name="token" value="{{token}}"> - <input type="hidden" name="action" value="updateCredentials"> - <input type="hidden" name="id" value="{{id}}"> - <div id="div"></div> - <button type="submit" class="btn btn-primary">{{lang_save}}</button> - </form> + <form method="post" action="?do=locationinfo" id="credentialsForm"> + <input type="hidden" name="token" value="{{token}}"> + <input type="hidden" name="action" value="updateCredentials"> + <input type="hidden" name="id" value="{{id}}"> + <div id="div"></div> + <button type="submit" class="btn btn-primary">{{lang_save}}</button> + </form> </div> <script type="text/javascript"> -// {{name}} name of auth {{type}} type of auth (string, int etc.) {{value}} value from the db -{{#credentials}} - if("{{type}}" == "string") { - $("#div").before('<label>{{name}}</label><br><input required type="text" name="{{name}}" value="{{value}}" form="credentialsForm"><br><br>'); - } else if("{{type}}" == "int") { - $("#div").before('<label>{{name}}</label><br><input required type="number" name="{{name}}" value="{{value}}" form="credentialsForm"><br><br>'); - } else if("{{type}}" == "bool") { - $("#div").before('<label>{{name}}</label><br><input type="checkbox" name="{{name}}" value="{{value}}" form="credentialsForm"><br><br>'); - } else if("{{type}}" == "array") { - $("#div").before('<label>{{name}}</label><br>\ + // {{name}} name of auth {{type}} type of auth (string, int etc.) {{value}} value from the db + {{#credentials}} + if ("{{type}}" == "string") { + $("#div").before('<label>{{name}}</label><br><input required type="text" name="{{name}}" value="{{value}}" form="credentialsForm"><br><br>'); + } else if ("{{type}}" == "int") { + $("#div").before('<label>{{name}}</label><br><input required type="number" name="{{name}}" value="{{value}}" form="credentialsForm"><br><br>'); + } else if ("{{type}}" == "bool") { + $("#div").before('<label>{{name}}</label><br><input type="checkbox" name="{{name}}" value="{{value}}" form="credentialsForm"><br><br>'); + } else if ("{{type}}" == "array") { + $("#div").before('<label>{{name}}</label><br>\ <select name="{{name}}" form="credentialsForm">\ {{#array}}\ <option value="{{option}}" {{#active}}selected{{/active}}>{{option}}</option>\ {{/array}}\ </select>\ <br><br>'); - } -{{/credentials}} + } + {{/credentials}} </script> diff --git a/modules-available/locationinfo/templates/location-info.html b/modules-available/locationinfo/templates/location-info.html index 3e832284..ef8de412 100644 --- a/modules-available/locationinfo/templates/location-info.html +++ b/modules-available/locationinfo/templates/location-info.html @@ -1,52 +1,65 @@ <div> -<h1>{{lang_mainHeader}}</h1> - -<br> -<h4>{{lang_serverTable}}</h4> -<div id="serverTable"> - - <table class="table table-condensed locations" style="margin-bottom:0;"> - <tr> - <th title="{{lang_serverID}}">{{lang_sID}}</th> - <th width="1">{{lang_serverType}}</th> - <th>{{lang_locationName}}</th> - <th>{{lang_serverUrl}}</th> - <th width="1"></th> - <th width="1"></th> - </tr> -{{#serverlist}} - <form method="post" action="?do=locationinfo" id="serverForm-{{id}}"> - <input type="hidden" name="token" value="{{token}}"> - <input id="serverFormAction-{{id}}" type="hidden" name="action" value="updateServer"> - <input type="submit" id="submit-serverForm-{{id}}" style="display:none;"> + <h1>{{lang_mainHeader}}</h1> + + <br> + <h4>{{lang_serverTable}}</h4> + <div id="serverTable"> + + <table class="table table-condensed locations" style="margin-bottom:0;"> + <tr> + <th title="{{lang_serverID}}">{{lang_sID}}</th> + <th width="1">{{lang_serverType}}</th> + <th>{{lang_locationName}}</th> + <th>{{lang_serverUrl}}</th> + <th width="1"></th> + <th width="1"></th> + </tr> + {{#serverlist}} + <form method="post" action="?do=locationinfo" id="serverForm-{{id}}"> + <input type="hidden" name="token" value="{{token}}"> + <input id="serverFormAction-{{id}}" type="hidden" name="action" value="updateServer"> + <input type="submit" id="submit-serverForm-{{id}}" style="display:none;"> <tr class=tablerow> <td align="center"><input id="input-id-{{id}}" name="id" type="hidden" value="{{id}}">{{id}}</td> <td id="type-{{id}}"> - <select disabled id="input-type-{{id}}" name="type" value="{{type}}" onchange="servertype_changed(this.value, {{id}});"> + <select disabled id="input-type-{{id}}" name="type" value="{{type}}" + onchange="servertype_changed(this.value, {{id}});"> {{#types}} - <option id="{{type}}" value="{{type}}" {{#active}}selected{{/active}} >{{display}} + <option id="{{type}}" value="{{type}}" {{#active}}selected{{/active}}>{{display}} {{/types}} </select> </td> <td id="name-{{id}}" style="padding:8px;"> - <input readonly required id="input-name-{{id}}" name="name" type="text" value="{{name}}" style="padding:0;height:100%;width:100%;"></input> + <input readonly required id="input-name-{{id}}" name="name" type="text" value="{{name}}" + style="padding:0;height:100%;width:100%;"></input> </td> <td id="url-{{id}}" style="padding:8px;"> - <input readonly required id="input-url-{{id}}" name="url" type="text" value="{{url}}" style="padding:0;height:100%;width:100%;"></input> + <input readonly required id="input-url-{{id}}" name="url" type="text" value="{{url}}" + style="padding:0;height:100%;width:100%;"></input> </td> - <td align="center" id="credentials-{{id}}" onclick="event.cancelBubble = true;" style="white-space:nowrap;"> - <button {{#auth}}class="btn btn-sm btn-success"{{/auth}}{{^auth}}class="btn btn-sm btn-danger"{{/auth}} id="credentials-btn-{{id}}" type="button" title="credentials" onclick="loadCredentialModal({{id}},'{{name}}');">{{lang_credentials}}</button> - <button class="btn btn-sm btn-primary table-refresh" id="refresh-btn-{{id}}" title="refresh" onclick="refreshButtonClick({{id}});">↺</button> + <td align="center" id="credentials-{{id}}" onclick="event.cancelBubble = true;" + style="white-space:nowrap;"> + <button {{#auth}}class="btn btn-sm btn-success" {{/auth}} + {{^auth}}class="btn btn-sm btn-danger"{{/auth}} id="credentials-btn-{{id}}" type="button" + title="credentials" onclick="loadCredentialModal({{id}},'{{name}}');">{{lang_credentials}} + </button> + <button class="btn btn-sm btn-primary table-refresh" id="refresh-btn-{{id}}" title="refresh" + onclick="refreshButtonClick({{id}});">↺ + </button> </td> <td align="center" id="btncell-{{id}}" style="white-space:nowrap;"> - <button class="btn btn-sm btn-primary table-edit" title="{{lang_edit}}" onclick="editButtonClick({{id}});" id="edit">✎</button> - <button class="btn btn-sm btn-danger table-delete" type="button" title="{{lang_delete}}" onclick="deleteButtonClick({{id}});">✘</button> + <button class="btn btn-sm btn-primary table-edit" title="{{lang_edit}}" + onclick="editButtonClick({{id}});" id="edit">✎ + </button> + <button class="btn btn-sm btn-danger table-delete" type="button" title="{{lang_delete}}" + onclick="deleteButtonClick({{id}});">✘ + </button> </td> </tr> </form> -{{/serverlist}} + {{/serverlist}} <form method="post" action="?do=locationinfo" id="serverForm-0"> <input type="hidden" name="token" value="{{token}}"> <input id="serverFormAction-0" type="hidden" name="action" value="updateServer"> @@ -56,38 +69,41 @@ </table> <br> - <button class="btn btn-success btn-sm" id="addServerButton" onclick="addNewServerRow()"><span class="glyphicon glyphicon-plus-sign"> {{lang_addServer}}</span></button> + <button class="btn btn-success btn-sm" id="addServerButton" onclick="addNewServerRow()"><span + class="glyphicon glyphicon-plus-sign"> {{lang_addServer}}</span></button> <br><br><br> -</div> -<br> + </div> + <br> -<h4>{{lang_buildingTable}}</h4> -<table class="table table-condensed locations" style="margin-bottom:0"> + <h4>{{lang_buildingTable}}</h4> + <table class="table table-condensed locations" style="margin-bottom:0"> - <tr> - <th>{{lang_locationName}}</th> - <th width=10>{{lang_locationID}}</th> - <th width=80>{{lang_locationInUse}}</th> - <th width=50>{{lang_locationIsHidden}}</th> - <th width=50>{{lang_openingTime}}</th> - <th width=50>{{lang_locationSettings}}</th> - </tr> + <tr> + <th>{{lang_locationName}}</th> + <th width=10>{{lang_locationID}}</th> + <th width=80>{{lang_locationInUse}}</th> + <th width=50>{{lang_locationIsHidden}}</th> + <th width=50>{{lang_openingTime}}</th> + <th width=50>{{lang_locationSettings}}</th> + </tr> -{{#list}} - <tr id="row{{locationid}}" class="tablerow"> + {{#list}} + <tr id="row{{locationid}}" class="tablerow"> - <td><div style="display:inline-block;width:{{depth}}em"></div><a href="modules-available/locationinfo/frontend/doorsign.html?id={{locationid}}">{{locationname}}</a></td> - <td align="center">[{{locationid}}]</td> - <td align="center">{{#hasPcs}}{{pcState}} / {{total}}{{/hasPcs}}</td> + <td> + <div style="display:inline-block;width:{{depth}}em"></div> + <a href="modules-available/locationinfo/frontend/doorsign.html?id={{locationid}}">{{locationname}}</a></td> + <td align="center">[{{locationid}}]</td> + <td align="center">{{#hasPcs}}{{pcState}} / {{total}}{{/hasPcs}}</td> - <td id={{locationid}} onclick="event.cancelBubble = true;" align="center"></td> - <script> - var cbh = document.getElementById('{{locationid}}'); - var cb = document.createElement('input'); + <td id={{locationid}} onclick="event.cancelBubble = true;" align="center"></td> + <script> + var cbh = document.getElementById('{{locationid}}'); + var cb = document.createElement('input'); - cb.type = 'checkbox'; - cbh.appendChild(cb); + cb.type = 'checkbox'; + cbh.appendChild(cb); cb.id = 'cb' + {{locationid}}; cb.value = {{hidden}}; @@ -95,183 +111,187 @@ cb.checked = true; } cb.addEventListener("click", function() { cbClick(this, {{locationid}}); }); - </script> - <td onclick="event.cancelBubble = true;"><a class="btn btn-sm btn-default" role="button" onclick="loadTimeModal({{locationid}}, '{{locationname}}');">{{lang_openingTime}}</a></td> - <td onclick="event.cancelBubble = true;"><a class="btn btn-sm btn-default" role="button" onclick="loadConfigModal({{locationid}}, '{{locationname}}');">{{lang_locationSettings}}</a></td> - </tr> - -{{/list}} -</table> - -<div class="modal fade" id="myModal" tabindex="-1" role="dialog"> - <div class="modal-dialog"> - - <div class="modal-content"> - <div class="modal-header" id="myModalHeader"></div> - <div class="modal-body" id="myModalBody"></div> - <div class="modal-footer"> - <a class="btn btn-primary" data-dismiss="modal">{{lang_close}}</a> - </div> - </div> - - </div> -</div> + </script> + <td onclick="event.cancelBubble = true;"><a class="btn btn-sm btn-default" role="button" + onclick="loadTimeModal({{locationid}}, '{{locationname}}');">{{lang_openingTime}}</a> + </td> + <td onclick="event.cancelBubble = true;"><a class="btn btn-sm btn-default" role="button" + onclick="loadConfigModal({{locationid}}, '{{locationname}}');">{{lang_locationSettings}}</a> + </td> + </tr> + {{/list}} + </table> + + <div class="modal fade" id="myModal" tabindex="-1" role="dialog"> + <div class="modal-dialog"> + + <div class="modal-content"> + <div class="modal-header" id="myModalHeader"></div> + <div class="modal-body" id="myModalBody"></div> + <div class="modal-footer"> + <a class="btn btn-primary" data-dismiss="modal">{{lang_close}}</a> + </div> + </div> + + </div> + </div> +</div> <script type="text/javascript"> -var lastPcSubTable = false; + var lastPcSubTable = false; + + function cbClick(cb, locID) { + var value; + + if (cb.checked == true) { + value = 1; + } else { + value = 0; + } + window.location.href = "?do=locationinfo&action=hide&id=" + locID + "&value=" + value; + } + + function loadCredentialModal(serverid, servername) { + $('#myModalHeader').text("[" + serverid + "] " + servername).css("font-weight", "Bold"); + + $('#myModal').modal('show'); + $('#myModalBody').load("?do=locationinfo&action=credentials&id=" + serverid); + } + + function loadTimeModal(locationId, locationName) { + $('#myModalHeader').text("[" + locationId + "] " + locationName).css("font-weight", "Bold"); -function cbClick(cb, locID) { - var value; + $('#myModal').modal('show'); + $('#myModalBody').load("?do=locationinfo&action=timetable&id=" + locationId); + } + + function loadConfigModal(locationId, locationName) { + $('#myModalHeader').text("[" + locationId + "] " + locationName).css("font-weight", "Bold"); - if (cb.checked == true) { - value = 1; - } else { - value = 0; + $('#myModal').modal('show'); + $('#myModalBody').load("?do=locationinfo&action=config&id=" + locationId); } - window.location.href = "?do=locationinfo&action=hide&id=" + locID + "&value=" + value; -} - -function loadCredentialModal(serverid, servername) { - $('#myModalHeader').text("[" + serverid + "] " + servername).css("font-weight","Bold"); - - $('#myModal').modal('show'); - $('#myModalBody').load("?do=locationinfo&action=credentials&id=" + serverid); -} - -function loadTimeModal(locationId, locationName) { - $('#myModalHeader').text("[" + locationId + "] " + locationName).css("font-weight","Bold"); - - $('#myModal').modal('show'); - $('#myModalBody').load("?do=locationinfo&action=timetable&id=" + locationId); -} - -function loadConfigModal(locationId, locationName) { - $('#myModalHeader').text("[" + locationId + "] " + locationName).css("font-weight","Bold"); - - $('#myModal').modal('show'); - $('#myModalBody').load("?do=locationinfo&action=config&id=" + locationId); -} - -// ########### Server Table ########### -var preEditName; -var preEditUrl; -var preEditUser; -var preEditPassword; -var preEditType; - -function deleteButtonClick(id) { - var del = confirm("{{lang_deleteConfirmation}}"); - if (del == true) { - $('#serverFormAction-' + id).val("deleteServer"); - $('#serverForm-' + id).submit(); + + // ########### Server Table ########### + var preEditName; + var preEditUrl; + var preEditUser; + var preEditPassword; + var preEditType; + + function deleteButtonClick(id) { + var del = confirm("{{lang_deleteConfirmation}}"); + if (del == true) { + $('#serverFormAction-' + id).val("deleteServer"); + $('#serverForm-' + id).submit(); + } } -}; - -function servertype_changed(value, id) { - if (value == "Frontend") { - $('#input-user-' + id).removeAttr('required'); - $('#input-password-' + id).removeAttr('required'); - } else { - $('#input-user-' + id).attr('required'); - $('#input-password-' + id).attr('required'); + + function servertype_changed(value, id) { + if (value == "Frontend") { + $('#input-user-' + id).removeAttr('required'); + $('#input-password-' + id).removeAttr('required'); + } else { + $('#input-user-' + id).attr('required'); + $('#input-password-' + id).attr('required'); + } } -}; - -function editButtonClick(id) { - var name = $('#input-name-' + id); - var url = $('#input-url-' + id); - var user = $('#input-user-' + id); - var password = $('#input-password-' + id); - var type = $('#input-type-' + id); - - name.attr('readonly', false); - url.attr('readonly', false); - user.attr('readonly', false); - password.attr('readonly', false); - type.attr('disabled', false); - - name.css("color", "#000"); - url.css("color", "#000"); - user.css("color", "#000"); - password.css("color", "#000"); - type.css("color", "#000"); - - preEditName = name.val(); - preEditUrl = url.val(); - preEditUser = user.val(); - preEditPassword = password.val(); - preEditType = type.val(); - - servertype_changed(preEditType, id); - - $('#btncell-' + id).html('\ + + function editButtonClick(id) { + var name = $('#input-name-' + id); + var url = $('#input-url-' + id); + var user = $('#input-user-' + id); + var password = $('#input-password-' + id); + var type = $('#input-type-' + id); + + name.attr('readonly', false); + url.attr('readonly', false); + user.attr('readonly', false); + password.attr('readonly', false); + type.attr('disabled', false); + + name.css("color", "#000"); + url.css("color", "#000"); + user.css("color", "#000"); + password.css("color", "#000"); + type.css("color", "#000"); + + preEditName = name.val(); + preEditUrl = url.val(); + preEditUser = user.val(); + preEditPassword = password.val(); + preEditType = type.val(); + + servertype_changed(preEditType, id); + + $('#btncell-' + id).html('\ <button class="btn btn-sm btn-success" title="{{lang_save}}" onclick="saveButtonClick(' + id + ');">✔</button> \ <button class="btn btn-sm btn-danger" title="{{lang_cancel}}" onclick="cancelButtonClick(' + id + ');">✘</button>'); - $('.table-edit').attr('disabled', true); - $('.table-delete').attr('disabled', true); - $('.table-refresh').attr('disabled', true); - $('#addServerButton').attr('disabled', true); -}; - -function saveButtonClick(id) { - $('#serverFormAction-' + id).val("updateServer"); - $('#submit-serverForm-' + id).trigger("click"); -}; - -function refreshButtonClick(id) { - $('#serverFormAction-' + id).val("checkConnection"); - $('#submit-serverForm-' + id).trigger("click"); -}; - -function addNewServer() { - $('#serverFormAction-0').val("updateServer"); - - $('#submit-serverForm-0').trigger("click"); -}; - -function cancelButtonClick(id) { - var name = $('#input-name-' + id); - var url = $('#input-url-' + id); - var user = $('#input-user-' + id); - var password = $('#input-password-' + id); - var type = $('#input-type-' + id); - - name.attr('readonly', true); - url.attr('readonly', true); - user.attr('readonly', true); - password.attr('readonly', true); - type.attr('disabled', true); - - name.css("color", ""); - url.css("color", ""); - user.css("color", ""); - password.css("color", ""); - type.css("color", ""); - - name.val(preEditName); - url.val(preEditUrl); - user.val(preEditUser); - password.val(preEditPassword); - type.val(preEditType); - - $('#btncell-' + id).html('\ + $('.table-edit').attr('disabled', true); + $('.table-delete').attr('disabled', true); + $('.table-refresh').attr('disabled', true); + $('#addServerButton').attr('disabled', true); + } + + function saveButtonClick(id) { + $('#serverFormAction-' + id).val("updateServer"); + $('#submit-serverForm-' + id).trigger("click"); + } + + function refreshButtonClick(id) { + $('#serverFormAction-' + id).val("checkConnection"); + $('#submit-serverForm-' + id).trigger("click"); + } + + function addNewServer() { + $('#serverFormAction-0').val("updateServer"); + + $('#submit-serverForm-0').trigger("click"); + } + + function cancelButtonClick(id) { + var name = $('#input-name-' + id); + var url = $('#input-url-' + id); + var user = $('#input-user-' + id); + var password = $('#input-password-' + id); + var type = $('#input-type-' + id); + + name.attr('readonly', true); + url.attr('readonly', true); + user.attr('readonly', true); + password.attr('readonly', true); + type.attr('disabled', true); + + name.css("color", ""); + url.css("color", ""); + user.css("color", ""); + password.css("color", ""); + type.css("color", ""); + + name.val(preEditName); + url.val(preEditUrl); + user.val(preEditUser); + password.val(preEditPassword); + type.val(preEditType); + + $('#btncell-' + id).html('\ <button class="btn btn-sm btn-primary table-edit" title="{{lang_edit}}" onclick="editButtonClick(' + id + ');" id="edit">✎</button> \ <button class="btn btn-sm btn-danger table-delete" type="button" title="{{lang_delete}}" onclick="deleteButtonClick(' + id + ');">✘</button>'); - $('.table-edit').attr('disabled', false); - $('.table-delete').attr('disabled', false); - $('.table-refresh').attr('disabled', false); - $('#addServerButton').attr('disabled', false); -} - -function deleteNewServer() { - $('#new').remove(); - $('.table-edit').attr('disabled', false); - $('.table-delete').attr('disabled', false); - $('#addServerButton').attr('disabled', false); -}; - -function addNewServerRow() { - $('#lastServerTableElement').before('<tr class=tablerow id="new">\ + $('.table-edit').attr('disabled', false); + $('.table-delete').attr('disabled', false); + $('.table-refresh').attr('disabled', false); + $('#addServerButton').attr('disabled', false); + } + + function deleteNewServer() { + $('#new').remove(); + $('.table-edit').attr('disabled', false); + $('.table-delete').attr('disabled', false); + $('#addServerButton').attr('disabled', false); + } + + function addNewServerRow() { + $('#lastServerTableElement').before('<tr class=tablerow id="new">\ <td align="center"><input id="input-id-0" name="id" type="hidden" form="serverForm-0" value="0"></td>\ <td id="type-0"><select id="input-type-0" name="type" form="serverForm-0" onchange="servertype_changed(this.value, 0)">\ {{#servertypelist}}<option value="{{type}}"> {{display}}{{/servertypelist}}\ @@ -286,6 +306,5 @@ function addNewServerRow() { $('.table-edit').attr('disabled', true); $('.table-delete').attr('disabled', true); $('#addServerButton').attr('disabled', true); -}; + } </script> -</div> diff --git a/modules-available/locationinfo/templates/timetable.html b/modules-available/locationinfo/templates/timetable.html index bb3f7991..29446f58 100644 --- a/modules-available/locationinfo/templates/timetable.html +++ b/modules-available/locationinfo/templates/timetable.html @@ -1,159 +1,166 @@ <div> -<div align="right"> - <label for="CB_1">{{lang_expertMode}}</label> - <input class="bs-switch" name="1" id="CB_1" type="checkbox" {{#expertMode}}checked="checked"{{/expertMode}}> -</div> -<br> - - <div id="easyMode" style="{{#expertMode}}display: none;{{/expertMode}}"> - <form method="post" action="?do=locationinfo" id="timeForm"> - <input type="hidden" name="token" value="{{token}}"> - <input type="hidden" name="action" value="updateOpeningTimeEasy"> - <input type="hidden" name="id" value="{{id}}"> - <input type="hidden" name="easyMode" value="{{easyMode}}"> - - <table class="table table-condensed locations" style="margin-bottom:0"> - <tr> - <th>{{lang_day}}</th> - <th>{{lang_openingTime}}</th> - <th>{{lang_closingTime}}</th> - </tr> - - <tr class=tablerow> - <td>{{lang_monTilFr}}</td> - <td> - <div class="input-group bootstrap-timepicker"> + <div align="right"> + <label for="CB_1">{{lang_expertMode}}</label> + <input class="bs-switch" name="1" id="CB_1" type="checkbox" {{#expertMode}}checked="checked"{{/expertMode}}> + </div> + <br> + + <div id="easyMode" style="{{#expertMode}}display: none;{{/expertMode}}"> + <form method="post" action="?do=locationinfo" id="timeForm"> + <input type="hidden" name="token" value="{{token}}"> + <input type="hidden" name="action" value="updateOpeningTimeEasy"> + <input type="hidden" name="id" value="{{id}}"> + <input type="hidden" name="easyMode" value="{{easyMode}}"> + + <table class="table table-condensed locations" style="margin-bottom:0"> + <tr> + <th>{{lang_day}}</th> + <th>{{lang_openingTime}}</th> + <th>{{lang_closingTime}}</th> + </tr> + + <tr class=tablerow> + <td>{{lang_monTilFr}}</td> + <td> + <div class="input-group bootstrap-timepicker"> <span class="input-group-addon"> <span class="glyphicon glyphicon-time"></span> </span> - <input type="text" class="form-control timepicker2" name="openingtime[]" id="openingtimepicker" pattern="[0-9]{1,2}:[0-9]{2}" value="{{openingtime0}}"> - </div> - </td> - <td> - <div class="input-group bootstrap-timepicker"> + <input type="text" class="form-control timepicker2" name="openingtime[]" id="openingtimepicker" + pattern="[0-9]{1,2}:[0-9]{2}" value="{{openingtime0}}"> + </div> + </td> + <td> + <div class="input-group bootstrap-timepicker"> <span class="input-group-addon"> <span class="glyphicon glyphicon-time"></span> </span> - <input type="text" class="form-control timepicker2" name="closingtime[]" id="openingtimepicker" pattern="[0-9]{1,2}:[0-9]{2}" value="{{closingtime0}}"> - </div> - </td> - </tr> - <tr class=tablerow> - <td>{{lang_saturday}}</td> - <td> - <div class="input-group bootstrap-timepicker"> + <input type="text" class="form-control timepicker2" name="closingtime[]" id="openingtimepicker" + pattern="[0-9]{1,2}:[0-9]{2}" value="{{closingtime0}}"> + </div> + </td> + </tr> + <tr class=tablerow> + <td>{{lang_saturday}}</td> + <td> + <div class="input-group bootstrap-timepicker"> <span class="input-group-addon"> <span class="glyphicon glyphicon-time"></span> </span> - <input type="text" class="form-control timepicker2" name="openingtime[]" id="openingtimepicker" pattern="[0-9]{1,2}:[0-9]{2}" value="{{openingtime1}}"> - </div> - </td> - <td> - <div class="input-group bootstrap-timepicker"> + <input type="text" class="form-control timepicker2" name="openingtime[]" id="openingtimepicker" + pattern="[0-9]{1,2}:[0-9]{2}" value="{{openingtime1}}"> + </div> + </td> + <td> + <div class="input-group bootstrap-timepicker"> <span class="input-group-addon"> <span class="glyphicon glyphicon-time"></span> </span> - <input type="text" class="form-control timepicker2" name="closingtime[]" id="openingtimepicker" pattern="[0-9]{1,2}:[0-9]{2}" value="{{closingtime1}}"> - </div> - </td> - </tr> - <tr class=tablerow> - <td>{{lang_sunday}}</td> - <td> - <div class="input-group bootstrap-timepicker"> + <input type="text" class="form-control timepicker2" name="closingtime[]" id="openingtimepicker" + pattern="[0-9]{1,2}:[0-9]{2}" value="{{closingtime1}}"> + </div> + </td> + </tr> + <tr class=tablerow> + <td>{{lang_sunday}}</td> + <td> + <div class="input-group bootstrap-timepicker"> <span class="input-group-addon"> <span class="glyphicon glyphicon-time"></span> </span> - <input type="text" class="form-control timepicker2" name="openingtime[]" id="openingtimepicker" pattern="[0-9]{1,2}:[0-9]{2}" value="{{openingtime2}}"> - </div> - </td> - <td> - <div class="input-group bootstrap-timepicker"> + <input type="text" class="form-control timepicker2" name="openingtime[]" id="openingtimepicker" + pattern="[0-9]{1,2}:[0-9]{2}" value="{{openingtime2}}"> + </div> + </td> + <td> + <div class="input-group bootstrap-timepicker"> <span class="input-group-addon"> <span class="glyphicon glyphicon-time"></span> </span> - <input type="text" class="form-control timepicker2" name="closingtime[]" id="openingtimepicker" pattern="[0-9]{1,2}:[0-9]{2}" value="{{closingtime2}}"> - </div> - </td> - </tr> - </table> - - <br> - <br> - <br> - <button type="submit" class="btn btn-primary">{{lang_save}}</button> - <br> - </form> - </div> - - <div id="expertMode" style="{{#easyMode}}display: none;{{/easyMode}}"> - <form method="post" action="?do=locationinfo" id="timeForm"> - <input type="hidden" name="token" value="{{token}}"> - <input type="hidden" name="action" value="updateOpeningTimeExpert"> - <input type="hidden" name="id" value="{{id}}"> - <input type="hidden" name="easyMode" value="{{easyMode}}"> - - - <table class="table table-condensed locations" style="margin-bottom:0"> - <tr> - <th>{{lang_day}}</th> - <th>{{lang_openingTime}}</th> - <th>{{lang_closingTime}}</th> - <th>{{lang_delete}}</th> - </tr> - - {{#openingtimes}} - <tr class=tablerow> - <td>{{days}}</td> - <td>{{openingtime}}</td> - <td>{{closingtime}}</td> - <td align="center"><input type="checkbox" name="delete[]" value="{{index}}"></td> - <!--<td><button class="btn btn-sm btn-danger">X</button></td>--> - </tr> - {{/openingtimes}} - - <tr id="lastOpenTimesTableElement"></tr> - </table> - - <br> - <a class="btn btn-success btn-sm" onclick=newOpeningTime()><span class="glyphicon glyphicon-plus-sign"></span> {{lang_openingTime}}</a> - <!--<a class="btn btn-danger btn-sm" onclick=>{{lang_deleteAll}}</a>--> - <br> - <br> - <button type="submit" class="btn btn-primary">{{lang_save}}</button> - <br> - </form> - </div> + <input type="text" class="form-control timepicker2" name="closingtime[]" id="openingtimepicker" + pattern="[0-9]{1,2}:[0-9]{2}" value="{{closingtime2}}"> + </div> + </td> + </tr> + </table> + + <br> + <br> + <br> + <button type="submit" class="btn btn-primary">{{lang_save}}</button> + <br> + </form> + </div> + + <div id="expertMode" style="{{#easyMode}}display: none;{{/easyMode}}"> + <form method="post" action="?do=locationinfo" id="timeForm"> + <input type="hidden" name="token" value="{{token}}"> + <input type="hidden" name="action" value="updateOpeningTimeExpert"> + <input type="hidden" name="id" value="{{id}}"> + <input type="hidden" name="easyMode" value="{{easyMode}}"> + + + <table class="table table-condensed locations" style="margin-bottom:0"> + <tr> + <th>{{lang_day}}</th> + <th>{{lang_openingTime}}</th> + <th>{{lang_closingTime}}</th> + <th>{{lang_delete}}</th> + </tr> + + {{#openingtimes}} + <tr class=tablerow> + <td>{{days}}</td> + <td>{{openingtime}}</td> + <td>{{closingtime}}</td> + <td align="center"><input type="checkbox" name="delete[]" value="{{index}}"></td> + <!--<td><button class="btn btn-sm btn-danger">X</button></td>--> + </tr> + {{/openingtimes}} + + <tr id="lastOpenTimesTableElement"></tr> + </table> + + <br> + <a class="btn btn-success btn-sm" onclick=newOpeningTime()><span class="glyphicon glyphicon-plus-sign"></span> + {{lang_openingTime}}</a> + <!--<a class="btn btn-danger btn-sm" onclick=>{{lang_deleteAll}}</a>--> + <br> + <br> + <button type="submit" class="btn btn-primary">{{lang_save}}</button> + <br> + </form> + </div> </div> <script> -setTimepicker(); -$('#CB_1').bootstrapSwitch(); -$('#CB_1').on('switchChange.bootstrapSwitch', function (e, data) { - - if (data == false) { - $('#expertMode').hide(); - $('#easyMode').show(); - } else { - $('#easyMode').hide(); - $('#expertMode').show(); - } -}); - - function setTimepicker() { - $('.timepicker2').timepicker({ - minuteStep: 1, - template: 'modal', - appendWidgetTo: 'body', - showSeconds: false, - showMeridian: false, - defaultTime: false - }); - }; - - function newOpeningTime() { - $('#lastOpenTimesTableElement').before('<tr>\ + setTimepicker(); + $('#CB_1').bootstrapSwitch(); + $('#CB_1').on('switchChange.bootstrapSwitch', function (e, data) { + + if (data == false) { + $('#expertMode').hide(); + $('#easyMode').show(); + } else { + $('#easyMode').hide(); + $('#expertMode').show(); + } + }); + + function setTimepicker() { + $('.timepicker2').timepicker({ + minuteStep: 1, + template: 'modal', + appendWidgetTo: 'body', + showSeconds: false, + showMeridian: false, + defaultTime: false + }); + } + + function newOpeningTime() { + $('#lastOpenTimesTableElement').before('<tr>\ <td>\ <div class="form-group options">\ <label><input required type="checkbox" name="days[]" value="Monday">{{lang_shortMonday}}</label>\ @@ -190,23 +197,18 @@ $('#CB_1').on('switchChange.bootstrapSwitch', function (e, data) { <input type="checkbox" name="dontadd[]" value="dontadd"\ </td>\ </tr>'); - setTimepicker(); - - $(function(){ - var requiredCheckboxes = $('.options :checkbox[required]'); - requiredCheckboxes.change(function(){ - if(requiredCheckboxes.is(':checked')) { - requiredCheckboxes.removeAttr('required'); - } else { - requiredCheckboxes.attr('required', 'required'); - } - }); - }); - }; - // <!--<button type="submit" class="btn btn-success btn-sm" onclick=>✓</button>-->\ - // <input type="time" name="openingtime[]">\ - // <input type="time" name="closingtime[]">\ - - + setTimepicker(); + + $(function () { + var requiredCheckboxes = $('.options :checkbox[required]'); + requiredCheckboxes.change(function () { + if (requiredCheckboxes.is(':checked')) { + requiredCheckboxes.removeAttr('required'); + } else { + requiredCheckboxes.attr('required', 'required'); + } + }); + }); + } </script> |