90
90
< ion-icon name ="add-circle-outline "> </ ion-icon >
91
91
</ div >
92
92
93
- < script >
94
- window . addEventListener ( 'DOMContentLoaded' , ( ) => {
95
- const savedGames = JSON . parse ( localStorage . getItem ( 'savedGames' ) ) || [ ] ;
96
-
97
- function addGame ( url , name ) {
98
- const game = {
99
- url,
100
- name
101
- } ;
102
- savedGames . push ( game ) ;
103
- localStorage . setItem ( 'savedGames' , JSON . stringify ( savedGames ) ) ;
104
- }
105
-
106
- function loadSavedGames ( ) {
107
- savedGames . forEach ( game => {
108
- const div = document . createElement ( 'div' ) ;
109
- div . title = game . name ;
110
- const img = document . createElement ( 'img' ) ;
111
- img . src = game . url ;
112
- img . width = 100 ;
113
- img . height = 100 ;
114
- div . appendChild ( img ) ;
115
- div . addEventListener ( 'click' , ( ) => {
116
- document . getElementById ( 'game-frame' ) . src = game . url ;
117
- document . getElementById ( 'game-frame' ) . style . display = 'inline' ;
118
- document . querySelector ( '.games' ) . style . display = 'none' ;
119
- document . querySelector ( '.header' ) . style . display = 'none' ;
120
- } ) ;
121
- document . querySelector ( '.games' ) . insertBefore ( div , document . getElementById ( 'add-game' ) ) ;
122
- } ) ;
123
- }
124
- loadSavedGames ( ) ;
125
-
126
- document . querySelector ( 'div[title="Add Your Own!"]' ) . addEventListener ( 'click' , ( ) => {
127
- const url = prompt ( 'URL: ' ) ;
128
- if ( url !== null && url !== '' ) {
129
- const name = prompt ( 'Name: ' ) ;
130
- if ( name !== null && name !== '' ) {
131
- addGame ( url , name ) ;
132
- const div = document . createElement ( 'div' ) ;
133
- div . title = name ;
134
- const img = document . createElement ( 'img' ) ;
135
- img . src = url ;
136
- img . width = 100 ;
137
- img . height = 100 ;
138
- div . appendChild ( img ) ;
139
- div . addEventListener ( 'click' , ( ) => {
140
- document . getElementById ( 'game-frame' ) . src = url ;
141
- document . getElementById ( 'game-frame' ) . style . display = 'inline' ;
142
- document . querySelector ( '.games' ) . style . display = 'none' ;
143
- document . querySelector ( '.header' ) . style . display = 'none' ;
93
+ < script >
94
+ ( function ( ) {
95
+ document . querySelector ( 'div[title="Add Your Own!"]' ) . addEventListener ( 'click' , ( ) => {
96
+ const p = prompt ( 'URL: ' ) ;
97
+
98
+ if ( p !== '' ) {
99
+ const z = prompt ( 'Name: ' ) ;
100
+
101
+ if ( z !== '' ) {
102
+ document . querySelector ( 'title' ) . innerText = z ;
103
+
104
+ document . querySelector ( 'iframe' ) . src = '/i/' + __uv$config . encodeUrl ( p ) ;
105
+
106
+ document . querySelector ( 'iframe' ) . style . display = 'inline' ;
107
+
108
+ document . querySelector ( '.games' ) . style . display = 'none' ;
109
+
110
+ document . querySelector ( '.header' ) . style . display = 'none' ;
111
+ } else {
112
+ alert ( 'Please provide a valid name' ) ;
113
+ }
114
+ } else {
115
+ alert ( 'Please provide a valid URL' ) ;
116
+ }
144
117
} ) ;
145
- document . querySelector ( '.games' ) . insertBefore ( div , document . getElementById ( 'add-game' ) ) ;
146
- } else {
147
- alert ( 'Please provide a valid name' ) ;
148
- }
149
- } else {
150
- alert ( 'Please provide a valid URL' ) ;
151
- }
152
- } ) ;
153
- } ) ;
154
- </ script >
118
+ } ) ( ) ;
119
+ </ script >
155
120
</ div >
156
121
157
122
< iframe src ="" style ="position:absolute;display:none;border:none;outline:none;width:100%;height:100%; "> </ iframe >
158
123
</ body >
159
- </ html >
124
+ </ html >
0 commit comments