0630
This commit is contained in:
@@ -62,7 +62,6 @@ export function deleteNote(key) {
|
||||
|
||||
|
||||
export function getNoteMeta(key) {
|
||||
console.log("getNoteMeta");
|
||||
let noteMeta = {};
|
||||
Jquery.ajax({
|
||||
method: 'GET',
|
||||
|
||||
@@ -18,9 +18,9 @@ export function setStoreText(text, secret, password) {
|
||||
let storeText = aesEncrypt(text, secretKey);
|
||||
storeText = zip(storeText);
|
||||
|
||||
let lock = '0';
|
||||
let lock = 0;
|
||||
if (password) {
|
||||
lock = '1';
|
||||
lock = 1;
|
||||
}
|
||||
|
||||
storage.local.setText(secret.storeKey + '.text', lock + '|' + secret.cipher + '|' + storeText);
|
||||
|
||||
@@ -161,7 +161,7 @@ export default {
|
||||
escapeText: '',
|
||||
key: '',
|
||||
md5: '',
|
||||
lock: '0',
|
||||
lock: 0,
|
||||
},
|
||||
secret: {
|
||||
storeKey: '',
|
||||
@@ -169,9 +169,9 @@ export default {
|
||||
cipher: '',
|
||||
},
|
||||
state: {
|
||||
lock: '0',
|
||||
locking: '0',
|
||||
commited: '0'
|
||||
lock: 0,
|
||||
locking: 0,
|
||||
commited: 0
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -93,19 +93,13 @@
|
||||
|
||||
|
||||
<div style="background: white;width:100%;height:40px;">
|
||||
<div style="float:left;width:auto;">
|
||||
|
||||
<Button-group size="large">
|
||||
|
||||
|
||||
</Button-group>
|
||||
|
||||
</div>
|
||||
<img style="height:40px;float:left;" src="favicon.png">
|
||||
<div style="float:left;width:auto;">
|
||||
|
||||
<Button-group size="large">
|
||||
|
||||
<Button type="error" :loading="loading"
|
||||
style="margin-left:5px; border-radius: 0px;font-size: 24px;" @click="submitNote()"
|
||||
icon="md-cloud-upload"></Button>
|
||||
|
||||
|
||||
</Button-group>
|
||||
@@ -120,24 +114,12 @@
|
||||
|
||||
<Button-group size="large">
|
||||
|
||||
<Button v-show="!showPassword" type="error"
|
||||
style="margin-right:5px; border-radius: 0px;font-size: 24px;" @click="showInput()"
|
||||
icon="md-unlock"></Button>
|
||||
|
||||
<Input v-show="!showPassword">
|
||||
<Button slot="append" type="error" style="margin-right:5px; border-radius: 0px;font-size: 24px;"
|
||||
icon="md-checkmark-circle"></Button>
|
||||
</Input>
|
||||
|
||||
|
||||
<Button type="error" :loading="loading"
|
||||
style="margin-right:5px; border-radius: 0px;font-size: 24px;" @click="submitNote()"
|
||||
icon="md-cloud-upload"></Button>
|
||||
|
||||
|
||||
<Button type="error" style="margin-left:0px; border-radius: 0px;font-size: 24px;"
|
||||
@click="createNote()" icon="md-add"></Button>
|
||||
<Button type="error" style="margin-left:0px; border-radius: 0px;font-size: 24px;"
|
||||
<Button type="error" style="margin-left:5px; border-radius: 0px;font-size: 24px;"
|
||||
@click="dropNote()" icon="md-trash"></Button>
|
||||
|
||||
</Button-group>
|
||||
@@ -206,7 +188,7 @@
|
||||
<div id="wrapper" style="border-left: 0px solid #FF3366;">
|
||||
|
||||
<Input element-id="noteText" type="textarea" :border="false" v-model="noteForm.text"
|
||||
:autosize="{ minRows: 30, maxRows: 1024 }" placeholder="Enter something..." v-on:input="log"
|
||||
:autosize="{ minRows: 30, maxRows: 4096 }" placeholder="Enter something..." v-on:input="log"
|
||||
@on-keydown="down" />
|
||||
</div>
|
||||
|
||||
@@ -269,11 +251,11 @@ export default {
|
||||
cipher: '',
|
||||
},
|
||||
state: {
|
||||
lock: '0',
|
||||
lock: 0,
|
||||
|
||||
locking: '0',
|
||||
locking: 0,
|
||||
|
||||
commited: '0'
|
||||
commited: 0
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -284,17 +266,17 @@ export default {
|
||||
|
||||
let keyMeta = storage.session.getObject(storeKey + '.keyMeta');
|
||||
if (keyMeta) {
|
||||
this.state.lock = '0';
|
||||
this.state.lock = 0;
|
||||
this.secret.cipher = keyMeta.cipher;
|
||||
storage.local.setText(storeKey + '.text', "0|" + this.secret.cipher);
|
||||
storage.session.setObject(storeKey + '.keyMeta', null);
|
||||
} else {
|
||||
let storeText = storage.local.getText(storeKey + '.text');
|
||||
this.state.lock = storeText.substring(0, 1);
|
||||
this.state.lock = parseInt(storeText.substring(0, 1));
|
||||
this.secret.cipher = storeText.substring(2, 34)
|
||||
}
|
||||
|
||||
if (this.state.lock == "1") {
|
||||
if (this.state.lock == 1) {
|
||||
this.show = false;
|
||||
this.noteForm.text = "*****lock*****";
|
||||
return;
|
||||
@@ -336,8 +318,8 @@ export default {
|
||||
let storeText = storage.local.getText(this.secret.storeKey + '.text');
|
||||
|
||||
if (null != storeText && '' != storeText) {
|
||||
let lock = storeText.substring(0, 1);
|
||||
if (lock == "1") {
|
||||
let lock = parseInt(storeText.substring(0, 1));
|
||||
if (lock == 1) {
|
||||
alert("note is encrypt!");
|
||||
return;
|
||||
}
|
||||
@@ -350,9 +332,9 @@ export default {
|
||||
let plainText = aesDecrypt(storeText, secretKey);
|
||||
if (plainText.startsWith("FLAGNOTE#")) {
|
||||
this.noteForm.text = plainText.substring(9);
|
||||
this.state.lock = "0";
|
||||
this.state.lock = 0;
|
||||
} else {
|
||||
if (this.state.lock == "1") {
|
||||
if (this.state.lock == 1) {
|
||||
alert("password is wrong!")
|
||||
}
|
||||
}
|
||||
@@ -396,28 +378,28 @@ export default {
|
||||
return saveNote(this.noteForm);
|
||||
},
|
||||
submitNote() {
|
||||
if (this.state.locking == "1") {
|
||||
if (this.state.locking == 1) {
|
||||
return;
|
||||
}
|
||||
this.state.locking = "1";
|
||||
this.state.locking = 1;
|
||||
|
||||
this.loading = true;
|
||||
|
||||
this.save().then(res => {
|
||||
if (res) {
|
||||
location.reload();
|
||||
this.state.locking = "0";
|
||||
this.state.locking = 0;
|
||||
}
|
||||
});
|
||||
},
|
||||
hideNote() {
|
||||
if (this.state.locking == "1") {
|
||||
if (this.state.locking == 1) {
|
||||
return;
|
||||
}
|
||||
this.state.locking = "1";
|
||||
this.state.locking = 1;
|
||||
|
||||
if (this.state.lock == "1") {
|
||||
this.state.locking = "0";
|
||||
if (this.state.lock == 1) {
|
||||
this.state.locking = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -427,7 +409,7 @@ export default {
|
||||
|
||||
setStoreText(this.noteForm.text, this.secret, password);
|
||||
|
||||
this.state.lock = "1"
|
||||
this.state.lock = 1
|
||||
|
||||
this.noteForm.text = '******lock******';
|
||||
|
||||
@@ -439,20 +421,20 @@ export default {
|
||||
noteText.selectionEnd = 1;
|
||||
|
||||
this.show = false;
|
||||
this.state.locking = "0";
|
||||
this.state.locking = 0;
|
||||
|
||||
|
||||
|
||||
},
|
||||
showNote() {
|
||||
if (this.state.locking == "1") {
|
||||
if (this.state.locking == 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.state.locking = "1";
|
||||
this.state.locking = 1;
|
||||
|
||||
if (this.state.lock == "0") {
|
||||
this.state.locking = "0";
|
||||
if (this.state.lock == 0) {
|
||||
this.state.locking = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -460,7 +442,7 @@ export default {
|
||||
|
||||
let storeText = storage.local.getText(this.secret.storeKey + '.text');
|
||||
if (storeText) {
|
||||
let lock = storeText.substring(0, 1);
|
||||
let lock = parseInt(storeText.substring(0, 1));
|
||||
|
||||
if (!lock) {
|
||||
alert("note is not encrypt!");
|
||||
|
||||
@@ -123,7 +123,7 @@ button span {
|
||||
<Button-group size="large">
|
||||
<Button type="error" style="margin-left:0px; border-radius: 0px;font-size: 24px;"
|
||||
@click="createNote()" icon="md-add"></Button>
|
||||
<Button type="error" style="margin-left:0px; border-radius: 0px;font-size: 24px;"
|
||||
<Button type="error" style="margin-left:5px; border-radius: 0px;font-size: 24px;"
|
||||
@click="dropNote()" icon="md-trash"></Button>
|
||||
</Button-group>
|
||||
</div>
|
||||
@@ -207,7 +207,7 @@ export default {
|
||||
escapeText: '',
|
||||
key: '',
|
||||
md5: '',
|
||||
lock: '0',
|
||||
lock: 0,
|
||||
ttl: 3600,
|
||||
ttlDesc: '',
|
||||
},
|
||||
@@ -217,9 +217,11 @@ export default {
|
||||
cipher: '',
|
||||
},
|
||||
state: {
|
||||
lock: '0',
|
||||
locking: '0',
|
||||
commited: '0'
|
||||
lock: 0,
|
||||
locking: 0,
|
||||
initTime: null,
|
||||
initTtl: null,
|
||||
commited: 0
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -230,6 +232,8 @@ export default {
|
||||
let noteMeta = storage.session.getObject(storeKey + '.noteMeta');
|
||||
if (noteMeta) {
|
||||
this.state.lock = noteMeta.lock;
|
||||
this.state.initTime = new Date().getTime();
|
||||
this.state.initTtl = noteMeta.ttl;
|
||||
this.secret.cipher = noteMeta.cipher;
|
||||
this.noteForm.md5 = noteMeta.md5;
|
||||
this.noteForm.ttl = noteMeta.ttl;
|
||||
@@ -246,24 +250,25 @@ export default {
|
||||
window.setInterval(function () {
|
||||
let ittl = parseInt(that.noteForm.ttl / 1000);
|
||||
let mins = parseInt(ittl / 60);
|
||||
if (mins < 10) {
|
||||
mins = "0" + mins;
|
||||
}
|
||||
if (mins < 0) {
|
||||
mins = "00";
|
||||
} else if (mins < 10) {
|
||||
mins = "0" + mins;
|
||||
}
|
||||
|
||||
let seds = parseInt(ittl % 60);
|
||||
if (seds < 10) {
|
||||
seds = "0" + seds;
|
||||
}
|
||||
|
||||
if (seds < 0) {
|
||||
seds = "00";
|
||||
} else if (seds < 10) {
|
||||
seds = "0" + seds;
|
||||
}
|
||||
that.noteForm.ttlDesc = mins + ":" + seds;
|
||||
that.noteForm.ttl -= 1000;
|
||||
that.noteForm.ttl = that.state.initTtl - (new Date().getTime() - that.state.initTime);
|
||||
|
||||
if (that.noteForm.ttl <= 0) {
|
||||
that.storage.local.delete(that.secret.storeKey + '.text');
|
||||
that.storage.session.delete(that.secret.storeKey + '.keyMeta');
|
||||
storage.local.delete(that.secret.storeKey + '.text');
|
||||
storage.session.delete(that.secret.storeKey + '.keyMeta');
|
||||
location.reload();
|
||||
}
|
||||
}, 1000)
|
||||
@@ -290,7 +295,7 @@ export default {
|
||||
|
||||
let password;
|
||||
|
||||
if (this.noteForm.lock == "1") {
|
||||
if (this.noteForm.lock == 1) {
|
||||
password = "123456"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user