scratch – Diff between revs 36 and 37

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
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="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> 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>
69 </span> 71  
70 </div> 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">
-   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>
-   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>
-   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,
-   143 action: 'SAVE'
-   144 }).done((data) => {
-   145 $('#trumbowyg').trumbowyg('enable');
-   146 }).fail(() => {
-   147 $('#trumbowyg').trumbowyg('enable');
-   148 });
-   149 });
-   150
-   151 // Retrieve the contents of the shared file.
-   152 $.post('share-text.php',
-   153 {
-   154 timestamp: window.performance.now(),
-   155 fingerprint: result,
104 data: $('#trumbowyg').trumbowyg('html'), 156 action: 'LOAD'
-   157 }).done((data) => {;
-   158 $('#trumbowyg')
105 }).done((data) => { 159 .trumbowyg('html', data);
-   160 $('#trumbowyg').trumbowyg('enable');
106 $('#trumbowyg').trumbowyg('enable'); 161 $('#trumbowyg').show();
107 }).fail(() => { 162 }).fail(() => {
-   163 $('#trumbowyg').trumbowyg('enable');
108 $('#trumbowyg').trumbowyg('enable'); 164 $('#trumbowyg').show();
109 }); -  
Line 110... Line -...
110 }); -  
111 -  
112 // Retrieve the contents of the shared file. -  
113 $.get('share-text.php' + '?t=' + window.performance.now(), -  
114 { -  
115 cache: false -  
116 }).done((data) => { -  
117 $('#trumbowyg') -  
118 .trumbowyg('html', data); -  
119 $('#trumbowyg').trumbowyg('enable'); -  
120 $('#trumbowyg').show(); -  
121 }).fail(() => { -  
122 $('#trumbowyg').trumbowyg('enable'); -  
123 $('#trumbowyg').show(); -  
124 }); 165 });
125 166
Line 126... Line 167...
126 // Enable the Clipboard button. 167 // Enable the Clipboard button.
127 new Clipboard('#clippy'); 168 new Clipboard('#copy-url');
Line 128... Line 169...
128 169
129 $('#save').click(() => { 170 $('#save').click(() => {
130 $('#editor').trumbowyg('disable'); 171 $('#editor').trumbowyg('disable');
131 172
132 var formData = new FormData(); 173 var formData = new FormData();
133 formData.append('file', new Blob( 174 formData.append('file', new Blob(
134 [ 175 [
135 $('#trumbowyg').trumbowyg('html') 176 $('#trumbowyg').trumbowyg('html')
Line 136... Line 177...
136 ] 177 ]
137 ), 178 ),
138 '.html' 179 '.html'
139 ); 180 );
140 181
141 $.ajax({ 182 $.ajax({
142 url: 'upload-files.php', 183 url: 'upload-files.php',
143 type: 'POST', 184 type: 'POST',
144 data: formData, 185 data: formData,
145 // cache: false // FF 186 // cache: false // FF
146 processData: false, 187 processData: false,
147 contentType: false 188 contentType: false
-   189 }).done((data) => {
-   190 $('#URL').val(data);
-   191 $('#trumbowyg').trumbowyg('enable');
-   192 }).fail(() => {
-   193 alert('failed');
-   194 $('#trumbowyg').trumbowyg('enable');
-   195 });
-   196 });
-   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) => {;
148 }).done((data) => { 212 $('#trumbowyg')
-   213 .trumbowyg('html', data);
-   214 $('#trumbowyg').trumbowyg('enable');
149 $('#URL').val(data); 215 $('#trumbowyg').show();
150 $('#trumbowyg').trumbowyg('enable'); 216 }).fail(() => {
Line 151... Line 217...
151 }).fail(() => { 217 $('#trumbowyg').trumbowyg('enable');
152 alert('failed'); 218 $('#trumbowyg').show();