-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.js
More file actions
147 lines (125 loc) · 8.28 KB
/
Copy pathmain.js
File metadata and controls
147 lines (125 loc) · 8.28 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
if (localStorage.getItem('viewrelesenote') == null) {
document.body.style = 'background:#fff; padding:10px';
document.body.innerHTML = '<b><center>- What\'s New -</center></b><br><font style="font-size: 12px"><b>Version <span id="version">1.0.0</span></b><br><br><small id="changelog">* Can Play Video File On Background Globally (before it was only for minimize)<br>* Video Hide And Show Fixed <br>* Subtitle On Off fixed <br>* Others All bugs are fixed</small></font><div style="width: 100%;text-align: center; font-weight: bold;background: #dedede; padding:5px 0px; margin-top:10px; position: fixed; left: 0px;bottom: 0px;"><b>OK</b></div>';
document.addEventListener('keydown', function (e) {
if (e.key == 'Enter') {
localStorage.setItem('viewrelesenote', 'yes');
if (window.confirm('Restart Required. Want To Continue ?')) { window.close(); }
}
});
var xhttp = new XMLHttpRequest();
xhttp.onload = function () {
var json = JSON.parse(this.responseText);
var v = json.version;
document.getElementById('version').innerHTML = v;
document.getElementById('changelog').innerHTML = json.changelog;
}
xhttp.open('GET', 'manifest.webapp', true);
xhttp.send();
} else {
if (localStorage.getItem('islocked') == 'yes' && gup('act', window.location.href) == '') {
var pass = prompt('Enter PassWord: ');
var spass = localStorage.getItem('lockedpass');
if (pass == spass) {
document.body.addEventListener('keydown', keydownpick);
function keydownpick(e) {
if (e.key == 'Enter') { window.location.href = 'files.html?ref=filelist'; }
if (e.key == 'SoftLeft' || e.key == 'F1') { settings(); }
if (e.key == 'SoftRight' || e.key == 'F2') { if (confirm('Are You Sure?')) { window.close(); } }
}
if (localStorage.getItem('opened_page') == 'videos') {
window.location.href = 'files.html?ref=filelist';
}
} else {
document.body.innerHTML = 'Wrong Access. Hold End Key To Exit.';
}
} else {
document.body.addEventListener('keydown', keydownpick);
function keydownpick(e) {
if (e.key == 'Enter') { window.location.href = 'files.html?ref=filelist'; }
if (e.key == 'SoftLeft' || e.key == 'F1') { settings(); }
if (e.key == 'SoftRight' || e.key == 'F2') { if (confirm('Are You Sure?')) { window.close(); } }
}
if (localStorage.getItem('opened_page') == 'videos') {
window.location.href = 'files.html?ref=filelist';
}
}
function settings() {
var e = document.createElement('div');
e.id = 'settings';
e.style = 'display: flex;position: fixed; top: 0px; left: 0px; width: 100%; height: 100%;background: rgba(0,0,0,0.5); justify-content: center; align-items: center;z-index: 55';
e.innerHTML = '<div style="width: 100%;height:auto; background: white; border-radius: 10px; display: block; padding:10px 5px 5px 7px"><div class="header">Setting</div><div class="content" style="background: white; bottom: 29px;display: block; padding: 20px">Extentions For Scan:<br><input type="text" value="mp4, 3gp, mkv, mpa" class="focusable" tabindex="0" id="extentions"><br>Play In Background: <input type="checkbox" id="bgplaybtn" class="focusable" tabindex="1" style="display: inline-block; width: auto;"><br>Lock: <input type="checkbox" id="lockbtn" class="focusable" tabindex="2" style="display: inline-block; width: auto;"><br><input type="text" id="inputpass" disabled="disable" placeholder="pass"><br><button id="resetbtn" class="focusable" tabindex="3">Reset</button></div><div class="footer"><div class="footerelement">Save</div><div class="footerelement">OK</div><div class="footerelement">Back</div></div></div>';
document.body.appendChild(e);
var lockbtn = document.querySelector('#lockbtn');
lockbtn.addEventListener('change', function () {
if (lockbtn.checked == true) {
document.querySelector('#inputpass').removeAttribute('disabled');
document.querySelector('#inputpass').setAttribute('class', 'focusable');
document.querySelector('#inputpass').setAttribute('tabindex', '3');
document.querySelectorAll('#resetbtn')[0].setAttribute('tabindex', '4')
} else if (lockbtn.checked == false) {
document.querySelector('#inputpass').setAttribute('disabled', 'disable');
document.querySelector('#inputpass').removeAttribute('class');
document.querySelector('#inputpass').removeAttribute('tabindex');
document.querySelectorAll('#resetbtn')[0].setAttribute('tabindex', '3');
}
});
var bgplaybtn = document.querySelector('#bgplaybtn');
bgplaybtn.addEventListener('change', function () {
if (bgplaybtn.checked == true) {
localStorage.setItem('bgplay', 'yes');
} else {
localStorage.removeItem('bgplay');
}
});
if (localStorage.getItem('bgplay') == 'yes') {
bgplaybtn.setAttribute('checked', 'check');
}
if (localStorage.getItem('islocked') == 'yes') { lockbtn.setAttribute('checked', 'check'); document.querySelector('#inputpass').placeholder = '******'; }
if (localStorage.getItem('filetypes') !== null) { document.querySelector('#extentions').value = localStorage.getItem('filetypes'); }
document.querySelectorAll('#resetbtn')[0].addEventListener('click', function () {
if (confirm('Restart Required. Are You Sure ?')) { window.localStorage.clear(); window.close(); }
});
document.querySelectorAll('.focusable')[0].focus();
document.body.removeEventListener('keydown', keydownpick);
document.body.addEventListener('keydown', keydownsetting);
}
function keydownsetting(e) {
switch (e.key) {
case 'ArrowDown': focus(1);
break;
case 'ArrowUp': focus(-1);
break;
case 'Down': focus(1);
break;
case 'Up': focus(-1);
break;
case 'Enter': document.activeElement.click();
break;
case 'SoftLeft': localStorage.setItem('filetypes', document.querySelectorAll('#extentions')[0].value);
if (document.querySelector('#lockbtn').checked == true && document.querySelector('#inputpass').value != '') { localStorage.setItem('islocked', 'yes'); localStorage.setItem('lockedpass', document.querySelector('#inputpass').value); } else if (document.querySelector('#lockbtn').checked == false) { localStorage.setItem('islocked', 'no'); localStorage.removeItem('lockedpass'); }
document.body.removeChild(document.querySelector('#settings'));
document.body.removeEventListener('keydown', keydownsetting); document.body.addEventListener('keydown', keydownpick);
break;
case 'F1': localStorage.setItem('filetypes', document.querySelectorAll('#extentions')[0].value);
if (document.querySelector('#lockbtn').checked == true && document.querySelector('#inputpass').value != '') { localStorage.setItem('islocked', 'yes'); localStorage.setItem('lockedpass', document.querySelector('#inputpass').value); } else if (document.querySelector('#lockbtn').checked == false) { localStorage.setItem('islocked', 'no'); localStorage.removeItem('lockedpass'); }
document.body.removeChild(document.querySelector('#settings'));
document.body.removeEventListener('keydown', keydownsetting); document.body.addEventListener('keydown', keydownpick);
break;
case 'SoftRight':
document.body.removeChild(document.querySelector('#settings'));
document.body.removeEventListener('keydown', keydownsetting);
document.body.addEventListener('keydown', keydownpick);
break;
}
function focus(move) {
var currentIndex = document.activeElement.tabIndex;
var next = currentIndex + move;
if (next > document.querySelectorAll('.focusable').length - 1) { next = 0; } else if (next < 0) { next = document.querySelectorAll('.focusable').length - 1; }
var items = document.querySelectorAll('.focusable');
var targetElement = items[next];
targetElement.focus();
targetElement.scrollIntoView({ block: 'center' });
}
}
}