-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBrowser.js
More file actions
210 lines (113 loc) · 5.09 KB
/
Browser.js
File metadata and controls
210 lines (113 loc) · 5.09 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
function open_browser() {
open_app("browser-app", "BROWSER", `
<div class="browser-body">
<div class="search-bar-box">
<input id="search-bar" type="text" placeholder="Enter URL">
<input id="search-button" type="submit" value="Search">
</div>
<hr />
<div class="bookmarks-box">
<button id="internet-archive-bookmark">Internet Archive</button>
<button id="wikipedia-bookmark">Wikipedia</button>
<button id="maps-bookmark">Maps</button>
<button id="bitchute-bookmark">BitChute</button>
<button id="dailymail-bookmark">DailyMail</button>
<button id="the-free-press-journal-bookmark">The Free Press Journal</button>
<button id="healthline-bookmark">Healthline</button>
</div>
<hr />
<div id="tabs-box">
<div id="tabs-list">
<div id="tab-box">
<div id="tab">Tab</div>
<button class="close-tab-button">x</button>
</div>
</div>
<button id="new-tab-button">+</button>
</div>
<hr />
<iframe id="search-results" src="https://wikipedia.org"></iframe>
</div>
`);
let search_bar = document.getElementById("search-bar");
let search_button = document.getElementById("search-button");
let search_results = document.getElementById("search-results");
search_bar.addEventListener("keypress", (event) => {
if (event.key == "Enter") {
browser_search(search_bar, search_results);
}
});
search_button.addEventListener("click", () => {
browser_search(search_bar, search_results);
});
open_new_tab();
open_bookmarks(search_results);
};
// ------------------------------------------------------------------------------------------------
function open_new_tab() {
let tabs_list = document.getElementById("tabs-list");
let new_tab_button = document.getElementById("new-tab-button");
new_tab_button.addEventListener("click", () => {
let new_tab = document.createElement("div");
new_tab.id = "tab";
new_tab.textContent = "Tab";
let close_tab_button = document.createElement("button");
close_tab_button.classList.add("close-tab-button");
close_tab_button.textContent = "x";
close_tab_button.addEventListener("click", close_tab);
let tab_box = document.createElement("div");
tab_box.id = "tab-box";
tab_box.appendChild(new_tab);
tab_box.appendChild(close_tab_button);
tabs_list.appendChild(tab_box);
});
};
// ------------------------------------------------------------------------------------------------
function close_tab(event) {
let tab_box = event.target.closest('#tab-box');
if (tab_box) {
tab_box.remove();
}
};
// ------------------------------------------------------------------------------------------------
function browser_search(search_bar, search_results) {
let search_query = "";
if (search_bar.value.startsWith("https://")) {
search_query = search_bar.value;
}
else {
search_query = "https://" + search_bar.value;
}
search_results.src = search_query;
};
// ------------------------------------------------------------------------------------------------
function open_bookmarks(search_results) {
let internet_archive_bookmark = document.getElementById("internet-archive-bookmark");
internet_archive_bookmark.addEventListener("click", () => {
search_results.src = "https://archive.org";
});
let wikipedia_bookmark = document.getElementById("wikipedia-bookmark");
wikipedia_bookmark.addEventListener("click", () => {
search_results.src = "https://wikipedia.org";
});
let maps_bookmark = document.getElementById("maps-bookmark");
maps_bookmark.addEventListener("click", () => {
search_results.src = "https://www.openstreetmap.org/export/embed.html?bbox=-0.004017949104309083%2C51.47612752641776%2C0.00030577182769775396%2C51.478569861898606&layer=mapnik";
});
let bitchute_bookmark = document.getElementById("bitchute-bookmark");
bitchute_bookmark.addEventListener("click", () => {
search_results.src = "https://bitchute.com";
});
let dailymail_bookmark = document.getElementById("dailymail-bookmark");
dailymail_bookmark.addEventListener("click", () => {
search_results.src = "https://dailymail.co.uk";
});
let the_free_press_journal_bookmark = document.getElementById("the-free-press-journal-bookmark");
the_free_press_journal_bookmark.addEventListener("click", () => {
search_results.src = "https://freepressjournal.in";
});
let healthline_bookmark = document.getElementById("healthline-bookmark");
healthline_bookmark.addEventListener("click", () => {
search_results.src = "https://healthline.com";
});
};