scratch – Diff between revs 36 and 37
?pathlinks?
Rev 36 | Rev 37 | |||
---|---|---|---|---|
Line 55... | Line 55... | |||
55 | <li class="active"><a href="#">Text</a></li> |
55 | <li class="active"><a href="#">Text</a></li> |
|
56 | </ul> |
56 | </ul> |
|
Line 57... | Line 57... | |||
57 | |
57 | |
|
58 | <div class="panel panel-default"> |
58 | <div class="panel panel-default"> |
|
- | 59 | <div class="panel-heading"> |
||
59 | <div class="panel-heading"> |
60 | <div class="form-group"> |
|
60 | <div class="input-group"> |
- | ||
61 | <input id="URL" type="text" class="form-control" readonly> |
61 | <div class="input-group"> |
|
62 | <span class="input-group-btn"> |
62 | <span class="input-group-btn"> |
|
63 | <button id="save" class="btn btn-default" type="button"> |
63 | <button id="save" class="btn btn-default" type="button"> |
|
64 | <i class="glyphicon glyphicon-globe"></i> |
64 | <i class="glyphicon glyphicon-globe"></i> |
|
65 | </button> |
65 | </button> |
|
66 | </span> |
66 | </span> |
|
67 | <span class="input-group-btn"> |
67 | <span class="input-group-btn"> |
|
- | 68 | <button id="copy-url" class="btn btn-default" type="button" data-clipboard-target="#URL"><img class="clippy" src="img/clipboard/clippy.svg" width="13" alt="Copy to Clipboard"></button> |
||
- | 69 | </span> |
||
- | 70 | <input id="URL" type="text" class="form-control" readonly> |
||
- | 71 | |
||
- | 72 | </div> |
||
- | 73 | </div> |
||
- | 74 | <form id="nick-form" data-toggle="validator" role="form"> |
||
- | 75 | <div class="form-group has-feedback"> |
||
- | 76 | <div class="input-group"> |
||
- | 77 | <span class="input-group-btn"> |
||
- | 78 | <button id="go" class="btn btn-default" type="button"> |
||
- | 79 | <i class="glyphicon glyphicon-play"></i> |
||
- | 80 | </button> |
||
- | 81 | </span> |
||
- | 82 | <span class="input-group-btn"> |
||
68 | <button id="clippy" class="btn btn-default" type="button" data-clipboard-target="#URL"><img class="clippy" src="img/clipboard/clippy.svg" width="13" alt="Copy to Clipboard"></button> |
83 | <button id="copy-nick" class="btn btn-default" type="button" data-clipboard-target="#nick"><img class="clippy" src="img/clipboard/clippy.svg" width="13" alt="Copy to Clipboard"></button> |
|
- | 84 | </span> |
||
69 | </span> |
85 | <input id="nick" type="text" class="form-control" pattern="^[A-Za-z0-9]{32}$" maxlength="32" minlength="32" data-error="The fingerprint is malformed." required> |
|
70 | </div> |
86 | </div> |
|
- | 87 | </div> |
||
- | 88 | </form> |
||
71 | </div> |
89 | </div> |
|
72 | <div class="panel-body" id="editorpanel"> |
90 | <div class="panel-body" id="editorpanel"> |
|
73 | <div id="trumbowyg" style="display: none; font-family: monospace;"> |
91 | <div id="trumbowyg" style="display: none; font-family: monospace;"> |
|
74 | </div> |
92 | </div> |
|
75 | </div> |
93 | </div> |
|
Line 90... | Line 108... | |||
90 | |
108 | |
|
91 | <!-- Trumbowyg --> |
109 | <!-- Trumbowyg --> |
|
92 | <script src="js/trumbowyg/trumbowyg.min.js"></script> |
110 | <script src="js/trumbowyg/trumbowyg.min.js"></script> |
|
93 | <!-- Clipboard --> |
111 | <!-- Clipboard --> |
|
- | 112 | <script src="js/clipboard/clipboard.min.js"></script> |
||
- | 113 | <!-- Fingerprint 2 --> |
||
- | 114 | <script src="js/fingerprintjs/fingerprint2.min.js"></script> |
||
- | 115 | <!-- js-cookie --> |
||
- | 116 | <script src="js/jscookie/js.cookie.js"></script> |
||
- | 117 | <!-- Bootstrap Validator --> |
||
94 | <script src="js/clipboard/clipboard.min.js"></script> |
118 | <script src="js/validator/validator.min.js"></script> |
|
95 | <script> |
119 | <script> |
|
- | 120 | $(document).ready(() => { |
||
- | 121 | // Get the fingerprint. |
||
- | 122 | new Fingerprint2().get((result, components) => { |
||
- | 123 | // Set the nick as a cookie. |
||
- | 124 | var nick = Cookies.get('nick'); |
||
- | 125 | if(!nick || nick.length !== 32) |
||
- | 126 | Cookies.set('nick', result, { path: '' }); |
||
- | 127 | else |
||
- | 128 | result = nick; |
||
- | 129 | |
||
- | 130 | // Set the nick. |
||
- | 131 | $('#nick').val(result); |
||
- | 132 | new Clipboard('#copy-nick'); |
||
96 | $(document).ready(() => { |
133 | |
|
97 | // Load the editor. |
134 | // Load the editor. |
|
98 | $('#trumbowyg').trumbowyg({ |
135 | $('#trumbowyg').trumbowyg({ |
|
99 | autogrow: true, |
136 | autogrow: true, |
|
100 | disabled: true |
137 | disabled: true |
|
101 | }).on('tbwchange', () => { |
138 | }).on('tbwchange', () => { |
|
102 | $('#editor').trumbowyg('disable'); |
139 | $('#editor').trumbowyg('disable'); |
|
103 | $.post('share-text.php', { |
140 | $.post('share-text.php', { |
|
- | 141 | data: $('#trumbowyg').trumbowyg('html'), |
||
- | 142 | fingerprint: result, |
||
104 | data: $('#trumbowyg').trumbowyg('html'), |
143 | action: 'SAVE' |
|
105 | }).done((data) => { |
144 | }).done((data) => { |
|
106 | $('#trumbowyg').trumbowyg('enable'); |
145 | $('#trumbowyg').trumbowyg('enable'); |
|
107 | }).fail(() => { |
146 | }).fail(() => { |
|
108 | $('#trumbowyg').trumbowyg('enable'); |
147 | $('#trumbowyg').trumbowyg('enable'); |
|
109 | }); |
148 | }); |
|
Line 110... | Line 149... | |||
110 | }); |
149 | }); |
|
111 | |
150 | |
|
112 | // Retrieve the contents of the shared file. |
151 | // Retrieve the contents of the shared file. |
|
- | 152 | $.post('share-text.php', |
||
- | 153 | { |
||
113 | $.get('share-text.php' + '?t=' + window.performance.now(), |
154 | timestamp: window.performance.now(), |
|
114 | { |
155 | fingerprint: result, |
|
115 | cache: false |
156 | action: 'LOAD' |
|
116 | }).done((data) => { |
157 | }).done((data) => {; |
|
117 | $('#trumbowyg') |
158 | $('#trumbowyg') |
|
118 | .trumbowyg('html', data); |
159 | .trumbowyg('html', data); |
|
119 | $('#trumbowyg').trumbowyg('enable'); |
160 | $('#trumbowyg').trumbowyg('enable'); |
|
120 | $('#trumbowyg').show(); |
161 | $('#trumbowyg').show(); |
|
121 | }).fail(() => { |
162 | }).fail(() => { |
|
122 | $('#trumbowyg').trumbowyg('enable'); |
163 | $('#trumbowyg').trumbowyg('enable'); |
|
Line 123... | Line 164... | |||
123 | $('#trumbowyg').show(); |
164 | $('#trumbowyg').show(); |
|
124 | }); |
165 | }); |
|
Line 125... | Line 166... | |||
125 | |
166 | |
|
126 | // Enable the Clipboard button. |
167 | // Enable the Clipboard button. |
|
Line 127... | Line 168... | |||
127 | new Clipboard('#clippy'); |
168 | new Clipboard('#copy-url'); |
|
Line 152... | Line 193... | |||
152 | alert('failed'); |
193 | alert('failed'); |
|
153 | $('#trumbowyg').trumbowyg('enable'); |
194 | $('#trumbowyg').trumbowyg('enable'); |
|
154 | }); |
195 | }); |
|
155 | }); |
196 | }); |
|
Line -... | Line 197... | |||
- | 197 | |
||
- | 198 | // When the user wants to assume a nickname. |
||
- | 199 | $('#go').click(() => { |
||
- | 200 | nick = $('#nick').val(); |
||
- | 201 | if(!nick || nick.length != 32) |
||
- | 202 | return; |
||
- | 203 | Cookies.set('nick', nick, { path: '' }); |
||
- | 204 | |
||
- | 205 | // Retrieve the contents of the shared file. |
||
- | 206 | $.post('share-text.php', |
||
- | 207 | { |
||
- | 208 | timestamp: window.performance.now(), |
||
- | 209 | fingerprint: nick, |
||
- | 210 | action: 'LOAD' |
||
- | 211 | }).done((data) => {; |
||
- | 212 | $('#trumbowyg') |
||
- | 213 | .trumbowyg('html', data); |
||
- | 214 | $('#trumbowyg').trumbowyg('enable'); |
||
- | 215 | $('#trumbowyg').show(); |
||
- | 216 | }).fail(() => { |
||
- | 217 | $('#trumbowyg').trumbowyg('enable'); |
||
- | 218 | $('#trumbowyg').show(); |
||
- | 219 | }); |
||
- | 220 | }); |
||
- | 221 | }); |
||
156 | |
222 | |
|
157 | }); |
223 | }); |
|
158 | </script> |
224 | </script> |
|
159 | </body> |
225 | </body> |