forked from kenta0g/brownbag
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
86 lines (76 loc) · 2.31 KB
/
app.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//ons.bootstrap();
// CordovaのAPIを呼び出す準備が整った
ons.ready(function() {
console.log("ons.ready");
readShopList();
});
var g_shop_list = null;
function getShopItem(index) {
if (g_shop_list == null) {
return null;
} else if (index < 0 || g_shop_list.length <= index) {
return null;
}
return g_shop_list[index];
}
function getShopItems() {
return g_shop_list;
}
function getShopItemCount() {
if (g_shop_list == null) {
return 0;
}
return g_shop_list.length;
}
function readShopList() {
$.getJSON("data.json" , function(data) {
g_shop_list = data;
console.log("readShopList(): length=" + getShopItemCount());
});
}
//--------------------------
// for sidemenu & pushpage
//--------------------------
window.fn = {};
window.fn.toggleMenu = function () {
document.getElementById('appSplitter').right.toggle();
};
window.fn.loadView = function (index) {
document.getElementById('appTabbar').setActiveTab(index);
document.getElementById('sidemenu').close();
};
window.fn.loadLink = function (url) {
window.open(url, '_blank');
};
window.fn.pushPage = function (page, anim) {
if (anim) {
document.getElementById('appNavigator').pushPage(page.id, { data: { title: page.title, index: page.index }, animation: anim });
} else {
document.getElementById('appNavigator').pushPage(page.id, { data: { title: page.title, index: page.index } });
}
};
//--------------------------
// アクティブなタブが変わる前に発火します。
//--------------------------
document.addEventListener('prechange', function(event) {
// ラベル設定
document.querySelector('ons-toolbar .center')
.innerHTML = event.tabItem.getAttribute('label');
});
//--------------------------
// initイベント
//--------------------------
document.addEventListener("init", function(event) {
var page = event.target;
if (page.id === "home-page") {
console.log("home-page");
} else if (page.id === "list-page") {
console.log("list-page");
} else if (page.id === "map-page") {
console.log("map-page");
} else if (page.id === "info-page") {
console.log("info-page");
} else if (page.id === "setting-page") {
console.log("setting-page");
}
});