diff --git a/css/main.css b/css/main.css index d7ba76e..3f1d138 100644 --- a/css/main.css +++ b/css/main.css @@ -140,7 +140,7 @@ input.inputer{border-bottom: 1px solid #ccc;width:75%;} justify-content: flex-start; font-family: ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace; } -.tag-list>.item-container,.visibility-list >.item-lock { +.tag-list>.item-container,.visibility-list >.item-lock,.tag-list .hidetag{ display: inline-block; background-color: #666; cursor: pointer; @@ -151,6 +151,9 @@ input.inputer{border-bottom: 1px solid #ccc;width:75%;} color: #fff; margin:0 6px 6px 0; } +.tag-list .hidetag{padding:0;float:right;} +.tag-hide{display: none;} +.tag-hide input.inputer{width:40%;font-size:11px;} .visibility-list .item-lock.lock-now{ background-color:rgb(22,163,74); @@ -167,13 +170,6 @@ input.inputer{border-bottom: 1px solid #ccc;width:75%;} justify-content: center; } - - - - - - - .tip{ margin-left: 36%; max-width: 640px; diff --git a/js/oper.js b/js/oper.js index c37caef..dbeaa01 100644 --- a/js/oper.js +++ b/js/oper.js @@ -1,7 +1,36 @@ -/** - * open_action: 打开这个页面执行的操作 - * open_text:打开这页面需要复原的输入框的内容 - */ +function get_info(callback) { + chrome.storage.sync.get( + { + apiUrl: '', + hidetag: '', + showtag: '', + memo_lock: '', + open_action: '', + open_content: '', + resourceIdList: [] + }, + function (items) { + var flag = false + var returnObject = {} + if (items.apiUrl === '' || items.repo === '') { + flag = false + } else { + flag = true + } + returnObject.status = flag + returnObject.apiUrl = items.apiUrl + returnObject.hidetag = items.hidetag + returnObject.showtag = items.showtag + returnObject.memo_lock = items.memo_lock + returnObject.open_content = items.open_content + returnObject.open_action = items.open_action + returnObject.resourceIdList = items.resourceIdList + + if (callback) callback(returnObject) + } + ) +} + get_info(function (info) { if (info.status) { //已经有绑定信息了,折叠 @@ -22,6 +51,8 @@ get_info(function (info) { $("#lock-now").text("登录用户可见") } $('#apiUrl').val(info.apiUrl) + $('#hideInput').val(info.hidetag) + $('#showInput').val(info.showtag) if (info.open_action === 'upload_image') { //打开的时候就是上传图片 uploadImage(info.open_content) @@ -214,6 +245,7 @@ $('#tags').click(function () { $.each(arrData, function(i,obj){ tagDom += '#'+obj+'' }); + tagDom += '' //console.log(tagDom) $("#taglist").html(tagDom).slideToggle(500) }); @@ -225,6 +257,26 @@ $('#tags').click(function () { }) }) +$(document).on("click","#hideTag",function () { + $('#taghide').slideToggle(500) +}) + +$('#saveTag').click(function () { + // 保存数据 + chrome.storage.sync.set( + { + hidetag: $('#hideInput').val(), + showtag: $('#showInput').val() + }, + function () { + $.message({ + message: '保存信息成功' + }) + $('#taghide').hide() + } + ) +}) + $('#lock').click(function () { $("#lock-wrapper").toggleClass( "!hidden", 1000 ); }) @@ -294,9 +346,9 @@ $('#random').click(function () { get_info(function (info) { if (info.status) { $("#randomlist").html('').hide() - var nowTag = $("textarea[name=text]").val().replace(/#([^\s#]+)/,'$1') ; - if( $("#taglist").is(':visible') && nowTag){ - var tagUrl = info.apiUrl+'&rowStatus=NORMAL&tag='+nowTag + var nowTag = $("textarea[name=text]").val().match(/#([^\s#]+)/) + if( $("#taglist").is(':visible') && nowTag[1]){ + var tagUrl = info.apiUrl+'&rowStatus=NORMAL&tag='+nowTag[1] $.get(tagUrl,function(data){ let randomNum = Math.floor(Math.random() * (data.data.length)); var randomData = data.data[randomNum] @@ -441,35 +493,6 @@ $('#blog_info_edit').click(function () { $('#blog_info').slideToggle() }) -function get_info(callback) { - chrome.storage.sync.get( - { - apiUrl: '', - memo_lock: 'Public', - open_action: '', - open_content: '', - resourceIdList: [] - }, - function (items) { - var flag = false - var returnObject = {} - if (items.apiUrl === '' || items.repo === '') { - flag = false - } else { - flag = true - } - returnObject.status = flag - returnObject.apiUrl = items.apiUrl - returnObject.memo_lock = items.memo_lock - returnObject.open_content = items.open_content - returnObject.open_action = items.open_action - returnObject.resourceIdList = items.resourceIdList - - if (callback) callback(returnObject) - } - ) -} - //发送操作 $('#content_submit_text').click(function () { var contentVal = $("textarea[name=text]").val() @@ -487,12 +510,23 @@ function sendText() { $.message({message: '发送中~~'}) //$("#content_submit_text").attr('disabled','disabled'); let content = $("textarea[name=text]").val() + 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' + } + } $.ajax({ url:info.apiUrl, type:"POST", data:JSON.stringify({ 'content': content, - 'visibility': info.memo_lock || '', + 'visibility': sendvisi, 'resourceIdList': info.resourceIdList || [], }), contentType:"application/json;", diff --git a/manifest.json b/manifest.json index 548e9e5..9c5b4cb 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "__MSG_extName__", - "version": "2023.02.26", + "version": "2023.03.05", "action": { "default_popup": "popup.html", "default_icon": "assets/logo_24x24.png", diff --git a/popup.html b/popup.html index 0842dc4..dbfc181 100644 --- a/popup.html +++ b/popup.html @@ -90,6 +90,28 @@
+
+ + + 保存 +
+