-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnews.js
80 lines (55 loc) · 1.93 KB
/
news.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
function get_news() {
var http = new XMLHttpRequest();
var url = "https://openseed.vagueentertainment.com:8675/corescripts/news.php";
// console.log(url)
var seen = "";
var news = "";
var testStr = "SELECT * FROM NEWS WHERE 1";
db.transaction(function(tx) {
var pull = tx.executeSql(testStr);
if(pull.rows.length === 1) {
seen = pull.rows.item(0).date;
} else {
seen = "none";
}
});
http.onreadystatechange = function() {
if (http.readyState == 4) {
//console.log(http.responseText);
//userid = http.responseText;
if(http.responseText === 100) {
console.log("Incorrect DevID");
} else if(http.responseText === 101) {
console.log("Incorrect AppID");
} else {
//console.log(http.responseText);
thenews = http.responseText.split("><")[0];
date = http.responseText.split("><")[1];
newscheck.stop();
if(seen != date) {
thisWindow.visible = true;
}
}
}
}
http.open('POST', url.trim(), true);
// console.log(http.statusText);
//http.send(null);
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.send("devid=" + devId + "&appid=" + appId + "&userid="+ userid + "&lastseen" + seen);
}
function dismiss_news(date) {
var testStr = "SELECT * FROM NEWS WHERE 1";
var insert = "INSERT INTO NEWS VALUES(?)";
var data = [date];
var update = "UPDATE NEWS SET date='"+date+"' WHERE 1";
db.transaction(function(tx) {
var pull = tx.executeSql(testStr);
if(pull.rows.length === 1) {
tx.executeSql(update);
} else {
tx.executeSql(insert,data);
}
});
thisWindow.visible = false;
}