/quickload/text.html |
@@ -57,8 +57,8 @@ |
|
<div class="panel panel-default"> |
<div class="panel-heading"> |
<div class="form-group"> |
<div class="input-group"> |
<input id="URL" type="text" class="form-control" readonly> |
<span class="input-group-btn"> |
<button id="save" class="btn btn-default" type="button"> |
<i class="glyphicon glyphicon-globe"></i> |
@@ -65,10 +65,28 @@ |
</button> |
</span> |
<span class="input-group-btn"> |
<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> |
<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> |
</span> |
<input id="URL" type="text" class="form-control" readonly> |
|
</div> |
</div> |
<form id="nick-form" data-toggle="validator" role="form"> |
<div class="form-group has-feedback"> |
<div class="input-group"> |
<span class="input-group-btn"> |
<button id="go" class="btn btn-default" type="button"> |
<i class="glyphicon glyphicon-play"></i> |
</button> |
</span> |
<span class="input-group-btn"> |
<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> |
</span> |
<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> |
</div> |
</div> |
</form> |
</div> |
<div class="panel-body" id="editorpanel"> |
<div id="trumbowyg" style="display: none; font-family: monospace;"> |
</div> |
@@ -92,66 +110,114 @@ |
<script src="js/trumbowyg/trumbowyg.min.js"></script> |
<!-- Clipboard --> |
<script src="js/clipboard/clipboard.min.js"></script> |
<!-- Fingerprint 2 --> |
<script src="js/fingerprintjs/fingerprint2.min.js"></script> |
<!-- js-cookie --> |
<script src="js/jscookie/js.cookie.js"></script> |
<!-- Bootstrap Validator --> |
<script src="js/validator/validator.min.js"></script> |
<script> |
$(document).ready(() => { |
// Load the editor. |
$('#trumbowyg').trumbowyg({ |
autogrow: true, |
disabled: true |
}).on('tbwchange', () => { |
$('#editor').trumbowyg('disable'); |
$.post('share-text.php', { |
data: $('#trumbowyg').trumbowyg('html'), |
}).done((data) => { |
// Get the fingerprint. |
new Fingerprint2().get((result, components) => { |
// Set the nick as a cookie. |
var nick = Cookies.get('nick'); |
if(!nick || nick.length !== 32) |
Cookies.set('nick', result, { path: '' }); |
else |
result = nick; |
|
// Set the nick. |
$('#nick').val(result); |
new Clipboard('#copy-nick'); |
|
// Load the editor. |
$('#trumbowyg').trumbowyg({ |
autogrow: true, |
disabled: true |
}).on('tbwchange', () => { |
$('#editor').trumbowyg('disable'); |
$.post('share-text.php', { |
data: $('#trumbowyg').trumbowyg('html'), |
fingerprint: result, |
action: 'SAVE' |
}).done((data) => { |
$('#trumbowyg').trumbowyg('enable'); |
}).fail(() => { |
$('#trumbowyg').trumbowyg('enable'); |
}); |
}); |
|
// Retrieve the contents of the shared file. |
$.post('share-text.php', |
{ |
timestamp: window.performance.now(), |
fingerprint: result, |
action: 'LOAD' |
}).done((data) => {; |
$('#trumbowyg') |
.trumbowyg('html', data); |
$('#trumbowyg').trumbowyg('enable'); |
$('#trumbowyg').show(); |
}).fail(() => { |
$('#trumbowyg').trumbowyg('enable'); |
$('#trumbowyg').show(); |
}); |
}); |
|
// Retrieve the contents of the shared file. |
$.get('share-text.php' + '?t=' + window.performance.now(), |
{ |
cache: false |
}).done((data) => { |
$('#trumbowyg') |
.trumbowyg('html', data); |
$('#trumbowyg').trumbowyg('enable'); |
$('#trumbowyg').show(); |
}).fail(() => { |
$('#trumbowyg').trumbowyg('enable'); |
$('#trumbowyg').show(); |
}); |
// Enable the Clipboard button. |
new Clipboard('#copy-url'); |
|
// Enable the Clipboard button. |
new Clipboard('#clippy'); |
|
$('#save').click(() => { |
$('#editor').trumbowyg('disable'); |
$('#save').click(() => { |
$('#editor').trumbowyg('disable'); |
|
var formData = new FormData(); |
formData.append('file', new Blob( |
[ |
$('#trumbowyg').trumbowyg('html') |
] |
), |
'.html' |
); |
var formData = new FormData(); |
formData.append('file', new Blob( |
[ |
$('#trumbowyg').trumbowyg('html') |
] |
), |
'.html' |
); |
|
$.ajax({ |
url: 'upload-files.php', |
type: 'POST', |
data: formData, |
// cache: false // FF |
processData: false, |
contentType: false |
}).done((data) => { |
$('#URL').val(data); |
$('#trumbowyg').trumbowyg('enable'); |
}).fail(() => { |
alert('failed'); |
$('#trumbowyg').trumbowyg('enable'); |
$.ajax({ |
url: 'upload-files.php', |
type: 'POST', |
data: formData, |
// cache: false // FF |
processData: false, |
contentType: false |
}).done((data) => { |
$('#URL').val(data); |
$('#trumbowyg').trumbowyg('enable'); |
}).fail(() => { |
alert('failed'); |
$('#trumbowyg').trumbowyg('enable'); |
}); |
}); |
|
// When the user wants to assume a nickname. |
$('#go').click(() => { |
nick = $('#nick').val(); |
if(!nick || nick.length != 32) |
return; |
Cookies.set('nick', nick, { path: '' }); |
|
// Retrieve the contents of the shared file. |
$.post('share-text.php', |
{ |
timestamp: window.performance.now(), |
fingerprint: nick, |
action: 'LOAD' |
}).done((data) => {; |
$('#trumbowyg') |
.trumbowyg('html', data); |
$('#trumbowyg').trumbowyg('enable'); |
$('#trumbowyg').show(); |
}).fail(() => { |
$('#trumbowyg').trumbowyg('enable'); |
$('#trumbowyg').show(); |
}); |
}); |
}); |
|
}); |