Advertisement
Guest User

Untitled

a guest
Jun 9th, 2017
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 137.85 KB | None | 0 0
  1. /*
  2. * Initialization
  3. */
  4.  
  5. // create instance of config class
  6. var config = new Config();
  7. // create the instance of the application class
  8. var application = new Application();
  9. // create the instanceof the interface class
  10. var myInterface = new Interface();
  11. var refreshPressed = false; // <- flag
  12.  
  13. $(document).ready(function() {
  14. document.title = Utils.getLangString('ui7_page_title', 'Vera™ - Smarter Home Control');
  15. if (checkBrowserSupport()) {
  16. $(View.idForBody()).html(View.returnBrowserNotSupported());
  17. } else {
  18. if($("#dateTimeContainer").length > 0){
  19. application.initialize();
  20. // code below
  21. window.onkeydown = function(event){
  22. var e = event || window.event;
  23. if(e.keyCode == 116){
  24. refreshPressed = true;
  25. }
  26. }
  27.  
  28. window.onbeforeunload = function(){
  29. for (var i = 0; i < 1000000000; i++){}
  30. if(refreshPressed === false){
  31. application.clearAuthCookie();
  32. }
  33. }
  34. // log out user from portal - iframe with portal url + logout part
  35. var logoutUrl = config.logoutUrl + '?no_return=true';
  36.  
  37. $('<iframe id="lg_t_frm"></iframe>').css('display', 'none')
  38. .attr('src', logoutUrl)
  39. .appendTo($(View.idForMenuBar()));
  40. }
  41. }
  42. });
  43.  
  44. $(document).ajaxComplete(function (event, xhr) {
  45. if (typeof xhr !== 'undefined' && typeof xhr.responseText !== 'undefined'
  46. && (xhr.responseText.indexOf(MMS_ERROR_TUNNEL_NOT_FOUND) !== -1
  47. || xhr.responseText.indexOf(MMS_ERROR_TUNNEL_FAILED) !== -1)) {
  48. if(typeof myInterface.upgradeInProgress === 'undefined'){
  49. myInterface.checkConnexionFailure();
  50. }
  51. }
  52.  
  53. if (typeof xhr !== 'undefined' && typeof xhr.responseText !== 'undefined') {
  54. if (xhr.responseText.indexOf(MMS_ERROR_SESSION_EXPIRED_1) !== -1 ||
  55. xhr.responseText.indexOf(MMS_ERROR_SESSION_EXPIRED_2) !== -1 ||
  56. xhr.responseText.indexOf(MMS_ERROR_SESSION_EXPIRED_3) !== -1) {
  57. if(typeof myInterface.upgradeInProgress === 'undefined'){
  58. application.fireEvent('on_ui_sessionTerminated');
  59. }
  60. }
  61. }
  62. });
  63.  
  64.  
  65.  
  66. // initialize plugins API...
  67. var api;
  68. if (config.enablePluginsAPI) {
  69. try {
  70. api = new API(config, application, myInterface);
  71.  
  72. // api should perform cleanup when cpanel is closed...
  73. myInterface.addEvent('on_ui_cpanel_cleanup', api, 'cleanUp');
  74. } catch (exception) {
  75. Utils.logError('Cannot instantiate plugins API ! Maybe api.js is not loaded...');
  76. }
  77. }
  78.  
  79.  
  80. application.addEvent("on_startup_showModalLoading", myInterface, "showStartupModalLoading");
  81. application.addEvent("on_startup_userDataLoaded", myInterface, "userDataLoaded");
  82. application.addEvent("on_startup_luStatusLoaded", myInterface, "luStatusLoaded");
  83. application.addEvent("on_startup_sysinfoLoaded", myInterface, "sysinfoLoaded");
  84. application.addEvent("on_startup_versionChecked", myInterface, "versionChecked");
  85. application.addEvent("on_startup_allowedUsers", myInterface, "allowedUsers");
  86.  
  87. // ui events
  88. application.addEvent("on_ui_requireUpgrade", myInterface, "requireUpgrade");
  89. application.addEvent("on_ui_requireSave", myInterface, "requireSave");
  90. application.addEvent("on_ui_userDataFirstLoaded", myInterface, "userDataFirstLoaded");
  91. application.addEvent("on_ui_userDataSaveInProgress", myInterface, "saveStarted");
  92. application.addEvent("on_ui_userDataSetTemperatureFormat", myInterface, "setTemperatureFormat");
  93.  
  94. // critical events
  95. application.addEvent("on_critical_engineNotAvailable", myInterface, "engineNotAvailable");
  96. application.addEvent("on_critical_authenticatedAccountNotAllowed", myInterface, "authenticatedAccountNotAllowed");
  97.  
  98. application.addEvent("on_ui_deviceJobsReceived", myInterface, "deviceJobsReceived");
  99. application.addEvent("on_ui_staticDataAdded", myInterface, "staticDataAdded");
  100. application.addEvent("on_ui_staticDataChanged", myInterface, "staticDataChanged");
  101. application.addEvent("on_ui_staticDataRemoved", myInterface, "staticDataRemoved");
  102. application.addEvent("on_ui_setupDeviceAdded", myInterface, "setupDeviceAdded");
  103. application.addEvent("on_ui_setupDeviceChanged", myInterface, "setupDeviceChanged");
  104. application.addEvent("on_ui_setupDeviceRemoved", myInterface, "setupDeviceRemoved");
  105. application.addEvent("on_ui_sectionAdded", myInterface, "sectionAdded");
  106. application.addEvent("on_ui_sectionChanged", myInterface, "sectionChanged");
  107. application.addEvent("on_ui_sectionRemoved", myInterface, "sectionRemoved");
  108. application.addEvent("on_ui_roomAdded", myInterface, "roomAdded");
  109. application.addEvent("on_ui_roomChanged", myInterface, "roomChanged");
  110. application.addEvent("on_ui_roomRemoved", myInterface, "roomRemoved");
  111. application.addEvent("on_ui_deviceAdded", myInterface, "deviceAdded");
  112. application.addEvent("on_ui_deviceChanged", myInterface, "deviceChanged");
  113. application.addEvent("on_ui_deviceRemoved", myInterface, "deviceRemoved");
  114. application.addEvent("on_ui_sceneAdded", myInterface, "sceneAdded");
  115. application.addEvent("on_ui_sceneChanged", myInterface, "sceneChanged");
  116. application.addEvent("on_ui_sceneRemoved", myInterface, "sceneRemoved");
  117. application.addEvent("on_ui_pluginAdded", myInterface, "pluginAdded");
  118. application.addEvent("on_ui_pluginChanged", myInterface, "pluginChanged");
  119. application.addEvent("on_ui_pluginRemoved", myInterface, "pluginRemoved");
  120. application.addEvent("on_ui_extraSubmenuItemAdded", myInterface, "extraSubmenuItemAdded");
  121. application.addEvent("on_ui_extraSubmenuItemChanged", myInterface, "extraSubmenuItemChanged");
  122. application.addEvent("on_ui_extraSubmenuItemRemoved", myInterface, "extraSubmenuItemRemoved");
  123. application.addEvent("on_ui_jobsUpdated", myInterface, "jobsUpdated");
  124. application.addEvent("on_ui_deviceStatusChanged", myInterface, "deviceStatusChanged");
  125. application.addEvent("on_ui_syncClock", myInterface, "syncClock");
  126. application.addEvent("on_ui_initFinished", myInterface, "initFinished");
  127. application.addEvent("on_ui_setUserAuthenticated", myInterface, "setUserAuthenticated");
  128. application.addEvent("on_ui_saveFinished", myInterface, "saveFinished");
  129. application.addEvent("on_ui_userDataLoaded", myInterface, "userDataMiscActions");
  130. application.addEvent("on_ui_accountUnitsLoaded", myInterface, "accountUnitsLoaded");
  131. application.addEvent("accountInformationLoaded", myInterface, "accountInformationLoaded");
  132. application.addEvent("on_ui_initNotLogged", myInterface, "initNotLogged");
  133. application.addEvent("on_ui_finishDrawingMenu", myInterface, "finishDrawingMenu");
  134. application.addEvent("on_ui_alertsUpdated", myInterface, "alertsUpdated");
  135. application.addEvent("on_ui_engineAvailable", myInterface, "engineAvailable");
  136. application.addEvent("on_ui_engineBusy", myInterface, "engineBusy");
  137. application.addEvent("on_ui_deviceTypeChanged", myInterface, "deviceTypeChanged");
  138. application.addEvent("on_ui_showModalLoading", myInterface, "showModalLoading");
  139. application.addEvent("on_ui_hideModalLoading", myInterface, "hideModalLoading");
  140. application.addEvent("on_ui_showUserDataSaveFailure", myInterface, "showUserDataSaveFailure");
  141. application.addEvent("on_ui_showErrorMessage", myInterface, "showMessagePopupError");
  142. application.addEvent("on_ui_refreshDashboardCards", myInterface, "refreshDashboardCards");
  143. application.addEvent("on_ui_2GEnabled", myInterface, "show2GEnabled");
  144. application.addEvent("on_startup_show2gInterface", myInterface, "show2GInterface");
  145. application.addEvent("on_ui_pinCodesReceived", myInterface, "handlePinCodesDeletion");
  146. application.addEvent("on_ui_userAdded", myInterface, "handleUserDataUserAdded");
  147. application.addEvent("on_ui_userChanged", myInterface, "handleUserDataUserChanged");
  148. application.addEvent("on_ui_userRemoved", myInterface, "handleUserDataUserRemoved");
  149. application.addEvent("on_ui_handleLanguage", myInterface, "handleLanguageSelector");
  150. application.addEvent("on_ui_languageHandlingFinished", myInterface, "languageHandlingFinished");
  151.  
  152. application.addEvent("on_ui_deviceRoomChanged", myInterface, "handleDeviceRoomChanged");
  153. application.addEvent("on_ui_deviceInvisibilityChanged", myInterface, "handleDeviceInvisibilityChanged");
  154.  
  155. // ****************** legacy functions and variables used for UI5 plugins compatibility ******************
  156. application.addEvent("on_startup_luStatusLoaded", myInterface, "initLegacyCode");
  157. application.addEvent("on_ui_sessionTerminated", myInterface, "sessionTerminated");
  158. application.addEvent("on_ui_showDefaultPage", myInterface, "showDefaultPage");
  159. application.addEvent("on_userdata_sceneAdded", myInterface, "handleUserDataSceneAdded");
  160.  
  161. ViewConfig.CUT_DEVICE_NAME_AT_LENGTH = 20;
  162. ViewConfig.CUT_ROOM_NAME_AT_LENGTH = 30;
  163.  
  164. // ****************** feedback handling ******************
  165. //if(config.debugMode != 'PRODUCTION'){
  166. // jQuery.ajax({
  167. // url: "https://jira.mios.com/s/d41d8cd98f00b204e9800998ecf8427e/en_USpstc-1988229788/6256/4/1.4.7/_/download/batch/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector-embededjs/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector-embededjs.js?collectorId=5baa6a95",
  168. // type: "get",
  169. // cache: true,
  170. // dataType: "script"
  171. // });
  172. //}
  173. // ****************** end feedback handling ******************
  174.  
  175. /*
  176. * Override core functions
  177. */
  178.  
  179. /*
  180. myInterface.initialize = function(){
  181. console.log('--- override initialize ---');
  182. }
  183.  
  184. application.checkAuthCookie = function(){
  185. console.log('--- override checkAuthCookie ---');
  186. };
  187.  
  188. */
  189. //generate a wep key - used in net-wifi tab
  190. function generate_wep_keys(length, passPhrase){
  191. $.ajax({
  192. url: config.generateWepKeyUrl,
  193. type: "POST",
  194. data: {len: length, passphrase: passPhrase},
  195. success: function(data){
  196. try{
  197. var keyObj = JSON.parse(data);
  198. var $iframeContent = $('#net_and_wifi_settings_iframe').contents();
  199. $iframeContent.find('input[name="wep_key1"]').val(keyObj.key1);
  200. $iframeContent.find('input[name="wep_key2"]').val(keyObj.key2);
  201. $iframeContent.find('input[name="wep_key3"]').val(keyObj.key3);
  202. $iframeContent.find('input[name="wep_key4"]').val(keyObj.key4);
  203. } catch(e) {}
  204. }
  205. });
  206. }
  207. function checkBrowserSupport(){
  208. try{
  209. var browserInfo = Utils.getBrowserAndVersion();
  210. var isNotSuported = false;
  211. if(browserInfo[0] === "Chrome" && Utils.int(browserInfo[1]) <= 30){
  212. isNotSuported = true;
  213. }else if(browserInfo[0] === "Firefox" && Utils.int(browserInfo[1]) <= 25){
  214. isNotSuported = true;
  215. }else if(browserInfo[0] === "MSIE" && Utils.int(browserInfo[1]) < 9){
  216. isNotSuported = true;
  217. }
  218. return isNotSuported;
  219. }catch(err){
  220. Utils.logError('Error in Interface.checkBrowserSupport: ' + err);
  221. }
  222. }
  223. View.returnBrowserNotSupported = function() {
  224.  
  225. var getChrome = Utils.getLangString("ui7_getChrome", "Get Chrome Browser");
  226. var getFirefox = Utils.getLangString("ui7_getFirefox", "Get Firefox Browser");
  227. var getIE = Utils.getLangString("ui7_getIe", "Get Internet Explorer 11 Browser");
  228. var getSafari = Utils.getLangString("ui7_getSafari", "Get Safari Browser");
  229. return `<div class="browserNotSupported">
  230. <p class="logoContainer"><img class="img-responsive" src="skins/default/img/other/logo_2.png"></p>
  231. <p>${Utils.getLangString("ui7_browserNotSuported", "Your browser is not supported.")}</p>
  232. <ul class="browserList">
  233. <li><a id="chromeIcon" href="http://www.google.com/chrome" title="${getChrome}"></a></li>
  234. <li><a id="firefoxIcon" href="http://www.mozilla.org/en-US/firefox/new/" title="${getFirefox}"></a></li>
  235. <li><a id="ieIcon" href="https://www.microsoft.com/en-us/download/internet-explorer-11-for-windows-7-details.aspx" title="${getIE}"></a></li>
  236. <li><a id="safariIcon" href="https://support.apple.com/downloads/safari" title="${getSafari}"></a></li>
  237. </ul>
  238. <p>${Utils.getLangString("ui7_browserNotSuportedInfo", "Please use the latest version of your prefered browser or Chrome browser with a version greater than 30, Firefox with a version greater than 25 or Internet Explorer with a version greater than 8.")}</p>
  239. </div>`;
  240.  
  241. };
  242. View.returnTestLuupCode = function() {
  243. var html = `<div><b>${Utils.getLangString("ui7_test_luup", "Test Luup code (Lua)")}</b></div>
  244. <div class="LuupHelpLink"><a target="_blank" href="http://wiki.micasaverde.com/index.php/Main_Page#Luup_code_and_Plugins">${Utils.getLangString("ui7_luup_help", "Find help about how to use luua code.")}</a></div>
  245. <div>
  246. <div>${Utils.getLangString("ui7_code", "Code")}*</div>
  247. <div><textarea class="form-control" rows="10" id="${View.idForUpnpCodeContent(true)}" wrap="off">${typeof myInterface.upnpTestCode !== 'undefined' ? myInterface.upnpTestCode : ''}</textarea></div>
  248. </div>
  249. <em>* ${Utils.getLangString("pkoem33_required_field", "Required field")}</em>
  250. <div><input type="button" class="vBtn" value="${Utils.getLangString("ui7_go", "GO")}" id="${View.idForTestUpnpCodeButton(true)}"></div>`;
  251. return html;
  252. };
  253. View.returnEditStartupLua = function() {
  254. var html = `<div><b>${Utils.getLangString("ui7_edit_startup_lua", "Edit Startup Lua")}</b></div>
  255. <div class="LuupHelpLink"><a target="_blank" href="http://wiki.micasaverde.com/index.php/Main_Page#Luup_code_and_Plugins">${Utils.getLangString("ui7_luup_help", "Find help about how to use luua code.")}</a></div>
  256. <div>
  257. <div>${Utils.getLangString("ui7_code", "Code")}</div>
  258. <div><textarea class="form-control" rows="10" id="${View.idForUpnpCodeContent(true)}" wrap="off">${application.userData.StartupCode ? Utils.jsonToLua(application.userData.StartupCode) : ''}</textarea></div>
  259. </div>
  260. <div></div>
  261. <div><input type="button" class="vBtn" value="${Utils.getLangString("ui7_go", "GO")}" id="${View.idForTestStartupLuaCodeButton(true)}"></div>`;
  262. return html;
  263. };
  264. View.returnCreateScenePageLuupCode = function(luupCode) {
  265. var labelSaveLua = Utils.getLangString('ui7_general_ucase_save_lua', 'Save lua');
  266. var labelBack = Utils.getLangString('ui7_general_ucase_back', 'Back');
  267. var txtPlaceholder = Utils.getLangString('ui7_create_scene_page_luup_code_enter_code_here', 'Enter your Luup code here...');
  268.  
  269. var txtLuupCode = (typeof luupCode !== 'undefined') ? luupCode : '';
  270.  
  271. var html = `<div class="clearfix" id="${View.idForCreateScenePageLuupCode(true)}">
  272. <div class="clearfix">
  273. <div class="pull-left flip scenes_button_back" id="${View.idForCreateScenePageLuupCodeButtonBack(true)}">${labelBack}</div>
  274. </div>
  275. <div class="clearfix">
  276. <div class="LuupHelpLink"><a target="_blank" href="http://wiki.micasaverde.com/index.php/Main_Page#Luup_code_and_Plugins">${Utils.getLangString("ui7_luup_help", "Find help about how to use luua code.")}</a></div>
  277. <textarea id="${View.idForCreateScenePageLuupCodeTextarea(true)}" rows="10" cols="40" class="full_width" placeholder="${txtPlaceholder}">${txtLuupCode}</textarea>
  278. </div>
  279. <div class="clearfix">
  280. <div class="pull-right flip scenes_button_done" id="${View.idForCreateScenePageLuupCodeButtonSave(true)}">${labelSaveLua}</div>
  281. </div>
  282. </div>`;
  283. return html;
  284. };
  285. View.returnSceneTriggerSummaryLuupEventContainer = function(triggerId) {
  286. var labelSaveLua = Utils.getLangString('ui7_general_ucase_save_lua', 'Save lua');
  287. var labelCancel = Utils.getLangString('ui7_general_ucase_cancel', 'Cancel');
  288. var labelDelete = Utils.getLangString('ui7_general_ucase_delete', 'Delete');
  289. var txtPlaceholder = Utils.getLangString('ui7_create_scene_page_luup_code_enter_code_here', 'Enter your Luup code here...');
  290.  
  291. var html = `<div class="clearfix hidden margin_top_10" id="${View.idForSceneTriggerDeviceSummaryLuupEventContainer(triggerId, true)}">
  292. <div class="clearfix">
  293. <div class="LuupHelpLink"><a target="_blank" href="http://wiki.micasaverde.com/index.php/Main_Page#Luup_code_and_Plugins">${Utils.getLangString("ui7_luup_help", "Find help using luua code")}</a></div>
  294. <textarea id="${View.idForSceneTriggerDeviceSummaryLuupEventCode(triggerId, true)}" rows="10" cols="40" class="full_width" placeholder="${txtPlaceholder}"></textarea>
  295. </div>
  296. <div class="clearfix">
  297. <div class="pull-right flip scenes_button_done" id="${View.idForSceneTriggerDeviceSummaryLuupEventButtonSave(triggerId, true)}" data-trigger_id="${triggerId}">${labelSaveLua}</div>
  298. <div class="pull-right flip scenes_button_done margin_right_10" id="${View.idForSceneTriggerDeviceSummaryLuupEventButtonCancel(triggerId, true)}" data-trigger_id="${triggerId}">${labelCancel}</div>
  299. <div class="pull-right flip scenes_button_done margin_right_10 hidden" id="${View.idForSceneTriggerDeviceSummaryLuupEventButtonDelete(triggerId, true)}" data-trigger_id="${triggerId}">${labelDelete}</div>
  300. </div>
  301. </div>`;
  302. return html;
  303. };
  304.  
  305. // new ids
  306. View.idForAddUserPhoneInput = function(inView){
  307. var id = 'add_user_phone_input';
  308. return typeof inView !== 'undefined' ? id : '#' + id;
  309. };
  310. View.idForAddUserPhoneInputContainer = function(inView){
  311. var id = 'add_user_phone_input_container';
  312. return typeof inView !== 'undefined' ? id : '#' + id;
  313. };
  314. // override - make the notification only user type checked by default
  315. View.returnUserRoleSelectionView = function(userObject) {
  316. try {
  317. var accessLevel = Utils.getLangString("ui7_account_access_level", "Access level");
  318. var accountAdministratorDescription = Utils.getLangString("ui7_account_administrator_access_level_description", "<b>Account Administrator</b><br/>A _UNIT_NAME_ Account Administrator has full control over the entire account. There must be at least one Account Administrator for each _UNIT_NAME_ Account; typically this is the person who sets the system(s) up. A _UNIT_NAME_ Account Administrator can control or change who else has access to each system and at which Permissions level. An Account Administrator can change any account information (such as the home address), and can change how the system operates (such as which sensors are active in Night Mode). An Account Administrator is entrusted with controlling all devices without restriction. <b><i>This is the highest level of control of your _UNIT_NAME_ Account.</i></b>");
  319. var advancedUserDescription = Utils.getLangString("ui7_advanced_user_access_level_description", "<b>Advanced User</b><br/>An Advanced User has permission to do almost everything an Account Administrator can do, with one exception: The Advanced User cannot create new users or change the status of others. Since an Advanced User can control all devices, this status should be reserved for those people who need to change device settings, and/or create, change and configure Scenes and Modes. The Advanced User permission level can only be assigned by an Account Administrator. <b><i>This is the second highest level of control of your _UNIT_NAME_ Account.</i></b>");
  320. var basicUserDescription = Utils.getLangString("ui7_basic_user_access_level_description", "<b>Basic User</b><br/>A Basic User can operate the _UNIT_NAME_ system as allowed by the Account Administrator(s). Typically this is the level that's assigned to most family members (especially children), or household help, or employees of a small business. Essentially a Basic User can use the system, but cannot make any changes to account settings or how the system is setup, and cannot create or change other users' accounts. <b><i>This Basic User level of permissions is usually the most common, especially for larger families or small businesses with employees.</i></b>");
  321. var notificationOnlyDescription = Utils.getLangString("ui7_notification_only_access_level_description", "<b>Notifications-Only Recipient</b><br/> A Notifications-Only Recipient will receive notifications by text and/or email when there are events such as security breaches, temperature extremes, and other safety or security occurrences (Which events will trigger these notifications is under the control of the Account or Guest Administrators). A Notifications-Only Recipient cannot control or configure your _UNIT_NAME_ system. <b><i>This is the lowest level of permissions granted.</i></b>");
  322.  
  323. var checkedAdministrator = typeof userObject !== 'undefined' && Utils.int(userObject.PK_PermissionRole) === CONFIG.PERMISSION_ROLE_END_USER ? ' checked ' : '';
  324. var checkedAdvancedUser = typeof userObject !== 'undefined' && Utils.int(userObject.PK_PermissionRole) === CONFIG.PERMISSION_ROLE_ADVANCED_USER ? ' checked ' : '';
  325. var checkedBasicUser = typeof userObject !== 'undefined' && Utils.int(userObject.PK_PermissionRole) === CONFIG.PERMISSION_ROLE_GUEST ? ' checked ' : '';
  326. var checkedNotificationOnly = typeof userObject === 'undefined' || (typeof userObject !== 'undefined' && Utils.int(userObject.PK_PermissionRole) === CONFIG.PERMISSION_ROLE_NOTIFICATION_ONLY) ? ' checked ' : '';
  327.  
  328. var html = `<div class="add_user_v2_access_level">${accessLevel}</div>
  329. <div class="add_user_v2_access_levels_containers">
  330. <div class="clearfix add_user_v2_level_container light_grey_bkg">
  331. <div class="pull-left flip add_user_v2_radio">
  332. <input id="add_user_permission_role_administrator" name="add_user_permission_role" type="radio" ${checkedAdministrator} value="${myInterface.returnUserAdminRoleValue()}" />
  333. </div>
  334. <div class="pull-left flip add_user_v2_radio_label">${accountAdministratorDescription}</div>
  335. </div>
  336. <div class="clearfix add_user_v2_level_container">
  337. <div class="pull-left flip add_user_v2_radio">
  338. <input id="add_user_permission_role_administrator" name="add_user_permission_role" type="radio" ${checkedAdvancedUser} value="${myInterface.returnAdvancedUserRoleValue()}" />
  339. </div>
  340. <div class="pull-left flip add_user_v2_radio_label">${advancedUserDescription}</div>
  341. </div>
  342. <div class="clearfix add_user_v2_level_container light_grey_bkg">
  343. <div class="pull-left flip add_user_v2_radio">
  344. <input id="add_user_permission_role_administrator" name="add_user_permission_role" type="radio" ${checkedBasicUser} value="${myInterface.returnUserGuestRoleValue()}" />
  345. </div>
  346. <div class="pull-left flip add_user_v2_radio_label">${basicUserDescription}</div>
  347. </div>
  348. <div class="clearfix add_user_v2_level_container">
  349. <div class="pull-left flip add_user_v2_radio">
  350. <input id="add_user_permission_role_administrator" name="add_user_permission_role" type="radio" ${checkedNotificationOnly} value="${myInterface.returnUserNotificationRoleValue()}" />
  351. </div>
  352. <div class="pull-left flip add_user_v2_radio_label">${notificationOnlyDescription}</div>
  353. </div>
  354. </div>`;
  355. return html;
  356. } catch (e) {
  357. Utils.logError('Error in VIew.returnUserRoleSelectionView(): ' + e);
  358. }
  359. };
  360. // override - add phone input for notification type user
  361. View.returnAddUserFormV2 = function(gateways) {
  362. try {
  363. var title = Utils.getLangString("ui7_account_add_user", "Add User");
  364. var labelButtonBack = Utils.getLangString("ui7_general_ucase_back", "Back");
  365. var accountPermissionLevels = Utils.getLangString("ui7_unit_account_permission_level", "_UNIT_NAME_ Account Permissions Levels");
  366. var accountPermissionLevelsDescription = Utils.getLangString("ui7_unit_account_permission_level_description", "Your _UNIT_NAME_ system is highly customizable, but to prevent accidental or unauthorized changes to system settings, each user is assigned one of four levels of permissions (Remember that a _UNIT_NAME_ Account may be able to access more than one _UNIT_NAME_ system - for example, you might have a home system and a small business system both controlled from a single Account). Each person who uses the Account - typically everyone who lives or works in the home or business - is designated as either an Administrator, Advanced User, Basic User, or Notifications Only Recipient, as explained below:");
  367. var permissionChartTitle = Utils.getLangString("ui7_permission_chart_title", "This chart summarizes these permissions levels.");
  368.  
  369. var html = `<div class="add_user_v2_container">
  370. <div class="add_user_v2_back_button_container clearfix">
  371. <div class="scenes_button_back" id="${View.idForBackToMyUsers(true)}">${labelButtonBack}</div>
  372. </div>
  373. <div class="add_user_v2_title">${title}</div>
  374. <div class="add_user_v2_inputs_container">`;
  375.  
  376. if (typeof config.emailAsUsername === 'undefined' || config.emailAsUsername === false) {
  377. html += `<div class="labelInputContainer clearfix">
  378. <div class="pull-left flip inputLabel add_user_v2_label">${Utils.getLangString("ui7_account_username", "Username:")}<span class="red">*</span></div>
  379. <div class="pull-left flip add_user_v2_input"><input id="${View.idForAddUserUsernameInput(true)}" class="customInput" type="text" autofocus/></div>
  380. </div>`;
  381. }
  382.  
  383. html += `<div id="${View.idForAddUserPhoneInputContainer(true)}" class="labelInputContainer clearfix">
  384. <div class="pull-left flip inputLabel add_user_v2_label">${Utils.getLangString("ui7_account_phone_number", "Phone number is: ")}<span class="red">*</span></div>
  385. <div class="pull-left flip add_user_v2_input"><input value="(+52) " id="${View.idForAddUserPhoneInput(true)}" class="customInput" type="text" /></div>
  386. </div>`;
  387.  
  388. html += `<div class="labelInputContainer clearfix">
  389. <div class="pull-left flip inputLabel add_user_v2_label">${Utils.getLangString("ui7_account_add_user_email_address", "User email is:")}<span class="red">*</span></div>
  390. <div class="pull-left flip add_user_v2_input"><input id="${View.idForAddUserEmailInput(true)}" class="customInput" type="text" /></div>
  391. </div>
  392. <div class="labelInputContainer clearfix">
  393. <div class="pull-left flip inputLabel add_user_v2_label">${Utils.getLangString("ui7_account_password", "Password:")}<span class="red">*</span></div>
  394. <div class="pull-left flip add_user_v2_input"><input data-input-type="password" id="${View.idForAddUserPasswordInput(true)}" class="customInput" type="password" /></div>
  395. </div>
  396. <div class="labelInputContainer clearfix">
  397. <div class="pull-left flip inputLabel add_user_v2_label">${Utils.getLangString("ui7_account_repeat_password", "Repeat Password:")}<span class="red">*</span></div>
  398. <div class="pull-left flip add_user_v2_input"><input data-input-type="password" id="${View.idForAddUserRepeatPasswordInput(true)}" class="customInput" type="password" /></div>
  399. </div>
  400. <div class="labelInputContainer clearfix">
  401. <div class="checkboxContainer pull-left flip inputLabel">
  402. <input class="customCheckbox" id="${View.idForShowPasswordCheckbox(true)}" type="checkbox" name="showPassword" />
  403. <label class="labelForCustomCheckbox" for="${View.idForShowPasswordCheckbox(true)}">${Utils.getLangString("ui7_showPassword", "Show Password")}</label>
  404. </div>
  405. <div id="${View.idForPasswordStrength(true)}" class="veryWeekPassword"><p id="${View.idForPasswordStrengthText(true)}">${Utils.getLangString("ui7_passwordVeryWeek", "Very Week")}</p></div>
  406. </div>
  407. <div class="labelInputContainer changePasswordInfo"><small>${Utils.getLangString("ui7_account_password_format", "<b>Hint: </b>Password must be at least 8 characters long.")}</small></div>
  408. <div class="labelInputContainer clearfix requiredContainer"><small class="pull-right flip"><span class="red">*</span>${Utils.getLangString("ui7_required", "Required")}</small></div>
  409. </div>
  410. <div class="add_user_v2_title_levels">${accountPermissionLevels}</div>
  411. <div class="add_user_v2_title_levels_description">${accountPermissionLevelsDescription}</div>
  412. ${View.returnUserRoleSelectionView()}
  413. <div class="add_user_v2_permission_chart_title">${permissionChartTitle}</div>
  414. ${View.returnChartPermissionLevelTable()}`;
  415.  
  416. html += View.returnSelectGatewayView(gateways);
  417.  
  418. html += `<div id="change_password_controls" class="clearfix col-sm-8 genericSaveButtonContainer">
  419. <input id="${View.idForAccountAddUser(true)}" class="vBtn pull-right flip margin_top_20" type="button" value="${Utils.getLangString("ui7_account_add_user", "Add User")}" />
  420. </div>
  421. </div>`;
  422. return html;
  423. } catch (e) {
  424. Utils.logError('Error in View.returnAddUserFormV2(): ' + e);
  425. }
  426. };
  427. // override - toggle phone input for notification type user
  428. Interface.prototype.addBehaviorToAddUserView = function(calledFrom){
  429. try{
  430. var that = this;
  431. $(View.idForBackToMyUsers()).off().on('click', function () {
  432. if (typeof calledFrom !== 'undefined') {
  433. that.handleMyModesArrowButtonClick();
  434. } else {
  435. that.get_unit_users();
  436. }
  437. });
  438.  
  439. $(View.idForAccountAddUser()).off('click').on('click', function () {
  440. that.addUser();
  441. });
  442.  
  443. var $permissionLevelRadios = $('input[name="add_user_permission_role"]');
  444. $permissionLevelRadios.each(function () {
  445.  
  446. $(this).off('click').on('click', function () {
  447. var levelValue = $(this).val();
  448. Utils.int(levelValue) === CONFIG.PERMISSION_ROLE_END_USER ?
  449. $(View.idForSelectGatewayContainer()).hide() : $(View.idForSelectGatewayContainer()).show();
  450. // if guest show phone number input
  451. Utils.int(levelValue) !== CONFIG.PERMISSION_ROLE_NOTIFICATION_ONLY ?
  452. $(View.idForAddUserPhoneInputContainer()).hide() : $(View.idForAddUserPhoneInputContainer()).show();
  453. });
  454.  
  455. if ($(this).is(':checked') && parseInt($(this).val()) === CONFIG.PERMISSION_ROLE_END_USER) {
  456. $(View.idForSelectGatewayContainer()).hide();
  457. }
  458. // hide phone input if not for notification only
  459. if ($(this).is(':checked') && parseInt($(this).val()) !== CONFIG.PERMISSION_ROLE_NOTIFICATION_ONLY) {
  460. $(View.idForAddUserPhoneInputContainer()).hide();
  461. }
  462. });
  463. $(View.idForShowPasswordCheckbox()).off().on('click', function () {
  464. that.displayPasswordInClearGeneric(View.idForShowPasswordCheckbox(), '.add_user_v2_inputs_container');
  465. });
  466. $(View.idForAddUserPasswordInput()).on('keypress keyup keydown', function () {
  467. var password = $(this).val();
  468. that.updatePasswordStrengthDisplay(that.checkPasswordStrength(password));
  469. });
  470. }catch(err){
  471. Utils.logError('Interface.addBehaviorToAddUserView() error: ' + err);
  472. }
  473. };
  474. // override - add phone number to user creation object and set interface flag
  475. Interface.prototype.returnNewAccountUserObject = function () {
  476. try {
  477. var that = this;
  478. var returnObject = {};
  479. //get username,email,password
  480. var username = $(View.idForAddUserUsernameInput()).val();
  481. var email = $(View.idForAddUserEmailInput()).val();
  482. var password = $(View.idForAddUserPasswordInput()).val();
  483. var permissionRole = $("input[name='add_user_permission_role']:checked").val();
  484. var repeatPasswordValue = document.getElementById("add_user_rpassword_input").value;
  485. returnObject.userObj = {
  486. params: {
  487. Username: typeof config.emailAsUsername !== 'undefined' && config.emailAsUsername === true ? '' : username,
  488. Email: email,
  489. Password: password,
  490. PK_Account: authObj.PK_Account,
  491. PK_Oem: MMS.getOem()
  492. },
  493. requireAuth: 1
  494. };
  495.  
  496. // get phone -> notification only guest
  497. var phone = $(View.idForAddUserPhoneInput()).val();
  498. phone = phone.replace(/\(.*?\)\s?/g, '').replace(/\ /g, '');
  499.  
  500. if(phone !== ''){
  501. returnObject.userObj.params.PhoneNumber = phone;
  502. returnObject.userObj.params.PK_Provider = 0;
  503. returnObject.userObj.params.PK_Country = 484;
  504. // set flag for new user to be validated
  505. that.newUserPK = true;
  506. }
  507.  
  508. returnObject.permissionRole = permissionRole;
  509. returnObject.gatewaySelected = that.isSelectedAnyGatewayFromAddUserList();
  510. returnObject.repeatPasswordValue = repeatPasswordValue;
  511. return returnObject;
  512. } catch (e) {
  513. Utils.logError('Error in Interface.returnNewAccountUserObject(): ' + e);
  514. }
  515.  
  516. return returnObject;
  517. };
  518. // override - update interface flag with user id
  519. Interface.prototype.handleUserCreationSuccess = function (transport) {
  520. try {
  521. var that = this;
  522. if (parseInt(transport.status) !== HTTP_STATUS_SUCCESS && parseInt(transport.status) !== HTTP_STATUS_SUCCESS_CREATED) {
  523. that.handleUserCreationError(transport);
  524. return;
  525. }
  526.  
  527. try {
  528. var response = JSON.parse(transport.responseText);
  529. var newUserObj = JSON.parse(Utils.base64Decode(response.Identity));
  530. } catch (e2) {
  531. Utils.logError('Error in Interface.handleUserCreationSuccess(): ' + e2);
  532. that.handleUserCreationError(transport);
  533. return;
  534. }
  535.  
  536. var roleAndPermissionsObject = that.returnUserInfoRoleObject();
  537. var updateObject = {
  538. roleAndPermissionsObject: roleAndPermissionsObject,
  539. PK_User: newUserObj.PK_User
  540. };
  541.  
  542. // update flag with newly created user id
  543. if(that.newUserPK === true){
  544. that.newUserPK = newUserObj.PK_User;
  545. }
  546.  
  547. MMS.updateUserPermissions(updateObject, that.handleUserCreationAndRoleUpdateSuccess, that.handleUserCreationAndRoleUpdateError, that);
  548. } catch (e) {
  549. Utils.logError('Error in Interface.handleUserCreationSuccess(): ' + e);
  550. }
  551. };
  552. // override - if flag then validate email and phone else normal flow
  553. Interface.prototype.handleUserCreationAndRoleUpdateSuccess = function (transport) {
  554. try {
  555. var that = this;
  556. if (parseInt(transport.status) !== HTTP_STATUS_SUCCESS && parseInt(transport.status) !== HTTP_STATUS_SUCCESS_CREATED) {
  557. that.handleUserCreationAndRoleUpdateError();
  558. return;
  559. }
  560.  
  561. // if flag newUserPK is set and is a number we try to validated his phone
  562. // and email if any
  563. if(typeof that.newUserPK !== 'undefined' && Utils.int(that.newUserPK) > 0){
  564. MMS.getUser(that.newUserPK, that.handleNewUserGetUserInfoSuccess, that.handleNewUserGetUserInfoError, that);
  565. } else {
  566. // else normal flow
  567. //hide loading
  568. that.hideModalLoading();
  569. that.showMessagePopup(Utils.getLangString("ui7_user_created", "User created, wait a few moments and your new user will appear in the list."), MessageCategory.SUCCESS, 5000);
  570. MMS.forceSyncUsers(that.forceSyncUsersSuccess, that.forceSyncUsersError, that);
  571. }
  572. } catch (e) {
  573. Utils.logError('Error in Interface.handleUserCreationAndRoleUpdateSuccess(): ' + e);
  574. }
  575. };
  576. // validation method
  577. Interface.prototype.handleNewUserGetUserInfoSuccess = function(transport){
  578. try{
  579. var that = this;
  580. var params;
  581. if (parseInt(transport.status) !== HTTP_STATUS_SUCCESS && parseInt(transport.status) !== HTTP_STATUS_SUCCESS_CREATED) {
  582. that.handleNewUserGetUserInfoError(transport);
  583. return;
  584. }
  585.  
  586. try {
  587. var userInfo = JSON.parse(transport.responseText);
  588. } catch (e2) {
  589. Utils.logError('Error in Interface.handleNewUserGetUserInfoSuccess(): ' + e2);
  590. that.handleNewUserGetUserInfoError(transport);
  591. return;
  592. }
  593.  
  594. // check phone
  595. var hasPhone = typeof userInfo.Phone !== 'undefined' && typeof userInfo.Phone.Phone !== 'undefined' &&
  596. Utils.trim(userInfo.Phone.Phone) !== '' ? true : false;
  597.  
  598. var isPhoneValid = typeof userInfo.Phone !== 'undefined' && typeof userInfo.Phone.Validated !== 'undefined' &&
  599. Utils.int(userInfo.Phone.Validated) > 0 ? true : false;
  600.  
  601. var hasValidationCode = typeof userInfo.Phone !== 'undefined' && typeof userInfo.Phone.ValidationCode !== 'undefined' &&
  602. Utils.int(userInfo.Phone.ValidationCode) > 0 ? true : false;
  603.  
  604. var PK_User = that.newUserPK;
  605. // reset flag as we won't need it any more
  606. delete that.newUserPK;
  607.  
  608. // validate if case
  609. if(hasPhone && !isPhoneValid && hasValidationCode){
  610. params = {
  611. code: userInfo.Phone.ValidationCode,
  612. method: 'sms',
  613. PK_User: PK_User
  614. };
  615. MMS.validateNotificationMethod(params, that.valdiateNotifOnlyPhoneSuccess, that.valdiateNotifOnlyPhoneError, that);
  616. }
  617.  
  618. // check email
  619. var isMailValid = typeof userInfo.Validated !== 'undefined' &&
  620. Utils.int(userInfo.Validated) > 0 ? true : false;
  621.  
  622. var hasMailValidationCode = typeof userInfo.ValidationCode !== 'undefined' &&
  623. Utils.int(userInfo.ValidationCode) > 0 ? true : false;
  624.  
  625. // validate if case
  626. if(!isMailValid && hasMailValidationCode){
  627. params = {
  628. code: userInfo.ValidationCode,
  629. method: 'email',
  630. PK_User: PK_User
  631. };
  632. MMS.validateNotificationMethod(params, that.valdiateNotifOnlyEmailSuccess, that.valdiateNotifOnlyEmailError, that);
  633. }
  634.  
  635. // resume normal flow and sync users
  636. //hide loading
  637. that.hideModalLoading();
  638. that.showMessagePopup(Utils.getLangString("ui7_user_created", "User created, wait a few moments and your new user will appear in the list."), MessageCategory.SUCCESS, 5000);
  639. MMS.forceSyncUsers(that.forceSyncUsersSuccess, that.forceSyncUsersError, that);
  640. } catch(e) {
  641. Utils.logError('Error in Interface.handleNewUserGetUserInfoSuccess(): ' + e);
  642. }
  643. };
  644. Interface.prototype.valdiateNotifOnlyEmailSuccess = function(){
  645. try{
  646. Utils.logCriticalError('Interface.valdiateNotifOnlyEmailSuccess(): OK - Validated Email');
  647. } catch(e) {
  648. Utils.logError('Error in Interface.valdiateNotifOnlyEmailSuccess(): ' + e);
  649. }
  650. };
  651. Interface.prototype.valdiateNotifOnlyEmailError = function(){
  652. try{
  653. Utils.logCriticalError('Interface.valdiateNotifOnlyEmailError(): ERROR - Failed Email Validation');
  654. } catch(e) {
  655. Utils.logError('Error in Interface.valdiateNotifOnlyEmailError(): ' + e);
  656. }
  657. };
  658. Interface.prototype.valdiateNotifOnlyPhoneSuccess = function(){
  659. try{
  660. Utils.logCriticalError('Interface.valdiateNotifOnlyPhoneSuccess(): OK - Validated Phone');
  661. } catch(e) {
  662. Utils.logError('Error in Interface.valdiateNotifOnlyPhoneSuccess(): ' + e);
  663. }
  664. };
  665. Interface.prototype.valdiateNotifOnlyPhoneError = function(){
  666. try{
  667. Utils.logCriticalError('Interface.valdiateNotifOnlyPhoneSuccess(): ERROR - Failed Phone Validation');
  668. } catch(e) {
  669. Utils.logError('Error in Interface.valdiateNotifOnlyPhoneError(): ' + e);
  670. }
  671. };
  672. Interface.prototype.handleNewUserGetUserInfoError = function(){
  673. try{
  674. var that = this;
  675. Utils.logCriticalError('Interface.handleNewUserGetUserInfoError(): we created the notification only user but could validate his phone/email');
  676. //hide loading
  677. that.hideModalLoading();
  678. that.showMessagePopup(Utils.getLangString("ui7_user_created", "User created, wait a few moments and your new user will appear in the list."), MessageCategory.SUCCESS, 5000);
  679. MMS.forceSyncUsers(that.forceSyncUsersSuccess, that.forceSyncUsersError, that);
  680. } catch(e) {
  681. Utils.logError('Error in Interface.handleNewUserGetUserInfoError(): ' + e);
  682. }
  683. };
  684.  
  685. myInterface.createDeviceControlImage = function (control, deviceId) {
  686. try {
  687. var baseImageURL = config.dataRequestUrl + '/data_request' + DOMPurify.sanitize(control.Display.url).replace(/&amp;/g, '&') + deviceId;
  688. var thumbnailImageURL = baseImageURL + '&res=low';
  689. var defaultSpinnerImg = 'skins/default/img/other/Wait_white.gif';
  690. var defaultSpinnerImgClass = 'camera_dashboard_view_item_position';
  691. var thumbnailRefreshInterval = (application.uiFlags.slowConnection) ? 0 : config.cameraThumbnailRetrievalInterval;
  692.  
  693. CameraImagePlayerDispatcher.getInstance().getCameraImagePlayer(InterfaceScreenView.DEVICES, thumbnailImageURL, deviceId, {
  694. refreshInterval: thumbnailRefreshInterval,
  695. classNameForImage: 'device_camera_thumbnail',
  696. classNameForContainer: 'device_camera_thumbnail_container',
  697. idForTargetContainer: View.idForDeviceControlGroup(deviceId, control.ControlGroup),
  698. defaultImage: {className: defaultSpinnerImgClass, src: defaultSpinnerImg},
  699. autoPlay: true,
  700. playOneFrame: true,
  701. maxRetriesIfError: 1
  702. });
  703. } catch (exception) {
  704. Utils.logError('Interface.createDeviceControlImage(): ' + exception);
  705. }
  706. };
  707. myInterface.createFavoriteDeviceControlImage = function (control, deviceId) {
  708. try {
  709. var baseImageURL = config.dataRequestUrl + '/data_request' + control.Display.url + deviceId;
  710. var thumbnailImageURL = baseImageURL + '&res=low';
  711. var defaultSpinnerImg = 'skins/default/img/other/Wait_white.gif';
  712. var defaultSpinnerImgClass = 'camera_favorite_view_item_position';
  713. var thumbnailRefreshInterval = (application.uiFlags.slowConnection) ? 0 : config.cameraThumbnailRetrievalInterval;
  714.  
  715. CameraImagePlayerDispatcher.getInstance().getCameraImagePlayer(InterfaceScreenView.INDEX, thumbnailImageURL, deviceId, {
  716. refreshInterval: thumbnailRefreshInterval,
  717. classNameForImage: 'device_camera_thumbnail',
  718. classNameForContainer: 'favorite_device_camera_thumbnail_container',
  719. idForTargetContainer: View.idForFavoritesDeviceControls(deviceId),
  720. defaultImage: {className: defaultSpinnerImgClass, src: defaultSpinnerImg},
  721. autoPlay: true,
  722. playOneFrame: true,
  723. maxRetriesIfError: 1
  724. });
  725. } catch (exception) {
  726. Utils.logError('Interface.createFavoriteDeviceControlImage(): ' + exception);
  727. }
  728. };
  729. myInterface.addCameraLargeThumbnailView = function (cameraObject) {
  730. try {
  731. var that = this;
  732. //set View
  733. $(View.idForCamerasCamerasContent()).append(View.returnCameraLargeThumbnailView(cameraObject));
  734. //attach handlers
  735. $(View.idForCameraLargeThumbnailViewContainer(cameraObject.id)).off('click').on('click', function () {
  736. that.showCameraPlayerAndDetails(cameraObject.id);
  737. });
  738. //start thumbnail viewer
  739. //TO DO -> 4:3 / 16:9
  740. var baseImageURL = config.dataRequestUrl + '/data_request' + application.getCameraControlDisplayUrl(cameraObject.id) + cameraObject.id;
  741. var thumbnailImageURL = baseImageURL + '&res=high';
  742. var defaultSpinnerImg = 'skins/default/img/other/Wait_white.gif';
  743. var defaultSpinnerImgClass = 'camera_large_view_item_position';
  744. var callbackObject = {
  745. 'context': that,
  746. 'function': 'handleLargeThumbnailViewBackground',
  747. 'arguments': cameraObject.id
  748. };
  749. var thumbnailRefreshInterval = (application.uiFlags.slowConnection) ? 0 : config.cameraThumbnailRetrievalInterval;
  750.  
  751. CameraImagePlayerDispatcher.getInstance().getCameraImagePlayer(InterfaceScreenView.CAMERAS_VIEW_LARGE, thumbnailImageURL, cameraObject.id, {
  752. refreshInterval: thumbnailRefreshInterval,
  753. classNameForImage: 'cameras_large_view_thumbnail',
  754. classNameForContainer: 'cameras_large_view_thumbnail_container',
  755. idForTargetContainer: View.idForCameraLargeThumbnailViewContainer(cameraObject.id),
  756. defaultImage: {className: defaultSpinnerImgClass, src: defaultSpinnerImg},
  757. autoPlay: true,
  758. playOneFrame: true,
  759. maxRetriesIfError: 5,
  760. afterDrawCallback: callbackObject,
  761. onErrorCallback: function() {
  762. Utils.logError('error loading image for camera: ' + cameraObject.id);
  763. }
  764. });
  765.  
  766. if(config.showCameraNameInCamerasPage){
  767. $(View.idForCameraLargeThumbnailViewContainer(cameraObject.id)).append('<div class="cameraNameLargeView">' + cameraObject.name + '</div>');
  768. }
  769. } catch (e) {
  770. Utils.logError("ERROR in Interface.addCameraLargeThumbnailView(): " + e);
  771. }
  772. };
  773. View.returnUnitSettingsContainerContent = function(args) {
  774. try {
  775. return `<div id="${View.idForDataContainer(true)}" class="unitSettingsPage">
  776. <h1 id="data_container_title" class="title">${Utils.getLangString("ui7_unit_settings", "Unit Settings")}</h1>
  777. <div class="dateTimeSettingsContainer clearfix">
  778. <h3 class="settingsLocation subTitle">${Utils.getLangString("ui7_settings_date_time", "Date/Time Settings:")}</h3>
  779. <div class="labelInputContainer clearfix">
  780. <div class="pull-left flip inputLabel">${Utils.getLangString("ui7_account_date_format", "Date Format: ")}</div>
  781. <div class="pull-left flip dateFormatSelectContainer customSelectBoxContainer">${View.returnSelectFromObject(dateFormatObject, View.idForDateFormatSelect(true), 'class="customSelectBox dateFormatSelectBox"', args.dateFormat)}</div>
  782. </div>
  783. <div class="labelInputContainer clearfix">
  784. <div class="pull-left flip inputLabel">${Utils.getLangString("ui7_account_time_format", "Time Format: ")}</div>
  785. <div class="pull-left flip timeFormatSelectContainer customSelectBoxContainer">${View.returnSelectFromObject(timeFormatObject, View.idForTimeFormatSelect(true), 'class="customSelectBox timeFormatSelectBox"', args.timeFormat)}</div>
  786. </div>
  787. <div class="labelInputContainer clearfix">
  788. <div class="pull-left flip inputLabel">${Utils.getLangString("ui7_account_temperature_format", "Temperature Format: ")}</div>
  789. <div class="pull-left flip temperatureFormatSelectContainer customSelectBoxContainer">${View.returnSelectFromObject(temperatureFormatObject, View.idForTemperatureSelect(true), 'class="customSelectBox temperatureFormatSelectBox"', args.tempFormat.toUpperCase())}</div>
  790. </div>
  791. <div id="${View.idForWeatherSettingsContainer(true)}"></div>
  792. <div class="labelInputContainer clearfix">
  793. <div class="pull-left flip inputLabel">${Utils.getLangString("ui7_account_timezone", "Timezone: ")}</div>
  794. <div class="pull-left flip timezoneFormatSelectContainer customSelectBoxContainer">${View.returnSelectFromTimezoneObject(args.timezones, View.idForTimezoneSelect(true), 'class="customSelectBox timezoneFormatSelectBox"', args.currentTimezone)}</div>
  795. </div>
  796. <div class=""><small class="note">${Utils.getLangString("ui7_account_automatic_date_time", '<b>Note:</b> Date/time is automatically updated for the selected timezone.')}</small></div>
  797. </div>
  798. <div id="notifications" class="deviceINformationContainer clearfix">
  799. <h3 class="deviceInformation subTitle">${Utils.getLangString("ui7_settings_device_information", "Device Information:")}</h3>
  800. ${View.returnRenameUnitFormView()}
  801. <div class="labelInputContainer clearfix">
  802. <div class="pull-left flip inputLabel">${Utils.getLangString("ui7_lang_mac_address", "MAC Address")}:</div>
  803. <div class="pull-left flip labelInfo">${DOMPurify.sanitize(args.macAddress)}</div>
  804. </div>
  805. <div class="labelInputContainer clearfix">
  806. <div class="pull-left flip inputLabel">${Utils.getLangString("ui7_settings_application_id", "Application ID")}: </div>
  807. <div class="pull-left flip labelInfo">${DOMPurify.sanitize(args.serialNumber)}</div>
  808. </div>
  809. <div class="labelInputContainer clearfix">
  810. <div class="pull-left flip inputLabel">${Utils.getLangString("ui7_settings_application_version", "Application Version")}: </div>
  811. <div class="pull-left flip labelInfo">${DOMPurify.sanitize(args.firmwareVersion)}</div>
  812. </div>
  813. </div>
  814. <div class="data_container_buttons clearfix genericSaveButtonContainer">
  815. <input id="${View.idForSaveUnitTimeSettingsBtn(true)}" class="vBtn pull-right" type="button" value="${Utils.getLangString("ui7_account_save_changes", "Save Changes")}" />
  816. </div>
  817. </div>
  818. </div>`;
  819. } catch (e) {
  820. Utils.logError('Error in View.returnUnitSettingsContainerContent(): ' + e);
  821. }
  822. };
  823. View.returnRenameUnitFormView = function() {
  824. try {
  825. var html = `<div class="labelInputContainer clearfix">
  826. <div class="pull-left flip inputLabel">${Utils.getLangString("ui7_account_unit_name", "Unit Name")}</div>
  827. <div class="pull-left flip"><input id="${View.idForAccountUnitName(true)}" class="customInput" type="text" value="" maxlength="30" /></div>
  828. </div>`;
  829. return html;
  830. } catch (e) {
  831. Utils.logError('Error in View.returnRenameUnitFormView(): ' + e);
  832. }
  833. };
  834. Interface.prototype.unit_settings = function () {
  835. try {
  836. var that = this;
  837. if(!that.isAllowedToViewUnitSettings()){
  838. return;
  839. }
  840. that.showModalLoading();
  841. if(typeof MMS.STATIC_DATA.Country === "undefined"){
  842. $(document).on("mmsStaticDataLoaded", that.handleUnitSettingsMmsStaticDataLoaded);
  843. return;
  844. }else{
  845. $.getJSON('timezone.json?rand=' + Math.random(), function(data){that.getUnitSetingsSuccess(data);});
  846. }
  847. } catch (e) {
  848. Utils.logError('Error in Interface.get_unit_settings(): ' + e.message);
  849. }
  850. };
  851. myInterface.handleUnitSettingsMmsStaticDataLoaded = function(event){
  852. $(document).off("mmsStaticDataLoaded");
  853. if(event.resolution === "success"){
  854. $.getJSON('timezone.json?rand=' + Math.random(), function(data){myInterface.getUnitSetingsSuccess(data);});
  855. }else{
  856. myInterface.errorLoadingUnitSettingsData();
  857. }
  858. };
  859. myInterface.errorLoadingUnitSettingsData = function(){
  860. var that = this;
  861. that.setView('returnUnitSettingsErrorView', {}, View.idForContent());
  862. };
  863. View.returnUnitSettingsErrorView = function(){
  864. var pageTitle = Utils.getLangString("ui7_unit_settings", "Unit Settings");
  865.  
  866. var html = `<div class="clearfix unitSettingsPage">
  867. <div class="clearfix">
  868. <div class=""><h1>${pageTitle}</h1></div>
  869. <div class="scenes_section_delimiter"></div>
  870. </div>
  871. <p>${Utils.getLangString("ui7_error_loadig_unit_settings_data", "Error loading Unit Settings data. Please reload 'Unit Settings' page.")}</p>
  872. </div>`;
  873. return html;
  874. };
  875. Interface.prototype.getUnitSetingsSuccess = function(data){
  876. try{
  877. var that = this;
  878. var weatherCity = "";
  879. var weatherCityUserData = '';
  880. var tempFormat = "C";
  881. if (typeof application.userData !== "undefined" && typeof application.userData.weatherSettings !== "undefined") {
  882. weatherCityUserData = application.userData.weatherSettings.weatherCity;
  883. tempFormat = application.userData.weatherSettings.tempFormat;
  884. }
  885. var weatherCityAccount = false;
  886. if (typeof authObj.accountInfo !== "undefined" && typeof authObj.accountInfo.Mailing !== "undefined") {
  887. weatherCityAccount = authObj.accountInfo.Mailing.PostalCode;
  888. }
  889. if (!!weatherCityUserData === true) {
  890. weatherCity = weatherCityUserData;
  891. } else {
  892. weatherCity = weatherCityAccount ? weatherCityAccount : "";
  893. }
  894. var args = {
  895. timezones: data,
  896. currentTimezone: application.sysinfo.timezone,
  897. dateFormat: that.getDateFormat(),
  898. timeFormat: (typeof (application.userData.timeFormat) !== "undefined") ? application.userData.timeFormat : config.defaultTimeFormat,
  899. weatherCity: weatherCity,
  900. tempFormat: tempFormat,
  901. serialNumber: application.sysinfo.installation_number,
  902. firmwareVersion: application.sysinfo.firmware_version,
  903. macAddress: application.sysinfo.hwaddr
  904. };
  905. that.setView('returnUnitSettingsContainerContent', args, View.idForContent());
  906. that.setView('returnWeatherSettingsContainer', {}, View.idForWeatherSettingsContainer());
  907. that.addBehaviorToUnitSettingsView();
  908. // add handlers for country change
  909. that.addWizardCountryHandlers();
  910. that.makeCountrySlelectBoxCustom();
  911. }catch(err){
  912. Utils.logError('Error in Interface.getUnitSetingsSuccess(): ' + err);
  913. }
  914. };
  915. Interface.prototype.addBehaviorToUnitSettingsView = function(){
  916. var that = this;
  917. that.addBehaviorToSaveDateTimeSettingsBtn();
  918. that.makeUnitSettingsTimezoneSlelectBoxCustom();
  919. that.displayRenameUnitForm();
  920. that.unitNameWaitRetries = 0;
  921. };
  922. Interface.prototype.displayRenameUnitForm = function () {
  923. try {
  924. var that = this;
  925. var unitName = '';
  926. if (that.unitNameWaitRetries > 5) {
  927. $(View.idForAccountUnitName()).val(unitName);
  928. return;
  929. }
  930.  
  931. if (authObj.gatewaysReceived === true) {
  932. unitName = application.returnUnitName();
  933. $(View.idForAccountUnitName()).val(unitName);
  934. } else {
  935. setTimeout(function () {
  936. that.unitNameWaitRetries++;
  937. that.displayRenameUnitForm();
  938. }, 1000);
  939. }
  940. } catch (e) {
  941. Utils.logError('Interface.displayRenameUnitForm(): ' + e);
  942. }
  943. };
  944. View.returnWeatherSettingsContainer = function() {
  945. try {
  946. if (application.uiFlags.noInternet) {
  947. return Utils.getLangString('ui7_location_internet_connection_required', 'You need an internet connection to choose the city you are located in.');
  948. }
  949. //telemx has only one country Mexico
  950. var userObject = {};
  951. userObject.Phone = {};
  952. userObject.Phone.PK_Country = config.setupWizardDefaultCountry;
  953. var html = `<div class="clearfix weatherSettingsContainer">
  954. <div class="clearfix">
  955. <div class="clearfix labelInputContainer hidden">
  956. <div class="pull-left flip inputLabel">${Utils.getLangString("ui7_account_country_provider", "Country:")}<span class="red">*</span></div>
  957. <div class="pull-left flip countrySelectBoxContainer">${View.returnCountrySelectBox(userObject, 1)}</div>
  958. </div>
  959. <div class="clearfix"></div>
  960. <div class="clearfix labelInputContainer">
  961. <div class="pull-left flip inputLabel">${Utils.getLangString("ui7_region_regional_settings", "Region:")}<span class="red">*</span></div>
  962. <div class="pull-left flip countrySelectContainer customSelectBoxContainer countrySelectBoxContainer locationSelectBox">
  963. <select class="customSelectBox accountSettingSCountrySelectBox" id="${View.idForSetupWizardRegion(true)}">
  964. <option value="-1">${Utils.getLangString("ui7_region_regional_settings", "Region")}</option>
  965. </select>
  966. </div>
  967. </div>
  968. <div class="clearfix"></div>
  969. <div class="clearfix labelInputContainer">
  970. <div class="pull-left flip inputLabel">${Utils.getLangString("ui7_city_regional_settings", "City:")}</div>
  971. <div class="pull-left flip countrySelectContainer customSelectBoxContainer countrySelectBoxContainer locationSelectBox">
  972. <select class="customSelectBox accountSettingSCountrySelectBox" id="${View.idForSetupWizardCity(true)}">
  973. <option value="-1">${Utils.getLangString("ui7_city_regional_settings", "City")}</option>
  974. </select>
  975. </div>
  976. </div>
  977. <div class="clearfix"></div>
  978. <div class="clearfix wizardCountryContainer"></div>
  979. <div class="clearfix wizardCountryContainer"></div>
  980. </div>
  981. </div>`;
  982. return html;
  983. } catch (err) {
  984. Utils.logError('Error in View.returnWeatherSettingsContainer(): ' + err);
  985. }
  986. };
  987. Interface.prototype.addBehaviorToSaveDateTimeSettingsBtn = function(){
  988. var that = this;
  989. $(View.idForSaveUnitTimeSettingsBtn()).off().on('click', function () {
  990. if (!application.hasPermission(UI_SAVE_CONFIGURATION)) {
  991. that.showMessagePopup(Utils.getLangString("ui7_permission_denied", "You don't have permission to access this functionality."), MessageCategory.NOTIFICATION);
  992. return;
  993. }
  994. that.updateUnitSettings();
  995. });
  996. };
  997. myInterface.updateUnitSettings = function(){
  998. var that = this;
  999. that.showStartupModalLoading();
  1000. var PK_Country = Utils.int($(View.idForCountryPhoneProvider()).val());
  1001. var country_description = $(View.idForCountryPhoneProvider()).find(":selected").text();
  1002. var region_description = $(View.idForSetupWizardRegion()).find(":selected").text();
  1003. var city_description = $(View.idForSetupWizardCity()).find(":selected").text();
  1004. var longitude = $(View.idForSetupWizardCity()).find(":selected").attr("longitude");
  1005. var latitude = $(View.idForSetupWizardCity()).find(":selected").attr("latitude");
  1006. var tempFormat = $(View.idForTemperatureSelect()).val();
  1007. var phoneNumber = that.userPhone.Phone ? that.userPhone.Phone : '';
  1008. var addToCityDescription = ' ';
  1009. var regionId = $(View.idForSetupWizardRegion()).val();
  1010. var unitTimeSettingsObj = that.getDeviceTimeSettingsFromDom();
  1011.  
  1012. application.userData.date_format = unitTimeSettingsObj.dateFormat;
  1013. application.userData.timeFormat = unitTimeSettingsObj.timeFormat;
  1014. application.uiFlags.userDataChanged = true;
  1015. // set timezone
  1016. application.setTimezone(unitTimeSettingsObj.timezone, that.updateUnitTimeSettingsSuccess, that.updateUnitTimeSettingserror, that);
  1017.  
  1018. var updateObject = {
  1019. json: {
  1020. PK_Account: authObj.PK_Account,
  1021. Phone: {
  1022. PK_Country: PK_Country,
  1023. Phone: phoneNumber
  1024. }
  1025. },
  1026. PK_User: authObj.PK_User
  1027. };
  1028.  
  1029. //call MMS.updateUser
  1030. MMS.updateUser(updateObject);
  1031.  
  1032. // store weather data
  1033. if (typeof (application.userData.weatherSettings) === 'undefined') {
  1034. application.userData.weatherSettings = {
  1035. "tempFormat": config.defaultTempFormat
  1036. };
  1037. }
  1038.  
  1039. if (typeof regionId !== 'undefined' || regionId !== '' || String(regionId) !== '-1') {
  1040. addToCityDescription += region_description;
  1041. }
  1042.  
  1043. //save country_pk - use it when we enter "Location" without being authenticated
  1044. application.userData.country_pk = PK_Country;
  1045.  
  1046. application.userData.weatherSettings.weatherCity = city_description + addToCityDescription;
  1047. application.userData.weatherSettings.weatherCountry = country_description;
  1048. application.userData.weatherSettings.tempFormat = tempFormat;
  1049. application.userData.City_description = city_description;
  1050. application.userData.Country_description = country_description;
  1051. application.userData.Region_description = region_description;
  1052. application.userData.latitude = latitude;
  1053. application.userData.longitude = longitude;
  1054.  
  1055. // save the user data...
  1056. application.sendCommandSaveUserData();
  1057.  
  1058. application.userDataVariableSet(0, '', 'TemperatureFormat', tempFormat, that.updateUnitWeatherSettingsSuccess, that.handleUpdateUnitNameError, that);
  1059. };
  1060. Interface.prototype.updateUnitTimeSettingsSuccess = function (transport) {
  1061. try {
  1062. var that = this;
  1063. if (typeof (transport.passedExtraObject) !== 'undefined') {
  1064. application.sysinfo.timezone = transport.passedExtraObject;
  1065. }
  1066.  
  1067. // request a clock sync...
  1068. application.requestClockSync();
  1069. that.updateDeviceName();
  1070. } catch (e) {
  1071. Utils.logError('Error in interface.updateUnitTimeSettingsSuccess(): ' + e);
  1072. }
  1073. };
  1074. Interface.prototype.handleUpdateUnitNameSuccess = function () {
  1075. var that = this;
  1076. that.hideModalLoading(true);
  1077. that.showMessagePopup(Utils.getLangString("ui7_unit_settings_update_success", "Unit settings updated successfully."), MessageCategory.SUCCESS);
  1078. MMS.getAccountDevices(that.getAccountDevicesSuccessCallback, that.getAccountDevicesErrorCallback, that);
  1079. };
  1080. Interface.prototype.handleUpdateUnitNameError = function () {
  1081. var that = this;
  1082. that.hideModalLoading(true);
  1083. that.showMessagePopup(Utils.getLangString("ui7_unit_settings_update_error", "Failed to update unit settings. Please try again."), MessageCategory.ERROR);
  1084. };
  1085. Interface.prototype.updateUnitWeatherSettingsSuccess = function () {
  1086. var that = this;
  1087. that.saveWeatherDataToMMS();
  1088. };
  1089. Interface.prototype.updateDeviceName = function () {
  1090. var that = this;
  1091. var unitName = '';
  1092.  
  1093. if($(View.idForAccountUnitName()).val() === ''){
  1094. unitName = $(View.idForAccountUnitName()).val();
  1095. }else{
  1096. unitName = Utils.trim(that.returnUnitNameValue());
  1097. }
  1098. if(that.validateUnitName(unitName)){
  1099. MMS.updateDeviceName(application.sysinfo.installation_number, unitName, that.handleUpdateUnitNameSuccess, that.handleUpdateUnitNameError, that);
  1100. }
  1101. };
  1102. Interface.prototype.initCardsCarousel = function(){
  1103. return;
  1104. };
  1105. Interface.prototype.view_dashboard = function (options) {
  1106. try {
  1107. var that = this;
  1108. // hide persistent content
  1109. that.hideContent();
  1110. //add alerts and cards carousel
  1111. that.drawRecentEventsAndCarousel();
  1112. //add house modes
  1113. that.drawHouseModes();
  1114. // add my favorites list...
  1115. that.drawMyFavorites();
  1116. //add all on/of/disarm etc device groups
  1117. that.drawDeviceGroups();
  1118. if(config.showGeneralAlerts){
  1119. // add general system alerts
  1120. that.handleGeneralSystemAlerts();
  1121. }
  1122.  
  1123. that.currentPage = "dashboard";
  1124. that.changeInterfaceScreen(InterfaceScreenView.INDEX);
  1125. window.addEventListener("resize", function () {
  1126. that.handleDashboardMasonryCreation.call(that);
  1127. });
  1128. if(config.showOverlayHelp){
  1129. if(overlayHelp.getOverlayActive()){
  1130. return;
  1131. }
  1132. }
  1133. if(that.systemInvokedDashboard && application.userData && (typeof application.userData.setup_wizard_finished === 'undefined' || application.userData.setup_wizard_finished === "0")){
  1134. return;
  1135. }
  1136. if (!application.userData.shouldHelpOverlayBeHidden && config.showOverlayHelp) {
  1137. overlayHelp.setDefaultHelpScreen(overlayHelp.overlayScreens.dashboardHelp);
  1138. overlayHelp.addPageHelp(overlayHelp.overlayScreens.dashboardHelp[0]);
  1139. overlayHelp.setOverlayActive(true);
  1140. }
  1141.  
  1142. // handle the camera card overlay
  1143. var overlayActive = overlayHelp.getOverlayActive();
  1144. var shouldDisplayCameraCardOverlay = typeof application.userData.display_card_overlay === 'undefined' ||
  1145. Utils.int(application.userData.display_card_overlay) === 1 ? true : false;
  1146. var canSeeCameraCardOverlay = application.isAuthenticated() && application.hasPermission(UI_HANDLE_ACM, true) &&
  1147. Utils.inArray('camera-card', config.cardsEnabled) ? true : false;
  1148.  
  1149. if(overlayActive === false && shouldDisplayCameraCardOverlay === true && canSeeCameraCardOverlay){
  1150. overlayHelp.setDefaultHelpScreen(overlayHelp.overlayScreens.cameraCardHelp);
  1151. overlayHelp.addPageHelp(overlayHelp.overlayScreens.cameraCardHelp[0]);
  1152. }
  1153. if (typeof options !== 'undefined' && typeof options.scrollTo !== 'undefined') {
  1154. that.scrollToElement($(options.scrollTo));
  1155. }
  1156. } catch (e) {
  1157. Utils.logError("ERROR in Interface.view_dashboard: " + e.message);
  1158. }
  1159. };
  1160. Interface.prototype.handleGeneralSystemAlerts = function(){
  1161. try{
  1162. var that = this;
  1163. // append containers
  1164. $(View.idForContent()).append(View.returnGeneralSystemAlertsFrame());
  1165.  
  1166. if(application.isAuthenticated()){
  1167. //show 'Loading Please wait....' status -> append before toggle button
  1168. $(View.idForSystemAlertsFrameToggle()).after($(View.returnGeneralSystemFetchingDataView()));
  1169. MMS.getUser(authObj.PK_User, that.systemAlertGetUserSuccess, that.systemAlertGetUserError, that);
  1170. }
  1171.  
  1172. // toggle content
  1173. $(View.idForSystemAlertsFrameToggle()).off('click').on('click', function(){
  1174. if($(this).hasClass('collapsed')){
  1175. $(this).removeClass('collapsed');
  1176. $(View.idForSystemAlertFrameBody()).slideDown('slow');
  1177. $("html, body").animate({ scrollTop: $(document).height() }, "slow");
  1178. } else {
  1179. $(this).addClass('collapsed');
  1180. $(View.idForSystemAlertFrameBody()).slideUp('slow');
  1181. }
  1182. });
  1183.  
  1184. // check if content is present and add/remove the 'no alerts' status
  1185. that.checkForGeneralAlertsContent();
  1186. } catch(e) {
  1187. Utils.logError("ERROR in Interface.handleGeneralSystemAlerts(): " + e);
  1188. }
  1189. };
  1190. View.returnHelpContent = function() {
  1191. try {
  1192. var manualsLabel = Utils.getLangString("ui7_manuals", "Manuals");
  1193. var faqLabel = Utils.getLangString("ui7_FAQ", "FAQ");
  1194. var forumLabel = Utils.getLangString("ui7_Forum", "Forum");
  1195. var html = `<div class="helpPageContainer clearFix">
  1196. <div class="supportContainer clearFix">
  1197. <h1 class="title">${Utils.getLangString("ui7_tech_support", "Customer Care")}</h1>
  1198. <div class="onlineColumn">
  1199. <h3 class="subTitle">
  1200. <span class="icon"></span>
  1201. <span class="">${Utils.getLangString("ui7_help_online_title", "Online Resources")}</span>
  1202. </h3>
  1203. <ul class="resourcesList">
  1204. <li><a href="" target="_blank" title="${manualsLabel}">${manualsLabel}</a></li>
  1205. <li><a href="" title="${faqLabel}" target="_blank">${faqLabel}</a></li>
  1206. <li><a href="" title="${forumLabel}" target="_blank">${forumLabel}</a></li>
  1207. </ul>
  1208. </div>
  1209. <div class="remoteColumn">
  1210. <h3 class="subTitle">
  1211. <span class="icon"></span>
  1212. <span class="">${Utils.getLangString("ui7_support_channels", "Support channels")}</span>
  1213. </h3>
  1214. <div class="suportChannelsContainers">
  1215. <p class="topText">${Utils.getLangString("ui7_support_channels_info", "If you prefer a support technician will help you solve your problems please call us at <span class='phone-number'>01-800-123-4335</span>.</br>If you want the support technician to take control of your system, please enable the following box:")}</p>
  1216. </div>
  1217. </div>
  1218. <div class="remoteAcessContainer">
  1219. <div id="${View.idForTechSupportInfo(true)}"><div class="round_loading"></div></div>
  1220. </div>
  1221. </div>`;
  1222.  
  1223. if (config.handleInstallerAccess === true) {
  1224. html += View.returnHandleInstallerAccessView();
  1225. }
  1226.  
  1227. return html;
  1228. } catch (e) {
  1229. Utils.logError('Error in View.returnHelpContent() error: ' + e);
  1230. }
  1231. };
  1232. View.returnTechSupportDisabled = function() {
  1233. return `<div>
  1234. <div class="checkboxContainer pull-left flip inputLabel">
  1235. <input class="customCheckbox" id="${View.idForEnableTechSupportBtn(true)}" type="checkbox" />
  1236. <label class="labelForCustomCheckbox" for="${View.idForEnableTechSupportBtn(true)}">${Utils.getLangString("ui7_help_remoteAccess_title", "Remote Access")}</label>
  1237. </div>
  1238. </div>`;
  1239. };
  1240. View.returnTechSupportEnabled = function(code) {
  1241. return `<div>
  1242. <div class="checkboxContainer clearfix flip inputLabel">
  1243. <input class="customCheckbox" id="${View.idForDisableTechSupportBtn(true)}" type="checkbox" checked />
  1244. <label class="labelForCustomCheckbox" for="${View.idForDisableTechSupportBtn(true)}">${Utils.getLangString("ui7_help_remoteAccess_title", "Remote Access")}</label>
  1245. </div>
  1246. <div class="supportEnabled">${code}</div>
  1247. </div>`;
  1248. };
  1249. myInterface.addCameraSmallThumbnailView = function (cameraObject) {
  1250. try {
  1251. var that = this;
  1252. //set View
  1253. $(View.idForCamerasCamerasContent()).append(View.returnCameraSmallThumbnailView(cameraObject));
  1254. //attach handlers
  1255. $(View.idForCameraSmallThumbnailViewContainer(cameraObject.id)).off('click').on('click', function () {
  1256. that.showCameraPlayerAndDetails(cameraObject.id);
  1257. });
  1258. //start thumbnail viewer
  1259. //TO DO -> 4:3 / 16:9
  1260. var baseImageURL = config.dataRequestUrl + '/data_request' + application.getCameraControlDisplayUrl(cameraObject.id) + cameraObject.id;
  1261. var thumbnailImageURL = baseImageURL + '&res=low';
  1262. var defaultSpinnerImg = 'skins/default/img/other/Wait_white.gif';
  1263. var callbackObject = {
  1264. 'context': that,
  1265. 'function': 'handleSamllThumbnailViewBackground',
  1266. 'arguments': cameraObject.id
  1267. };
  1268. var defaultSpinnerImgClass = 'camera_small_view_item_position';
  1269. var thumbnailRefreshInterval = (application.uiFlags.slowConnection) ? 0 : config.cameraThumbnailRetrievalInterval;
  1270. CameraImagePlayerDispatcher.getInstance().getCameraImagePlayer(InterfaceScreenView.CAMERAS_VIEW_SMALL, thumbnailImageURL, cameraObject.id, {
  1271. refreshInterval: thumbnailRefreshInterval,
  1272. classNameForImage: 'cameras_small_view_thumbnail',
  1273. classNameForContainer: 'cameras_small_view_thumbnail_container',
  1274. idForTargetContainer: View.idForCameraSmallThumbnailViewContainer(cameraObject.id),
  1275. defaultImage: {className: defaultSpinnerImgClass, src: defaultSpinnerImg},
  1276. autoPlay: true,
  1277. playOneFrame: true,
  1278. maxRetriesIfError: 5,
  1279. afterDrawCallback: callbackObject,
  1280. onErrorCallback: function() {
  1281. Utils.logError('error loading image for camera: ' + cameraObject.id);
  1282. }
  1283. });
  1284.  
  1285. if(config.showCameraNameInCamerasPage){
  1286. $(View.idForCameraSmallThumbnailViewContainer(cameraObject.id)).append('<div class="cameraNameSmallView">' + cameraObject.name + '</div>');
  1287. }
  1288. } catch (e) {
  1289. Utils.logError("ERROR in Interface.addCameraSmallThumbnailView(): " + e);
  1290. }
  1291. };
  1292.  
  1293. /*********************/
  1294. /* override kit flow */
  1295. /*********************/
  1296.  
  1297. myInterface.lastVisitedKitDevice = 0;
  1298.  
  1299. myInterface.appendWizardFrameAndStartWizard = function (wizardObject, targetContainer, extraParams) {
  1300. try {
  1301. var that = this;
  1302.  
  1303. Utils.logDebug(wizardObject);
  1304. that.setView('returnSetupWizardFrame', {}, View.idForContent());
  1305. $(View.idForSetupWizardFrameWelcomeUser()).hide();
  1306. //hide step 1 content and deselect header
  1307. $(View.idForSetupWizardFrameSelectDeviceHead()).removeClass('selected');
  1308. $(View.idForSetupWizardFrameSelectDeviceContentContainer()).slideUp();
  1309. $(View.idForSetupWizardFramePairDeviceControls()).hide();
  1310.  
  1311. if (typeof (extraParams) !== 'undefined' && typeof (extraParams.deviceId) !== 'undefined') {
  1312. wiz = new DeviceWizard(wizardObject, View.idForSetupWizardFramePairDeviceContent(), extraParams.deviceId);
  1313. } else {
  1314. wiz = new DeviceWizard(wizardObject, View.idForSetupWizardFramePairDeviceContent());
  1315. }
  1316.  
  1317. // set plugin related parameters - at least pluginToBeInstalledId has to exist
  1318. if(typeof extraParams !== 'undefined' && typeof extraParams.pluginToBeInstalledId !== 'undefined'){
  1319. // set plugin id
  1320. wiz.pluginToBeInstalledId = extraParams.pluginToBeInstalledId;
  1321. // set plugin version if available
  1322. if(typeof extraParams.pluginToBeInstalledVerison !== 'undefined'){
  1323. wiz.pluginToBeInstalledVerison = extraParams.pluginToBeInstalledVerison;
  1324. }
  1325. }
  1326.  
  1327. if (typeof (extraParams) !== 'undefined' && typeof (extraParams.step) !== 'undefined') {
  1328. wiz.startWizard(extraParams.step);
  1329. } else {
  1330. wiz.startWizard();
  1331. }
  1332.  
  1333. wiz.removeEvent('on_ui_finishDeviceWizard', that, 'signalFinishedDeviceWizard');
  1334. wiz.addEvent('on_ui_finishDeviceWizard', that, 'signalFinishedDeviceWizard');
  1335.  
  1336. //select step 2 header and show content
  1337. $(View.idForSetupWizardFramePairDeviceHead()).addClass('selected').removeClass('setup_wizard_border_top_dashed');
  1338. $(View.idForSetupWizardFramePairDevice()).slideDown();
  1339. //attach 'Back' button event
  1340. $(View.idForDeviceWizardBackButton()).off('click').on('click', function () {
  1341. that.returnToWizardDeviceSelection();
  1342. });
  1343. } catch (e) {
  1344. Utils.logError('Interface.appendWizardFrameAndStartWizard() error: ' + e);
  1345. }
  1346. };
  1347.  
  1348. myInterface.getDeviceWizardObjectAndStartWizardSuccess = function (transport) {
  1349. try {
  1350. var that = this;
  1351. var wizardObject = JSON.parse(transport.responseText);
  1352.  
  1353. if (typeof wizardObject !== 'object' || Utils.isEmpty(wizardObject)){
  1354. that.getDeviceWizardObjectAndStartWizardError(transport);
  1355. } else {
  1356.  
  1357. var requestedWizardObject = transport.passedExtraObject.requestedWizardObject;
  1358. var requestedWizardObjectId = requestedWizardObject.PK_KitDevice;
  1359.  
  1360. try {
  1361. wiz.removeAllWizardEvents();
  1362. } catch (e2) {
  1363. Utils.logError("ERROR in Interface.getDeviceWizardObjectAndStartWizardSuccess(): failed to remove events ");
  1364. }
  1365.  
  1366. // store the device json so we won't ask it again
  1367. var key = 'wizard_' + requestedWizardObjectId;
  1368. if(typeof that.storedDeviceWizards[key] === 'undefined'){
  1369. var storedObject = {
  1370. wizard: transport.responseText,
  1371. // keep this thing stored for 30 mins
  1372. timestamp: Date.now()
  1373. };
  1374. that.storedDeviceWizards[key] = storedObject;
  1375. }
  1376.  
  1377. wiz = new DeviceWizard(wizardObject, View.idForSetupWizardFramePairDeviceContent());
  1378. // if device is camera
  1379. if(that.isKitDeviceCamera(requestedWizardObject)){
  1380. wiz.deviceIsCamera = true;
  1381. // set different param for camera - will be used in camera
  1382. // manual installation
  1383. wiz.Camera_PK_KitDevice = requestedWizardObjectId;
  1384. // if device is plugin
  1385. } else if(typeof requestedWizardObject.Plugin !== 'undefined') {
  1386. wiz.pluginToBeInstalledId = Utils.int(requestedWizardObject.Plugin);
  1387. // if device is Z-Wave
  1388. } else {
  1389. wiz.PK_KitDevice = requestedWizardObjectId;
  1390. }
  1391.  
  1392. wiz.startWizard();
  1393.  
  1394. wiz.removeEvent('on_ui_finishDeviceWizard', that, 'signalFinishedDeviceWizard');
  1395. wiz.addEvent('on_ui_finishDeviceWizard', that, 'signalFinishedDeviceWizard');
  1396. }
  1397. that.hideModalLoading();
  1398. } catch (e) {
  1399. Utils.logError("ERROR in Interface.getDeviceWizardObjectAndStartWizardSuccess: " + e);
  1400. }
  1401. };
  1402.  
  1403. myInterface.signalFinishedDeviceWizard = function(){
  1404. try{
  1405. var that = this;
  1406. that.lastVisitedKitDevice = 0;
  1407. } catch(e) {
  1408. Utils.logError('Interface.signalFinishedDeviceWizard() error: ' + e);
  1409. }
  1410. };
  1411.  
  1412. myInterface.showInstallKitAndAdditionalDevicesFrame = function (formattedWizardCategoriesObject, kitDevicesObject) {
  1413. try {
  1414. var that = this;
  1415.  
  1416. //get kit devices object
  1417. var kitDevices = that.getKitAndInstalledDevicesObject();
  1418.  
  1419. //add kit wizard views to container
  1420. that.setView('returnKitAndAdditionalDevicesFrame', {}, View.idForSetupWizardFrameSelectDeviceContent());
  1421.  
  1422. // handle the 'Next' button actions
  1423. $(View.idForKitDeviceSelectKitBtn()).off('click').on('click', function(){
  1424. that.showSelectedKitAndAdditionalDevices();
  1425. });
  1426.  
  1427. // handle 'Back' to kit selection actions
  1428. $(View.idForKitDeviceSelectBackBtn()).off('click').on('click', function(){
  1429. that.backToKitSelectionAction();
  1430. });
  1431.  
  1432. // if no kits hide buttons and header
  1433. if(kitDevices.length === 0){
  1434. $(View.selectDivByAttribute('data-kit_device_select_label')).hide();
  1435. $(View.selectDivByAttribute('data-install_kit_device_btn_container')).hide();
  1436. // else add tem
  1437. } else {
  1438. var firstKit = kitDevices.filter(kit => {
  1439. return kit.PK_Kit == 331;
  1440. });
  1441. var secondKit = kitDevices.filter(kit => {
  1442. return kit.PK_Kit == 311;
  1443. });
  1444. var thirdKit = kitDevices.filter(kit => {
  1445. return kit.PK_Kit == 321;
  1446. });
  1447. var orderKits = firstKit.concat(secondKit, thirdKit);
  1448. for(var i = 0; i < orderKits.length; i++){
  1449.  
  1450. var kitInfo = {
  1451. kit: orderKits[i],
  1452. kitIndex: i,
  1453. kitCount: orderKits.length
  1454. };
  1455.  
  1456. that.addKitAndDevicesContent(kitInfo);
  1457. }
  1458. }
  1459.  
  1460. //add additional devices wizards V3
  1461. that.addV3SetupWizardAdditionalDevicesViewsAndHandlers(formattedWizardCategoriesObject, kitDevicesObject);
  1462.  
  1463. // add generic insteon, upnp device wizards
  1464. that.addGenericWizards();
  1465.  
  1466. // TODO: remove when we migrate to new apps
  1467. that.addPluginWizards();
  1468.  
  1469. //bind toggle on kit devices container
  1470. $(View.idForSetupWizardToggleKitDevicesContainer()).off('click').on('click', function () {
  1471. that.toggleSetupWizardKitDevicesContainer();
  1472. });
  1473. $(View.idForSetupWizardToggleAdditionalDevicesControl()).off('click').on('click', function () {
  1474. that.toggleSetupWizardAdditionalDevicesContainer();
  1475. });
  1476. //hide welcome
  1477. $(View.idForSetupWizardFrameWelcomeUser()).hide();
  1478. //show devices selector
  1479. $(View.idForSetupWizardFrameSelectDevice()).show();
  1480.  
  1481. if(typeof that.lastVisitedKitDevice !== 'undefined' && that.lastVisitedKitDevice !== 0){
  1482. that.showSelectedKitAndAdditionalDevices(that.lastVisitedKitDevice);
  1483. }
  1484. } catch (e) {
  1485. Utils.logError("ERROR in Interface.showInstallKitAndAdditionalDevicesFrame: " + e);
  1486. }
  1487. };
  1488.  
  1489. myInterface.backToKitSelectionAction = function(){
  1490. try{
  1491. var that = this;
  1492.  
  1493. var $parentContainer = $(View.idForSetupWizardFrameSelectDeviceContentContainer());
  1494. $parentContainer.find('[data-kit_device_select_label]').show();
  1495. $parentContainer.find('[data-install_kit_device_btn_container]').show();
  1496. $parentContainer.find('[data-kit_device_back_btn_container]').hide();
  1497. $(View.selectDivByAttribute('data-device_kit_container')).hide();
  1498. $(View.selectDivByAttribute('data-device_kit_pk')).show();
  1499. $(View.idForSetupWizardToggleAdditionalDevicesTitle()).hide();
  1500.  
  1501. // also reset the visited kit so we won't return to it
  1502. that.lastVisitedKitDevice = 0;
  1503. } catch(e) {
  1504. Utils.logError("ERROR in Interface.backToKitSelectionAction: " + e);
  1505. }
  1506. };
  1507.  
  1508. myInterface.showSelectedKitAndAdditionalDevices = function(kitPk){
  1509. try{
  1510. var that = this;
  1511.  
  1512. // get kit pk
  1513. var pk = typeof kitPk !== 'undefined' ? kitPk :
  1514. $(View.selectDivByAttribute('data-device_kit_selected', 1)).attr('data-device_kit_pk');
  1515.  
  1516. // check if valid
  1517. if(typeof pk === 'undefined'){
  1518. that.showMessagePopup(Utils.getLangString("ui7_tlm_please_select_kit", "Please select a kit to continue."), MessageCategory.ERROR);
  1519. return;
  1520. }
  1521.  
  1522. // hide all
  1523. $(View.selectDivByAttribute('data-device_kit_pk')).each(function(){
  1524. $(this).hide();
  1525. });
  1526.  
  1527. // show the kit content
  1528. var $parentContainer = $(View.idForSetupWizardFrameSelectDeviceContentContainer());
  1529. $parentContainer.find('[data-kit_device_select_label]').hide();
  1530. $parentContainer.find('[data-install_kit_device_btn_container]').hide();
  1531. $parentContainer.find('[data-kit_device_back_btn_container]').show();
  1532. $(View.idForKitContainerDevices(pk)).show();
  1533. //$(View.idForSetupWizardToggleAdditionalDevicesTitle()).show();
  1534. } catch(e) {
  1535. Utils.logError("ERROR in Interface.showSelectedKitAndAdditionalDevices: " + e);
  1536. }
  1537. };
  1538.  
  1539. myInterface.addKitAndDevicesContent = function(kitInfo){
  1540. try{
  1541. var that = this;
  1542. var pk = kitInfo.kit.PK_Kit;
  1543.  
  1544. // add frame
  1545. $(View.idForSetupWizardKitsContainer()).append(View.returnKitContainer(pk, kitInfo.kitCount));
  1546.  
  1547. // add devices and handlers
  1548. for(var i = 0; i < kitInfo.kit.combinedDevices.length; i++){
  1549. that.addKitDeviceViewAndEvents(pk, kitInfo.kit.combinedDevices[i]);
  1550. }
  1551.  
  1552. // make it selectable
  1553. $(View.idForKitContainerHeader(pk)).off('click').on('click', function(){
  1554. that.selectKitToInstall(pk);
  1555. });
  1556.  
  1557. } catch(e) {
  1558. Utils.logError('Error in Interface.addKitAndDevicesContent: ' + e);
  1559. }
  1560. };
  1561.  
  1562. myInterface.selectKitToInstall = function(pk){
  1563. try{
  1564. var that = this;
  1565.  
  1566. // unselect all
  1567. $(View.selectDivByAttribute('data-device_kit_pk')).each(function(){
  1568. $(this).attr('data-device_kit_selected', 0).find('[data-device_kit_overlay]').hide();
  1569. });
  1570. // apply overlay
  1571. $(View.idForKitContainerHeader(pk)).attr('data-device_kit_selected', 1).find('[data-device_kit_overlay]').show();
  1572.  
  1573. // set flag to remember the kit we want to install
  1574. that.lastVisitedKitDevice = Utils.int(pk);
  1575. } catch(e) {
  1576. Utils.logError('Error in Interface.selectKitToInstall: ' + e);
  1577. }
  1578. };
  1579.  
  1580. myInterface.toggleSetupWizardAdditionalDevicesContainer = function () {
  1581. var that = this;
  1582.  
  1583. if ($(View.idForSetupWizardKitAndDevicesFrameAdditionalContainer()).is(':visible')) {
  1584. that.slideUpAdditionalDevicesContainer();
  1585. } else {
  1586. //show additional devices
  1587. $(View.idForSetupWizardKitAndDevicesFrameAdditionalContainer()).slideDown();
  1588. $(View.idForSetupWizardToggleAdditionalDevicesTitle()).addClass('expanded');
  1589. $(View.idForSetupWizardToggleAdditionalDevicesControl()).addClass('icon_minus').removeClass('icon_additional_devices_plus');
  1590. }
  1591. };
  1592.  
  1593. View.returnKitContainer = function(pk, kitCount){
  1594. try{
  1595. var kitNameLangTag = 'ui7_device_kit_' + config.PK_Oem + '_' + pk + '_name';
  1596. var defaultKitName = Utils.getLangString('ui7_general_ucase_kit', 'Kit') + ' ' + pk;
  1597. var kitName = Utils.getLangString(kitNameLangTag, defaultKitName);
  1598. var oldKitName = Utils.getLangString("ui7_includedDevicesInStarterSolution", "Devices included in your Starter Solution are...");
  1599.  
  1600. // if we have only 1 kit - use the old translation for the kit header
  1601. kitName = kitCount === 1 ? oldKitName : kitName;
  1602.  
  1603. var html = `<div data-device_kit_pk="${pk}" class="pull-left tlm_kit_device_container" id="${View.idForKitContainerHeader(pk, true)}">
  1604. <div data-device_kit_overlay="1" style="display: none;" class="tlm_kit_device_container_overlay"></div>
  1605. <div class="tlm_kit_device_kit_title">${kitName}</div>
  1606. <img class="tlm_kit_device_kit_image" src="skins/default/img/other/kit_device_img_${pk}.png" />
  1607. </div>
  1608. <div data-device_kit_container="1" style="display: none;" id="${View.idForKitContainerDevices(pk, true)}"></div>`;
  1609. return html;
  1610. } catch(e) {
  1611. Utils.logError('Error in View.returnKitContainer(): ' + e);
  1612. }
  1613. };
  1614.  
  1615. View.idForKitDeviceSelectKitBtn = function(inView){
  1616. var id = 'kit_device_select_kit_btn';
  1617. return typeof inView !== 'undefined' ? id : '#' + id;
  1618. };
  1619.  
  1620. View.idForKitDeviceSelectBackBtn = function(inView){
  1621. var id = 'kit_device_select_kit_back_btn';
  1622. return typeof inView !== 'undefined' ? id : '#' + id;
  1623. };
  1624.  
  1625. View.returnAddRoomForm = function() {
  1626. try {
  1627. var title = Utils.getLangString("ui7_createRoom", "Create Room");
  1628. var labelButtonCancel = Utils.getLangString("ui7_general_ucase_cancel", "Cancel");
  1629. var html = `<div class="clearfix createRoomContainer">
  1630. <div class=""><h1>${title}</h1></div>
  1631. <div class="scenes_section_delimiter"></div>
  1632. <div class="roomsContent" id="${View.idForRoomsContent(true)}">
  1633. <div class="scenes_button_cancel" id="${View.idForCancelRoomCreation(true)}">${labelButtonCancel}</div>
  1634. </div>
  1635. <div class="clearfix">
  1636. <div class="col-xs-12">${Utils.getLangString("ui7_general_enter_room_name", "Enter Room Name")}</div>
  1637. <div class="col-xs-5"><input id="${View.idForAddRoomNameInput(true)}" class="customInput" type="text" maxlength="${ViewConfig.CUT_ROOM_NAME_AT_LENGTH}" autofocus /></div>
  1638. </div>
  1639. <div class="breaker"></div>
  1640. <div class="clearfix genericSaveButtonContainer">
  1641. <button id="${View.idForSettingsRoomsAddRoomViewAddRoom(true)}" class="vBtn pull-right flip">${Utils.getLangString("ui7_general_add_room", "Add Room")}</button>
  1642. </div>
  1643. </div>`;
  1644. return html;
  1645. } catch (e) {
  1646. Utils.logError('View.returnAddRoomForm() error: ' + e);
  1647. }
  1648. };
  1649.  
  1650. View.returnAddRoomInlineForm = function() {
  1651. try {
  1652. var html = `<div class="clearfix device_cpanel_add_room_container">
  1653. <div class="pull-left flip inputLabel">${Utils.getLangString("ui7_general_enter_room_name", "Enter Room Name")}</div>
  1654. <div class="pull-left flip padding_left_15"><input id="${View.idForAddRoomNameInput(true)}" class="customInput" type="text" maxlength="${ViewConfig.CUT_ROOM_NAME_AT_LENGTH}" autofocus /></div>
  1655. </div>`;
  1656. return html;
  1657. } catch (e) {
  1658. Utils.logError('View.returnAddRoomInlineForm() error: ' + e);
  1659. }
  1660. };
  1661.  
  1662. View.returnEditRoomForm = function(roomObject) {
  1663. try {
  1664. var title = Utils.getLangString("ui7_general_edit_room", "Edit Room");
  1665. var labelButtonCancel = Utils.getLangString("ui7_general_ucase_cancel", "Cancel");
  1666. var html = `<div class="clearfix createRoomContainer">
  1667. <div class=""><h1>${title}</h1></div>
  1668. <div class="scenes_section_delimiter"></div>
  1669. <div class="roomsContent" id="${View.idForRoomsContent(true)}">
  1670. <div class="light_cancel_button" id="${View.idForCancelRoomEdit(true)}">${labelButtonCancel}</div>
  1671. </div>
  1672. <div class="clearfix">
  1673. <div class="col-xs-12">${Utils.getLangString("ui7_general_edit_room_name", "Edit Room Name: ")}</div>
  1674. <div class="col-xs-5"><input autofocus id="${View.idForEditRoomNameInput(true)}" value="${DOMPurify.sanitize(roomObject.roomName)}" class="customInput" maxlength="${ViewConfig.CUT_ROOM_NAME_AT_LENGTH}" type="text" autofocus /></div>
  1675. </div>
  1676. <div class="breaker"></div>
  1677. <div class="clearfix genericSaveButtonContainer">
  1678. <button id="${View.idForSettingsRoomsSaveRoom(true)}" class="vBtn pull-right flip">${Utils.getLangString("ui7_general_ucase_save", "Save")}</button>
  1679. </div>
  1680. </div>`;
  1681.  
  1682. return html;
  1683. } catch (e) {
  1684. Utils.logError('View.returnEditRoomForm() error: ' + e);
  1685. }
  1686. };
  1687. View.returnCreateSceneContainerStepThree = function (options) {
  1688. var labelFinish = Utils.getLangString('ui7_wizard_lang_finish', 'Finish');
  1689. var labelSceneName = Utils.getLangString('ui7_name', 'Name');
  1690. var labelUntitledScene = Utils.getLangString('ui7_scenes_step_three_untitled_scene', 'Untitled Scene');
  1691. var labelThisSceneRuns = Utils.getLangString('ui7_scenes_step_three_scene_runs', 'This scene runs...');
  1692. var labelWhenThisSceneRuns = Utils.getLangString('ui7_scenes_step_three_when_scene_runs', 'When this scene runs...');
  1693. var labelNameYourScene = Utils.getLangString('ui7_scenes_step_three_name_your_scene', 'Name Your Scene');
  1694.  
  1695. var showChooseRoomContainer = false;
  1696. if (typeof options !== 'undefined') {
  1697. if (typeof options.showChooseRoomContainer !== 'undefined') {
  1698. showChooseRoomContainer = options.showChooseRoomContainer;
  1699. }
  1700. }
  1701.  
  1702. var html = `<div class="clearfix hidden" id="${View.idForCreateSceneContainerStepThree(true)}">
  1703. ${View.returnCreateSceneStepThreeTitle()}
  1704. <div class="clearfix create_scene_step_content hidden" id="${View.idForCreateSceneContainerStepThreeContent(true)}">
  1705. <div class="clearfix create_scene_step_three_row font_weight_bold">${labelThisSceneRuns}</div>
  1706. ${View.returnCreateSceneStepThreeSelectMode()}
  1707. <div class="clearfix create_scene_step_three_row font_weight_bold">${labelWhenThisSceneRuns}</div>
  1708. ${View.returnCreateSceneStepThreeNotifyUsersContainer()}
  1709. <div class="clearfix hidden" id="${View.idForCreateSceneContainerStepThreeTestResult(true)}"></div>`;
  1710. if (showChooseRoomContainer) {
  1711. html += View.returnCreateSceneStepThreeSelectRoomContainer(options.roomList, options.roomId);
  1712. }
  1713.  
  1714. html += `<div class="clearfix create_scene_step_three_subtitle">${labelNameYourScene}</div>
  1715. <div class="clearfix padding_top_10">
  1716. <div class="pull-left flip inputLabel inputLabelXs col-xs-2 margin_left_20">${labelSceneName}:</div>
  1717. <div class="pull-left flip col-xs-5 inputContainerXs">
  1718. <input class="customInput" type="text" id="${View.idForCreateSceneContainerStepThreeSceneName(true)}" value="${labelUntitledScene}" maxlength="${SCENE_NAME_LENGTH_MAX}" />
  1719. </div>
  1720. </div>
  1721. <div class="clearfix create_scene_step_three_section_delimiter"></div>
  1722. <div class="clearfix">
  1723. <div class="pull-right flip scenes_button_finish" id="${View.idForCreateSceneContainerStepThreeFinish(true)}">${labelFinish}</div>
  1724. </div>
  1725. </div>
  1726. </div>`;
  1727. return html;
  1728. };
  1729. View.returnWizardTemplateT7 = function(){
  1730. try{
  1731. var toReplaceWith = typeof config.timeForCameraDetection !== 'undefined' ?
  1732. config.timeForCameraDetection : WIZARD_WAIT_FOR_OTHER_DEVICES_TIMER;
  1733.  
  1734. var cameraWaitForDetection = Utils.getLangString("ui7_camera_detection_wait_for", "Within _CAM_DETECT_TIME_ minutes, a image will appear within the frame when the pairing is successful.");
  1735. cameraWaitForDetection = cameraWaitForDetection.replace('_CAM_DETECT_TIME_', toReplaceWith);
  1736.  
  1737. return `<div>
  1738. <div class="wiz_cam_detect_p1_style">${cameraWaitForDetection}</div>
  1739. <div class="wiz_v3_cam_test_container">
  1740. <div class="round_loading round_loading_test_cam"></div>
  1741. <img />
  1742. </div>
  1743. </div>`;
  1744. } catch(e) {
  1745. Utils.logError('View.returnWizardTemplateT7() error: ' + e);
  1746. }
  1747. };
  1748. myInterface.changeCameraCredentialsEvents = function (cameraId) {
  1749. try {
  1750. var that = this;
  1751. var customSeparator = '<div id="customSeparatorCC" class="customSeparatorCC"></div>';
  1752.  
  1753. $(View.idForCameraUsesDefaultCredentialsCloseB()).on('click', function(){
  1754. $(View.idForCameraUsesDefaultCredentialsContainer()).css('display', 'none');
  1755. if($(View.idForCameraUsesDefaultCredentialsToggleContainer()).css('display') === 'block'){
  1756. $(View.idForCameraUsesDefaultCredentialsToggleContainer()).remove();
  1757. }
  1758. });
  1759. $(View.idForCameraUsesDefaultCredentialsArrowB()).on('click', function(){
  1760. if($(View.idForCameraUsesDefaultCredentialsToggleContainer()).css('display') === 'none'){
  1761. $(View.idForChangeNowLabel()).addClass('cameraChangeDefaultPassOpen');
  1762. $(View.idForChangeNowLabel()).removeClass('cameraChangeDefaultPassClosed');
  1763. $(View.idForCameraUsesDefaultCredentialsArrowB()).css('backgroundImage', 'url("skins/default/img/other/cam_creds_arrow_up.png")');
  1764. $(customSeparator).insertAfter(View.idForChangeNowLabel());
  1765. }else{
  1766. $(View.idForChangeNowLabel()).removeClass('cameraChangeDefaultPassOpen');
  1767. $(View.idForChangeNowLabel()).addClass('cameraChangeDefaultPassClosed');
  1768. $(View.idForCameraUsesDefaultCredentialsArrowB()).css('backgroundImage', 'url("skins/default/img/other/cam_creds_arrow_down.png")');
  1769. $('#customSeparatorCC').remove();
  1770. }
  1771. $(View.idForCameraUsesDefaultCredentialsToggleContainer()).slideToggle( "fast", function() {
  1772. if($(View.idForCameraUsesDefaultCredentialsToggleContainer()).css('display') === 'block'){
  1773. $(View.idForCameraBasicSettingsSaveDetailsWarningToggle()).on('click', function(){
  1774. that.handleSaveCameraDetailsOnDefaultWarning(cameraId);
  1775. });
  1776. }
  1777. });
  1778. });
  1779. } catch (e) {
  1780. Utils.logError("ERROR in Interface.changeCameraCredentialsEvents(): " + e);
  1781. }
  1782. };
  1783. myInterface.handleSaveCameraDetailsOnDefaultWarning = function (cameraId) {
  1784. try {
  1785. var that = this;
  1786. var username = $(View.idForCameraBasicSettingsUsername()).val();
  1787. var password = $(View.idForCameraBasicSettingsPassword()).val();
  1788. var newUsername = Utils.trim($(View.idForCameraBasicSettingsNewUsernameWarningToggle()).val());
  1789. var newPassword = Utils.trim($(View.idForCameraBasicSettingsNewPasswordWarningToggle()).val());
  1790. if (newPassword && !newUsername) {
  1791. that.showMessagePopup(Utils.getLangString("ui7_cameraNewUserNameEmpty", "New username can't be empty"), MessageCategory.ERROR);
  1792. return;
  1793. }
  1794. if (!/^[a-zA-Z0-9]+$/.test(newPassword) || !/^[a-zA-Z0-9]+$/.test(newUsername)) {
  1795. that.showMessagePopup(Utils.getLangString("ui7_unsuported_camera_credentials_characters", "Username and password fields can not be empty and should contain only letters and numbers."), MessageCategory.ERROR);
  1796. return;
  1797. }
  1798. that.showStartupModalLoading();
  1799. setTimeout(function () {
  1800. that.hideModalLoading(true);
  1801. $(View.idForCameraUsesDefaultCredentialsCloseB()).click();
  1802. $(View.idForCameraViewLiveControl(cameraId)).click();
  1803. }, 10000);
  1804. if (newUsername !== '' || newPassword !== '') {
  1805. //plugin will treat as null/nil an empty string so we send _EMPTY_STRING_ string instead
  1806. var settingsObject = {
  1807. username: Utils.trim(username) === '' ? '_EMPTY_STRING_' : username,
  1808. password: Utils.trim(password) === '' ? '_EMPTY_STRING_' : password,
  1809. newUsername: Utils.trim(newUsername) === '' ? '_EMPTY_STRING_' : newUsername,
  1810. newPassword: Utils.trim(newPassword) === '' ? '_EMPTY_STRING_' : newPassword,
  1811. cameraId: cameraId
  1812. };
  1813. that.currentCpanelCameraId = cameraId;
  1814. that.changeCameraUsernameAndPasswordPluginRequest(settingsObject, that.sendUsernameAndPasswordToCameraSuccess, that.sendUsernameAndPasswordToCameraError, that, 20);
  1815. } else {
  1816. that.modifyAdvancedCameraOtherFields(cameraId);
  1817. }
  1818. } catch (e) {
  1819. Utils.logError("ERROR in Interface.handleSaveCameraDetailsOnDefaultWarning(): " + e);
  1820. }
  1821. };
  1822. View.returnSetupHouseModes = function() {
  1823. var activeMode = parseInt(application.luStatus.Mode);
  1824. var modeDisarmedActive = (activeMode == MODE_DISARMED);
  1825. var modeArmedAwayActive = (activeMode == MODE_ARMED_AWAY);
  1826. var modeArmedAtHomeActive = (activeMode == MODE_ARMED_AT_HOME);
  1827. var modeVacationActive = (activeMode == MODE_VACATION);
  1828. var labelButtonBack = Utils.getLangString("ui7_general_back", "Back");
  1829. var presetModeInfoText = Utils.getLangString("ui7_presetModesInfo", "Preset Modes allow you to quickly and easily automate multiple functions into one simple button press. For example, when you are Away, your Vera Smart Home Controller will automatically lock your door, turn off the lights, and adjust the thermostat to save you money. Click any of the modes below to customize.");
  1830.  
  1831. return `<div id="${View.idForDataContainer(true)}" class="presetModesPageContainer">
  1832. <h3 id="data_container_title" class="configure_modes_title">${Utils.getLangString("ui7_configure_house_modes", "Configure House Modes")}</h3>
  1833. <button id="modesPrevBtn" class="presetModeBtn hidden presetModesContolBtnLeft"></button>
  1834. <button id="modesNextBtn" class="presetModeBtn hidden group_devices_arrow"></button>
  1835. <div id="data_container_content">
  1836. <div class="breaker"></div>
  1837. <div id="configure_preset_modes">
  1838. <div>
  1839. <p class="presetModeInfoText">${presetModeInfoText}</p>
  1840. </div>
  1841. <div class="breaker"></div>
  1842. <div class="presetModeHeaderIconContainer">
  1843. ${View.returnSetupHouseModeHome(modeDisarmedActive)}
  1844. ${View.returnSetupHouseModeAway(modeArmedAwayActive)}
  1845. ${View.returnSetupHouseModeNight(modeArmedAtHomeActive)}
  1846. ${View.returnSetupHouseModeVacation(modeVacationActive)}
  1847. <div class="breaker"></div>
  1848. </div>
  1849. <div class="margin_bottom_15 presetModeHeaderIcon">
  1850. ${View.returnSetupHouseModeRecommendedButton(MODE_DISARMED, 'even')}
  1851. ${View.returnSetupHouseModeRecommendedButton(MODE_ARMED_AWAY)}
  1852. ${View.returnSetupHouseModeRecommendedButton(MODE_ARMED_AT_HOME, 'even')}
  1853. ${View.returnSetupHouseModeRecommendedButton(MODE_VACATION)}
  1854. <div class="breaker"></div>
  1855. </div>
  1856. <div class="breaker"></div>
  1857. </div>
  1858. <div class="breaker"></div>
  1859. </div>
  1860. ${View.returnWhatSensorsAreArmed()}
  1861. ${View.returnWhatToDoWhenSensorTrips()}
  1862. ${View.returnWhoShouldBeNotified()}
  1863. ${View.returnWhatToDoWhenModeSelected()}
  1864. ${View.returnChangeDelay()}
  1865. <div class="clearfix"><div class="scenes_button_back" id="${View.idForPresetModesBackToDashboard(true)}">${labelButtonBack}</div></div>
  1866. </div>`;
  1867. };
  1868. myInterface.view_cameras = function () {
  1869. try {
  1870. var that = this;
  1871.  
  1872. //removed permission checking because any user that can access the gateway
  1873. // will have the right to access this area
  1874.  
  1875. //set view
  1876. that.setView('returnCamerasFrame', {}, View.idForContent());
  1877. //attach events
  1878. $(View.idForCamerasAddCameraControl()).off('click').on('click', function () {
  1879. that.withPermissionCheck(UI_ADD_DEVICE, function () {
  1880. if (!application.userData.shouldHelpOverlayBeHidden && config.showOverlayHelp) {
  1881. overlayHelp.setDefaultHelpScreen(overlayHelp.overlayScreens.installDeviceHelp);
  1882. overlayHelp.addPageHelp(overlayHelp.overlayScreens.installDeviceHelp[0]);
  1883. }
  1884. that.startDeviceWizardFromDevicesSection();
  1885. });
  1886. });
  1887. $(View.idForCamerasViewBySmall()).off('click').on('click', function () {
  1888. that.viewCamerasBySmallView();
  1889. });
  1890. $(View.idForCamerasViewByLarge()).off('click').on('click', function () {
  1891. that.viewCamerasByLargeView();
  1892. });
  1893. $(View.idForCamerasBackControl()).off('click').on('click', function () {
  1894. that.handleCamerasBack();
  1895. });
  1896. //show small thumbnails view by default
  1897. that.showCamerasByViewSize();
  1898.  
  1899. } catch (e) {
  1900. Utils.logError("ERROR in Interface.view_cameras(): " + e.message);
  1901. }
  1902. };
  1903. myInterface.getListOfDevicesFromKits = function(){
  1904. var kitsList = myInterface.getKitAndInstalledDevicesObject();
  1905. var devicesList = [];
  1906. var addedDevicesPk = [];
  1907. kitsList.forEach(function(kit){
  1908. kit.combinedDevices.forEach(function(device){
  1909. if(!Utils.inArray(Utils.int(device.PK_KitDevice), addedDevicesPk)){
  1910. devicesList.push(device);
  1911. addedDevicesPk.push(Utils.int(device.PK_KitDevice));
  1912. }
  1913. });
  1914. });
  1915. return devicesList;
  1916. };
  1917. myInterface.getSearchableDeviceList = function(kitsDevicesList, devicesAndPluginsList){
  1918. var deviceList = [];
  1919. kitsDevicesList.forEach(function(kitDevice){
  1920. devicesAndPluginsList.forEach(function(device){
  1921. if(Utils.int(kitDevice.PK_KitDevice) === Utils.int(device.PK_KitDevice)){
  1922. deviceList.push(device);
  1923. }
  1924. });
  1925. });
  1926. return deviceList;
  1927. };
  1928. myInterface.searchDeviceWizardBeginSearch = function (searchTerm, devicesAndPlugins) {
  1929. try {
  1930. var that = this;
  1931. // return if search term is empty
  1932. if(Utils.trim(searchTerm) === ''){
  1933. return;
  1934. }
  1935. that.searchDeviceWizardResetSearch();
  1936. // hide everything except header and append search results container
  1937. //$(View.idForSetupWizardFrameSelectDeviceContentContainer()).hide();
  1938. if ($(View.idForWizardDeviceSearchContainer()).length === 0) {
  1939. //$(View.idForSetupWizardFrameSelectDevice()).append(View.returnDeviceSearchResultsContainerView());
  1940. if($("#searchResultsAditionalInfo").length === 0){
  1941. $(View.idForSetupWizardFrameSelectDeviceContentContainer()).prepend(View.returnAditionalSearchResultsInfo());
  1942. }
  1943. $(View.idForSetupWizardFrameSelectDeviceContentContainer()).prepend(View.returnDeviceSearchResultsContainerView());
  1944. that.eanbleNoSearchResultOptions();
  1945. }
  1946. // clear content from last search
  1947. $(View.idForWizardDeviceSearchResultsContent()).html('');
  1948. var result = [];
  1949.  
  1950. //search only in devices included in kits
  1951. var kitDevices = that.getSearchableDeviceList(that.getListOfDevicesFromKits(), devicesAndPlugins);
  1952. // get specific results - match the entire search term
  1953. result = result.concat(that.getEntireSearchTermMatches(searchTerm, kitDevices, [], []));
  1954. // search for parts - if device already found - don't add it to the list
  1955. var resultClone = result.slice();
  1956. result = result.concat(that.getSearchTermPartsMatches(searchTerm, kitDevices, [], [], resultClone));
  1957. result = result.concat(that.getSearchTermMatchesFromPlugins(searchTerm));
  1958. if (result.length === 0) {
  1959. $("#searchResultsAditionalInfo").remove();
  1960. that.addNoSearchResultGenericDevice();
  1961. } else {
  1962. // show results and paginate
  1963. that.deviceWizardSearchShowAndPaginateResults(result, searchTerm);
  1964. }
  1965. } catch (e) {
  1966. Utils.logError('Interface.searchDeviceWizardBeginSearch() error: ' + e);
  1967. }
  1968. };
  1969. View.static_startManualCameraInstallationView = function(options) {
  1970. var inputMaxLength = typeof config.deviceNameLength !== 'undefined' ? config.deviceNameLength : ViewConfig.CUT_DEVICE_NAME_AT_LENGTH;
  1971.  
  1972. var html = `<div class="cameraManualInstallContainer">
  1973. <div class="networkAvailableDevicesSection">
  1974. <div class="containerHeaderWithBigBottomBorder">${Utils.getLangString("ui7_find_network_camera", "Find Your Camera’s IP Address on the Network")}</div>
  1975. <div id="networkDevicesListContainer"></div>
  1976. <div class="margin_top_20 clearfix">
  1977. <div id="${View.idForManualInstallCameraListNetworkDevices(true)}" class="setup_wizard_button testManualCameraBtn pull-right">${Utils.getLangString("ui7_refresh_list", "Refresh list")}</div>
  1978. </div>
  1979. </div>
  1980. <div id="cameraManualConfigurationSection" class="cameraManualConfigurationSection">
  1981. <div class="containerHeaderWithBigBottomBorder">${Utils.getLangString("ui7_manual_configuration", "Manual Configuration")}</div>
  1982. <div id="manualConfigurationContainer">
  1983. <div class="inputLabel" select_camera_type="1">${Utils.getLangString("ui7_select_camera_type", "Select camera type")}<span class="red">*</span></div>
  1984. <div class="cameraTypesSelectBoxContainer customSelectBoxContainer">
  1985. ${View.returnCameraTypesPulldown(options.PK_KitDevice)}
  1986. <span class="position_relative bubbleInfo helpListBtn presetModeQuestion" id="${View.idForManualCameraInstallHints(true)}" data-toggle="tooltip" data-placement="right" >?
  1987. <div id="${View.idForCameraHints(true)}" class="camera_hints_container">
  1988. <div class="pull-right cursor_pointer margin_right_10" id="${View.idForManualCameraInstallCloseHints(true)}">X</div>
  1989. <div>${Utils.getLangString("ui7_manual_install_camera_hints_title", "Camera Installation Hints")}</div>
  1990. <hr class="cross_street_text_separator"/>
  1991. <span class="cross_street_explanation">${Utils.getLangString("ui7_manual_install_camera_hints_content", 'If you install a camera fresh out of the box you will have to fill in it\'s default username and password.<br/><br/> For the Vistacam HD model we provide a possible set of default username/password. For other models, the default credentials may be found on a sticker on the camera itself, or in the user manual.<br/><br/>The default credentials could be invalid if the camera was used before and its options modified or auto detected by other _UNITS_NAME_PLURAL_. In this case you will have to perform a factory reset. Consult each model manual on how to do that.<br/><br/>To make it easier to discover the IP of the camera there is a List Network Devices button at the bottom of this form which will bring a list of devices in your local network. You can pick the camera IP from that list.')}</span>
  1992. </div>
  1993. </span>
  1994. </div>
  1995. <input class="customInput" type="hidden" id="${View.idForManualInstallIpCameraCustomUrl(true)}" />
  1996. <div class="labelInputContainer"
  1997. <div class="inputLabel">${Utils.getLangString("ui7_camera_ip_address", "Camera IP Address")}<span class="red">*</span></div>
  1998. <div><input id="${View.idForManualInstallIpCameraIp(true)}" class="customInput" type="text" /></div>
  1999. </div>
  2000. <div class="labelInputContainer">
  2001. <div class="inputLabel">${Utils.getLangString("ui7_camera_username", "Camera Username")}</div>
  2002. <div><input id="${View.idForInstallDeviceExtraFieldsUsername(true)}" class="customInput" type="text" /></div>
  2003. </div>
  2004. <div class="labelInputContainer">
  2005. <div class="inputLabel">${Utils.getLangString("ui7_camera_password", "Camera Password")}</div>
  2006. <div><input id="${View.idForInstallDeviceExtraFieldsPassword(true)}" class="customInput" type="text" /></div>
  2007. </div>
  2008. </div>
  2009. <div id="testCameraConfigurationSection" class="testCameraConfigurationSection">
  2010. <div class="containerHeaderWithBigBottomBorder">${Utils.getLangString("ui7_test_camera_configuration", "Test Your Camera Configuration")}</div>
  2011. <div class="testCameraInfo">
  2012. <p><b>${Utils.getLangString("ui7_test_camera_info_1", "Click Test Button below to confirm your Camera Configuration.")}</b></p>
  2013. <p>${Utils.getLangString("ui7_test_camera_info_2", "Camera snapshot will appear below within <b>15 to 60 seconds</b>.")}</p>
  2014. </div>
  2015. <div id="testManualCameraContainer" class="testManualCameraContainer">
  2016. <div class="round_loading centerSpinner hidden"></div>
  2017. <img class="hidden" id="${View.idForManualInstallIpCameraTestImage(true)}" />
  2018. <div id="noImageContainer" class="hidden">${View.manulaCameraErrorView()}</div>
  2019. </div>
  2020. <div id="testManualCameraBtn" class="setup_wizard_button testManualCameraBtn">${Utils.getLangString("ui7_test", "Test")}</div>
  2021. </div>
  2022. <div id="nameYourCameraSection" class="nameYourCameraSection">
  2023. <div class="containerHeaderWithBigBottomBorder">${Utils.getLangString("ui7_name_your_camera", "Name Your Camera")}</div>
  2024. <div class="labelInputContainer">
  2025. <div class="inputLabel">${Utils.getLangString("ui7_camera_name", "Camera Name")}<span class="red">*</span></div>
  2026. <div><input id="${View.idForManualInstallCameraDeviceName(true)}" maxlength="${inputMaxLength}" class="customInput" type="text" /></div>
  2027. <p class="required"><span class="red">*</span>${Utils.getLangString("ui7_required", "Required")}</p>
  2028. </div>
  2029. </div>
  2030. <div id="selectRoomCameraSection" class="selectRoomCameraSection">
  2031. <div class="containerHeaderWithBigBottomBorder">${Utils.getLangString("ui7_select_room_camera", "Select Room for Camera")}</div>
  2032. <div class="inputLabel">${Utils.getLangString("ui7_room", "Room")}</div>
  2033. <div class="clearfix">
  2034. <div class="manualCameraRoomSelectContainer customSelectBoxContainer" id="${View.idForWizardRoomsContainer(true)}">${View.returnSelectFromObject(myInterface.returnRoomsObject(true), View.idForInstallDevicesRoomContainer(true), 'class="customSelectBox"', '')}</div>
  2035. <div class="pull-left flip line_height_50 padding_left_15" id="${View.idForWizardV3DeviceToRoomWidgetMessage(true)}"></div>
  2036. <div class="labelInputContainer clearfix" id="${View.idForDeviceCpanelAddRoom(true)}">
  2037. <div id="${View.idForInstallDeviceAddNameRoomCameraExtraFields(true)}"></div>
  2038. </div>
  2039. </div>`;
  2040. return html;
  2041. };
  2042. myInterface.handleSaveCameraDetails = function (cameraId) {
  2043. try {
  2044. var that = this;
  2045. var username = $(View.idForCameraBasicSettingsUsername()).val();
  2046. var password = $(View.idForCameraBasicSettingsPassword()).val();
  2047. var newUsername = $(View.idForCameraBasicSettingsNewUsername()).val();
  2048. var newPassword = $(View.idForCameraBasicSettingsNewPassword()).val();
  2049. //var room = $(View.idForDeviceCpanelRoomContainer()).val();
  2050. if (Utils.trim(newPassword) && !Utils.trim(newUsername)) {
  2051. that.showMessagePopup(Utils.getLangString("ui7_cameraNewUserNameEmpty", "New username can't be empty"), MessageCategory.ERROR);
  2052. return;
  2053. }
  2054. if (newUsername !== '' || newPassword !== '') {
  2055. if (!/^[a-zA-Z0-9]+$/.test(newPassword) || !/^[a-zA-Z0-9]+$/.test(newUsername)) {
  2056. that.showMessagePopup(Utils.getLangString("ui7_unsuported_camera_new_credentials_characters", "New Username and new Password fields should contain only letters and numbers."), MessageCategory.ERROR);
  2057. return;
  2058. }
  2059. //plugin will treat as null/nil an empty string so we send _EMPTY_STRING_ string instead
  2060. var settingsObject = {
  2061. username: Utils.trim(username) === '' ? '_EMPTY_STRING_' : username,
  2062. password: Utils.trim(password) === '' ? '_EMPTY_STRING_' : password,
  2063. newUsername: Utils.trim(newUsername) === '' ? '_EMPTY_STRING_' : newUsername,
  2064. newPassword: Utils.trim(newPassword) === '' ? '_EMPTY_STRING_' : newPassword,
  2065. cameraId: cameraId
  2066. };
  2067. that.currentCpanelCameraId = cameraId;
  2068. that.changeCameraUsernameAndPasswordPluginRequest(settingsObject, that.sendUsernameAndPasswordToCameraSuccess, that.sendUsernameAndPasswordToCameraError, that, 20);
  2069. } else {
  2070. that.modifyAdvancedCameraOtherFields(cameraId);
  2071. }
  2072. } catch (e) {
  2073. Utils.logError("ERROR in Interface.handleSaveCameraDetails(): " + e);
  2074. }
  2075. };
  2076. View.returnKitAndAdditionalDevicesFrame = function() {
  2077. try {
  2078. var topMessage = Utils.getLangString("ui7_tlm_select_kit_to_install", "Please select your kit");
  2079.  
  2080. var html = `<div data-kit_device_select_label="1" class="tlm_install_kit_device_label">${topMessage}</div>
  2081. <div data-kit_device_back_btn_container="1" class="clearfix tlm_install_kit_device_btn_container" style="display: none;">
  2082. <button id="${View.idForKitDeviceSelectBackBtn(true)}" class="pull-left btn btn-default vBtn">${Utils.getLangString("ui7_general_ucase_back", "Back")}</button>
  2083. </div>
  2084. <div class="clearfix" id="${View.idForSetupWizardKitsContainer(true)}"></div>
  2085. <div data-install_kit_device_btn_container="1" class="clearfix tlm_install_kit_device_btn_container">
  2086. <button id="${View.idForKitDeviceSelectKitBtn(true)}" class="pull-right btn btn-default vBtn">${Utils.getLangString("ui7_wizard_lang_next", "Next")}</button>
  2087. </div>
  2088. <div style="display: none;" id="${View.idForSetupWizardToggleAdditionalDevicesTitle(true)}" class="setup_wizard_aditional_devices_label clearfix">
  2089. <div class="pull-left flip">${Utils.getLangString("ui7_additionalDevices", "Additional Devices")}</div>
  2090. <div id="${View.idForSetupWizardToggleAdditionalDevicesControl(true)}" class="pull-right flip icon_additional_devices_plus"></div>
  2091. </div>
  2092. <div id="${View.idForSetupWizardKitAndDevicesFrameAdditionalContainer(true)}" class="aditionalDevicesContainer"></div>`;
  2093. return html;
  2094. } catch (e) {
  2095. Utils.logError('Error in View.returnKitAndAdditionalDevicesFrame(): ' + e);
  2096. }
  2097. };
  2098.  
  2099. myInterface.playCameraStream = function (cameraId) {
  2100. try {
  2101. var that = this;
  2102.  
  2103. if(that.browserSupportsFlash()){
  2104. // reset retry counter
  2105. that.retryGetStreamingUrlCounter = 0;
  2106.  
  2107. // use flow player
  2108. // streaming from relay
  2109. if(config.uiMode === UI_RELAY_MODE){
  2110. that.playCameraFlashRemote(cameraId);
  2111. return;
  2112. }
  2113. // or local
  2114. that.playCameraFlash(cameraId);
  2115. } else {
  2116. // use old player
  2117. that.playCameraHtml(cameraId);
  2118. }
  2119. } catch (e) {
  2120. Utils.logError("ERROR in Interface.playCameraStream(): " + e);
  2121. }
  2122. };
  2123. application.initParseUserData = function(userDataObject) {
  2124. try {
  2125. var that = this;
  2126.  
  2127. // if user data was modified locally, prevent parsing as it may override local changes
  2128. that.tempFormatUpdated = (typeof userDataObject.weatherSettings === "undefined") ? "C" : userDataObject.weatherSettings.tempFormat;
  2129. that.weatherCityUpdated = (typeof userDataObject.weatherSettings === "undefined") ? "Austin" : userDataObject.weatherSettings.weatherCity;
  2130. that.weatherCountryUpdated = (typeof userDataObject.weatherSettings === "undefined") ? "USA" : userDataObject.weatherSettings.weatherCountry;
  2131. if (that.uiFlags.userDataChanged) {
  2132. that.fireEvent('on_ui_requireSave');
  2133. return;
  2134. }
  2135.  
  2136. // if parsing already started, stop
  2137. if (that.userDataParsingInProgress) {
  2138. Utils.logError('User data parsing already in progress.');
  2139. return;
  2140. }
  2141.  
  2142. // start parsing
  2143. that.userDataParsingInProgress = true;
  2144.  
  2145. // fire event if user data was loaded for the first time
  2146. if (that.userData === null) {
  2147. that.tempFormat = (typeof userDataObject.weatherSettings === "undefined") ? "C" : userDataObject.weatherSettings.tempFormat;
  2148. that.weatherCity = (typeof userDataObject.weatherSettings === "undefined") ? "Austin" : userDataObject.weatherSettings.weatherCity;
  2149. that.weatherCountry = (typeof userDataObject.weatherSettings === "undefined") ? "USA" : userDataObject.weatherSettings.weatherCountry;
  2150. that.fireEvent('on_ui_userDataFirstLoaded');
  2151. }
  2152.  
  2153. // parse user data
  2154. that.parseUserData(userDataObject);
  2155.  
  2156. // end parsing
  2157. that.userDataParsingInProgress = false;
  2158. } catch (e) {
  2159. Utils.logCriticalError('Error in Application.initParseUserData: ' + e);
  2160. }
  2161. };
  2162.  
  2163. View.returnChangeDelay = function() {
  2164. var labelTitle = Utils.getLangString('ui7_preset_modes_how_much_time_to_wait', 'How much time to wait before changing mode ?');
  2165. var txt1 = Utils.getLangString('ui7_modes_delay_wait', 'Wait');
  2166. var txt2 = Utils.getLangString('ui7_preset_modes_seconds_before_changing', 'seconds before changing to any mode other than home');
  2167. var txt3 = Utils.getLangString('ui7_preset_modes_seconds_before_reporting', 'seconds before reporting a motion, door, window tripped');
  2168.  
  2169. return `<div class="preset_header_tab margin_top_25">
  2170. <div class="preset-section-label-title">${labelTitle}</div>
  2171. </div>
  2172. <div class="clearfix margin_top_10">
  2173. <div class="pull-left flip">
  2174. ${txt1} &nbsp;
  2175. <input type="text" id="${View.idForModeChangeDelay(true)}" value="" size="5" />&nbsp;
  2176. ${txt2}
  2177. </div>
  2178. <div class="pull-left flip margin_left_15 hidden" id="${View.idForModeChangeDelayMessage(true)}"></div>
  2179. </div>
  2180. <div class="clearfix margin_top_10 hidden">
  2181. <div class="pull-left flip">
  2182. ${txt1} &nbsp;
  2183. <input type="text" id="${View.idForModeBreachDelay(true)}" value="28" size="5" />&nbsp;
  2184. ${txt3}
  2185. </div>
  2186. <div class="pull-left flip margin_left_15 hidden" id="${View.idForModeBreachDelayMessage(true)}"></div>
  2187. </div>`;
  2188. };
  2189. Interface.prototype.checkPasswordStrength = function(password) {
  2190. var passwordStrengthIndicator = 0;
  2191. if (password.length >= 8) {
  2192. if (/[0-9]/.test(password)) {
  2193. passwordStrengthIndicator += 1;
  2194. }
  2195. if (/[A-Z]/.test(password)) {
  2196. passwordStrengthIndicator += 1;
  2197. }
  2198. if (/[a-z]/.test(password)) {
  2199. passwordStrengthIndicator += 1;
  2200. }
  2201. }
  2202. return passwordStrengthIndicator;
  2203. };
  2204. Interface.prototype.validatePassword = function(passwordObject) {
  2205. var that = this;
  2206. if (passwordObject.oldPassword === '' || passwordObject.newPassword === '' || passwordObject.repeatPassword === '') {
  2207. that.showMessagePopup(Utils.getLangString("ui7_account_FILL_REQUIRED_FIELDS", "Please fill required fields"), MessageCategory.ERROR, 0);
  2208. return false;
  2209. }
  2210. if(passwordObject.newPassword === passwordObject.oldPassword) {
  2211. that.showMessagePopup(Utils.getLangString("ui7_account_identical_passwords", "New password is identical with the Old password, please choose a different password."), MessageCategory.ERROR, 0);
  2212. return false;
  2213. }
  2214. if (passwordObject.newPassword !== passwordObject.repeatPassword) {
  2215. that.showMessagePopup(Utils.getLangString("ui7_account_WRONG_CONFIRM_PASSWORD", "Confirm password does not match"), MessageCategory.ERROR, 0);
  2216. return false;
  2217. }
  2218. if (passwordObject.newPassword.length < 8) {
  2219. that.showMessage(Utils.getLangString("ui7_account_password_minimum_size", "Password must be at least 8 characters long."), {autoHide: false});
  2220. return false;
  2221. }
  2222. if(!/[0-9]/.test(passwordObject.newPassword)){
  2223. that.showMessage(Utils.getLangString("ui7_account_password_number_error", "Password must contain at least one number."), {autoHide: false});
  2224. return false;
  2225. }
  2226. if(!/[A-Z]/.test(passwordObject.newPassword)){
  2227. that.showMessage(Utils.getLangString("ui7_account_password_uppercase_letter_error", "Password must contain at least 1 uppercase letter."), {autoHide: false});
  2228. return false;
  2229. }
  2230. if(!/[a-z]/.test(passwordObject.newPassword)){
  2231. that.showMessage(Utils.getLangString("ui7_account_password_lowercaseLetter", "Password must contain at least 1 lowercase letter."), {autoHide: false});
  2232. return false;
  2233. }
  2234. if(authObj.PK_Account && passwordObject.newPassword.indexOf(authObj.PK_Account) !== -1){
  2235. that.showMessage(Utils.getLangString("ui7_account_password_account_number_error", "Password cannot contain the account number."), {autoHide: false});
  2236. return false;
  2237. }
  2238. if(authObj.accountInfo && authObj.accountInfo.Mailing && authObj.accountInfo.Mailing.FirstName && passwordObject.newPassword.toLowerCase().indexOf(authObj.accountInfo.Mailing.FirstName.toLowerCase()) !== -1){
  2239. that.showMessage(Utils.getLangString("ui7_account_password_firstname_error", "Password cannot contain user first name."), {autoHide: false});
  2240. return false;
  2241. }
  2242. if(authObj.accountInfo && authObj.accountInfo.Mailing && authObj.accountInfo.Mailing.LastName && passwordObject.newPassword.toLowerCase().indexOf(authObj.accountInfo.Mailing.LastName.toLowerCase()) !== -1){
  2243. that.showMessage(Utils.getLangString("ui7_account_password_lastname_error", "Password cannot contain user last name."), {autoHide: false});
  2244. return false;
  2245. }
  2246. if(authObj.authUsername && passwordObject.newPassword.toLowerCase().indexOf(authObj.authUsername.toLowerCase()) !== -1){
  2247. that.showMessage(Utils.getLangString("ui7_account_password_username_error", "Password cannot contain user username."), {autoHide: false});
  2248. return false;
  2249. }
  2250. return true;
  2251. };
  2252. Interface.prototype.validateNewUser = function(userData){
  2253. try{
  2254. var that = this;
  2255. var userObject = userData.userObj;
  2256. if (Utils.int(userData.permissionRole) !== Utils.int(CONFIG.PERMISSION_ROLE_END_USER) && !userData.gatewaySelected) {
  2257. that.showMessagePopup(Utils.getLangString("ui7_account_select_at_least_one_unit", "Please select which gateway/gateways the user is allowed to control."), MessageCategory.NOTIFICATION, 0);
  2258. return false;
  2259. }
  2260. if (!config.emailAsUsername) {
  2261. if (userObject.params.Username === '') {
  2262. that.showMessagePopup(Utils.getLangString("ui7_account_FILL_REQUIRED_FIELDS", "Please fill required fields"), MessageCategory.NOTIFICATION, 0);
  2263. return false;
  2264. }
  2265.  
  2266. if (typeof config.newUserAcceptedCharacters !== 'undefined' && !config.newUserAcceptedCharacters.test(userObject.params.Username)) {
  2267. that.showMessagePopup(Utils.getLangString("ui7_mios_add_user_username_requirments", "Username should contain only letters, numbers and special character: .,@,_"), MessageCategory.NOTIFICATION, 0);
  2268. return false;
  2269. }
  2270. }
  2271. if (userObject.params.Email === '') {
  2272. that.showMessagePopup(Utils.getLangString("ui7_account_FILL_REQUIRED_FIELDS", "Please fill required fields"), MessageCategory.NOTIFICATION, 0);
  2273. return false;
  2274. }
  2275. if (!Utils.isValidEmail(userObject.params.Email)) {
  2276. that.showMessagePopup(Utils.getLangString("ui7_account_invalid_email_address", "Invalid email address."), MessageCategory.NOTIFICATION, 0);
  2277. return false;
  2278. }
  2279. if (userObject.params.Password === '') {
  2280. that.showMessagePopup(Utils.getLangString("ui7_account_FILL_REQUIRED_FIELDS", "Please fill required fields"), MessageCategory.NOTIFICATION, 0);
  2281. return false;
  2282. }
  2283. if (Utils.trim(userObject.params.Password).length < 8) {
  2284. that.showMessagePopup(Utils.getLangString("ui7_account_password_format", "Password must be at least 8 characters long."), MessageCategory.NOTIFICATION, 0);
  2285. return false;
  2286. }
  2287. if (userObject.params.Password !== userData.repeatPasswordValue) {
  2288. that.showMessagePopup(Utils.getLangString("ui7_account_WRONG_CONFIRM_PASSWORD", "Confirm password does not match"), MessageCategory.ERROR, 0);
  2289. return false;
  2290. }
  2291. if(!/[0-9]/.test(userObject.params.Password)){
  2292. that.showMessage(Utils.getLangString("ui7_account_password_number_error", "Password must contain at least one number."), {autoHide: false});
  2293. return false;
  2294. }
  2295. if(!/[A-Z]/.test(userObject.params.Password)){
  2296. that.showMessage(Utils.getLangString("ui7_account_password_uppercase_letter_error", "Password must contain at least 1 uppercase letter."), {autoHide: false});
  2297. return false;
  2298. }
  2299. if(!/[a-z]/.test(userObject.params.Password)){
  2300. that.showMessage(Utils.getLangString("ui7_account_password_lowercaseLetter", "Password must contain at least 1 lowercase letter."), {autoHide: false});
  2301. return false;
  2302. }
  2303. if(authObj.PK_Account && userObject.params.Password.indexOf(authObj.PK_Account) !== -1){
  2304. that.showMessage(Utils.getLangString("ui7_account_password_account_number_error", "Password cannot contain the account number."), {autoHide: false});
  2305. return false;
  2306. }
  2307. if(authObj.userInfo && authObj.userInfo.FirstName && userObject.params.Password.toLowerCase().indexOf(authObj.userInfo.FirstName.toLowerCase()) !== -1){
  2308. that.showMessage(Utils.getLangString("ui7_account_password_firstname_error", "Password cannot contain user first name."), {autoHide: false});
  2309. return false;
  2310. }
  2311. if(authObj.userInfo && authObj.userInfo.Name && userObject.params.Password.toLowerCase().indexOf(authObj.userInfo.Name.toLowerCase()) !== -1){
  2312. that.showMessage(Utils.getLangString("ui7_account_password_lastname_error", "Password cannot contain user last name."), {autoHide: false});
  2313. return false;
  2314. }
  2315. if(userObject.params.Username && userObject.params.Password.toLowerCase().indexOf(userObject.params.Username.toLowerCase()) !== -1){
  2316. that.showMessage(Utils.getLangString("ui7_account_password_username_error", "Password cannot contain user username."), {autoHide: false});
  2317. return false;
  2318. }
  2319. if(authObj.authUsername && userObject.params.Password.toLowerCase().indexOf(authObj.authUsername.toLowerCase()) !== -1){
  2320. that.showMessage(Utils.getLangString("ui7_account_password_username_error_other_user", "Password cannot contain your username."), {autoHide: false});
  2321. return false;
  2322. }
  2323. return true;
  2324. }catch(err){
  2325. Utils.logError('Error in Interface.validateNewUser(): ' + err);
  2326. }
  2327. };
  2328. myInterface.terminateSessionNoUserActivity = function () {
  2329. application.logout(true);
  2330. };
  2331. Interface.prototype.handleScanForIpAndListResultsSuccessCallback3 = function (transport) {
  2332. try {
  2333. var that = this;
  2334. var ipsObject = Utils.parseJson(transport.responseText);
  2335. if(ipsObject.ip_requests.length > 0){
  2336. that.setView('installCameraDeviceIpsList3', ipsObject.ip_requests, "#networkDevicesListContainer");
  2337. $("#networkDevicesListContainer").find('[data-camera-ip]').each(function(){
  2338. $(this).off().on('click', function(){
  2339. var cameraIp = $(this).data("camera-ip");
  2340. that.addIpToManualIpCameraINstallationField(cameraIp);
  2341. });
  2342. });
  2343. $("#cameraManualConfigurationSection").fadeIn();
  2344. that.addBehaviorToCameraIpField();
  2345. // MANUAL WITH PK
  2346. if($(View.idForManualInstallIpCameraTypeSelect()).parent().hasClass('hidden')){
  2347. $("#testCameraConfigurationSection").fadeIn();
  2348. }
  2349. }else{
  2350. that.handleScanForIpAndListResultsErrorCallback();
  2351. }
  2352. } catch (e) {
  2353. Utils.logError('Interface.handleScanForIpAndListResultsSuccessCallback3(): ' + e);
  2354. }
  2355. };
  2356. myInterface.addBehaviorToCameraIpField = function(){
  2357. $(View.idForManualInstallIpCameraIp()).attr('disabled', false).css('background', 'auto');
  2358. $(View.idForManualInstallIpCameraIp()).off().on('input', function(){
  2359. myInterface.autoFillCameraURL(wiz.Camera_PK_KitDevice);
  2360. });
  2361. };
  2362. Interface.prototype.handleScanForIpAndListResultsErrorCallback = function () {
  2363. try {
  2364. var that = this;
  2365. that.setView('returnNoNetworkDeviceDetectedView', {}, "#networkDevicesListContainer");
  2366. $("#cameraManualConfigurationSection").fadeIn();
  2367. that.addBehaviorToCameraIpField();
  2368. // MANUAL WITH PK
  2369. if($(View.idForManualInstallIpCameraTypeSelect()).parent().hasClass('hidden')){
  2370. $("#testCameraConfigurationSection").fadeIn();
  2371. }
  2372. } catch (e) {
  2373. Utils.logError('Interface.handleScanForIpAndListResultsErrorCallback() error: ' + e);
  2374. }
  2375. };
  2376. myInterface.startWizardIfIsNotFinished = function(){
  2377. var that = this;
  2378. if($("#wizard_content").is(":visible")){
  2379. return;
  2380. }
  2381. if (application.userData !== null &&
  2382. (typeof (application.userData.setup_wizard_finished) === 'undefined' || parseInt(application.userData.setup_wizard_finished) !== 1) &&
  2383. typeof (that.setupWizardStartedByFirstUserData) === 'undefined' && !that.hideSetupWizardIfNotEndUser && authObj.PK_PermissionRole !== CONFIG.PERMISSION_ROLE_GUEST
  2384. ) {
  2385. // prevent from starting setup wizard again after token refresh
  2386. // see the handleCMEnrollmentFinished method
  2387. if (typeof that.preventSetupWizardStarting === 'undefined') {
  2388. if(that.checkIfPermissionInSetupDevices("ui_view_setup_wizard", application.userData.SetupDevices)){
  2389. that.runItem("ui_view_setup_wizard");
  2390. }else{
  2391. that.preventSetupWizardStarting = true;
  2392. that.showDefaultPage();
  2393. }
  2394. }else{
  2395. that.showDefaultPage();
  2396. }
  2397. } else {
  2398. if (typeof currentLoginCallback === 'function') {
  2399. currentLoginCallback();
  2400. } else {
  2401. that.showDefaultPage();
  2402. }
  2403. }
  2404. };
  2405. View.returnNoNetworkDeviceDetectedView = function(){
  2406. return `<div class="text-center">${Utils.getLangString("ui7_no_device_detected_error", "Failed to retrieve camera IP, try again by clicking on 'Refresh list' button or add camera IP on the 'Camera IP Address' field below.")}</div>`;
  2407. };
  2408. View.returnMyAccountPreferencesContainerContent = function(userObject) {
  2409. try {
  2410. var phoneNumber = "";
  2411. var userName = "";
  2412. var phoneNotificationEnabled = 0;
  2413.  
  2414. if(typeof (userObject.FirstName) !== 'undefined' && userObject.FirstName !== 'undefined'){
  2415. userName = DOMPurify.sanitize(userObject.FirstName);
  2416. }
  2417. if (typeof (userObject.Phone) !== 'undefined' && typeof (userObject.Phone.Phone) !== 'undefined') {
  2418. phoneNumber = DOMPurify.sanitize(myInterface.setUserInfoCountryPrefix(userObject));
  2419. }
  2420. var validationPhoneWarning = '';
  2421. if (typeof (userObject.Phone.Phone) === 'undefined' || userObject.Phone.Phone.trim() === '') {
  2422. validationPhoneWarning = `<div class="size_350 my_profile_warning_style">${Utils.getLangString("ui7_youHaveToSetupPhone", "You have to set up a phone number in order to receive notifications.")}</div>`;
  2423. } else {
  2424. if (Utils.int(userObject.Phone.Validated) === 0) {
  2425. validationPhoneWarning = `<div class="validationInfo">${Utils.getLangString("ui7_phoneMustBeValidated", "Phone number must be validated in order to receive notifications.") + ' ' + Utils.getLangString("ui7_click", "Click") + ' '}<button class="buttonLink" id="${View.idForGoToValidatePhoneBtn(true)}">${Utils.getLangString("ui7_here", "here")}</button>${' ' + Utils.getLangString("ui7_toValidate", "to validate")}.</div>`;
  2426. }
  2427. }
  2428. var validationEmailWarning = '';
  2429. if (Utils.int(userObject.Validated) === 0) {
  2430. validationEmailWarning = `<div class="validationInfo">${Utils.getLangString("ui7_emailMustBeValidated", "Email must be validated in order to receive notifications.") + ' ' + Utils.getLangString("ui7_click", "Click") + ' '}<button class="buttonLink" id="${View.idForGoToValidateEmailBtn(true)}">${Utils.getLangString("ui7_here", "here")}</button>${' ' + Utils.getLangString("ui7_toValidate", "to validate")}.</div>`;
  2431. }
  2432. if (!!userObject.PhoneNotifications && !!phoneNumber) {
  2433. phoneNotificationEnabled = 1;
  2434. }
  2435. var html = `<h3 class="subTitle">${Utils.getLangString("ui7_account_notify_as_follows", "I want to be notified as follows")}</h3>
  2436. <div class="labelInputContainer clearfix userNameContainer">
  2437. <div class="pull-left flip inputLabel">${Utils.getLangString("ui7_account_username", "Username")}</div>
  2438. <div class="pull-left flip labelInfo" id="${View.idForPreferencesUsername(true)}"><b>${DOMPurify.sanitize(userObject.Username)}</b></div>
  2439. </div>
  2440. <div class="labelInputContainer clearfix">
  2441. <div class="pull-left flip inputLabel">${Utils.getLangString("ui7_myNameIs", "My First Name is:")}<span id="${View.idForUserNameOcupancy(true)}" class="countryPrefix"></span></div>
  2442. <div class="pull-left flip"><input id="${View.idForUserName(true)}" class="customInput" type="text" value="${userName}" /></div>
  2443. </div>
  2444.  
  2445. <div class="labelInputContainer clearfix">
  2446. <div class="pull-left flip inputLabel">${Utils.getLangString("ui7_account_country_provider", "Country:")}</div>
  2447. <div class="pull-left flip countrySelectBoxContainer">${View.returnCountrySelectBox(userObject, phoneNotificationEnabled)}</div>
  2448. </div>
  2449. <div class="labelInputContainer clearfix">
  2450. <div class="pull-left flip inputLabel">${Utils.getLangString("ui7_account_phone_provider", "Phone Provider:")}</div>
  2451. <div id="${View.idForProviderSelectContainer(true)}" class="pull-left flip providerSelectContainer customSelectBoxContainer">${View.returnPhoneProvider(userObject.Phone.PK_Country, userObject.Phone.PK_Provider, userObject.PhoneNotifications)}</div>
  2452. </div>
  2453. <div class="labelInputContainer clearfix">
  2454. <div class="pull-left flip inputLabel">${Utils.getLangString("ui7_myPhoneNumberIs", "My Phone Number is:")}<span id="${View.idForPhonePrefix(true)}" class="countryPrefix"></span></div>
  2455. <div class="pull-left flip"><input id="${View.idForAccountPhoneNumber(true)}" class="customInput" type="text" value="${phoneNumber}" /></div>
  2456. </div>
  2457. <div class="providerNote"><small><strong>${Utils.getLangString("ui7_devices_help_note", "Note:")}</strong>${Utils.getLangString("ui7_providerMayCharge", "Provider may charge you for text messages")}.</small></div>
  2458. <div class="labelInputContainer clearfix checkboxContainer">
  2459. <input class="pull-left flip customCheckbox" id="${View.idForAccountNotifyPhone(true)}" ${phoneNotificationEnabled ? 'checked' : ''} type="checkbox" />
  2460. <label class="labelForCustomCheckbox" for="account_notify_phone">${Utils.getLangString("ui7_account_send_message_phone", "Send a text message to my mobile phone")}</label>
  2461. </div>`;
  2462. if (config.enablePushNotifications) {
  2463. html += `<div class="labelInputContainer clearfix checkboxContainer">
  2464. <div class="pull-left flip">
  2465. <input class="phoneNotificationCheckbox" id="${View.idForAccountNotifyPushNotifications(true)}" ${typeof userObject.PushNotifications !== 'undefined' && Utils.int(userObject.PushNotifications) === 1 ? 'checked' : ''} type="checkbox" />
  2466. <label class="phoneLabel" for="${View.idForAccountNotifyPushNotifications(true)}">${Utils.getLangString("ui7_account_send_push_notification", "Send me push notifications")}</label>
  2467. </div>
  2468. <div class="pull-left flip"></div>
  2469. </div>`;
  2470. }
  2471. html += ` <div class="labelInputContainer clearfix" id="${View.idForPhoneValidationContainer(true)}">${validationPhoneWarning}</div>
  2472. <div class="labelInputContainer clearfix">
  2473. <div class="pull-left flip inputLabel">${Utils.getLangString("ui7_account_email_address", "My email is: ")}</div>
  2474. <div class="pull-left flip"><input id="${View.idForAccountEmailAddress(true)}" class="customInput" type="text" value="${DOMPurify.sanitize(userObject.Email)}"/></div>
  2475. </div>
  2476. <div class="labelInputContainer clearfix checkboxContainer">
  2477. <div class="float_left"><input class="customCheckbox" id="${View.idForAccountNotifyEmail(true)}" ${Utils.int(userObject.EmailNotifications) === 1 ? 'checked' : ''} type="checkbox" />
  2478. <label class="labelForCustomCheckbox" for="account_notify_email">${Utils.getLangString("ui7_account_send_email", "Send me an email")}</label>
  2479. </div>
  2480. <div class="float_left"></div>
  2481. </div>
  2482. <div id="${View.idForUpdateAccountValidateEmailMessageContainer(true)}" class="labelInputContainer clearfix">${validationEmailWarning}</div>`;
  2483. if (config.emailAsUsername) {
  2484. html += `<div class="labelInputContainer clearfix">
  2485. <div class="pull-left flip inputLabel">${Utils.getLangString("ui7_account_password", "Password:")}</div>
  2486. <div class="pull-left flip"><input id="${View.idForAddUserPasswordInput(true)}" class="customInput" type="password" value=""/></div>
  2487. </div>`;
  2488. }
  2489. html += `<div class="genericSaveButtonContainer clearfix">
  2490. <input id="${View.idForSaveUserInfoBtn(true)}" class="vBtn pull-right flip" type="button" value="${Utils.getLangString("ui7_account_save_changes", "Save Changes")}" />
  2491. </div>`;
  2492. return html;
  2493. } catch (e) {
  2494. Utils.logError('Error in View.returnMyAccountPreferencesContainerContent(): ' + e.message);
  2495. }
  2496. };
  2497. var dateFormatObject = [
  2498. {
  2499. value: 'mm/dd/yy',
  2500. label: 'MM-DD-AAAA'
  2501. },
  2502. {
  2503. value: 'dd/mm/yy',
  2504. label: 'DD-MM-AAAA'
  2505. },
  2506. {
  2507. value: 'yy/mm/dd',
  2508. label: 'AAAA-MM-DD'
  2509. }
  2510. ];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement