mirror of
https://github.com/Jonnyan404/memos-bber.git
synced 2026-04-25 03:58:37 +09:00
匹配 v0.22.3
This commit is contained in:
+136
-125
@@ -141,35 +141,63 @@ function initDrag() {
|
||||
}
|
||||
|
||||
let relistNow = []
|
||||
function uploadImage(data) {
|
||||
function uploadImage(file) {
|
||||
$.message({
|
||||
message: chrome.i18n.getMessage("picUploading"),
|
||||
autoClose: false
|
||||
})
|
||||
//根据data判断是图片地址还是base64加密的数据
|
||||
get_info(function (info) {
|
||||
const formData = new FormData()
|
||||
});
|
||||
const reader = new FileReader();
|
||||
reader.onload = function(e) {
|
||||
const base64String = e.target.result.split(',')[1];
|
||||
uploadImageNow(base64String, file);
|
||||
};
|
||||
reader.onerror = function(error) {
|
||||
console.error('Error reading file:', error);
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
};
|
||||
|
||||
function uploadImageNow(base64String, file) {
|
||||
get_info(function(info) {
|
||||
if (info.status) {
|
||||
let old_name = data.name.split('.');
|
||||
let file_ext = data.name.split('.').pop();
|
||||
let now = dayjs().format('YYYYMMDDHHmmss')
|
||||
let old_name = file.name.split('.');
|
||||
let file_ext = file.name.split('.').pop();
|
||||
let now = dayjs().format('YYYYMMDDHHmmss');
|
||||
let new_name = old_name[0] + '_' + now + '.' + file_ext;
|
||||
formData.append('file', data, new_name)
|
||||
var upAjaxUrl = info.apiUrl + 'api/v1/resource/blob'
|
||||
var hideTag = info.hidetag
|
||||
var showTag = info.showtag
|
||||
var nowTag = $("textarea[name=text]").val().match(/(#[^\s#]+)/)
|
||||
var sendvisi = info.memo_lock || ''
|
||||
if(nowTag){
|
||||
if(nowTag[1] == showTag){
|
||||
sendvisi = 'PUBLIC'
|
||||
}else if(nowTag[1] == hideTag){
|
||||
sendvisi = 'PRIVATE'
|
||||
}
|
||||
}
|
||||
const data = {
|
||||
content: base64String,
|
||||
visibility: sendvisi,
|
||||
filename: new_name,
|
||||
type: file.type
|
||||
};
|
||||
var upAjaxUrl = info.apiUrl + 'api/v1/resources';
|
||||
$.ajax({
|
||||
url: upAjaxUrl,
|
||||
data: formData,
|
||||
data: JSON.stringify(data),
|
||||
type: 'post',
|
||||
cache: false,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
headers: { 'Authorization': 'Bearer ' + info.apiTokens },
|
||||
success: function (data) {
|
||||
console.log(data)
|
||||
if (data.id) {
|
||||
//获取到图片
|
||||
relistNow.push(data.id)
|
||||
if (data.uid) {
|
||||
relistNow.push({
|
||||
"name":data.name,
|
||||
"uid":data.uid,
|
||||
"type":data.type
|
||||
})
|
||||
chrome.storage.sync.set(
|
||||
{
|
||||
open_action: '',
|
||||
@@ -198,13 +226,13 @@ function uploadImage(data) {
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
});
|
||||
}else {
|
||||
$.message({
|
||||
message: chrome.i18n.getMessage("placeApiUrl")
|
||||
})
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
$('#saveKey').click(function () {
|
||||
@@ -325,48 +353,52 @@ $(document).on("click",".item-lock",function () {
|
||||
|
||||
$('#search').click(function () {
|
||||
get_info(function (info) {
|
||||
const pattern = $("textarea[name=text]").val()
|
||||
var filter = "?filter=" + encodeURIComponent(`creator == 'users/${info.userid}' && visibilities == ['PUBLIC', 'PROTECTED'] && content_search == ['${pattern}']`);
|
||||
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",
|
||||
url:info.apiUrl+"api/v1/memos"+filter,
|
||||
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 += '<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){
|
||||
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
|
||||
let searchData = data.memos
|
||||
if(searchData.length == 0){
|
||||
$.message({
|
||||
message: chrome.i18n.getMessage("searchNone")
|
||||
})
|
||||
}else{
|
||||
for(var i=0;i < searchData.length;i++){
|
||||
searchDom += '<div class="random-item"><div class="random-time"><span id="random-link" data-uid="'+searchData[i].uid+'"><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-name="'+searchData[i].name+'" data-uid="'+searchData[i].uid+'"><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(searchData.createTime).fromNow()+'</div><div class="random-content">'+searchData[i].content.replace(/!\[.*?\]\((.*?)\)/g,' <img class="random-image" src="$1"/> ').replace(/\[(.*?)\]\((.*?)\)/g,' <a href="$2" target="_blank">$1</a> ')+'</div>'
|
||||
if(searchData[i].resources && searchData[i].resources.length > 0){
|
||||
var resources = searchData[i].resources;
|
||||
for(var j=0;j < resources.length;j++){
|
||||
var restype = resources[j].type.slice(0,5);
|
||||
var resexlink = resources[j].externalLink
|
||||
var resLink = '',fileId=''
|
||||
if(resexlink){
|
||||
resLink = resexlink
|
||||
}else{
|
||||
fileId = resources[j].publicId || resources[j].filename
|
||||
resLink = info.apiUrl+'file/'+resources[j].name+'/'+fileId
|
||||
}
|
||||
if(restype == 'image'){
|
||||
searchDom += '<img class="random-image" src="'+resLink+'"/>'
|
||||
}
|
||||
if(restype !== 'image'){
|
||||
searchDom += '<a target="_blank" rel="noreferrer" href="'+resLink+'">'+resourceList[j].filename+'</a>'
|
||||
if(restype == 'image'){
|
||||
searchDom += '<img class="random-image" src="'+resLink+'"/>'
|
||||
}
|
||||
if(restype !== 'image'){
|
||||
searchDom += '<a target="_blank" rel="noreferrer" href="'+resLink+'">'+resources[j].filename+'</a>'
|
||||
}
|
||||
}
|
||||
}
|
||||
searchDom += '</div>'
|
||||
}
|
||||
searchDom += '</div>'
|
||||
window.ViewImage && ViewImage.init('.random-image')
|
||||
$("#randomlist").html(searchDom).slideDown(500);
|
||||
}
|
||||
window.ViewImage && ViewImage.init('.random-image')
|
||||
$("#randomlist").html(searchDom).slideDown(500);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
@@ -384,59 +416,22 @@ $('#search').click(function () {
|
||||
|
||||
$('#random').click(function () {
|
||||
get_info(function (info) {
|
||||
var filter = "?filter=" + encodeURIComponent(`creator == 'users/${info.userid}'`);
|
||||
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]
|
||||
$.ajax({
|
||||
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'
|
||||
$.ajax({
|
||||
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
|
||||
$.ajax({
|
||||
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
|
||||
$.ajax({
|
||||
url:randomUrl2,
|
||||
type:"GET",
|
||||
contentType:"application/json;",
|
||||
dataType:"json",
|
||||
headers : {'Authorization':'Bearer ' + info.apiTokens},
|
||||
success: function(data2){
|
||||
var randomData = data2[0]
|
||||
randDom(randomData)
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
var randomUrl = info.apiUrl + 'api/v1/memos' + filter;
|
||||
$.ajax({
|
||||
url:randomUrl,
|
||||
type:"GET",
|
||||
contentType:"application/json;",
|
||||
dataType:"json",
|
||||
headers : {'Authorization':'Bearer ' + info.apiTokens},
|
||||
success: function(data){
|
||||
let randomNum = Math.floor(Math.random() * (data.memos.length));
|
||||
var randomData = data.memos[randomNum]
|
||||
randDom(randomData)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
$.message({
|
||||
message: chrome.i18n.getMessage("placeApiUrl")
|
||||
@@ -447,24 +442,24 @@ $('#random').click(function () {
|
||||
|
||||
function randDom(randomData){
|
||||
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>'
|
||||
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 randomDom = '<div class="random-item"><div class="random-time"><span id="random-link" data-uid="'+randomData.uid+'"><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-uid="'+randomData.uid+'" data-name="'+randomData.name+'"><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(randomData.createTime).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.resources && randomData.resources.length > 0){
|
||||
var resources = randomData.resources;
|
||||
for(var j=0;j < resources.length;j++){
|
||||
var restype = resources[j].type.slice(0,5);
|
||||
var resexlink = resources[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
|
||||
fileId = resources[j].publicId || resources[j].filename
|
||||
resLink = info.apiUrl+'file/'+resources[j].name+'/'+fileId
|
||||
}
|
||||
if(restype == 'image'){
|
||||
randomDom += '<img class="random-image" src="'+resLink+'"/>'
|
||||
}
|
||||
if(restype !== 'image'){
|
||||
randomDom += '<a target="_blank" rel="noreferrer" href="'+resLink+'">'+resourceList[j].filename+'</a>'
|
||||
randomDom += '<a target="_blank" rel="noreferrer" href="'+resLink+'">'+resources[j].filename+'</a>'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -475,21 +470,22 @@ function randDom(randomData){
|
||||
}
|
||||
|
||||
$(document).on("click","#random-link",function () {
|
||||
var memoId = $("#random-link").data('id');
|
||||
var memoUid = $("#random-link").data('uid');
|
||||
get_info(function (info) {
|
||||
chrome.tabs.create({url:info.apiUrl+"m/"+memoId})
|
||||
chrome.tabs.create({url:info.apiUrl+"m/"+memoUid})
|
||||
})
|
||||
})
|
||||
|
||||
$(document).on("click","#random-delete",function () {
|
||||
get_info(function (info) {
|
||||
var memosId = $("#random-delete").data('id');
|
||||
var deleteUrl = info.apiUrl+'api/v1/memo/'+memosId
|
||||
var memoUid = $("#random-delete").data('uid');
|
||||
var memosName = $("#random-delete").data('name');
|
||||
var deleteUrl = info.apiUrl+'api/v1/'+memosName
|
||||
$.ajax({
|
||||
url:deleteUrl,
|
||||
type:"PATCH",
|
||||
data:JSON.stringify({
|
||||
'id': memosId,
|
||||
'uid': memoUid,
|
||||
'rowStatus': "ARCHIVED"
|
||||
}),
|
||||
contentType:"application/json;",
|
||||
@@ -579,7 +575,7 @@ function getOne(memosId){
|
||||
get_info(function (info) {
|
||||
if (info.apiUrl) {
|
||||
$("#randomlist").html('').hide()
|
||||
var getUrl = info.apiUrl+'api/v1/memo/'+memosId
|
||||
var getUrl = info.apiUrl+'api/v1/'+memosId
|
||||
$.ajax({
|
||||
url:getUrl,
|
||||
type:"GET",
|
||||
@@ -622,24 +618,39 @@ function sendText() {
|
||||
type:"POST",
|
||||
data:JSON.stringify({
|
||||
'content': content,
|
||||
'visibility': sendvisi,
|
||||
'resourceIdList': info.resourceIdList || [],
|
||||
'visibility': sendvisi
|
||||
}),
|
||||
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('')
|
||||
}
|
||||
if(info.resourceIdList.length > 0 ){
|
||||
//匹配图片
|
||||
$.ajax({
|
||||
url:info.apiUrl+'api/v1/'+data.name+'/resources',
|
||||
type:"PATCH",
|
||||
data:JSON.stringify({
|
||||
'resources': info.resourceIdList || [],
|
||||
}),
|
||||
contentType:"application/json;",
|
||||
dataType:"json",
|
||||
headers : {'Authorization':'Bearer ' + info.apiTokens},
|
||||
success: function(res){
|
||||
getOne(data.name)
|
||||
}
|
||||
})
|
||||
}else{
|
||||
getOne(data.name)
|
||||
}
|
||||
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(
|
||||
|
||||
Reference in New Issue
Block a user