scratch – Diff between revs 76 and 77
?pathlinks?
Rev 76 | Rev 77 | |||
---|---|---|---|---|
Line 79... | Line 79... | |||
79 | </span> |
79 | </span> |
|
80 | </div> |
80 | </div> |
|
81 | </div> |
81 | </div> |
|
82 | </form> |
82 | </form> |
|
83 | </div> |
83 | </div> |
|
84 | <div class="panel-body" id="editorpanel"> |
84 | <div class="panel-body" id="editorpanel"> |
|
85 | <div id="trumbowyg"> |
85 | <div id="trumbowyg"> |
|
86 | </div> |
86 | </div> |
|
87 | </div> |
87 | </div> |
|
88 | </div> |
88 | </div> |
|
Line 97... | Line 97... | |||
97 | |
97 | |
|
98 | <!-- jQuery --> |
98 | <!-- jQuery --> |
|
99 | <script src="bower_components/jquery/dist/jquery.min.js"></script> |
99 | <script src="bower_components/jquery/dist/jquery.min.js"></script> |
|
100 | <!-- BootStrap --> |
100 | <!-- BootStrap --> |
|
- | 101 | <script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script> |
||
- | 102 | <!-- Velocity --> |
||
Line 101... | Line 103... | |||
101 | <script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script> |
103 | <script src="bower_components/velocity/velocity.min.js"></script> |
|
102 | |
104 | |
|
103 | <!-- Trumbowyg --> |
105 | <!-- Trumbowyg --> |
|
104 | <script src="bower_components/trumbowyg/dist/trumbowyg.min.js"></script> |
106 | <script src="bower_components/trumbowyg/dist/trumbowyg.min.js"></script> |
|
Line 166... | Line 168... | |||
166 | if(fingerprint == nick) |
168 | if(fingerprint == nick) |
|
167 | $('#home-icon').addClass("text-success"); |
169 | $('#home-icon').addClass("text-success"); |
|
168 | else |
170 | else |
|
169 | $('#home-icon').addClass("text-danger"); |
171 | $('#home-icon').addClass("text-danger"); |
|
Line -... | Line 172... | |||
- | 172 | |
||
- | 173 | var autoSaveTimeoutID; |
||
170 | |
174 | |
|
171 | function saveTextFile() { |
175 | function saveTextFile() { |
|
172 | $.post('text.php', { |
176 | $.post('text.php', { |
|
173 | data: $('#trumbowyg').trumbowyg('html'), |
177 | data: $('#trumbowyg').trumbowyg('html'), |
|
174 | fingerprint: result, |
178 | fingerprint: result, |
|
- | 179 | action: 'SAVE' |
||
- | 180 | }).done((data) => { |
||
- | 181 | |
||
- | 182 | // Visual feedback for a successful save. |
||
- | 183 | $('#editorpanel') |
||
- | 184 | .delay(250) |
||
- | 185 | .velocity( |
||
- | 186 | { |
||
- | 187 | borderColor: '#ff99ff' |
||
- | 188 | }, |
||
- | 189 | 200) |
||
- | 190 | .delay(500) |
||
175 | action: 'SAVE', |
191 | .velocity( |
|
- | 192 | { |
||
- | 193 | borderColor: '#ecf0f1' |
||
- | 194 | }, |
||
- | 195 | 200); |
||
- | 196 | |
||
- | 197 | }).fail(() => { |
||
- | 198 | // Reschedule saving of the file. |
||
- | 199 | if(autoSaveTimeoutID) |
||
- | 200 | window.clearTimeout(autoSaveTimeoutID); |
||
176 | timeout: 0 |
201 | autoSaveTimeoutID = window.setTimeout(saveTextFile, 250); |
|
177 | }); |
202 | }); |
|
178 | } |
- | ||
Line 179... | Line 203... | |||
179 | var autoSaveTimeoutID = window.setTimeout(saveTextFile, 250); |
203 | } |
|
180 | |
204 | |
|
181 | // Load the editor. |
205 | // Load the editor. |
|
182 | $('#trumbowyg').trumbowyg({ |
206 | $('#trumbowyg').trumbowyg({ |
|
183 | semantic: true, |
207 | semantic: true, |
|
184 | autogrow: true, |
208 | autogrow: true, |
|
185 | disabled: true |
209 | disabled: true |
|
186 | }).on('tbwchange', () => { |
210 | }).on('tbwchange', () => { |
|
187 | // Clear the value of the URL box because the URL will have changed. |
211 | // Clear the value of the URL box because the URL will have changed. |
|
- | 212 | $('#URL').val(''); |
||
188 | $('#URL').val(''); |
213 | // Reschedule saving of the file. |
|
189 | // Reschedule saving of the file. |
214 | if(autoSaveTimeoutID) |
|
190 | window.clearTimeout(autoSaveTimeoutID); |
215 | window.clearTimeout(autoSaveTimeoutID); |
|
Line 191... | Line 216... | |||
191 | autoSaveTimeoutID = window.setTimeout(saveTextFile, 250); |
216 | autoSaveTimeoutID = window.setTimeout(saveTextFile, 1000); |
|
192 | }); |
217 | }); |
|
193 | |
218 | |