-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtvphp.js
114 lines (103 loc) · 4.24 KB
/
tvphp.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
function getObjectText(obj){ return document.all ? obj.innerText : obj.textContent; }
function touch(url) {
var tmp = new XMLHttpRequest();
tmp.open("GET", url, true);
tmp.send([]);
}
function getChildClassed(item, classPattern){
for (var i in item.childNodes){
var point = item.childNodes[i];
if(point.className && point.className.search(classPattern) != -1)
return point;
}
window.alert('FAIL');
return [];
}
function setVisibilities() {
var base = document.getElementById("ShowInformation");
var allshows = getChildClassed(base, "tbody").childNodes;
var groupflag = '';
var minrating = 0;
for(var i in allshows) {
var show = allshows[i];
if (show.className == "Infoa" || show.className == "Infob") {
groupflag = (show.showUnrated != undefined) ? show.showUnrated : (show.getAttribute("unrated") == "on");
minrating = show.getAttribute("minrating");
}
else if(show.className == "Show") {
var r = getChildClassed(show, /rating/);
var r = r.className.charAt(r.className.length-1);
var channelName = getObjectText(getChildClassed(show, "channel"));
var rating = (r == 0 || minrating < r || minrating == r);
var unrated = (r != 0 || groupflag);
var channel = (base[channelName] == undefined) ? true : base[channelName];
show.style.display = ( unrated && channel && rating) ? "" : "none";
}
}
}
function getTime(item, name) {
var starttime = getChildClassed(item, /time/).getAttribute(name).split(':');
var starttime = new Date(starttime[2], starttime[1], starttime[0], starttime[3], starttime[4], 0, 0);
return starttime;
}
function hover(item) {
var start = getTime(item, "starttime");
var end = getTime(item, "endtime");
var allshows = getChildClassed(document.getElementById("ShowInformation"), "tbody").childNodes;
for(var i in allshows) {
var show = allshows[i];
if(show.className == "Show") {
var s = getTime(show, "starttime");
var e = getTime(show, "endtime");
if ((s <= start && start < e) || (s < end && end <= e) || (start <= s && e <= end))
show.style.background = "#ddd";
}
}
item.style.background = "#888";
}
function leave(item) {
var allshows = getChildClassed(document.getElementById("ShowInformation"), "tbody").childNodes;
for(var i in allshows) {
var show = allshows[i];
if(show.className == "Show")
show.style.background = "";
}
}
function toggle(item) {
if (item.showUnrated != undefined)
item.showUnrated = item.showUnrated ? false : true;
else
item.showUnrated = !(item.getAttribute("unrated") == "on");
touch(""+location.protocol+"//"+location.host+'/toggle.php?period='+item.id+'&to='+(item.showUnrated ? "on" : "off")+"&ajax=1");
setVisibilities();
}
function channelSwitch(name) {
var base = document.getElementById("ShowInformation");
base[name] = !(base[name] == undefined || base[name]);
touch(""+location.protocol+"//"+location.host+'/switch.php?to='+(base[name]?'on':'off')+'&channel='+name+'&ajax=1');
document.getElementById(name.replace(/ /g, '_')).className = base[name] ? "active" : "inactive";
setVisibilities();
return false;
}
last = '';
function setRating(rating, name) {
if (name != last)
setVisibilities();
last = name;
var allshows = getChildClassed(document.getElementById("ShowInformation"), /tbody/).childNodes;
for(var i in allshows) {
if (allshows[i].className == "Show" && getObjectText(getChildClassed(allshows[i], /show/)) == name) {
var ratingdisplay = getChildClassed(allshows[i], /rating/);
ratingdisplay.className = "ratings:"+rating;
for(var j in [0, 1, 2, 3, 4, 5]) {
var img = getChildClassed(getChildClassed(ratingdisplay, j), /img/);
if(j == 0)
img.src = 'x.png';
else
img.src = (j <= rating) ? 'black.png' : 'white.png';
}
}
}
touch(""+location.protocol+"//"+location.host+"/set.php?show="+escape(name)+"&rating="+rating+"&ajax=1");
return false;
}