diff --git a/js/oper.js b/js/oper.js
index 2c8cf41..4fb6585 100644
--- a/js/oper.js
+++ b/js/oper.js
@@ -256,7 +256,7 @@ $('#saveKey').click(function () {
$('#opensite').click(function () {
get_info(function (info) {
- chrome.tabs.create({ url: info.apiUrl })
+ chrome.tabs.create({url:info.apiUrl})
})
})
@@ -290,7 +290,7 @@ $('#tags').click(function () {
})
})
-$(document).on("click", "#hideTag", function () {
+$(document).on("click","#hideTag",function () {
$('#taghide').slideToggle(500)
})
@@ -311,75 +311,75 @@ $('#saveTag').click(function () {
})
$('#lock').click(function () {
- $("#lock-wrapper").toggleClass("!hidden", 1000);
+ $("#lock-wrapper").toggleClass( "!hidden", 1000 );
})
-$(document).on("click", ".item-lock", function () {
- $("#lock-wrapper").toggleClass("!hidden", 1000);
+$(document).on("click",".item-lock",function () {
+ $("#lock-wrapper").toggleClass( "!hidden", 1000 );
$("#lock-now").text($(this).text())
- _this = $(this)[0].dataset.type;
- chrome.storage.sync.set(
- { memo_lock: _this }
- )
+ _this = $(this)[0].dataset.type;
+ chrome.storage.sync.set(
+ {memo_lock: _this}
+ )
})
$('#search').click(function () {
get_info(function (info) {
- if (info.status) {
- $("#randomlist").html('').hide()
- var searchDom = ""
- const pattern = $("textarea[name=text]").val()
- if (pattern) {
- $.ajax({
- //memos+"api/"+apiV1+"memo?creatorId="+bbMemo.creatorId+"&content="+serchText+"&limit=20";
- url: info.apiUrl + "api/v1/memo",
- type: "GET",
- contentType: "application/json;",
- dataType: "json",
- headers: { 'Authorization': 'Bearer ' + info.apiTokens },
- success: function (data) {
- const options = { keys: ['content'] };
- const fuse = new Fuse(data, options);
- var searchData = fuse.search(pattern)
- for (var i = 0; i < searchData.length; i++) {
- searchDom += '
' + dayjs(new Date(searchData[i].item.createdTs) * 1000).fromNow() + '
' + searchData[i].item.content.replace(/!\[.*?\]\((.*?)\)/g, '

').replace(/\[(.*?)\]\((.*?)\)/g, '
$1 ') + '
'
- if (searchData[i].item.resourceList && searchData[i].item.resourceList.length > 0) {
- var resourceList = searchData[i].item.resourceList;
- for (var j = 0; j < resourceList.length; j++) {
- var restype = resourceList[j].type.slice(0, 5);
- var resexlink = resourceList[j].externalLink
- var resLink = '', fileId = ''
- if (resexlink) {
- resLink = resexlink
- } else {
- fileId = resourceList[j].publicId || resourceList[j].filename
- resLink = info.apiUrl + 'o/r/' + resourceList[j].id + '/' + fileId
- }
- if (restype == 'image') {
- searchDom += '

'
- }
- if (restype !== 'image') {
- searchDom += '
' + resourceList[j].filename + ''
- }
+ if (info.status) {
+ $("#randomlist").html('').hide()
+ var searchDom = ""
+ const pattern = $("textarea[name=text]").val()
+ if(pattern){
+ $.ajax({
+ //memos+"api/"+apiV1+"memo?creatorId="+bbMemo.creatorId+"&content="+serchText+"&limit=20";
+ url:info.apiUrl+"api/v1/memo",
+ type:"GET",
+ contentType:"application/json;",
+ dataType:"json",
+ headers : {'Authorization':'Bearer ' + info.apiTokens},
+ success: function(data){
+ const options = {keys: ['content']};
+ const fuse = new Fuse(data, options);
+ var searchData = fuse.search(pattern)
+ for(var i=0;i < searchData.length;i++){
+ searchDom += '
'+dayjs(new Date(searchData[i].item.createdTs)*1000).fromNow()+'
'+searchData[i].item.content.replace(/!\[.*?\]\((.*?)\)/g,'

').replace(/\[(.*?)\]\((.*?)\)/g,'
$1 ')+'
'
+ if(searchData[i].item.resourceList && searchData[i].item.resourceList.length > 0){
+ var resourceList = searchData[i].item.resourceList;
+ for(var j=0;j < resourceList.length;j++){
+ var restype = resourceList[j].type.slice(0,5);
+ var resexlink = resourceList[j].externalLink
+ var resLink = '',fileId=''
+ if(resexlink){
+ resLink = resexlink
+ }else{
+ fileId = resourceList[j].publicId || resourceList[j].filename
+ resLink = info.apiUrl+'o/r/'+resourceList[j].id+'/'+fileId
+ }
+ if(restype == 'image'){
+ searchDom += '

'
+ }
+ if(restype !== 'image'){
+ searchDom += '
'+resourceList[j].filename+''
}
}
- searchDom += '
'
}
- window.ViewImage && ViewImage.init('.random-image')
- $("#randomlist").html(searchDom).slideDown(500);
+ searchDom += '
'
}
- });
- } else {
- $.message({
- message: chrome.i18n.getMessage("searchNow")
- })
- }
- } else {
+ window.ViewImage && ViewImage.init('.random-image')
+ $("#randomlist").html(searchDom).slideDown(500);
+ }
+ });
+ }else{
$.message({
- message: chrome.i18n.getMessage("placeApiUrl")
+ message: chrome.i18n.getMessage("searchNow")
})
}
- })
+ } else {
+ $.message({
+ message: chrome.i18n.getMessage("placeApiUrl")
+ })
+ }
+})
})
$('#random').click(function () {
@@ -387,47 +387,47 @@ $('#random').click(function () {
if (info.status) {
$("#randomlist").html('').hide()
var nowTag = $("textarea[name=text]").val().match(/#([^\s#]+)/)
- if ($("#taglist").is(':visible') && nowTag[1]) {
- var tagUrl = info.apiUrl + 'api/v1/memo?rowStatus=NORMAL&tag=' + nowTag[1]
+ if( $("#taglist").is(':visible') && nowTag[1]){
+ var tagUrl = info.apiUrl+'api/v1/memo?rowStatus=NORMAL&tag='+nowTag[1]
$.ajax({
- url: tagUrl,
- type: "GET",
- contentType: "application/json;",
- dataType: "json",
- headers: { 'Authorization': 'Bearer ' + info.apiTokens },
- success: function (data) {
+ url:tagUrl,
+ type:"GET",
+ contentType:"application/json;",
+ dataType:"json",
+ headers : {'Authorization':'Bearer ' + info.apiTokens},
+ success: function(data){
let randomNum = Math.floor(Math.random() * (data.length));
var randomData = data[randomNum]
randDom(randomData)
}
})
- } else {
- var randomUrl0 = info.apiUrl + 'api/v1/memo?rowStatus=NORMAL&limit=1'
+ }else{
+ var randomUrl0 = info.apiUrl+'api/v1/memo?rowStatus=NORMAL&limit=1'
$.ajax({
- url: randomUrl0,
- type: "GET",
- contentType: "application/json;",
- dataType: "json",
- headers: { 'Authorization': 'Bearer ' + info.apiTokens },
- success: function (data0) {
+ url:randomUrl0,
+ type:"GET",
+ contentType:"application/json;",
+ dataType:"json",
+ headers : {'Authorization':'Bearer ' + info.apiTokens},
+ success: function(data0){
var creatorId = data0[0].creatorId
- var randomUrl1 = info.apiUrl + 'api/v1/memo/stats?creatorId=' + creatorId
+ var randomUrl1 = info.apiUrl+'api/v1/memo/stats?creatorId='+creatorId
$.ajax({
- url: randomUrl1,
- type: "GET",
- contentType: "application/json;",
- dataType: "json",
- headers: { 'Authorization': 'Bearer ' + info.apiTokens },
- success: function (data1) {
+ url:randomUrl1,
+ type:"GET",
+ contentType:"application/json;",
+ dataType:"json",
+ headers : {'Authorization':'Bearer ' + info.apiTokens},
+ success: function(data1){
let randomNum = Math.floor(Math.random() * (data1.length)) + 1;
- var randomUrl2 = info.apiUrl + 'api/v1/memo?rowStatus=NORMAL&limit=1&offset=' + randomNum
+ var randomUrl2 = info.apiUrl+'api/v1/memo?rowStatus=NORMAL&limit=1&offset='+randomNum
$.ajax({
- url: randomUrl2,
- type: "GET",
- contentType: "application/json;",
- dataType: "json",
- headers: { 'Authorization': 'Bearer ' + info.apiTokens },
- success: function (data2) {
+ url:randomUrl2,
+ type:"GET",
+ contentType:"application/json;",
+ dataType:"json",
+ headers : {'Authorization':'Bearer ' + info.apiTokens},
+ success: function(data2){
var randomData = data2[0]
randDom(randomData)
}
@@ -445,72 +445,72 @@ $('#random').click(function () {
})
})
-function randDom(randomData) {
+function randDom(randomData){
get_info(function (info) {
- var randomDom = '' + dayjs(new Date(randomData.createdTs * 1000)).fromNow() + '
' + randomData.content.replace(/!\[.*?\]\((.*?)\)/g, '

').replace(/\[(.*?)\]\((.*?)\)/g, '
$1 ') + '
'
- if (randomData.resourceList && randomData.resourceList.length > 0) {
- var resourceList = randomData.resourceList;
- for (var j = 0; j < resourceList.length; j++) {
- var restype = resourceList[j].type.slice(0, 5);
- var resexlink = resourceList[j].externalLink
- var resLink = '', fileId = ''
- if (resexlink) {
- resLink = resexlink
- } else {
- fileId = resourceList[j].publicId || resourceList[j].filename
- resLink = info.apiUrl + 'o/r/' + resourceList[j].id + '/' + fileId
- }
- if (restype == 'image') {
- randomDom += '

'
- }
- if (restype !== 'image') {
- randomDom += '
' + resourceList[j].filename + ''
- }
+ var randomDom = '
'+dayjs(new Date(randomData.createdTs * 1000)).fromNow()+'
'+randomData.content.replace(/!\[.*?\]\((.*?)\)/g,'

').replace(/\[(.*?)\]\((.*?)\)/g,'
$1 ')+'
'
+ if(randomData.resourceList && randomData.resourceList.length > 0){
+ var resourceList = randomData.resourceList;
+ for(var j=0;j < resourceList.length;j++){
+ var restype = resourceList[j].type.slice(0,5);
+ var resexlink = resourceList[j].externalLink
+ var resLink = '',fileId=''
+ if(resexlink){
+ resLink = resexlink
+ }else{
+ fileId = resourceList[j].publicId || resourceList[j].filename
+ resLink = info.apiUrl+'o/r/'+resourceList[j].id+'/'+fileId
+ }
+ if(restype == 'image'){
+ randomDom += '

'
+ }
+ if(restype !== 'image'){
+ randomDom += '
'+resourceList[j].filename+''
}
}
- randomDom += '
'
- window.ViewImage && ViewImage.init('.random-image')
- $("#randomlist").html(randomDom).slideDown(500);
+ }
+ randomDom += '
'
+ window.ViewImage && ViewImage.init('.random-image')
+ $("#randomlist").html(randomDom).slideDown(500);
})
}
-$(document).on("click", "#random-link", function () {
+$(document).on("click","#random-link",function () {
var memoId = $("#random-link").data('id');
get_info(function (info) {
- chrome.tabs.create({ url: info.apiUrl + "m/" + memoId })
+ chrome.tabs.create({url:info.apiUrl+"m/"+memoId})
})
})
-$(document).on("click", "#random-delete", function () {
- get_info(function (info) {
- var memosId = $("#random-delete").data('id');
- var deleteUrl = info.apiUrl + 'api/v1/memo/' + memosId
- $.ajax({
- url: deleteUrl,
- type: "PATCH",
- data: JSON.stringify({
- 'id': memosId,
- 'rowStatus': "ARCHIVED"
- }),
- contentType: "application/json;",
- dataType: "json",
- headers: { 'Authorization': 'Bearer ' + info.apiTokens },
- success: function (result) {
- $("#randomlist").html('').hide()
- $.message({
- message: chrome.i18n.getMessage("archiveSuccess")
- })
- }, error: function (err) {//清空open_action(打开时候进行的操作),同时清空open_content
- $.message({
- message: chrome.i18n.getMessage("archiveFailed")
- })
- }
- })
+$(document).on("click","#random-delete",function () {
+get_info(function (info) {
+ var memosId = $("#random-delete").data('id');
+ var deleteUrl = info.apiUrl+'api/v1/memo/'+memosId
+ $.ajax({
+ url:deleteUrl,
+ type:"PATCH",
+ data:JSON.stringify({
+ 'id': memosId,
+ 'rowStatus': "ARCHIVED"
+ }),
+ contentType:"application/json;",
+ dataType:"json",
+ headers : {'Authorization':'Bearer ' + info.apiTokens},
+ success: function(result){
+ $("#randomlist").html('').hide()
+ $.message({
+ message: chrome.i18n.getMessage("archiveSuccess")
+ })
+ },error:function(err){//清空open_action(打开时候进行的操作),同时清空open_content
+ $.message({
+ message: chrome.i18n.getMessage("archiveFailed")
+ })
+ }
})
})
+})
-$(document).on("click", ".item-container", function () {
- var tagHtml = $(this).text() + " "
+$(document).on("click",".item-container",function () {
+ var tagHtml = $(this).text()+" "
add(tagHtml);
})
@@ -521,10 +521,10 @@ $('#newtodo').click(function () {
$('#getlink').click(function () {
chrome.tabs.query({ active: true, currentWindow: true }, ([tab]) => {
- var linkHtml = " [" + tab.title + "](" + tab.url + ") "
- if (tab.url) {
+ var linkHtml = " ["+tab.title+"]("+tab.url+") "
+ if(tab.url){
add(linkHtml);
- } else {
+ }else{
$.message({
message: chrome.i18n.getMessage("getTabFailed")
})
@@ -536,13 +536,13 @@ $('#upres').click(async function () {
$('#inFile').click()
})
-$('#inFile').on('change', function (data) {
- var fileVal = $('#inFile').val();
+$('#inFile').on('change', function(data){
+ var fileVal = $('#inFile').val();
var file = null
- if (fileVal == '') {
+ if(fileVal == '') {
return;
}
- file = this.files[0];
+ file= this.files[0];
uploadImage(file)
});
@@ -550,10 +550,10 @@ function add(str) {
var tc = document.getElementById("content");
var tclen = tc.value.length;
tc.focus();
- if (typeof document.selection != "undefined") {
+ if(typeof document.selection != "undefined"){
document.selection.createRange().text = str;
- } else {
- tc.value =
+ }else{
+ tc.value =
tc.value.substr(0, tc.selectionStart) +
str +
tc.value.substring(tc.selectionStart, tclen);
@@ -566,35 +566,35 @@ $('#blog_info_edit').click(function () {
$('#content_submit_text').click(function () {
var contentVal = $("textarea[name=text]").val()
- if (contentVal) {
+ if(contentVal){
sendText()
- } else {
+ }else{
$.message({
message: chrome.i18n.getMessage("placeContent")
})
}
})
-function getOne(memosId) {
+function getOne(memosId){
get_info(function (info) {
- if (info.apiUrl) {
- $("#randomlist").html('').hide()
- var getUrl = info.apiUrl + 'api/v1/memo/' + memosId
- $.ajax({
- url: getUrl,
- type: "GET",
- contentType: "application/json;",
- dataType: "json",
- headers: { 'Authorization': 'Bearer ' + info.apiTokens },
- success: function (data) {
- randDom(data)
- }
- })
- } else {
- $.message({
- message: chrome.i18n.getMessage("placeApiUrl")
- })
- }
+ if (info.apiUrl) {
+ $("#randomlist").html('').hide()
+ var getUrl = info.apiUrl+'api/v1/memo/'+memosId
+ $.ajax({
+ url:getUrl,
+ type:"GET",
+ contentType:"application/json;",
+ dataType:"json",
+ headers : {'Authorization':'Bearer ' + info.apiTokens},
+ success: function(data){
+ randDom(data)
+ }
+ })
+ } else {
+ $.message({
+ message: chrome.i18n.getMessage("placeApiUrl")
+ })
+ }
})
}
@@ -610,47 +610,46 @@ function sendText() {
var showTag = info.showtag
var nowTag = $("textarea[name=text]").val().match(/(#[^\s#]+)/)
var sendvisi = info.memo_lock || ''
- if (nowTag) {
- if (nowTag[1] == showTag) {
+ if(nowTag){
+ if(nowTag[1] == showTag){
sendvisi = 'PUBLIC'
- } else if (nowTag[1] == hideTag) {
+ }else if(nowTag[1] == hideTag){
sendvisi = 'PRIVATE'
}
}
$.ajax({
- url: info.apiUrl + 'api/v1/memos',
- type: "POST",
- data: JSON.stringify({
+ url:info.apiUrl+'api/v1/memos',
+ type:"POST",
+ data:JSON.stringify({
'content': content,
'visibility': sendvisi,
'resourceIdList': info.resourceIdList || [],
}),
- contentType: "application/json;",
- dataType: "json",
- headers: { 'Authorization': 'Bearer ' + info.apiTokens },
- success: function (data) {
- //发送成功
- getOne(data.id)
- chrome.storage.sync.set(
- { open_action: '', open_content: '', resourceIdList: '' },
- function () {
- $.message({
- message: chrome.i18n.getMessage("memoSuccess")
- })
- //$("#content_submit_text").removeAttr('disabled');
- $("textarea[name=text]").val('')
- }
+ contentType:"application/json;",
+ dataType:"json",
+ headers : {'Authorization':'Bearer ' + info.apiTokens},
+ success: function(data){
+ //发送成功
+ getOne(data.id)
+ chrome.storage.sync.set(
+ { open_action: '', open_content: '',resourceIdList:''},
+ function () {
+ $.message({
+ message: chrome.i18n.getMessage("memoSuccess")
+ })
+ //$("#content_submit_text").removeAttr('disabled');
+ $("textarea[name=text]").val('')
+ }
)
- }, error: function (err) {//清空open_action(打开时候进行的操作),同时清空open_content
- chrome.storage.sync.set(
- { open_action: '', open_content: '', resourceIdList: '' },
- function () {
- $.message({
- message: chrome.i18n.getMessage("memoFailed")
- })
- }
- )
- },
+ },error:function(err){//清空open_action(打开时候进行的操作),同时清空open_content
+ chrome.storage.sync.set(
+ { open_action: '', open_content: '',resourceIdList:'' },
+ function () {
+ $.message({
+ message: chrome.i18n.getMessage("memoFailed")
+ })
+ }
+ )},
})
} else {
$.message({