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