-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathhelpers.js
70 lines (65 loc) · 1.55 KB
/
helpers.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
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)", "i"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
function stripTags(text) {
var tmp = document.createElement("div");
tmp.innerHTML = text;
return tmp.textContent || tmp.innerText;
}
function getCookie(name) {
var re = new RegExp(name + "=([^;]+)");
var value = re.exec(document.cookie);
return (value != null) ? unescape(value[1]) : null;
}
function setCookie(name, value) {
document.cookie = name + " = " + value + "; expires=Mon, 14 Sep 2025 18:49:22 GMT; path=/";
}
function formatSeconds(seconds) {
var s = Math.floor(seconds % 60);
var m = Math.floor((seconds / 60) % 60);
var u = Math.floor(((seconds / 60) / 60 ) % 60);
if (u > 0 && m < 10) {
m = '0' + m;
}
if (s < 10) {
s = '0' + s;
}
if (u < 1) {
return (m + ':' + s);
}
else if (u >= 1) {
return (u + ':' + m + ':' + s);
}
}
function getDeviceIcon(type) {
switch (type) {
case "smartphone":
return "";
case "computer":
return "";
case "speaker":
case "avr":
return "";
case "tv":
case "stb":
return ""
case "gameconsole":
return "";
case "castvideo":
case "castaudio":
return "";
case "automobile":
return "";
case "audiodongle":
return "";
case "unknown":
default:
return "";
}
}