mirror of
https://github.com/Jonnyan404/memos-bber.git
synced 2026-04-25 03:58:37 +09:00
分享当前页面
This commit is contained in:
+46
-32
@@ -62,6 +62,16 @@ $(document).on("click",".item-container",function () {
|
||||
var tagHtml = $(this).text()+" "
|
||||
add(tagHtml);
|
||||
})
|
||||
$('#getlink').click(function () {
|
||||
chrome.tabs.getSelected(null, function (tab) {
|
||||
var linkHtml = " ["+tab.title+"]("+tab.url+") "
|
||||
if(tab.url){
|
||||
add(linkHtml);
|
||||
}else{
|
||||
$.message({message: '获取失败 😂'})
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
function add(str) {
|
||||
var tc = document.getElementById("content");
|
||||
@@ -107,44 +117,48 @@ function get_info(callback) {
|
||||
|
||||
//发送操作
|
||||
$('#content_submit_text').click(function () {
|
||||
sendText()
|
||||
var contentVal = $('#content').val()
|
||||
if(contentVal){
|
||||
sendText()
|
||||
}else{
|
||||
$.message({message: '写点什么,再记呗?'})
|
||||
}
|
||||
})
|
||||
function sendText() {
|
||||
get_info(function (info) {
|
||||
if (info.status) {
|
||||
//信息满足了
|
||||
$.message({message: '发送中'})
|
||||
$("#content_submit_text").attr('disabled','disabled');
|
||||
$.message({message: '发送中~~'})
|
||||
//$("#content_submit_text").attr('disabled','disabled');
|
||||
let content = $('#content').val()
|
||||
$.ajax({
|
||||
url:info.apiUrl,
|
||||
type:"POST",
|
||||
data:JSON.stringify({'content': content}),
|
||||
contentType:"application/json;",
|
||||
dataType:"json",
|
||||
success: function(result){
|
||||
//发送成功
|
||||
chrome.storage.sync.set(
|
||||
{ open_action: '', open_content: '' },
|
||||
function () {
|
||||
$.message({
|
||||
message: '发送成功!'
|
||||
})
|
||||
$("#content_submit_text").removeAttr('disabled');
|
||||
$('#content').val('')
|
||||
}
|
||||
)
|
||||
},
|
||||
error:function(err){//清空open_action(打开时候进行的操作),同时清空open_content
|
||||
chrome.storage.sync.set(
|
||||
{ open_action: '', open_content: '' },
|
||||
function () {
|
||||
$.message({
|
||||
message: '网络问题发送成功!'
|
||||
})
|
||||
}
|
||||
)},
|
||||
})
|
||||
$.ajax({
|
||||
url:info.apiUrl,
|
||||
type:"POST",
|
||||
data:JSON.stringify({'content': content}),
|
||||
contentType:"application/json;",
|
||||
dataType:"json",
|
||||
success: function(result){
|
||||
//发送成功
|
||||
chrome.storage.sync.set(
|
||||
{ open_action: '', open_content: '' },
|
||||
function () {
|
||||
$.message({
|
||||
message: '发送成功!😊'
|
||||
})
|
||||
//$("#content_submit_text").removeAttr('disabled');
|
||||
$('#content').val('')
|
||||
}
|
||||
)
|
||||
},error:function(err){//清空open_action(打开时候进行的操作),同时清空open_content
|
||||
chrome.storage.sync.set(
|
||||
{ open_action: '', open_content: '' },
|
||||
function () {
|
||||
$.message({
|
||||
message: '网络问题,发送失败!😭'
|
||||
})
|
||||
}
|
||||
)},
|
||||
})
|
||||
} else {
|
||||
$.message({
|
||||
message: '请先填写好 API 链接'
|
||||
|
||||
Reference in New Issue
Block a user