This repository was archived by the owner on Nov 11, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
102 lines (73 loc) · 2.87 KB
/
script.js
File metadata and controls
102 lines (73 loc) · 2.87 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
// Objects
const urlTextBox = document.getElementById('urlTextBox');
const linksBox = document.getElementById('linksBox');
const linksListTitle = document.getElementById('linksListTitle');
// Buttons
const submitButton = document.getElementById('submitButton');
const libraryButton = document.getElementById('libraryButton');
const saveButton = document.getElementById('saveButton');
const loadButton = document.getElementById('loadButton');
const runButton = document.getElementById('runButton');
// Misc
var i = 0;
var linksList = [];
function renderList(){
linksListTitle.innerHTML = `Currently Mounted Links (${linksList.length})`;
linksBox.value = linksList.join('');
}
// Check For Mobile Devices
if (screen.width <= 480){
location.href = 'https://rhet0rical.dev/mobile.html';
}
// Events
submitButton.addEventListener('click', function(){
let submittedURL = urlTextBox.value;
console.log(`Attempting To Mount \"${submittedURL}\" Onto linksList...`);
if (submittedURL.includes('https://') == true){
linksList.push(`• ${submittedURL}\n`);
console.log('Added Successfully.');
} else {
console.error('Failed To Add Item. Check To Make Sure It Contains An \"https://\" And Try Again.');
alert('Failed To Add Item. Check To Make Sure It Contains An \"https://\" And Try Again.');
}
renderList();
});
saveButton.addEventListener('click', function(){
console.log(`Attempting To Save \"${linksList}\" To LocalStorage...`);
try {
localStorage.setItem('storedLinksList', JSON.stringify(linksList));
console.log('Successfully Saved To LocalStorage.');
} catch (error) {
console.error(`Failed To Save To LocalStorage: ${error}.`);
alert(`Failed To Save To LocalStorage: ${error}.`);
}
renderList();
})
loadButton.addEventListener('click', function(){
console.log(`Attempting To Load List From LocalStorage...`);
try {
linksList = JSON.parse(localStorage.getItem('storedLinksList'));
console.log(`Loaded Data From LocalStorage Successfully: ${linksList}.`);
} catch (error) {
console.error(`Failed To Load From LocalStorage: ${error}.`);
alert(`Failed To Get Data From LocalStorage. You May Have Nothing Saved. Check Console For More Details.`);
}
renderList();
})
runButton.addEventListener('click', function(){
for(i = 0; i < linksList.length; i++){
try {
if (linksList[i].includes('https://') == true){
console.log(`Attempting To Open ${linksList[i]}...`)
window.open(linksList[i].replace('•', ''));
} else {
break;
}
} catch (error) {
console.error(`Failed To Open Page: ${linksList[i]}`);
}
}
})
libraryButton.addEventListener('click', function(){
window.open('/installr/library.html');
})