forked from jacques24681/HAGearS3
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
41 lines (37 loc) · 1.45 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// TODO Use some type of requireJs or custom stuff like settingsUI
// require ViewNetadata from /js/view/ViewMetadata.js
$(function () {
var viewManager;
var dataManager = new DataManager();
var entitiesPage = new EntitiesPage(dataManager);
var settingsPage = new SettingsPage(dataManager);
var mainPage = new MainPage(dataManager, entitiesPage);
var runBefore = localStorage.getItem('ha-run-before');
if (runBefore) {
// Fetch initial data
$('#main-spinner').removeClass('hidden');
dataManager.load(function(){
hideSpinner();
entitiesPage.update();
}.bind(this), hideSpinner);
} else {
$('#error-popup-contents').text("This appears to be your first time running HomeAssistant! Scroll down to the bottom on the homepage and enter your url and password in the settings menu. You will need to disable autocorrect to enter the url.");
tau.changePage('error-popup');
localStorage.setItem('ha-run-before', true);
}
// Handle hardware back button
document.addEventListener('tizenhwkey', function onTizenhwkey(e) {
if (e.keyName === 'back') {
if (document.getElementsByClassName('ui-page-active')[0]
.id === 'main' && !tau.activePage
.querySelector('.ui-popup-active')) {
tizen.application.getCurrentApplication().exit();
} else {
history.back();
}
}
});
function hideSpinner() {
$('#main-spinner').addClass('hidden');
}
});