77 < title > Sploder</ title >
88</ head >
99< script >
10+ document . addEventListener ( 'DOMContentLoaded' , function ( ) {
11+ function getUrl ( ) {
12+ return new URL ( window . location . href ) . searchParams . get ( 'url' ) ;
13+ }
1014 // Check get parameter to get URL
11- const queryString = window . location . search ;
12- const urlParams = new URLSearchParams ( queryString ) ;
13- const url = urlParams . get ( 'url' ) ;
14-
15+ let url = getUrl ( ) ;
16+ document . getElementById ( 'sploder-url' ) . textContent = getUrl ( ) ;
17+ document . getElementById ( "content-frame" ) . setAttribute ( 'src' , url ) ;
1518 // If the URL is not provided, redirect to the update page
16- if ( url == null ) {
17- window . location . href = "http://sploder.local/update" ;
18- }
19+ // window.href.location = urlParam + '/update';
1920
2021 var page ;
2122 var prevpage ;
5859// Custom built code to check if user is online.
5960// I have no idea how or why this works.
6061 function online ( ) {
61- if ( document . getElementById ( "content-frame" ) . contentWindow . location . href != "chrome-error://chromewebdata/" ) {
62- page = document . getElementById ( "content-frame" ) . contentWindow . location . href ;
63- } else if ( page == undefined ) {
62+ if ( document . getElementById ( "content-frame" ) . contentWindow . location . href != "chrome-error://chromewebdata/" ) {
63+ page = document . getElementById ( "content-frame" ) . contentWindow . location . href ;
64+ } else if ( page == undefined ) {
6465 page = url ;
6566 }
66- if ( page . includes ( "offline.html" ) ) {
67+
68+ if ( page . includes ( "offline.html" ) ) {
6769 page = "test" ;
6870 } else {
69-
70-
71- const frame = document . getElementById ( 'content-frame' ) ;
72- var url = "http://sploder.local/php/ping.php" ;
73- var xhttp = new XMLHttpRequest ( ) ;
74- xhttp . onreadystatechange = function ( ) {
75-
76- if ( this . readyState == 4 && this . status != 200 && frame . getAttribute ( 'src' ) != "offline.html?retry=" + page ) {
71+ const frame = document . getElementById ( 'content-frame' ) ;
72+ const queryString = window . location . search ;
73+ // Check get parameter to get URL
74+ const urlParam = getUrl ( ) ;
75+ var url = urlParam + '/php/ping.php' ;
76+ var xhttp = new XMLHttpRequest ( ) ;
77+ xhttp . onreadystatechange = function ( ) {
78+ const offlineUrl = "offline.html?retry=" + page + '&url=' + encodeURIComponent ( urlParam ) ;
79+ if ( this . readyState == 4 && this . status != 200 && frame . getAttribute ( 'src' ) != offlineUrl ) {
7780 if ( page != "test" ) {
78- prevpage = page ;
81+ prevpage = page ;
7982 }
8083 pagestat = "offline" ;
8184 page = "offline.html" ;
82- frame . setAttribute ( 'src' , 'offline.html?retry=' + page ) ;
83-
85+ frame . setAttribute ( 'src' , offlineUrl ) ;
8486 } else if ( document . getElementById ( "content-frame" ) . contentWindow . location . href != "chrome-error://chromewebdata/" ) {
8587 page = document . getElementById ( "content-frame" ) . contentWindow . location . href ;
8688 } else {
8991 }
9092 //pagestat = "online";
9193 }
92-
9394 } ;
9495 xhttp . open ( "GET" , url , true ) ;
9596 xhttp . send ( ) ;
96-
9797 }
9898 }
9999 // Prevent scrolling using JavaScript
113113 event . preventDefault ( ) ; // Disable keyboard scrolling
114114 }
115115 } ) ;
116-
117-
118-
119-
116+ } ) ;
120117</ script >
121118< style >
122119 body , html {
163160 }
164161</ style >
165162< body >
166-
167163 < div class ="window " style ="width: 100%; height: calc(100% - 3px) ">
168164 < div class ="title-bar ">
169165 < img class ="title-bar-icon " src ="images/icon.png ">
170- < div class ="title-bar-text "> Sploder</ div >
166+ < div class ="title-bar-text "> Sploder < span id =" sploder-url " > </ span > </ div >
171167 < div class ="titlebar-movable "> </ div >
172168 < div class ="title-bar-controls ">
173169 < button id ="min-btn " onclick ="win.minimize() " aria-label ="Minimize "> </ button >
178174 < div class ="window-body "
179175 style ="width: 100%; height: calc(100% - 50px); margin-left: 3px; margin-top:0px; padding-bottom: -50px; ">
180176 < iframe id ="content-frame " onload ="online(); " src ="">
181- </ iframe >
182- < script >
183- document . getElementById ( "content-frame" ) . setAttribute ( 'src' , url ) ;
184- </ script >
185-
177+ </ iframe >
186178 </ div >
187179 </ div >
188-
189180</ body >
190- </ html >
181+ </ html >
0 commit comments