revert the formatting

This commit is contained in:
inertia
2024-06-13 19:06:32 +08:00
parent 05a1f535fe
commit 1d15a1d27b
+199 -200
View File
@@ -256,7 +256,7 @@ $('#saveKey').click(function () {
$('#opensite').click(function () { $('#opensite').click(function () {
get_info(function (info) { 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) $('#taghide').slideToggle(500)
}) })
@@ -311,75 +311,75 @@ $('#saveTag').click(function () {
}) })
$('#lock').click(function () { $('#lock').click(function () {
$("#lock-wrapper").toggleClass("!hidden", 1000); $("#lock-wrapper").toggleClass( "!hidden", 1000 );
}) })
$(document).on("click", ".item-lock", function () { $(document).on("click",".item-lock",function () {
$("#lock-wrapper").toggleClass("!hidden", 1000); $("#lock-wrapper").toggleClass( "!hidden", 1000 );
$("#lock-now").text($(this).text()) $("#lock-now").text($(this).text())
_this = $(this)[0].dataset.type; _this = $(this)[0].dataset.type;
chrome.storage.sync.set( chrome.storage.sync.set(
{ memo_lock: _this } {memo_lock: _this}
) )
}) })
$('#search').click(function () { $('#search').click(function () {
get_info(function (info) { get_info(function (info) {
if (info.status) { if (info.status) {
$("#randomlist").html('').hide() $("#randomlist").html('').hide()
var searchDom = "" var searchDom = ""
const pattern = $("textarea[name=text]").val() const pattern = $("textarea[name=text]").val()
if (pattern) { if(pattern){
$.ajax({ $.ajax({
//memos+"api/"+apiV1+"memo?creatorId="+bbMemo.creatorId+"&content="+serchText+"&limit=20"; //memos+"api/"+apiV1+"memo?creatorId="+bbMemo.creatorId+"&content="+serchText+"&limit=20";
url: info.apiUrl + "api/v1/memo", url:info.apiUrl+"api/v1/memo",
type: "GET", type:"GET",
contentType: "application/json;", contentType:"application/json;",
dataType: "json", dataType:"json",
headers: { 'Authorization': 'Bearer ' + info.apiTokens }, headers : {'Authorization':'Bearer ' + info.apiTokens},
success: function (data) { success: function(data){
const options = { keys: ['content'] }; const options = {keys: ['content']};
const fuse = new Fuse(data, options); const fuse = new Fuse(data, options);
var searchData = fuse.search(pattern) var searchData = fuse.search(pattern)
for (var i = 0; i < searchData.length; i++) { for(var i=0;i < searchData.length;i++){
searchDom += '<div class="random-item"><div class="random-time"><span id="random-link" data-id="' + searchData[i].item.id + '"><svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="32" height="32"><path d="M864 640a32 32 0 0 1 64 0v224.096A63.936 63.936 0 0 1 864.096 928H159.904A63.936 63.936 0 0 1 96 864.096V159.904C96 124.608 124.64 96 159.904 96H384a32 32 0 0 1 0 64H192.064A31.904 31.904 0 0 0 160 192.064v639.872A31.904 31.904 0 0 0 192.064 864h639.872A31.904 31.904 0 0 0 864 831.936V640zm-485.184 52.48a31.84 31.84 0 0 1-45.12-.128 31.808 31.808 0 0 1-.128-45.12L815.04 166.048l-176.128.736a31.392 31.392 0 0 1-31.584-31.744 32.32 32.32 0 0 1 31.84-32l255.232-1.056a31.36 31.36 0 0 1 31.584 31.584L924.928 388.8a32.32 32.32 0 0 1-32 31.84 31.392 31.392 0 0 1-31.712-31.584l.736-179.392L378.816 692.48z" fill="#666" data-spm-anchor-id="a313x.7781069.0.i12" class="selected"/></svg></span><span id="random-delete" data-id="' + searchData[i].item.id + '"><svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="32" height="32"><path d="M224 322.6h576c16.6 0 30-13.4 30-30s-13.4-30-30-30H224c-16.6 0-30 13.4-30 30 0 16.5 13.5 30 30 30zm66.1-144.2h443.8c16.6 0 30-13.4 30-30s-13.4-30-30-30H290.1c-16.6 0-30 13.4-30 30s13.4 30 30 30zm339.5 435.5H394.4c-16.6 0-30 13.4-30 30s13.4 30 30 30h235.2c16.6 0 30-13.4 30-30s-13.4-30-30-30z" fill="#666"/><path d="M850.3 403.9H173.7c-33 0-60 27-60 60v360c0 33 27 60 60 60h676.6c33 0 60-27 60-60v-360c0-33-27-60-60-60zm-.1 419.8l-.1.1H173.9l-.1-.1V464l.1-.1h676.2l.1.1v359.7z" fill="#666"/></svg></span>' + dayjs(new Date(searchData[i].item.createdTs) * 1000).fromNow() + '</div><div class="random-content">' + searchData[i].item.content.replace(/!\[.*?\]\((.*?)\)/g, ' <img class="random-image" src="$1"/> ').replace(/\[(.*?)\]\((.*?)\)/g, ' <a href="$2" target="_blank">$1</a> ') + '</div>' searchDom += '<div class="random-item"><div class="random-time"><span id="random-link" data-id="'+searchData[i].item.id+'"><svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="32" height="32"><path d="M864 640a32 32 0 0 1 64 0v224.096A63.936 63.936 0 0 1 864.096 928H159.904A63.936 63.936 0 0 1 96 864.096V159.904C96 124.608 124.64 96 159.904 96H384a32 32 0 0 1 0 64H192.064A31.904 31.904 0 0 0 160 192.064v639.872A31.904 31.904 0 0 0 192.064 864h639.872A31.904 31.904 0 0 0 864 831.936V640zm-485.184 52.48a31.84 31.84 0 0 1-45.12-.128 31.808 31.808 0 0 1-.128-45.12L815.04 166.048l-176.128.736a31.392 31.392 0 0 1-31.584-31.744 32.32 32.32 0 0 1 31.84-32l255.232-1.056a31.36 31.36 0 0 1 31.584 31.584L924.928 388.8a32.32 32.32 0 0 1-32 31.84 31.392 31.392 0 0 1-31.712-31.584l.736-179.392L378.816 692.48z" fill="#666" data-spm-anchor-id="a313x.7781069.0.i12" class="selected"/></svg></span><span id="random-delete" data-id="'+searchData[i].item.id+'"><svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="32" height="32"><path d="M224 322.6h576c16.6 0 30-13.4 30-30s-13.4-30-30-30H224c-16.6 0-30 13.4-30 30 0 16.5 13.5 30 30 30zm66.1-144.2h443.8c16.6 0 30-13.4 30-30s-13.4-30-30-30H290.1c-16.6 0-30 13.4-30 30s13.4 30 30 30zm339.5 435.5H394.4c-16.6 0-30 13.4-30 30s13.4 30 30 30h235.2c16.6 0 30-13.4 30-30s-13.4-30-30-30z" fill="#666"/><path d="M850.3 403.9H173.7c-33 0-60 27-60 60v360c0 33 27 60 60 60h676.6c33 0 60-27 60-60v-360c0-33-27-60-60-60zm-.1 419.8l-.1.1H173.9l-.1-.1V464l.1-.1h676.2l.1.1v359.7z" fill="#666"/></svg></span>'+dayjs(new Date(searchData[i].item.createdTs)*1000).fromNow()+'</div><div class="random-content">'+searchData[i].item.content.replace(/!\[.*?\]\((.*?)\)/g,' <img class="random-image" src="$1"/> ').replace(/\[(.*?)\]\((.*?)\)/g,' <a href="$2" target="_blank">$1</a> ')+'</div>'
if (searchData[i].item.resourceList && searchData[i].item.resourceList.length > 0) { if(searchData[i].item.resourceList && searchData[i].item.resourceList.length > 0){
var resourceList = searchData[i].item.resourceList; var resourceList = searchData[i].item.resourceList;
for (var j = 0; j < resourceList.length; j++) { for(var j=0;j < resourceList.length;j++){
var restype = resourceList[j].type.slice(0, 5); var restype = resourceList[j].type.slice(0,5);
var resexlink = resourceList[j].externalLink var resexlink = resourceList[j].externalLink
var resLink = '', fileId = '' var resLink = '',fileId=''
if (resexlink) { if(resexlink){
resLink = resexlink resLink = resexlink
} else { }else{
fileId = resourceList[j].publicId || resourceList[j].filename fileId = resourceList[j].publicId || resourceList[j].filename
resLink = info.apiUrl + 'o/r/' + resourceList[j].id + '/' + fileId resLink = info.apiUrl+'o/r/'+resourceList[j].id+'/'+fileId
} }
if (restype == 'image') { if(restype == 'image'){
searchDom += '<img class="random-image" src="' + resLink + '"/>' searchDom += '<img class="random-image" src="'+resLink+'"/>'
} }
if (restype !== 'image') { if(restype !== 'image'){
searchDom += '<a target="_blank" rel="noreferrer" href="' + resLink + '">' + resourceList[j].filename + '</a>' searchDom += '<a target="_blank" rel="noreferrer" href="'+resLink+'">'+resourceList[j].filename+'</a>'
}
} }
} }
searchDom += '</div>'
} }
window.ViewImage && ViewImage.init('.random-image') searchDom += '</div>'
$("#randomlist").html(searchDom).slideDown(500);
} }
}); window.ViewImage && ViewImage.init('.random-image')
} else { $("#randomlist").html(searchDom).slideDown(500);
$.message({ }
message: chrome.i18n.getMessage("searchNow") });
}) }else{
}
} else {
$.message({ $.message({
message: chrome.i18n.getMessage("placeApiUrl") message: chrome.i18n.getMessage("searchNow")
}) })
} }
}) } else {
$.message({
message: chrome.i18n.getMessage("placeApiUrl")
})
}
})
}) })
$('#random').click(function () { $('#random').click(function () {
@@ -387,47 +387,47 @@ $('#random').click(function () {
if (info.status) { if (info.status) {
$("#randomlist").html('').hide() $("#randomlist").html('').hide()
var nowTag = $("textarea[name=text]").val().match(/#([^\s#]+)/) var nowTag = $("textarea[name=text]").val().match(/#([^\s#]+)/)
if ($("#taglist").is(':visible') && nowTag[1]) { if( $("#taglist").is(':visible') && nowTag[1]){
var tagUrl = info.apiUrl + 'api/v1/memo?rowStatus=NORMAL&tag=' + nowTag[1] var tagUrl = info.apiUrl+'api/v1/memo?rowStatus=NORMAL&tag='+nowTag[1]
$.ajax({ $.ajax({
url: tagUrl, url:tagUrl,
type: "GET", type:"GET",
contentType: "application/json;", contentType:"application/json;",
dataType: "json", dataType:"json",
headers: { 'Authorization': 'Bearer ' + info.apiTokens }, headers : {'Authorization':'Bearer ' + info.apiTokens},
success: function (data) { success: function(data){
let randomNum = Math.floor(Math.random() * (data.length)); let randomNum = Math.floor(Math.random() * (data.length));
var randomData = data[randomNum] var randomData = data[randomNum]
randDom(randomData) randDom(randomData)
} }
}) })
} else { }else{
var randomUrl0 = info.apiUrl + 'api/v1/memo?rowStatus=NORMAL&limit=1' var randomUrl0 = info.apiUrl+'api/v1/memo?rowStatus=NORMAL&limit=1'
$.ajax({ $.ajax({
url: randomUrl0, url:randomUrl0,
type: "GET", type:"GET",
contentType: "application/json;", contentType:"application/json;",
dataType: "json", dataType:"json",
headers: { 'Authorization': 'Bearer ' + info.apiTokens }, headers : {'Authorization':'Bearer ' + info.apiTokens},
success: function (data0) { success: function(data0){
var creatorId = data0[0].creatorId 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({ $.ajax({
url: randomUrl1, url:randomUrl1,
type: "GET", type:"GET",
contentType: "application/json;", contentType:"application/json;",
dataType: "json", dataType:"json",
headers: { 'Authorization': 'Bearer ' + info.apiTokens }, headers : {'Authorization':'Bearer ' + info.apiTokens},
success: function (data1) { success: function(data1){
let randomNum = Math.floor(Math.random() * (data1.length)) + 1; 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({ $.ajax({
url: randomUrl2, url:randomUrl2,
type: "GET", type:"GET",
contentType: "application/json;", contentType:"application/json;",
dataType: "json", dataType:"json",
headers: { 'Authorization': 'Bearer ' + info.apiTokens }, headers : {'Authorization':'Bearer ' + info.apiTokens},
success: function (data2) { success: function(data2){
var randomData = data2[0] var randomData = data2[0]
randDom(randomData) randDom(randomData)
} }
@@ -445,72 +445,72 @@ $('#random').click(function () {
}) })
}) })
function randDom(randomData) { function randDom(randomData){
get_info(function (info) { get_info(function (info) {
var randomDom = '<div class="random-item"><div class="random-time"><span id="random-link" data-id="' + randomData.id + '"><svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="32" height="32"><path d="M864 640a32 32 0 0 1 64 0v224.096A63.936 63.936 0 0 1 864.096 928H159.904A63.936 63.936 0 0 1 96 864.096V159.904C96 124.608 124.64 96 159.904 96H384a32 32 0 0 1 0 64H192.064A31.904 31.904 0 0 0 160 192.064v639.872A31.904 31.904 0 0 0 192.064 864h639.872A31.904 31.904 0 0 0 864 831.936V640zm-485.184 52.48a31.84 31.84 0 0 1-45.12-.128 31.808 31.808 0 0 1-.128-45.12L815.04 166.048l-176.128.736a31.392 31.392 0 0 1-31.584-31.744 32.32 32.32 0 0 1 31.84-32l255.232-1.056a31.36 31.36 0 0 1 31.584 31.584L924.928 388.8a32.32 32.32 0 0 1-32 31.84 31.392 31.392 0 0 1-31.712-31.584l.736-179.392L378.816 692.48z" fill="#666" data-spm-anchor-id="a313x.7781069.0.i12" class="selected"/></svg></span><span id="random-delete" data-id="' + randomData.id + '"><svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="32" height="32"><path d="M224 322.6h576c16.6 0 30-13.4 30-30s-13.4-30-30-30H224c-16.6 0-30 13.4-30 30 0 16.5 13.5 30 30 30zm66.1-144.2h443.8c16.6 0 30-13.4 30-30s-13.4-30-30-30H290.1c-16.6 0-30 13.4-30 30s13.4 30 30 30zm339.5 435.5H394.4c-16.6 0-30 13.4-30 30s13.4 30 30 30h235.2c16.6 0 30-13.4 30-30s-13.4-30-30-30z" fill="#666"/><path d="M850.3 403.9H173.7c-33 0-60 27-60 60v360c0 33 27 60 60 60h676.6c33 0 60-27 60-60v-360c0-33-27-60-60-60zm-.1 419.8l-.1.1H173.9l-.1-.1V464l.1-.1h676.2l.1.1v359.7z" fill="#666"/></svg></span>' + dayjs(new Date(randomData.createdTs * 1000)).fromNow() + '</div><div class="random-content">' + randomData.content.replace(/!\[.*?\]\((.*?)\)/g, ' <img class="random-image" src="$1"/> ').replace(/\[(.*?)\]\((.*?)\)/g, ' <a href="$2" target="_blank">$1</a> ') + '</div>' var randomDom = '<div class="random-item"><div class="random-time"><span id="random-link" data-id="'+randomData.id+'"><svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="32" height="32"><path d="M864 640a32 32 0 0 1 64 0v224.096A63.936 63.936 0 0 1 864.096 928H159.904A63.936 63.936 0 0 1 96 864.096V159.904C96 124.608 124.64 96 159.904 96H384a32 32 0 0 1 0 64H192.064A31.904 31.904 0 0 0 160 192.064v639.872A31.904 31.904 0 0 0 192.064 864h639.872A31.904 31.904 0 0 0 864 831.936V640zm-485.184 52.48a31.84 31.84 0 0 1-45.12-.128 31.808 31.808 0 0 1-.128-45.12L815.04 166.048l-176.128.736a31.392 31.392 0 0 1-31.584-31.744 32.32 32.32 0 0 1 31.84-32l255.232-1.056a31.36 31.36 0 0 1 31.584 31.584L924.928 388.8a32.32 32.32 0 0 1-32 31.84 31.392 31.392 0 0 1-31.712-31.584l.736-179.392L378.816 692.48z" fill="#666" data-spm-anchor-id="a313x.7781069.0.i12" class="selected"/></svg></span><span id="random-delete" data-id="'+randomData.id+'"><svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="32" height="32"><path d="M224 322.6h576c16.6 0 30-13.4 30-30s-13.4-30-30-30H224c-16.6 0-30 13.4-30 30 0 16.5 13.5 30 30 30zm66.1-144.2h443.8c16.6 0 30-13.4 30-30s-13.4-30-30-30H290.1c-16.6 0-30 13.4-30 30s13.4 30 30 30zm339.5 435.5H394.4c-16.6 0-30 13.4-30 30s13.4 30 30 30h235.2c16.6 0 30-13.4 30-30s-13.4-30-30-30z" fill="#666"/><path d="M850.3 403.9H173.7c-33 0-60 27-60 60v360c0 33 27 60 60 60h676.6c33 0 60-27 60-60v-360c0-33-27-60-60-60zm-.1 419.8l-.1.1H173.9l-.1-.1V464l.1-.1h676.2l.1.1v359.7z" fill="#666"/></svg></span>'+dayjs(new Date(randomData.createdTs * 1000)).fromNow()+'</div><div class="random-content">'+randomData.content.replace(/!\[.*?\]\((.*?)\)/g,' <img class="random-image" src="$1"/> ').replace(/\[(.*?)\]\((.*?)\)/g,' <a href="$2" target="_blank">$1</a> ')+'</div>'
if (randomData.resourceList && randomData.resourceList.length > 0) { if(randomData.resourceList && randomData.resourceList.length > 0){
var resourceList = randomData.resourceList; var resourceList = randomData.resourceList;
for (var j = 0; j < resourceList.length; j++) { for(var j=0;j < resourceList.length;j++){
var restype = resourceList[j].type.slice(0, 5); var restype = resourceList[j].type.slice(0,5);
var resexlink = resourceList[j].externalLink var resexlink = resourceList[j].externalLink
var resLink = '', fileId = '' var resLink = '',fileId=''
if (resexlink) { if(resexlink){
resLink = resexlink resLink = resexlink
} else { }else{
fileId = resourceList[j].publicId || resourceList[j].filename fileId = resourceList[j].publicId || resourceList[j].filename
resLink = info.apiUrl + 'o/r/' + resourceList[j].id + '/' + fileId resLink = info.apiUrl+'o/r/'+resourceList[j].id+'/'+fileId
} }
if (restype == 'image') { if(restype == 'image'){
randomDom += '<img class="random-image" src="' + resLink + '"/>' randomDom += '<img class="random-image" src="'+resLink+'"/>'
} }
if (restype !== 'image') { if(restype !== 'image'){
randomDom += '<a target="_blank" rel="noreferrer" href="' + resLink + '">' + resourceList[j].filename + '</a>' randomDom += '<a target="_blank" rel="noreferrer" href="'+resLink+'">'+resourceList[j].filename+'</a>'
}
} }
} }
randomDom += '</div>' }
window.ViewImage && ViewImage.init('.random-image') randomDom += '</div>'
$("#randomlist").html(randomDom).slideDown(500); 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'); var memoId = $("#random-link").data('id');
get_info(function (info) { 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 () { $(document).on("click","#random-delete",function () {
get_info(function (info) { get_info(function (info) {
var memosId = $("#random-delete").data('id'); var memosId = $("#random-delete").data('id');
var deleteUrl = info.apiUrl + 'api/v1/memo/' + memosId var deleteUrl = info.apiUrl+'api/v1/memo/'+memosId
$.ajax({ $.ajax({
url: deleteUrl, url:deleteUrl,
type: "PATCH", type:"PATCH",
data: JSON.stringify({ data:JSON.stringify({
'id': memosId, 'id': memosId,
'rowStatus': "ARCHIVED" 'rowStatus': "ARCHIVED"
}), }),
contentType: "application/json;", contentType:"application/json;",
dataType: "json", dataType:"json",
headers: { 'Authorization': 'Bearer ' + info.apiTokens }, headers : {'Authorization':'Bearer ' + info.apiTokens},
success: function (result) { success: function(result){
$("#randomlist").html('').hide() $("#randomlist").html('').hide()
$.message({ $.message({
message: chrome.i18n.getMessage("archiveSuccess") message: chrome.i18n.getMessage("archiveSuccess")
}) })
}, error: function (err) {//清空open_action(打开时候进行的操作),同时清空open_content },error:function(err){//清空open_action(打开时候进行的操作),同时清空open_content
$.message({ $.message({
message: chrome.i18n.getMessage("archiveFailed") message: chrome.i18n.getMessage("archiveFailed")
}) })
} }
})
}) })
}) })
})
$(document).on("click", ".item-container", function () { $(document).on("click",".item-container",function () {
var tagHtml = $(this).text() + " " var tagHtml = $(this).text()+" "
add(tagHtml); add(tagHtml);
}) })
@@ -521,10 +521,10 @@ $('#newtodo').click(function () {
$('#getlink').click(function () { $('#getlink').click(function () {
chrome.tabs.query({ active: true, currentWindow: true }, ([tab]) => { chrome.tabs.query({ active: true, currentWindow: true }, ([tab]) => {
var linkHtml = " [" + tab.title + "](" + tab.url + ") " var linkHtml = " ["+tab.title+"]("+tab.url+") "
if (tab.url) { if(tab.url){
add(linkHtml); add(linkHtml);
} else { }else{
$.message({ $.message({
message: chrome.i18n.getMessage("getTabFailed") message: chrome.i18n.getMessage("getTabFailed")
}) })
@@ -536,13 +536,13 @@ $('#upres').click(async function () {
$('#inFile').click() $('#inFile').click()
}) })
$('#inFile').on('change', function (data) { $('#inFile').on('change', function(data){
var fileVal = $('#inFile').val(); var fileVal = $('#inFile').val();
var file = null var file = null
if (fileVal == '') { if(fileVal == '') {
return; return;
} }
file = this.files[0]; file= this.files[0];
uploadImage(file) uploadImage(file)
}); });
@@ -550,9 +550,9 @@ function add(str) {
var tc = document.getElementById("content"); var tc = document.getElementById("content");
var tclen = tc.value.length; var tclen = tc.value.length;
tc.focus(); tc.focus();
if (typeof document.selection != "undefined") { if(typeof document.selection != "undefined"){
document.selection.createRange().text = str; document.selection.createRange().text = str;
} else { }else{
tc.value = tc.value =
tc.value.substr(0, tc.selectionStart) + tc.value.substr(0, tc.selectionStart) +
str + str +
@@ -566,35 +566,35 @@ $('#blog_info_edit').click(function () {
$('#content_submit_text').click(function () { $('#content_submit_text').click(function () {
var contentVal = $("textarea[name=text]").val() var contentVal = $("textarea[name=text]").val()
if (contentVal) { if(contentVal){
sendText() sendText()
} else { }else{
$.message({ $.message({
message: chrome.i18n.getMessage("placeContent") message: chrome.i18n.getMessage("placeContent")
}) })
} }
}) })
function getOne(memosId) { function getOne(memosId){
get_info(function (info) { get_info(function (info) {
if (info.apiUrl) { if (info.apiUrl) {
$("#randomlist").html('').hide() $("#randomlist").html('').hide()
var getUrl = info.apiUrl + 'api/v1/memo/' + memosId var getUrl = info.apiUrl+'api/v1/memo/'+memosId
$.ajax({ $.ajax({
url: getUrl, url:getUrl,
type: "GET", type:"GET",
contentType: "application/json;", contentType:"application/json;",
dataType: "json", dataType:"json",
headers: { 'Authorization': 'Bearer ' + info.apiTokens }, headers : {'Authorization':'Bearer ' + info.apiTokens},
success: function (data) { success: function(data){
randDom(data) randDom(data)
} }
}) })
} else { } else {
$.message({ $.message({
message: chrome.i18n.getMessage("placeApiUrl") message: chrome.i18n.getMessage("placeApiUrl")
}) })
} }
}) })
} }
@@ -610,47 +610,46 @@ function sendText() {
var showTag = info.showtag var showTag = info.showtag
var nowTag = $("textarea[name=text]").val().match(/(#[^\s#]+)/) var nowTag = $("textarea[name=text]").val().match(/(#[^\s#]+)/)
var sendvisi = info.memo_lock || '' var sendvisi = info.memo_lock || ''
if (nowTag) { if(nowTag){
if (nowTag[1] == showTag) { if(nowTag[1] == showTag){
sendvisi = 'PUBLIC' sendvisi = 'PUBLIC'
} else if (nowTag[1] == hideTag) { }else if(nowTag[1] == hideTag){
sendvisi = 'PRIVATE' sendvisi = 'PRIVATE'
} }
} }
$.ajax({ $.ajax({
url: info.apiUrl + 'api/v1/memos', url:info.apiUrl+'api/v1/memos',
type: "POST", type:"POST",
data: JSON.stringify({ data:JSON.stringify({
'content': content, 'content': content,
'visibility': sendvisi, 'visibility': sendvisi,
'resourceIdList': info.resourceIdList || [], 'resourceIdList': info.resourceIdList || [],
}), }),
contentType: "application/json;", contentType:"application/json;",
dataType: "json", dataType:"json",
headers: { 'Authorization': 'Bearer ' + info.apiTokens }, headers : {'Authorization':'Bearer ' + info.apiTokens},
success: function (data) { success: function(data){
//发送成功 //发送成功
getOne(data.id) getOne(data.id)
chrome.storage.sync.set( chrome.storage.sync.set(
{ open_action: '', open_content: '', resourceIdList: '' }, { open_action: '', open_content: '',resourceIdList:''},
function () { function () {
$.message({ $.message({
message: chrome.i18n.getMessage("memoSuccess") message: chrome.i18n.getMessage("memoSuccess")
}) })
//$("#content_submit_text").removeAttr('disabled'); //$("#content_submit_text").removeAttr('disabled');
$("textarea[name=text]").val('') $("textarea[name=text]").val('')
} }
) )
}, error: function (err) {//清空open_action(打开时候进行的操作),同时清空open_content },error:function(err){//清空open_action(打开时候进行的操作),同时清空open_content
chrome.storage.sync.set( chrome.storage.sync.set(
{ open_action: '', open_content: '', resourceIdList: '' }, { open_action: '', open_content: '',resourceIdList:'' },
function () { function () {
$.message({ $.message({
message: chrome.i18n.getMessage("memoFailed") message: chrome.i18n.getMessage("memoFailed")
}) })
} }
) )},
},
}) })
} else { } else {
$.message({ $.message({