-
Notifications
You must be signed in to change notification settings - Fork 13
/
example_app.js
executable file
·61 lines (54 loc) · 1.63 KB
/
example_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
if (App === "undefined") var App = {}; // Eslint error.
if (tvOS === "undefined") var tvOS = {}; // Eslint error.
if (evaluateScripts === "undefined") var evaluateScripts = {}; // Eslint error.
evaluateScripts(
["https://0xwdg.github.io/tvOS.js/tvOS.js"],
function (success) {
if (success) {
// init App.
var old_count = "";
var myArray = [];
var count = 0;
// load data
tvOS.ajax("http://api.the-app-team.com/StartUp/", "GET", function (data) {
data = JSON.parse(data);
for (var i in data) {
myArray.push({
title: data[i]["title"],
description: data[i]["description"],
subtitle: data[i]["date"],
action: "clickedOn",
accessibilityText: "None",
});
count++;
}
});
var publish_checker = function () {
if (old_count === count) {
tvOS.listView(
"Meetups in Amsterdam",
myArray,
"http://the-app-team.com/assets/images/logo.png"
);
} else {
old_count = count;
setTimeout(publish_checker, 100);
}
};
setTimeout(publish_checker, 100);
} else {
console.log("Missing it all!");
}
}
);
function clickedOn(event) {
tvOS.alert(event, "Return to example list?", ["Yes", "No"], function (event) {
if (event.toLowerCase() === "yes") {
tvOS.location("https://0xwdg.github.io/tvOS.js/index.js");
} else {
tvOS.dismiss(); // Remove alert!
}
});
}
// Becouse that weird eslint hates functions :/
if (typeof clickedOn === "undefined") console.log("ok");