-
Notifications
You must be signed in to change notification settings - Fork 13
/
example_instagram.js
executable file
·71 lines (65 loc) · 2.05 KB
/
example_instagram.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
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(
"https://www.wdgwv.com/XML2JSON.php?feed=http://iconosquare.com/feed/wesdegroot&num=20",
"GET",
function (data) {
data = JSON.parse(data);
data = data["responseData"]["feed"]["entries"];
for (var i in data) {
myArray.push({
image: data[i]["content"].split('src="')[1].split('"')[0], // Extract image (Q&D)
title: data[i]["title"],
// description: data[i]['content'],
subtitle: String(new Date(data[i]["publishedDate"])).substring(
0,
24
), // better :)
action: "clickedOn",
accessibilityText: "None",
});
count++;
}
}
);
var publish_checker = function () {
if (old_count === count) {
tvOS.listView(
"Instagram: @wesdegroot",
myArray,
"http://www.hipmarketing.nl/wp-content/uploads/2015/08/instagram-logo-transparent.png",
382,
1057
);
} 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");