filereader for stikkedizr

This commit is contained in:
Claude 2016-09-02 09:01:34 +02:00
parent 3ad89358da
commit a82362cda2
4 changed files with 60 additions and 1 deletions

View File

@ -202,12 +202,69 @@ ST.crypto_generate_key = function(len) {
return key; return key;
} }
ST.filereader = function() {
$("#code").fileReaderJS({
// CSS Class to add to the drop element when a drag is active
dragClass: "drag",
// A string to match MIME types, for instance
accept: false,
// An object specifying how to read certain MIME types
// For example: {
// 'image/*': 'DataURL',
// 'data/*': 'ArrayBuffer',
// 'text/*' : 'Text'
// }
readAsMap: {},
// How to read any files not specified by readAsMap
readAsDefault: 'DataURL',
on: {
beforestart: function(e, file) {
// return false if you want to skip this file
},
loadstart: function(e, file) { /* Native ProgressEvent */ },
progress: function(e, file) { /* Native ProgressEvent */ },
load: function(e, file) { /* Native ProgressEvent */ },
error: function(e, file) { /* Native ProgressEvent */ },
loadend: function(e, file) {
try {
var words = CryptoJS.enc.Base64.parse(e.target.result.split(',')[1]);
var utf8 = CryptoJS.enc.Utf8.stringify(words);
$('#code').val(utf8);
} catch (err) {
console.error(err);
console.info('event: ', e);
console.info('file: ', file);
};
},
abort: function(e, file) { /* Native ProgressEvent */ },
skip: function(e, file) {
// Called when a file is skipped. This happens when:
// 1) A file doesn't match the accept option
// 2) false is returned in the beforestart callback
},
groupstart: function(group) {
// Called when a 'group' (a single drop / copy / select that may
// contain multiple files) is receieved.
// You can ignore this event if you don't care about groups
},
groupend: function(group) {
// Called when a 'group' is finished.
// You can ignore this event if you don't care about groups
}
}
});
}
ST.init = function() { ST.init = function() {
ST.expand(); ST.expand();
ST.show_embed(); ST.show_embed();
ST.spamadmin(); ST.spamadmin();
ST.line_highlighter(); ST.line_highlighter();
ST.crypto(); ST.crypto();
ST.filereader();
}; };
$(document).ready(function() { $(document).ready(function() {

View File

@ -15,6 +15,7 @@ $this->carabiner->js('jquery.js');
$this->carabiner->js('jquery.timers.js'); $this->carabiner->js('jquery.timers.js');
$this->carabiner->js('crypto-js/rollups/aes.js'); $this->carabiner->js('crypto-js/rollups/aes.js');
$this->carabiner->js('lz-string-1.3.3-min.js'); $this->carabiner->js('lz-string-1.3.3-min.js');
$this->carabiner->js('filereader.js');
$this->carabiner->js('stikked.js'); $this->carabiner->js('stikked.js');
$this->carabiner->js('codemirror/codemirror.js'); $this->carabiner->js('codemirror/codemirror.js');
$this->carabiner->js('codemirror_exec.js'); $this->carabiner->js('codemirror_exec.js');

View File

@ -54,7 +54,7 @@ if(isset($insert)){
<section> <section>
<div class="row"> <div class="row">
<div class="col-12 col-sm-12 col-lg-12"> <div class="col-12 col-sm-12 col-lg-12">
<blockquote class="CodeMirror"><span class="text_formatted"><span class="container"><?php echo $paste; ?></span></span></blockquote> <blockquote class="CodeMirror"><span class="text_formatted"><span class="container" id="code"><?php echo $paste; ?></span></span></blockquote>
</div> </div>
</div> </div>
</section> </section>

View File

@ -10,6 +10,7 @@ $this->carabiner->js('jquery.js');
$this->carabiner->js('jquery.timers.js'); $this->carabiner->js('jquery.timers.js');
$this->carabiner->js('crypto-js/rollups/aes.js'); $this->carabiner->js('crypto-js/rollups/aes.js');
$this->carabiner->js('lz-string-1.3.3-min.js'); $this->carabiner->js('lz-string-1.3.3-min.js');
$this->carabiner->js('filereader.js');
$this->carabiner->js('stikked.js'); $this->carabiner->js('stikked.js');
$this->carabiner->js('codemirror/codemirror.js'); $this->carabiner->js('codemirror/codemirror.js');
$this->carabiner->js('codemirror_exec.js'); $this->carabiner->js('codemirror_exec.js');