scratch – Diff between revs 100 and 115
?pathlinks?
Rev 100 | Rev 115 | |||
---|---|---|---|---|
1 | <!DOCTYPE html> |
1 | <!DOCTYPE html> |
|
2 | <html lang="en"> |
2 | <html lang="en"> |
|
3 | <head> |
3 | <head> |
|
4 | <meta charset="utf-8"> |
4 | <meta charset="utf-8"> |
|
5 | <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
5 | <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
|
6 | <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> |
6 | <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> |
|
7 | <meta http-equiv="Pragma" content="no-cache" /> |
7 | <meta http-equiv="Pragma" content="no-cache" /> |
|
8 | <meta http-equiv="Expires" content="0" /> |
8 | <meta http-equiv="Expires" content="0" /> |
|
9 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
9 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
|
10 | <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> |
10 | <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> |
|
11 | <meta name="description" content="quick asset upload"> |
11 | <meta name="description" content="quick asset upload"> |
|
12 | <meta name="author" content="Wizardry and Steamworks"> |
12 | <meta name="author" content="Wizardry and Steamworks"> |
|
13 | <link rel="icon" href="favicon.ico"> |
13 | <link rel="icon" href="favicon.ico"> |
|
14 | |
14 | |
|
15 | <title>scratch</title> |
15 | <title>scratch</title> |
|
16 | |
16 | |
|
17 | <!-- Bootstrap core CSS --> |
17 | <!-- Bootstrap core CSS --> |
|
18 | <link href="bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"> |
18 | <link href="bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"> |
|
19 | <!-- Font Awesome --> |
19 | <!-- Font Awesome --> |
|
20 | <link href="bower_components/font-awesome/css/font-awesome.min.css" rel="stylesheet"> |
20 | <link href="bower_components/font-awesome/css/font-awesome.min.css" rel="stylesheet"> |
|
21 | <!-- Trumbowyg --> |
21 | <!-- Trumbowyg --> |
|
22 | <link href="bower_components/trumbowyg/dist/ui/trumbowyg.min.css" rel="stylesheet"> |
22 | <link href="bower_components/trumbowyg/dist/ui/trumbowyg.min.css" rel="stylesheet"> |
|
23 | |
23 | |
|
24 | <!-- Site-wide style CCS --> |
24 | <!-- Site-wide style CCS --> |
|
25 | <link href="css/style.css" rel="stylesheet"> |
25 | <link href="css/style.css" rel="stylesheet"> |
|
26 | |
26 | |
|
27 | <!-- Local style --> |
27 | <!-- Local style --> |
|
28 | <link href="css/text/style.css" rel="stylesheet"> |
28 | <link href="css/text/style.css" rel="stylesheet"> |
|
29 | </head> |
29 | </head> |
|
30 | |
30 | |
|
31 | <body> |
31 | <body> |
|
32 | |
32 | |
|
33 | <!-- Main component for a primary marketing message or call to action --> |
33 | <!-- Main component for a primary marketing message or call to action --> |
|
34 | <div class="paralax-background"></div> |
34 | <div class="paralax-background"></div> |
|
35 | <div class="jumbotron"> |
35 | <div class="jumbotron"> |
|
36 | <h1>scratch copy</h1> |
36 | <h1>scratch copy</h1> |
|
37 | <p class="quote">the asset sharer</p> |
37 | <p class="quote">the asset sharer</p> |
|
38 | </div> |
38 | </div> |
|
39 | |
39 | |
|
40 | <div class="container"> |
40 | <div class="container"> |
|
41 | |
41 | |
|
42 | <ul class="nav nav-tabs"> |
42 | <ul class="nav nav-tabs"> |
|
43 | <li><a href="index.html">Home</a></li> |
43 | <li><a href="index.html">Home</a></li> |
|
44 | <li><a href="file.html">File</a></li> |
44 | <li><a href="file.html">File</a></li> |
|
45 | <li class="active"><a href="#">Text</a></li> |
45 | <li class="active"><a href="#">Text</a></li> |
|
46 | <li><a href="draw.html">Draw</a></li> |
46 | <li><a href="draw.html">Draw</a></li> |
|
47 | <li><a href="link.html">Link</a></li> |
47 | <li><a href="link.html">Link</a></li> |
|
- | 48 | <li><a href="gallery.html">Gallery</a></li> |
||
48 | </ul> |
49 | </ul> |
|
49 | |
50 | |
|
50 | <div id="main-panel" class="panel panel-default"> |
51 | <div id="main-panel" class="panel panel-default"> |
|
51 | <div class="panel-heading"> |
52 | <div class="panel-heading"> |
|
52 | <div class="form-group"> |
53 | <div class="form-group"> |
|
53 | <div class="input-group"> |
54 | <div class="input-group"> |
|
54 | <span class="input-group-btn"> |
55 | <span class="input-group-btn"> |
|
55 | <button id="save" class="btn btn-default" type="button" data-toggle="tooltip" data-placement="auto" title="Generate link."> |
56 | <button id="save" class="btn btn-default" type="button" data-toggle="tooltip" data-placement="auto" title="Generate link."> |
|
56 | <i class="glyphicon glyphicon-share"></i> |
57 | <i class="glyphicon glyphicon-share"></i> |
|
57 | </button> |
58 | </button> |
|
58 | </span> |
59 | </span> |
|
59 | <input id="URL" type="text" class="form-control" readonly> |
60 | <input id="URL" type="text" class="form-control" readonly> |
|
60 | <span class="input-group-btn"> |
61 | <span class="input-group-btn"> |
|
61 | <button id="copy-url" class="btn btn-default" type="button" data-clipboard-target="#URL" data-toggle="tooltip" data-placement="auto" title="Copy to clipboard."><i class="glyphicon glyphicon-paperclip"></i></button> |
62 | <button id="copy-url" class="btn btn-default" type="button" data-clipboard-target="#URL" data-toggle="tooltip" data-placement="auto" title="Copy to clipboard."><i class="glyphicon glyphicon-paperclip"></i></button> |
|
62 | </span> |
63 | </span> |
|
63 | </div> |
64 | </div> |
|
64 | </div> |
65 | </div> |
|
65 | <form id="nick-form" role="form"> |
66 | <form id="nick-form" role="form"> |
|
66 | <div class="form-group has-feedback"> |
67 | <div class="form-group has-feedback"> |
|
67 | <div class="input-group"> |
68 | <div class="input-group"> |
|
68 | <span class="input-group-btn"> |
69 | <span class="input-group-btn"> |
|
69 | <button id="go" class="btn btn-default" type="button" data-toggle="tooltip" data-placement="auto" title="Load document."> |
70 | <button id="go" class="btn btn-default" type="button" data-toggle="tooltip" data-placement="auto" title="Load document."> |
|
70 | <i class="glyphicon glyphicon-play"></i> |
71 | <i class="glyphicon glyphicon-play"></i> |
|
71 | </button> |
72 | </button> |
|
72 | </span> |
73 | </span> |
|
73 | <span class="input-group-btn"> |
74 | <span class="input-group-btn"> |
|
74 | <button id="reset" class="btn btn-default" type="button" data-toggle="tooltip" data-placement="auto" title="Reset document."> |
75 | <button id="reset" class="btn btn-default" type="button" data-toggle="tooltip" data-placement="auto" title="Reset document."> |
|
75 | <i id="home-icon" class="glyphicon glyphicon-home"></i> |
76 | <i id="home-icon" class="glyphicon glyphicon-home"></i> |
|
76 | </button> |
77 | </button> |
|
77 | </span> |
78 | </span> |
|
78 | <input id="nick" type="text" class="form-control" pattern="^[A-Za-z0-9]{32}$" maxlength="32"> |
79 | <input id="nick" type="text" class="form-control" pattern="^[A-Za-z0-9]{32}$" maxlength="32"> |
|
79 | <span class="input-group-btn"> |
80 | <span class="input-group-btn"> |
|
80 | <button id="copy-nick" class="btn btn-default" type="button" data-clipboard-target="#nick" data-toggle="tooltip" data-placement="auto" title="Copy to clipboard."><i class="glyphicon glyphicon-paperclip"></i></button> |
81 | <button id="copy-nick" class="btn btn-default" type="button" data-clipboard-target="#nick" data-toggle="tooltip" data-placement="auto" title="Copy to clipboard."><i class="glyphicon glyphicon-paperclip"></i></button> |
|
81 | </span> |
82 | </span> |
|
82 | </div> |
83 | </div> |
|
83 | </div> |
84 | </div> |
|
84 | </form> |
85 | </form> |
|
85 | </div> |
86 | </div> |
|
86 | <div class="panel-body" id="editorpanel"> |
87 | <div class="panel-body" id="editorpanel"> |
|
87 | <div id="trumbowyg"> |
88 | <div id="trumbowyg"> |
|
88 | </div> |
89 | </div> |
|
89 | </div> |
90 | </div> |
|
90 | </div> |
91 | </div> |
|
91 | |
92 | |
|
92 | </div> <!-- /container --> |
93 | </div> <!-- /container --> |
|
93 | |
94 | |
|
94 | <div id="footer"> |
95 | <div id="footer"> |
|
95 | <div class="container"> |
96 | <div class="container"> |
|
96 | <p class="text-muted credit text-center">Copyright <i class="glyphicon glyphicon-copyright-mark"></i> 2017 <a href="http://grimore.org">Wizardry and Steamworks</a>.</p> |
97 | <p class="text-muted credit text-center">Copyright <i class="glyphicon glyphicon-copyright-mark"></i> 2017 <a href="http://grimore.org">Wizardry and Steamworks</a>.</p> |
|
97 | </div> |
98 | </div> |
|
98 | </div> |
99 | </div> |
|
99 | |
100 | |
|
100 | <!-- jQuery --> |
101 | <!-- jQuery --> |
|
101 | <script src="bower_components/jquery/dist/jquery.min.js"></script> |
102 | <script src="bower_components/jquery/dist/jquery.min.js"></script> |
|
102 | <!-- BootStrap --> |
103 | <!-- BootStrap --> |
|
103 | <script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script> |
104 | <script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script> |
|
104 | <!-- Velocity --> |
105 | <!-- Velocity --> |
|
105 | <script src="bower_components/velocity/velocity.min.js"></script> |
106 | <script src="bower_components/velocity/velocity.min.js"></script> |
|
106 | |
107 | |
|
107 | <!-- Trumbowyg --> |
108 | <!-- Trumbowyg --> |
|
108 | <script src="bower_components/trumbowyg/dist/trumbowyg.min.js"></script> |
109 | <script src="bower_components/trumbowyg/dist/trumbowyg.min.js"></script> |
|
109 | <!-- Clipboard --> |
110 | <!-- Clipboard --> |
|
110 | <script src="bower_components/clipboard/dist/clipboard.min.js"></script> |
111 | <script src="bower_components/clipboard/dist/clipboard.min.js"></script> |
|
111 | <!-- Fingerprint 2 --> |
112 | <!-- Fingerprint 2 --> |
|
112 | <script src="bower_components/fingerprintjs2/dist/fingerprint2.min.js"></script> |
113 | <script src="bower_components/fingerprintjs2/dist/fingerprint2.min.js"></script> |
|
113 | <!-- js-cookie --> |
114 | <!-- js-cookie --> |
|
114 | <script src="bower_components/js-cookie/src/js.cookie.js"></script> |
115 | <script src="bower_components/js-cookie/src/js.cookie.js"></script> |
|
115 | <!-- Bootstrap Validator --> |
116 | <!-- Bootstrap Validator --> |
|
116 | <script src="bower_components/bootstrap-validator/dist/validator.min.js"></script> |
117 | <script src="bower_components/bootstrap-validator/dist/validator.min.js"></script> |
|
117 | <script> |
118 | <script> |
|
118 | $(document).ready(() => { |
119 | $(document).ready(() => { |
|
119 | // Attach the form validator. |
120 | // Attach the form validator. |
|
120 | $('#nick-form').validator({ |
121 | $('#nick-form').validator({ |
|
121 | focus: false |
122 | focus: false |
|
122 | }).on('invalid.bs.validator', () => { |
123 | }).on('invalid.bs.validator', () => { |
|
123 | $('#go').attr('disabled', true); |
124 | $('#go').attr('disabled', true); |
|
124 | }).on('valid.bs.validator', () => { |
125 | }).on('valid.bs.validator', () => { |
|
125 | $('#go').attr('disabled', false); |
126 | $('#go').attr('disabled', false); |
|
126 | }); |
127 | }); |
|
127 | |
128 | |
|
128 | // Enable the Clipboard button. |
129 | // Enable the Clipboard button. |
|
129 | new Clipboard('#copy-url'); |
130 | new Clipboard('#copy-url'); |
|
130 | |
131 | |
|
131 | // Get the fingerprint. |
132 | // Get the fingerprint. |
|
132 | new Fingerprint2({ |
133 | new Fingerprint2({ |
|
133 | //excludeUserAgent: true, |
134 | //excludeUserAgent: true, |
|
134 | //excludeLanguage: true, |
135 | //excludeLanguage: true, |
|
135 | excludeColorDepth: true, |
136 | excludeColorDepth: true, |
|
136 | excludeScreenResolution: true, |
137 | excludeScreenResolution: true, |
|
137 | excludeAvailableScreenResolution: true, |
138 | excludeAvailableScreenResolution: true, |
|
138 | //excludeTimezoneOffset: true, |
139 | //excludeTimezoneOffset: true, |
|
139 | excludeSessionStorage: true, |
140 | excludeSessionStorage: true, |
|
140 | excludeIndexedDB: true, |
141 | excludeIndexedDB: true, |
|
141 | excludeAddBehavior: true, |
142 | excludeAddBehavior: true, |
|
142 | excludeOpenDatabase: true, |
143 | excludeOpenDatabase: true, |
|
143 | //excludeCpuClass: true, |
144 | //excludeCpuClass: true, |
|
144 | //excludePlatform: true, |
145 | //excludePlatform: true, |
|
145 | excludeDoNotTrack: true, |
146 | excludeDoNotTrack: true, |
|
146 | excludeCanvas: true, |
147 | excludeCanvas: true, |
|
147 | excludeWebGL: true, |
148 | excludeWebGL: true, |
|
148 | excludeAdBlock: true, |
149 | excludeAdBlock: true, |
|
149 | //excludeHasLiedLanguages: true, |
150 | //excludeHasLiedLanguages: true, |
|
150 | //excludeHasLiedResolution: true, |
151 | //excludeHasLiedResolution: true, |
|
151 | //excludeHasLiedOs: true, |
152 | //excludeHasLiedOs: true, |
|
152 | //excludeHasLiedBrowser: true, |
153 | //excludeHasLiedBrowser: true, |
|
153 | excludeJsFonts: true, |
154 | excludeJsFonts: true, |
|
154 | excludeFlashFonts: true, |
155 | excludeFlashFonts: true, |
|
155 | excludePlugins: true, |
156 | excludePlugins: true, |
|
156 | excludeIEPlugins: true, |
157 | excludeIEPlugins: true, |
|
157 | //excludeTouchSupport: true, |
158 | //excludeTouchSupport: true, |
|
158 | excludePixelRatio: true |
159 | excludePixelRatio: true |
|
159 | }).get((result, components) => { |
160 | }).get((result, components) => { |
|
160 | // Set the nick as a cookie. |
161 | // Set the nick as a cookie. |
|
161 | const fingerprint = result; |
162 | const fingerprint = result; |
|
162 | var nick = Cookies.get('nick'); |
163 | var nick = Cookies.get('nick'); |
|
163 | if(!nick || !/^[A-Za-z0-9]{32}$/.test(nick)) { |
164 | if(!nick || !/^[A-Za-z0-9]{32}$/.test(nick)) { |
|
164 | Cookies.set('nick', result, { path: '' }); |
165 | Cookies.set('nick', result, { path: '' }); |
|
165 | nick = result; |
166 | nick = result; |
|
166 | } |
167 | } |
|
167 | else |
168 | else |
|
168 | result = nick; |
169 | result = nick; |
|
169 | |
170 | |
|
170 | // Set the nick. |
171 | // Set the nick. |
|
171 | $('#nick').val(result); |
172 | $('#nick').val(result); |
|
172 | new Clipboard('#copy-nick'); |
173 | new Clipboard('#copy-nick'); |
|
173 | |
174 | |
|
174 | if(fingerprint == nick) |
175 | if(fingerprint == nick) |
|
175 | $('#home-icon').addClass("text-success"); |
176 | $('#home-icon').addClass("text-success"); |
|
176 | else |
177 | else |
|
177 | $('#home-icon').addClass("text-danger"); |
178 | $('#home-icon').addClass("text-danger"); |
|
178 | |
179 | |
|
179 | var autoSaveTimeoutID; |
180 | var autoSaveTimeoutID; |
|
180 | |
181 | |
|
181 | function saveTextFile() { |
182 | function saveTextFile() { |
|
182 | $.get('session.php').then((token) => { |
183 | $.get('session.php').then((token) => { |
|
183 | $.post('text.php', { |
184 | $.post('text.php', { |
|
184 | data: $('#trumbowyg').trumbowyg('html'), |
185 | data: $('#trumbowyg').trumbowyg('html'), |
|
185 | token: token, |
186 | token: token, |
|
186 | fingerprint: result, |
187 | fingerprint: result, |
|
187 | action: 'SAVE', |
188 | action: 'SAVE', |
|
188 | token: token |
189 | token: token |
|
189 | }).done((data) => { |
190 | }).done((data) => { |
|
190 | |
191 | |
|
191 | // Visual feedback for a successful save. |
192 | // Visual feedback for a successful save. |
|
192 | $('#editorpanel') |
193 | $('#editorpanel') |
|
193 | .delay(250) |
194 | .delay(250) |
|
194 | .velocity( |
195 | .velocity( |
|
195 | { |
196 | { |
|
196 | borderColor: '#ff99ff' |
197 | borderColor: '#ff99ff' |
|
197 | }, |
198 | }, |
|
198 | 200) |
199 | 200) |
|
199 | .delay(500) |
200 | .delay(500) |
|
200 | .velocity( |
201 | .velocity( |
|
201 | { |
202 | { |
|
202 | borderColor: '#ecf0f1' |
203 | borderColor: '#ecf0f1' |
|
203 | }, |
204 | }, |
|
204 | 200); |
205 | 200); |
|
205 | |
206 | |
|
206 | }).fail(() => { |
207 | }).fail(() => { |
|
207 | // Reschedule saving of the file. |
208 | // Reschedule saving of the file. |
|
208 | if(autoSaveTimeoutID) |
209 | if(autoSaveTimeoutID) |
|
209 | window.clearTimeout(autoSaveTimeoutID); |
210 | window.clearTimeout(autoSaveTimeoutID); |
|
210 | autoSaveTimeoutID = window.setTimeout(saveTextFile, 250); |
211 | autoSaveTimeoutID = window.setTimeout(saveTextFile, 250); |
|
211 | }); |
212 | }); |
|
212 | }); |
213 | }); |
|
213 | } |
214 | } |
|
214 | |
215 | |
|
215 | // Load the editor. |
216 | // Load the editor. |
|
216 | $('#trumbowyg').trumbowyg({ |
217 | $('#trumbowyg').trumbowyg({ |
|
217 | semantic: true, |
218 | semantic: true, |
|
218 | autogrow: true, |
219 | autogrow: true, |
|
219 | disabled: true |
220 | disabled: true |
|
220 | }).on('tbwchange', () => { |
221 | }).on('tbwchange', () => { |
|
221 | // Clear the value of the URL box because the URL will have changed. |
222 | // Clear the value of the URL box because the URL will have changed. |
|
222 | $('#URL').val(''); |
223 | $('#URL').val(''); |
|
223 | // Reschedule saving of the file. |
224 | // Reschedule saving of the file. |
|
224 | if(autoSaveTimeoutID) |
225 | if(autoSaveTimeoutID) |
|
225 | window.clearTimeout(autoSaveTimeoutID); |
226 | window.clearTimeout(autoSaveTimeoutID); |
|
226 | autoSaveTimeoutID = window.setTimeout(saveTextFile, 1000); |
227 | autoSaveTimeoutID = window.setTimeout(saveTextFile, 1000); |
|
227 | }); |
228 | }); |
|
228 | |
229 | |
|
229 | // Retrieve the contents of the shared file. |
230 | // Retrieve the contents of the shared file. |
|
230 | $('#trumbowyg').trumbowyg('disable'); |
231 | $('#trumbowyg').trumbowyg('disable'); |
|
231 | $.get('session.php').then((token) => { |
232 | $.get('session.php').then((token) => { |
|
232 | $.post('text.php', |
233 | $.post('text.php', |
|
233 | { |
234 | { |
|
234 | timestamp: window.performance.now(), |
235 | timestamp: window.performance.now(), |
|
235 | fingerprint: result, |
236 | fingerprint: result, |
|
236 | action: 'LOAD', |
237 | action: 'LOAD', |
|
237 | token: token |
238 | token: token |
|
238 | }).done((data) => {; |
239 | }).done((data) => {; |
|
239 | $('#trumbowyg') |
240 | $('#trumbowyg') |
|
240 | .trumbowyg('html', data); |
241 | .trumbowyg('html', data); |
|
241 | $('#trumbowyg').trumbowyg('enable'); |
242 | $('#trumbowyg').trumbowyg('enable'); |
|
242 | $('#trumbowyg').show(); |
243 | $('#trumbowyg').show(); |
|
243 | }).fail(() => { |
244 | }).fail(() => { |
|
244 | $('#trumbowyg').trumbowyg('enable'); |
245 | $('#trumbowyg').trumbowyg('enable'); |
|
245 | $('#trumbowyg').show(); |
246 | $('#trumbowyg').show(); |
|
246 | }); |
247 | }); |
|
247 | }); |
248 | }); |
|
248 | |
249 | |
|
249 | $('#save').click(() => { |
250 | $('#save').click(() => { |
|
250 | $('#editor').trumbowyg('disable'); |
251 | $('#editor').trumbowyg('disable'); |
|
251 | var formData = new FormData(); |
252 | var formData = new FormData(); |
|
252 | formData.append('file', new Blob( |
253 | formData.append('file', new Blob( |
|
253 | [ |
254 | [ |
|
254 | $('#trumbowyg').trumbowyg('html') |
255 | $('#trumbowyg').trumbowyg('html') |
|
255 | ] |
256 | ] |
|
256 | ), |
257 | ), |
|
257 | '.html' |
258 | '.html' |
|
258 | ); |
259 | ); |
|
259 | $.get('session.php').then((token) => { |
260 | $.get('session.php').then((token) => { |
|
260 | formData.append('token', token); |
261 | formData.append('token', token); |
|
261 | $.ajax({ |
262 | $.ajax({ |
|
262 | url: 'file.php', |
263 | url: 'file.php', |
|
263 | type: 'POST', |
264 | type: 'POST', |
|
264 | data: formData, |
265 | data: formData, |
|
265 | // cache: false // FF |
266 | // cache: false // FF |
|
266 | processData: false, |
267 | processData: false, |
|
267 | contentType: false |
268 | contentType: false |
|
268 | }).done((data) => { |
269 | }).done((data) => { |
|
269 | // Serialize JSON to object. |
270 | // Serialize JSON to object. |
|
270 | data = JSON.parse(data); |
271 | data = JSON.parse(data); |
|
271 | |
272 | |
|
272 | $('#URL') |
273 | $('#URL') |
|
273 | .val( |
274 | .val( |
|
274 | location.protocol |
275 | location.protocol |
|
275 | .concat("//") |
276 | .concat("//") |
|
276 | .concat(window.location.hostname) |
277 | .concat(window.location.hostname) |
|
277 | .concat("/") |
278 | .concat("/") |
|
278 | .concat(data.hash) |
279 | .concat(data.hash) |
|
279 | ); |
280 | ); |
|
280 | $('#trumbowyg').trumbowyg('enable'); |
281 | $('#trumbowyg').trumbowyg('enable'); |
|
281 | }).fail(() => { |
282 | }).fail(() => { |
|
282 | $('#trumbowyg').trumbowyg('enable'); |
283 | $('#trumbowyg').trumbowyg('enable'); |
|
283 | }); |
284 | }); |
|
284 | }); |
285 | }); |
|
285 | }); |
286 | }); |
|
286 | |
287 | |
|
287 | // When the button is clicked, navigate to the fingerprint. |
288 | // When the button is clicked, navigate to the fingerprint. |
|
288 | $('#go').click(() => { |
289 | $('#go').click(() => { |
|
289 | nick = $('#nick').val(); |
290 | nick = $('#nick').val(); |
|
290 | if(!nick || !/^[A-Za-z0-9]{32}$/.test(nick)) |
291 | if(!nick || !/^[A-Za-z0-9]{32}$/.test(nick)) |
|
291 | return; |
292 | return; |
|
292 | Cookies.set('nick', nick, { path: '' }); |
293 | Cookies.set('nick', nick, { path: '' }); |
|
293 | result = nick; |
294 | result = nick; |
|
294 | |
295 | |
|
295 | // Retrieve the contents of the shared file. |
296 | // Retrieve the contents of the shared file. |
|
296 | $('#editor').trumbowyg('disable'); |
297 | $('#editor').trumbowyg('disable'); |
|
297 | $.get('session.php').then((token) => { |
298 | $.get('session.php').then((token) => { |
|
298 | $.post('text.php', |
299 | $.post('text.php', |
|
299 | { |
300 | { |
|
300 | timestamp: window.performance.now(), |
301 | timestamp: window.performance.now(), |
|
301 | fingerprint: nick, |
302 | fingerprint: nick, |
|
302 | action: 'LOAD', |
303 | action: 'LOAD', |
|
303 | token: token |
304 | token: token |
|
304 | }).done((data) => {; |
305 | }).done((data) => {; |
|
305 | $('#trumbowyg') |
306 | $('#trumbowyg') |
|
306 | .trumbowyg('html', data); |
307 | .trumbowyg('html', data); |
|
307 | $('#trumbowyg').trumbowyg('enable'); |
308 | $('#trumbowyg').trumbowyg('enable'); |
|
308 | $('#trumbowyg').show(); |
309 | $('#trumbowyg').show(); |
|
309 | |
310 | |
|
310 | if(fingerprint == nick) |
311 | if(fingerprint == nick) |
|
311 | $('#home-icon').addClass("text-success").removeClass("text-danger"); |
312 | $('#home-icon').addClass("text-success").removeClass("text-danger"); |
|
312 | else |
313 | else |
|
313 | $('#home-icon').addClass("text-danger").removeClass("text-success"); |
314 | $('#home-icon').addClass("text-danger").removeClass("text-success"); |
|
314 | |
315 | |
|
315 | }).fail(() => { |
316 | }).fail(() => { |
|
316 | $('#trumbowyg').trumbowyg('enable'); |
317 | $('#trumbowyg').trumbowyg('enable'); |
|
317 | $('#trumbowyg').show(); |
318 | $('#trumbowyg').show(); |
|
318 | }); |
319 | }); |
|
319 | }); |
320 | }); |
|
320 | }); |
321 | }); |
|
321 | |
322 | |
|
322 | // When the form is submitted, naigate to the fingerprint. |
323 | // When the form is submitted, naigate to the fingerprint. |
|
323 | $('#nick-form').submit((e) => { |
324 | $('#nick-form').submit((e) => { |
|
324 | e.preventDefault(); |
325 | e.preventDefault(); |
|
325 | |
326 | |
|
326 | nick = $('#nick').val(); |
327 | nick = $('#nick').val(); |
|
327 | if(!nick || !/^[A-Za-z0-9]{32}$/.test(nick)) |
328 | if(!nick || !/^[A-Za-z0-9]{32}$/.test(nick)) |
|
328 | return; |
329 | return; |
|
329 | Cookies.set('nick', nick, { path: '' }); |
330 | Cookies.set('nick', nick, { path: '' }); |
|
330 | result = nick; |
331 | result = nick; |
|
331 | |
332 | |
|
332 | // Retrieve the contents of the shared file. |
333 | // Retrieve the contents of the shared file. |
|
333 | $('#editor').trumbowyg('disable'); |
334 | $('#editor').trumbowyg('disable'); |
|
334 | $.get('session.php').then((token) => { |
335 | $.get('session.php').then((token) => { |
|
335 | $.post('text.php', |
336 | $.post('text.php', |
|
336 | { |
337 | { |
|
337 | timestamp: window.performance.now(), |
338 | timestamp: window.performance.now(), |
|
338 | fingerprint: nick, |
339 | fingerprint: nick, |
|
339 | action: 'LOAD', |
340 | action: 'LOAD', |
|
340 | token: token |
341 | token: token |
|
341 | }).done((data) => {; |
342 | }).done((data) => {; |
|
342 | $('#trumbowyg') |
343 | $('#trumbowyg') |
|
343 | .trumbowyg('html', data); |
344 | .trumbowyg('html', data); |
|
344 | $('#trumbowyg').trumbowyg('enable'); |
345 | $('#trumbowyg').trumbowyg('enable'); |
|
345 | $('#trumbowyg').show(); |
346 | $('#trumbowyg').show(); |
|
346 | |
347 | |
|
347 | if(fingerprint == nick) |
348 | if(fingerprint == nick) |
|
348 | $('#home-icon').addClass("text-success").removeClass("text-danger"); |
349 | $('#home-icon').addClass("text-success").removeClass("text-danger"); |
|
349 | else |
350 | else |
|
350 | $('#home-icon').addClass("text-danger").removeClass("text-success"); |
351 | $('#home-icon').addClass("text-danger").removeClass("text-success"); |
|
351 | |
352 | |
|
352 | }).fail(() => { |
353 | }).fail(() => { |
|
353 | $('#trumbowyg').trumbowyg('enable'); |
354 | $('#trumbowyg').trumbowyg('enable'); |
|
354 | $('#trumbowyg').show(); |
355 | $('#trumbowyg').show(); |
|
355 | }); |
356 | }); |
|
356 | }); |
357 | }); |
|
357 | }); |
358 | }); |
|
358 | |
359 | |
|
359 | // While the nick is changing, navigate to the changed fingerprint. |
360 | // While the nick is changing, navigate to the changed fingerprint. |
|
360 | $("#nick").on('input', () => { |
361 | $("#nick").on('input', () => { |
|
361 | nick = $('#nick').val(); |
362 | nick = $('#nick').val(); |
|
362 | if(!nick || !/^[A-Za-z0-9]{32}$/.test(nick)) |
363 | if(!nick || !/^[A-Za-z0-9]{32}$/.test(nick)) |
|
363 | return; |
364 | return; |
|
364 | Cookies.set('nick', nick, { path: '' }); |
365 | Cookies.set('nick', nick, { path: '' }); |
|
365 | result = nick; |
366 | result = nick; |
|
366 | |
367 | |
|
367 | // Retrieve the contents of the shared file. |
368 | // Retrieve the contents of the shared file. |
|
368 | $('#editor').trumbowyg('disable'); |
369 | $('#editor').trumbowyg('disable'); |
|
369 | $.get('session.php').then((token) => { |
370 | $.get('session.php').then((token) => { |
|
370 | $.post('text.php', |
371 | $.post('text.php', |
|
371 | { |
372 | { |
|
372 | timestamp: window.performance.now(), |
373 | timestamp: window.performance.now(), |
|
373 | fingerprint: nick, |
374 | fingerprint: nick, |
|
374 | action: 'LOAD', |
375 | action: 'LOAD', |
|
375 | token: token |
376 | token: token |
|
376 | }).done((data) => {; |
377 | }).done((data) => {; |
|
377 | $('#trumbowyg') |
378 | $('#trumbowyg') |
|
378 | .trumbowyg('html', data); |
379 | .trumbowyg('html', data); |
|
379 | $('#trumbowyg').trumbowyg('enable'); |
380 | $('#trumbowyg').trumbowyg('enable'); |
|
380 | $('#trumbowyg').show(); |
381 | $('#trumbowyg').show(); |
|
381 | |
382 | |
|
382 | if(fingerprint == nick) |
383 | if(fingerprint == nick) |
|
383 | $('#home-icon').addClass("text-success").removeClass("text-danger"); |
384 | $('#home-icon').addClass("text-success").removeClass("text-danger"); |
|
384 | else |
385 | else |
|
385 | $('#home-icon').addClass("text-danger").removeClass("text-success"); |
386 | $('#home-icon').addClass("text-danger").removeClass("text-success"); |
|
386 | }).fail(() => { |
387 | }).fail(() => { |
|
387 | $('#trumbowyg').trumbowyg('enable'); |
388 | $('#trumbowyg').trumbowyg('enable'); |
|
388 | $('#trumbowyg').show(); |
389 | $('#trumbowyg').show(); |
|
389 | }); |
390 | }); |
|
390 | }); |
391 | }); |
|
391 | }); |
392 | }); |
|
392 | |
393 | |
|
393 | // When the reset button is pressed, navigate to the fingerprint. |
394 | // When the reset button is pressed, navigate to the fingerprint. |
|
394 | $('#reset').click(() => { |
395 | $('#reset').click(() => { |
|
395 | Cookies.set('nick', fingerprint, { path: '' }); |
396 | Cookies.set('nick', fingerprint, { path: '' }); |
|
396 | $('#nick').val(fingerprint); |
397 | $('#nick').val(fingerprint); |
|
397 | result = fingerprint; |
398 | result = fingerprint; |
|
398 | nick = fingerprint; |
399 | nick = fingerprint; |
|
399 | |
400 | |
|
400 | // Retrieve the contents of the shared file. |
401 | // Retrieve the contents of the shared file. |
|
401 | $('#editor').trumbowyg('disable'); |
402 | $('#editor').trumbowyg('disable'); |
|
402 | $.get('session.php').then((token) => { |
403 | $.get('session.php').then((token) => { |
|
403 | $.post('text.php', |
404 | $.post('text.php', |
|
404 | { |
405 | { |
|
405 | timestamp: window.performance.now(), |
406 | timestamp: window.performance.now(), |
|
406 | fingerprint: fingerprint, |
407 | fingerprint: fingerprint, |
|
407 | action: 'LOAD', |
408 | action: 'LOAD', |
|
408 | token: token |
409 | token: token |
|
409 | }).done((data) => {; |
410 | }).done((data) => {; |
|
410 | $('#trumbowyg') |
411 | $('#trumbowyg') |
|
411 | .trumbowyg('html', data); |
412 | .trumbowyg('html', data); |
|
412 | $('#trumbowyg').trumbowyg('enable'); |
413 | $('#trumbowyg').trumbowyg('enable'); |
|
413 | $('#trumbowyg').show(); |
414 | $('#trumbowyg').show(); |
|
414 | if(fingerprint == nick) |
415 | if(fingerprint == nick) |
|
415 | $('#home-icon').addClass("text-success").removeClass("text-danger"); |
416 | $('#home-icon').addClass("text-success").removeClass("text-danger"); |
|
416 | else |
417 | else |
|
417 | $('#home-icon').addClass("text-danger").removeClass("text-success"); |
418 | $('#home-icon').addClass("text-danger").removeClass("text-success"); |
|
418 | }).fail(() => { |
419 | }).fail(() => { |
|
419 | $('#trumbowyg').trumbowyg('enable'); |
420 | $('#trumbowyg').trumbowyg('enable'); |
|
420 | $('#trumbowyg').show(); |
421 | $('#trumbowyg').show(); |
|
421 | }); |
422 | }); |
|
422 | }); |
423 | }); |
|
423 | }); |
424 | }); |
|
424 | }); |
425 | }); |
|
425 | |
426 | |
|
426 | // Scroll to the panel. |
427 | // Scroll to the panel. |
|
427 | $('html, body').animate({ |
428 | $('html, body').animate({ |
|
428 | scrollTop: $('#main-panel').offset().top |
429 | scrollTop: $('#main-panel').offset().top |
|
429 | }, 'slow'); |
430 | }, 'slow'); |
|
430 | }); |
431 | }); |
|
431 | </script> |
432 | </script> |
|
432 | <!-- Jumbotron parallax effect --> |
433 | <!-- Jumbotron parallax effect --> |
|
433 | <script> |
434 | <script> |
|
434 | var jumboHeight = $('.jumbotron').outerHeight(); |
435 | var jumboHeight = $('.jumbotron').outerHeight(); |
|
435 | function parallax(){ |
436 | function parallax(){ |
|
436 | var scrolled = $(window).scrollTop(); |
437 | var scrolled = $(window).scrollTop(); |
|
437 | $('.paralax-background').css('height', (jumboHeight-scrolled) + 'px'); |
438 | $('.paralax-background').css('height', (jumboHeight-scrolled) + 'px'); |
|
438 | } |
439 | } |
|
439 | |
440 | |
|
440 | $(window).scroll(function(e){ |
441 | $(window).scroll(function(e){ |
|
441 | parallax(); |
442 | parallax(); |
|
442 | }); |
443 | }); |
|
443 | </script> |
444 | </script> |
|
444 | </body> |
445 | </body> |
|
445 | </html> |
446 | </html> |
|
446 | |
447 | |