Adding switch to keep tagging field on or off.
Adding debugging mode.
This commit is contained in:
parent
11b15e1b9b
commit
4ebd6fbe29
@ -45,6 +45,11 @@
|
||||
|
||||
<script>
|
||||
|
||||
//If tagging should be one all the time. False if show only after pasting.
|
||||
const tagging_always_on = true;
|
||||
const debugging = window.debugging;
|
||||
|
||||
// Include
|
||||
const pubsub = require('pubsub-js');
|
||||
const empty = require('empty-lite');
|
||||
const hash = require('hash.js');
|
||||
@ -65,7 +70,7 @@
|
||||
export default {
|
||||
state: {
|
||||
message:"Paste something in this window.",
|
||||
show_tagging: false
|
||||
show_tagging: tagging_always_on
|
||||
},
|
||||
components: {
|
||||
TimechainTag,
|
||||
@ -78,6 +83,9 @@
|
||||
onMounted(){
|
||||
document.addEventListener('paste', this.pasteEvent.bind(this));
|
||||
},
|
||||
/**
|
||||
* CLeans up the paste input and get it ready for a new paste
|
||||
*/
|
||||
cleanFields(){
|
||||
this.clean_props.forEach(f=>{
|
||||
this[f]=null;
|
||||
@ -86,15 +94,20 @@
|
||||
el.innerHTML = `<p>${this.state.message}</p>`;
|
||||
el.classList.remove('paste-html');
|
||||
pubsub.publish('tag.clean');
|
||||
this.update({show_tagging:false});
|
||||
this.update({show_tagging:tagging_always_on});
|
||||
pubsub.publish('timestamp-resume',true);
|
||||
},
|
||||
/**
|
||||
* Window paste event has been fire.
|
||||
*/
|
||||
pasteEvent(e){
|
||||
e.preventDefault();
|
||||
|
||||
console.log("Paste Event");
|
||||
console.log("Item 1", e.clipboardData.items[0]);
|
||||
console.log("Item 2", e.clipboardData.items[1]);
|
||||
if(debugging){
|
||||
console.log("Paste Event");
|
||||
console.log("Item 1", e.clipboardData.items[0]);
|
||||
console.log("Item 2", e.clipboardData.items[1]);
|
||||
}
|
||||
|
||||
let known_type = true;
|
||||
let isFile = false;
|
||||
@ -104,15 +117,13 @@
|
||||
|
||||
if(types.indexOf('Files') > -1){
|
||||
|
||||
|
||||
const c = e.clipboardData.items.length;
|
||||
|
||||
console.log("FILES!!", c);
|
||||
debugging && console.log("FILES!!", c);
|
||||
|
||||
for(let i=0; i < c ; i++){
|
||||
console.log(i);
|
||||
debugging && console.log("Clip Data",i, e.clipboardData.items[i]);
|
||||
const t = e.clipboardData.items[i].type;
|
||||
console.log("Clip Data", e.clipboardData.items[i]);
|
||||
|
||||
if(t == 'image/jpeg'){
|
||||
isFile = true;
|
||||
@ -126,12 +137,8 @@
|
||||
}
|
||||
|
||||
}else if (types.indexOf('text/html') > -1) {
|
||||
//this.content_mime = 'text/html';
|
||||
//this.update();
|
||||
this.isHTML(e);
|
||||
}else if(types.indexOf('text/plain') > -1){
|
||||
//this.content_mime = 'text/plain';
|
||||
//this.update();
|
||||
this.isTEXT(e);
|
||||
}else{
|
||||
known_type = false;
|
||||
@ -244,7 +251,7 @@
|
||||
this.cleanFields();
|
||||
},
|
||||
onSave(){
|
||||
console.log("Save button pressed");
|
||||
debugging && console.log("Save button pressed");
|
||||
const TR = new TimeChainDataSqliteRecord();
|
||||
|
||||
const ts = Math.floor(new Date().getTime());
|
||||
@ -252,7 +259,7 @@
|
||||
const hs = hash.sha256().update(this.content).digest('hex');
|
||||
const tags = JSON.parse(this.content_tags);
|
||||
|
||||
console.log("tags:",tags);
|
||||
debugging && console.log("tags:",tags);
|
||||
|
||||
TR.add(id,ts,this.content,this.content_mime,hs).then(res=>{
|
||||
if(res != 1){
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user