From 7950042eb6146bdc901855b042d4d7f24df493ed Mon Sep 17 00:00:00 2001 From: Cutls Date: Fri, 8 Mar 2019 03:19:26 +0900 Subject: [PATCH] add theme and fix for macOS --- app/css/master.css | 4 + app/css/pickr.css | 1 + app/js/emoji/default-emoji.js | 2 +- app/js/lang/lang.en.js | 1 + app/js/lang/lang.ja.js | 1 + app/js/login/login.js | 12 +- app/js/login/manager.js | 20 +-- app/js/platform/end.js | 7 +- app/js/platform/first.js | 76 +++++++++++ app/js/platform/pickr.js | 2 + app/js/post/bb-md.js | 4 +- app/js/post/emoji.js | 2 +- app/js/post/img.js | 6 +- app/js/post/misskeystatus.js | 16 +-- app/js/post/post.js | 14 +-- app/js/post/status.js | 42 +++---- app/js/tl/card.js | 2 +- app/js/tl/datails.js | 16 ++- app/js/tl/date.js | 10 +- app/js/tl/dm.js | 3 - app/js/tl/filter.js | 8 +- app/js/tl/list.js | 12 +- app/js/tl/notification.js | 8 +- app/js/tl/parse.js | 21 ++-- app/js/tl/poll.js | 2 +- app/js/tl/src.js | 2 +- app/js/tl/tl.js | 4 +- app/js/ui/img.js | 6 +- app/js/ui/layout.js | 2 +- app/js/ui/scroll.js | 2 +- app/js/ui/settings.js | 168 ++++++++++++++++++++++--- app/js/ui/theme.js | 6 + app/js/userdata/prof-edit.js | 8 +- app/js/userdata/showOnTL.js | 2 +- app/language.js | 16 ++- app/main.js | 94 +++++++++++++- app/nano.html | 4 +- app/package-lock.json | 19 ++- app/package.json | 3 +- app/view/en/index.html | 4 +- app/view/en/setting.html | 88 ++++++++++--- app/view/ja/index.html | 4 +- app/view/ja/setting.html | 88 ++++++++++--- app/view/make/language/setting.en.json | 12 ++ app/view/make/language/setting.ja.json | 13 ++ app/view/make/setting.sample.html | 86 +++++++++++-- app/view/ps/index.html | 4 +- app/view/ps/setting.html | 88 ++++++++++--- 48 files changed, 814 insertions(+), 201 deletions(-) create mode 100644 app/css/pickr.css create mode 100644 app/js/platform/pickr.js diff --git a/app/css/master.css b/app/css/master.css index f9a2b862..39045d7e 100644 --- a/app/css/master.css +++ b/app/css/master.css @@ -298,6 +298,10 @@ blockquote:before, .quote:before { border-color:var(--color); padding:5px; } +#pickers{ + display:flex; + flex-wrap: wrap; +} /*スクロールバー*/ diff --git a/app/css/pickr.css b/app/css/pickr.css new file mode 100644 index 00000000..8fbd6027 --- /dev/null +++ b/app/css/pickr.css @@ -0,0 +1 @@ +.pickr{position:relative;overflow:visible;z-index:1}.pickr *{box-sizing:border-box}.pickr button,.pickr input{outline:none;border:none}.pickr button:focus,.pickr input:focus{box-shadow:0 0 0 1px #f1f3f4,0 0 0 3px currentColor}.pickr .pcr-button{position:relative;height:2em;width:2em;padding:.5em;border-radius:.15em;cursor:pointer;background:currentColor;transition:all .3s;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif}.pickr .pcr-button:before{background:url('data:image/svg+xml;utf8, ');background-size:.5em;border-radius:.15em;z-index:-1}.pickr .pcr-button:after,.pickr .pcr-button:before{position:absolute;content:"";top:0;left:0;width:100%;height:100%}.pickr .pcr-button:after{background:url('data:image/svg+xml;utf8, ') no-repeat 50%;background-size:70%;opacity:0}.pickr .pcr-button.clear{background:hsla(0,0%,100%,.25)}.pickr .pcr-button.clear:after{opacity:1}.pickr .pcr-button.clear:focus{box-shadow:0 0 0 1px #f1f3f4,0 0 0 3px #75797e}.pickr .pcr-button.disabled{cursor:not-allowed}.pcr-app{margin-top: 10px;display:flex;flex-direction:column;z-index:10000;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;box-shadow:0 .15em 1.5em 0 rgba(0,0,0,.1),0 0 1em 0 rgba(0,0,0,.03);top:5px;height:15em;width:28.5em;max-width:95vw;padding:.8em;border-radius:.1em;opacity:0;visibility:hidden;transition:opacity .3s}.pcr-app.visible{visibility:visible;opacity:1}.pcr-app .swatches{display:flex;flex-wrap:wrap;margin-top:.75em}@supports (display:grid){.pcr-app .swatches{display:grid;align-items:center;justify-content:space-around;grid-template-columns:repeat(auto-fit,1.75em)}}.pcr-app .swatches>button{position:relative;width:1.75em;height:1.75em;border-radius:.15em;cursor:pointer;margin:2.5px;flex-shrink:0;justify-self:center;transition:all .15s;overflow:hidden;background:transparent;z-index:1}.pcr-app .swatches>button:before{position:absolute;content:"";top:0;left:0;width:100%;height:100%;background:url('data:image/svg+xml;utf8, ');background-size:6px;border-radius:.15em;z-index:-1}.pcr-app .swatches>button:after{content:"";position:absolute;top:0;left:0;width:100%;height:100%;background:currentColor;border:1px solid rgba(0,0,0,.05);border-radius:.15em;box-sizing:border-box}.pcr-app .swatches>button:hover{filter:brightness(1.05)}.pcr-app .pcr-interaction{display:flex;align-items:center;margin:.75em -.2em 0}.pcr-app .pcr-interaction>*{margin:0 .2em}.pcr-app .pcr-interaction input{letter-spacing:.07em;font-size:.75em;text-align:center;cursor:pointer;color:#75797e;background:#f1f3f4;border-radius:.15em;transition:all .15s;padding:.45em .5em}.pcr-app .pcr-interaction input:hover{filter:brightness(.975)}.pcr-app .pcr-interaction input:focus{box-shadow:0 0 0 1px #f1f3f4,0 0 0 3px rgba(66,133,244,.75)}.pcr-app .pcr-interaction .pcr-result{color:#75797e;text-align:left;flex-grow:1;min-width:1em;transition:all .2s;border-radius:.15em;background:#f1f3f4;cursor:text}.pcr-app .pcr-interaction .pcr-result::selection{background:#4285f4;color:#fff}.pcr-app .pcr-interaction .pcr-type.active{color:#fff;background:#4285f4}.pcr-app .pcr-interaction .pcr-clear,.pcr-app .pcr-interaction .pcr-save{width:auto;color:#fff}.pcr-app .pcr-interaction .pcr-clear:hover,.pcr-app .pcr-interaction .pcr-save:hover{filter:brightness(.925)}.pcr-app .pcr-interaction .pcr-save{background:#4285f4}.pcr-app .pcr-interaction .pcr-clear{background:#f44250}.pcr-app .pcr-interaction .pcr-clear:focus{box-shadow:0 0 0 1px #f1f3f4,0 0 0 3px rgba(244,66,80,.75)}.pcr-app .pcr-selection{display:flex;justify-content:space-between;flex-grow:1}.pcr-app .pcr-selection .pcr-picker{position:absolute;height:18px;width:18px;border:2px solid #fff;border-radius:100%;user-select:none;cursor:-moz-grab;cursor:-webkit-grabbing}.pcr-app .pcr-selection .pcr-color-preview{position:relative;z-index:1;width:2em;display:flex;flex-direction:column;justify-content:space-between;margin-right:.75em}.pcr-app .pcr-selection .pcr-color-preview:before{position:absolute;content:"";top:0;left:0;width:100%;height:100%;background:url('data:image/svg+xml;utf8, ');background-size:.5em;border-radius:.15em;z-index:-1}.pcr-app .pcr-selection .pcr-color-preview .pcr-last-color{cursor:pointer;transition:background-color .3s,box-shadow .3s;border-radius:.15em .15em 0 0;z-index:2}.pcr-app .pcr-selection .pcr-color-preview .pcr-current-color{border-radius:0 0 .15em .15em}.pcr-app .pcr-selection .pcr-color-preview .pcr-current-color,.pcr-app .pcr-selection .pcr-color-preview .pcr-last-color{background:currentColor;width:100%;height:50%}.pcr-app .pcr-selection .pcr-color-chooser,.pcr-app .pcr-selection .pcr-color-opacity,.pcr-app .pcr-selection .pcr-color-palette{position:relative;user-select:none;display:flex;flex-direction:column}.pcr-app .pcr-selection .pcr-color-palette{width:100%;z-index:1}.pcr-app .pcr-selection .pcr-color-palette .pcr-palette{height:100%;border-radius:.15em}.pcr-app .pcr-selection .pcr-color-palette .pcr-palette:before{position:absolute;content:"";top:0;left:0;width:100%;height:100%;background:url('data:image/svg+xml;utf8, ');background-size:.5em;border-radius:.15em;z-index:-1}.pcr-app .pcr-selection .pcr-color-chooser,.pcr-app .pcr-selection .pcr-color-opacity{margin-left:.75em}.pcr-app .pcr-selection .pcr-color-chooser .pcr-picker,.pcr-app .pcr-selection .pcr-color-opacity .pcr-picker{left:50%;transform:translateX(-50%)}.pcr-app .pcr-selection .pcr-color-chooser .pcr-slider,.pcr-app .pcr-selection .pcr-color-opacity .pcr-slider{width:8px;height:100%;border-radius:50em}.pcr-app .pcr-selection .pcr-color-chooser .pcr-slider{background:linear-gradient(180deg,red,#ff0,#0f0,#0ff,#00f,#f0f,red)}.pcr-app .pcr-selection .pcr-color-opacity .pcr-slider{background:linear-gradient(180deg,transparent,#000),url('data:image/svg+xml;utf8, ');background-size:100%,50%} \ No newline at end of file diff --git a/app/js/emoji/default-emoji.js b/app/js/emoji/default-emoji.js index 84ea9ecb..8c227803 100644 --- a/app/js/emoji/default-emoji.js +++ b/app/js/emoji/default-emoji.js @@ -70,7 +70,7 @@ function defEmoji(target){ $("#textarea").focus(); var selin = $("#textarea").prop('selectionStart'); if(!selin){ - selin=0; + selin=0; } localStorage.setItem("cursor", selin); } diff --git a/app/js/lang/lang.en.js b/app/js/lang/lang.en.js index 1165fbde..fba697ba 100644 --- a/app/js/lang/lang.en.js +++ b/app/js/lang/lang.en.js @@ -177,6 +177,7 @@ var lang={ "lang_parse_voted":"Voted", "lang_parse_vote":"Voted", "lang_parse_unvoted":"Show the result without voting", + "lang_parse_endedvote":"Expired", //misskey "lang_misskeyparse_renote":"Repost", "lang_misskeyparse_renoteqt":"Renote", diff --git a/app/js/lang/lang.ja.js b/app/js/lang/lang.ja.js index 73c1dcde..c6e8e855 100644 --- a/app/js/lang/lang.ja.js +++ b/app/js/lang/lang.ja.js @@ -178,6 +178,7 @@ var lang={ "lang_parse_voted":"投票済みです", "lang_parse_vote":"投票", "lang_parse_unvoted":"結果だけ見る", + "lang_parse_endedvote":"終了済み", //misskey "lang_misskeyparse_renote":"再投稿", "lang_misskeyparse_renoteqt":"引用", diff --git a/app/js/login/login.js b/app/js/login/login.js index cc21e28a..811eef26 100644 --- a/app/js/login/login.js +++ b/app/js/login/login.js @@ -11,9 +11,9 @@ function ck() { if(!main){ localStorage.setItem("main",0) } - var domain = localStorage.getItem("domain_0"); + var domainz = localStorage.getItem("domain_0"); var at = localStorage.getItem("acct_0_at"); - var oldat = localStorage.getItem(domain + "_at"); + var oldat = localStorage.getItem(domainz + "_at"); if(oldat){ console.log("Move to New Account Management System") var multi = localStorage.getItem("multi"); @@ -77,7 +77,7 @@ function login(url) { var httpreq = new XMLHttpRequest(); httpreq.open('POST', start, true); httpreq.setRequestHeader('Content-Type', 'application/json'); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(JSON.stringify({ scopes: 'read write follow', client_name: "TheDesk(PC)", @@ -85,7 +85,7 @@ function login(url) { website: "https://thedesk.top" })); httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { var json = httpreq.response; console.log(json); var auth = "https://" + url + "/oauth/authorize?client_id=" + json[ @@ -96,9 +96,7 @@ function login(url) { localStorage.setItem("client_secret", json["client_secret"]); $("#auth").show(); $("#masara").hide(); - const { - shell - } = require('electron'); + const { shell } = require('electron'); shell.openExternal(auth); diff --git a/app/js/login/manager.js b/app/js/login/manager.js index 29cba80a..a3a8ee31 100644 --- a/app/js/login/manager.js +++ b/app/js/login/manager.js @@ -286,7 +286,7 @@ function login(url) { var httpreq = new XMLHttpRequest(); httpreq.open('POST', start, true); httpreq.setRequestHeader('Content-Type', 'application/json'); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(JSON.stringify({ scopes: 'read write follow', client_name: "TheDesk(PC)", @@ -294,7 +294,7 @@ function login(url) { website: "https://thedesk.top" })); httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { var json = httpreq.response; console.log(json); localStorage.setItem("msky","false"); @@ -332,7 +332,7 @@ function misskeyLogin(url) { var httpreq = new XMLHttpRequest(); httpreq.open('POST', start, true); httpreq.setRequestHeader('Content-Type', 'application/json'); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; localStorage.setItem("msky","true"); if(url=="misskey.xyz" && misskeytoken){ var mkc=misskeytoken; @@ -362,7 +362,7 @@ function misskeyLogin(url) { appSecret: mkc })); httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { var json = httpreq.response; console.log(json); const { @@ -407,13 +407,13 @@ function code(code) { var httpreq = new XMLHttpRequest(); httpreq.open('POST', start, true); httpreq.setRequestHeader('Content-Type', 'application/json'); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(JSON.stringify({ token:code, appSecret:localStorage.getItem("mkc") })); httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { var json = httpreq.response; var i = sha256(json.accessToken + localStorage.getItem("mkc")); console.log(json); @@ -454,7 +454,7 @@ function code(code) { var httpreq = new XMLHttpRequest(); httpreq.open('POST', start, true); httpreq.setRequestHeader('Content-Type', 'application/json'); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(JSON.stringify({ grant_type: "authorization_code", redirect_uri: "https://thedesk.top/hello.html", @@ -463,7 +463,7 @@ function code(code) { code: code })); httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { var json = httpreq.response; console.log(json); if (json["access_token"]) { @@ -595,13 +595,13 @@ function misskeyRefresh(obj,target,url){ var httpreq = new XMLHttpRequest(); httpreq.open('POST', start, true); httpreq.setRequestHeader('Content-Type', 'application/json'); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(JSON.stringify({ username:obj[target].user, i:localStorage.getItem("at") })); httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { var json = httpreq.response; console.log(json); return; diff --git a/app/js/platform/end.js b/app/js/platform/end.js index 8dc28f14..41ef4583 100644 --- a/app/js/platform/end.js +++ b/app/js/platform/end.js @@ -58,9 +58,7 @@ //hrefがhttp/httpsならブラウザで if(urls){ if (urls[0]) { - const { - shell - } = require('electron'); + const {shell} = require('electron'); if(~url.indexOf("thedeks.top")){ //alert("If you recieve this alert, let the developer(Cutls@kirishima.cloud) know it with a screenshot."); url="https://thedesk.top"; @@ -81,8 +79,7 @@ //よく使うライブラリ /*マルチバイト用切り出し*/ $.isSurrogatePear = function(upper, lower) { - return 0xD800 <= upper && upper <= 0xDBFF && 0xDC00 <= lower && lower <= - 0xDFFF; + return 0xD800 <= upper && upper <= 0xDBFF && 0xDC00 <= lower && lower <= 0xDFFF; }; $.mb_strlen = function(str) { var ret = 0; diff --git a/app/js/platform/first.js b/app/js/platform/first.js index 47b34426..0b96aec1 100644 --- a/app/js/platform/first.js +++ b/app/js/platform/first.js @@ -81,4 +81,80 @@ function formattimeutc(date){ str=str+date.getUTCMinutes() } return str; +} +var electron = require("electron"); +var ipc = electron.ipcRenderer; +ipc.send('custom-css-request', ""); +ipc.on('custom-css-response', function (event, arg) { + if(arg==""){ return false; } + var styleNode = document.createElement("style"); + styleNode.setAttribute("type","text/css") + + var content = document.createTextNode(arg) + styleNode.append(content) + document.getElementsByTagName("head")[0].append(styleNode) +}) +ipc.on('theme-css-response', function (event, arg) { + if(arg==""){ return false; } + var styleNode = document.createElement("style"); + styleNode.setAttribute("type","text/css") + + var content = document.createTextNode(arg) + styleNode.append(content) + document.getElementsByTagName("head")[0].append(styleNode) +}) +function makeCID(){ + return randomStr(8)+"-"+randomStr(4)+"-"+randomStr(4)+"-"+randomStr(4)+"-"+randomStr(12); +} +function randomStr(l){ + // 生成する文字列に含める文字セット + var c = "abcdefghijklmnopqrstuvwxyz0123456789"; + var cl = c.length; + var r = ""; + for(var i=0; i4&&void 0!==arguments[4]?arguments[4]:{};return e instanceof HTMLCollection||e instanceof NodeList?e=Array.from(e):Array.isArray(e)||(e=[e]),Array.isArray(o)||(o=[o]),e.forEach(e=>o.forEach(o=>e[t](o,i,function(t){for(var e=1;e1&&void 0!==arguments[1]?arguments[1]:{};const n=c(e,"data-con"),i=c(e,"data-key");i&&(o[i]=e);const s=Array.from(e.children),r=n?o[n]={}:o;for(let e of s){const o=c(e,"data-arr");o?(r[o]||(r[o]=[])).push(e):t(e,r)}return o}(a(t))}function p(t){let e=t.path||t.composedPath&&t.composedPath();if(e)return e;let o=t.target.parentElement;for(e=[t.target,o];o=o.parentElement;)e.push(o);return e.push(document,window),e}function h(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const o=t=>t>="0"&&t<="9"||"-"===t||"."===t;function n(n){const i=t.value,s=t.selectionStart;let r=s,a="";for(let t=s-1;t>0&&o(i[t]);t--)a=i[t]+a,r--;for(let t=s,e=i.length;t0&&!isNaN(a)&&isFinite(a)){const o=n.deltaY<0?1:-1,s=n.ctrlKey?5*o:o;let c=Number(a)+s;!e&&c<0&&(c=0);const l=i.substr(0,r)+c+i.substring(r+a.length,i.length),p=r+String(c).length;t.value=l,t.focus(),t.setSelectionRange(p,p)}n.preventDefault(),t.dispatchEvent(new Event("input"))}i(t,"focus",()=>i(window,"wheel",n)),i(t,"blur",()=>s(window,"wheel",n))}function u(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var o=[],n=!0,i=!1,s=void 0;try{for(var r,a=t[Symbol.iterator]();!(n=(r=a.next()).done)&&(o.push(r.value),!e||o.length!==e);n=!0);}catch(t){i=!0,s=t}finally{try{n||null==a.return||a.return()}finally{if(i)throw s}}return o}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}const d=Math.min,f=Math.max;function v(t,e,o){t=t/360*6,e/=100,o/=100;let n=Math.floor(t),i=t-n,s=o*(1-e),r=o*(1-i*e),a=o*(1-(1-i)*e),c=n%6;return[255*[o,r,s,s,a,o][c],255*[a,o,o,r,s,s][c],255*[s,s,a,o,o,r][c]]}function y(t,e,o){let n,i,s;const r=d(t/=255,e/=255,o/=255),a=f(t,e,o),c=a-r;if(0===c)n=i=0;else{i=c/a;let s=((a-t)/6+c/2)/c,r=((a-e)/6+c/2)/c,l=((a-o)/6+c/2)/c;t===a?n=l-r:e===a?n=1/3+s-l:o===a&&(n=2/3+r-s),n<0?n+=1:n>1&&(n-=1)}return[360*n,100*i,100*(s=a)]}function g(t,e,o,n){return e/=100,o/=100,[...y(255*(1-d(1,(t/=100)*(1-(n/=100))+n)),255*(1-d(1,e*(1-n)+n)),255*(1-d(1,o*(1-n)+n)))]}function m(t,e,o){return e/=100,[t,2*(e*=(o/=100)<.5?o:1-o)/(o+e)*100,100*(o+e)]}function b(t){return y(...t.match(/.{2}/g).map(t=>parseInt(t,16)))}function _(t){const e={cmyk:/^cmyk[\D]+(\d+)[\D]+(\d+)[\D]+(\d+)[\D]+(\d+)/i,rgba:/^(rgb|rgba)[\D]+(\d+)[\D]+(\d+)[\D]+(\d+)[\D]*?([\d.]+|$)/i,hsla:/^(hsl|hsla)[\D]+(\d+)[\D]+(\d+)[\D]+(\d+)[\D]*?([\d.]+|$)/i,hsva:/^(hsv|hsva)[\D]+(\d+)[\D]+(\d+)[\D]+(\d+)[\D]*?([\d.]+|$)/i,hex:/^#?(([\dA-Fa-f]{3,4})|([\dA-Fa-f]{6})|([\dA-Fa-f]{8}))$/i},o=t=>t.map(t=>/^(|\d+)\.\d+|\d+$/.test(t)?Number(t):void 0);let n;for(let r in e)if(n=e[r].exec(t))switch(r){case"cmyk":{let t=u(o(n),5),e=t[1],i=t[2],s=t[3],a=t[4];if(e>100||i>100||s>100||a>100)break;return{values:[...g(e,i,s,a),1],type:r}}case"rgba":{let t=u(o(n),6),e=t[2],i=t[3],s=t[4],a=t[5],c=void 0===a?1:a;if(e>255||i>255||s>255||c<0||c>1)break;return{values:[...y(e,i,s),c],type:r}}case"hex":{const t=(t,e)=>[t.substring(0,e),t.substring(e,t.length)];let e,o=u(n,2)[1];if(3===o.length?o+="F":6===o.length&&(o+="FF"),4===o.length){var i=u(t(o,3).map(t=>t+t),2);o=i[0],e=i[1]}else if(8===o.length){var s=u(t(o,6),2);o=s[0],e=s[1]}return e=parseInt(e,16)/255,{values:[...b(o),e],type:r}}case"hsla":{let t=u(o(n),6),e=t[2],i=t[3],s=t[4],a=t[5],c=void 0===a?1:a;if(e>360||i>100||s>100||c<0||c>1)break;return{values:[...m(e,i,s),c],type:r}}case"hsva":{let t=u(o(n),6),e=t[2],i=t[3],s=t[4],a=t[5],c=void 0===a?1:a;if(e>360||i>100||s>100||c<0||c>1)break;return{values:[e,i,s,c],type:r}}}return{values:null,type:null}}function w(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;const i=Math.ceil,s={h:t,s:e,v:o,a:n,toHSVA(){const t=[s.h,s.s,s.v],e=t.map(i);return t.push(s.a),t.toString=(()=>`hsva(${e[0]}, ${e[1]}%, ${e[2]}%, ${s.a.toFixed(1)})`),t},toHSLA(){const t=function(t,e,o){let n=(2-(e/=100))*(o/=100)/2;return 0!==n&&(e=1===n?0:n<.5?e*o/(2*n):e*o/(2-2*n)),[t,100*e,100*n]}(s.h,s.s,s.v),e=t.map(i);return t.push(s.a),t.toString=(()=>`hsla(${e[0]}, ${e[1]}%, ${e[2]}%, ${s.a.toFixed(1)})`),t},toRGBA(){const t=v(s.h,s.s,s.v),e=t.map(i);return t.push(s.a),t.toString=(()=>`rgba(${e[0]}, ${e[1]}, ${e[2]}, ${s.a.toFixed(1)})`),t},toCMYK(){const t=function(t,e,o){const n=v(t,e,o),i=n[0]/255,s=n[1]/255,r=n[2]/255;let a,c,l,p;return[100*(c=1===(a=d(1-i,1-s,1-r))?0:(1-i-a)/(1-a)),100*(l=1===a?0:(1-s-a)/(1-a)),100*(p=1===a?0:(1-r-a)/(1-a)),100*a]}(s.h,s.s,s.v),e=t.map(i);return t.toString=(()=>`cmyk(${e[0]}%, ${e[1]}%, ${e[2]}%, ${e[3]}%)`),t},toHEX(){const t=function(t,e,o){return v(t,e,o).map(t=>Math.round(t).toString(16).padStart(2,"0"))}(...[s.h,s.s,s.v]);return t.toString=(()=>{const e=s.a>=1?"":Number((255*s.a).toFixed(0)).toString(16).toUpperCase().padStart(2,"0");return`#${t.join("").toUpperCase()+e}`}),t},clone:()=>w(s.h,s.s,s.v,s.a)};return s}function k(t){const e={options:Object.assign({lockX:!1,lockY:!1,onchange:()=>0},t),_tapstart(t){i(document,["mouseup","touchend","touchcancel"],e._tapstop),i(document,["mousemove","touchmove"],e._tapmove),t.preventDefault(),e._tapmove(t)},_tapmove(t){const o=e.options,n=e.cache,i=o.element,s=e.options.wrapper.getBoundingClientRect();let r=0,a=0;if(t){const e=t&&t.touches&&t.touches[0];r=t?(e||t).clientX:0,a=t?(e||t).clientY:0,rs.left+s.width&&(r=s.left+s.width),as.top+s.height&&(a=s.top+s.height),r-=s.left,a-=s.top}else n&&(r=n.x*s.width,a=n.y*s.height);o.lockX||(i.style.left=`calc(${r/s.width*100}% - ${i.offsetWidth/2}px)`),o.lockY||(i.style.top=`calc(${a/s.height*100}% - ${i.offsetWidth/2}px)`),e.cache={x:r/s.width,y:a/s.height},o.onchange(r,a)},_tapstop(){s(document,["mouseup","touchend","touchcancel"],e._tapstop),s(document,["mousemove","touchmove"],e._tapmove)},trigger(){e._tapmove()},update(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=e.options.wrapper.getBoundingClientRect();e._tapmove({clientX:n.left+t,clientY:n.top+o})},destroy(){const t=e.options,o=e._tapstart;s([t.wrapper,t.element],"mousedown",o),s([t.wrapper,t.element],"touchstart",o,{passive:!1})}},o=e.options,n=e._tapstart;return i([o.wrapper,o.element],"mousedown",n),i([o.wrapper,o.element],"touchstart",n,{passive:!1}),e}function A(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=Object.assign({onchange:()=>0,className:"",elements:[]},t),i(t.elements,"click",e=>{t.elements.forEach(o=>o.classList[e.target===o?"add":"remove"](t.className)),t.onchange(e)}),{destory:()=>s(t.elements,"click",this._ontap)}}class C{constructor(t){this.options=Object.assign({useAsButton:!1,disabled:!1,comparison:!0,components:{interaction:{}},strings:{},swatches:null,default:"fff",defaultRepresentation:"HEX",position:"middle",adjustableNumbers:!0,showAlways:!1,parent:void 0,closeWithKey:"Escape"},t),this.options.components.interaction||(this.options.components.interaction={}),this._initializingActive=!0,this._recalc=!0,this._color=w(),this._lastColor=w(),this._swatchColors=[],this._eventListener={swatchselect:[],change:[],save:[],init:[]},this._preBuild(),this._buildComponents(),this._bindEvents(),this._representation=this.options.defaultRepresentation,this.setColorRepresentation(this._representation),this._finalBuild(),this._rePositioningPicker();const e=this.options.swatches;e&&e.length&&e.forEach(t=>this.addSwatch(t)),requestAnimationFrame(function t(){if(!this._root.app.offsetParent)return requestAnimationFrame(t.bind(this));this.setColor(this.options.default),this._initializingActive=!1,this._emit("init")}.bind(this))}_preBuild(){const t=this.options;"string"==typeof t.el&&(t.el=document.querySelector(t.el)),this._root=function(t){const e=t.components,o=t.strings,n=t.useAsButton,i=t=>t?"":'style="display:none" hidden',s=l(`\n
\n \n ${n?"":''}\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n
\n
\n
\n `),r=s.interaction;return r.options.find(t=>!t.hidden&&!t.classList.add("active")),r.type=(()=>r.options.find(t=>t.classList.contains("active"))),s}(t),t.useAsButton&&(t.parent||(t.parent="body"),this._root.button=t.el),document.body.appendChild(this._root.root)}_finalBuild(){const t=this.options,e=this._root;document.body.removeChild(e.root),t.parent&&("string"==typeof t.parent&&(t.parent=document.querySelector(t.parent)),t.parent.appendChild(e.app)),t.useAsButton||t.el.parentElement.replaceChild(e.root,t.el),t.disabled&&this.disable(),t.comparison||(e.button.style.transition="none",t.useAsButton||(e.preview.lastColor.style.transition="none")),t.showAlways?e.app.classList.add("visible"):this.hide()}_buildComponents(){const t=this,e=this.options.components,o={palette:k({element:t._root.palette.picker,wrapper:t._root.palette.palette,onchange(e,o){const n=t._color,i=t._root,s=t.options;n.s=e/this.wrapper.offsetWidth*100,n.v=100-o/this.wrapper.offsetHeight*100,n.v<0&&(n.v=0);const r=n.toRGBA().toString();this.element.style.background=r,this.wrapper.style.background=`\n linear-gradient(to top, rgba(0, 0, 0, ${n.a}), transparent), \n linear-gradient(to left, hsla(${n.h}, 100%, 50%, ${n.a}), rgba(255, 255, 255, ${n.a}))\n `,s.comparison||(i.button.style.color=r,s.useAsButton||(i.preview.lastColor.style.color=r)),i.preview.currentColor.style.color=r,t._recalc&&t._updateOutput(),i.button.classList.remove("clear")}}),hue:k({lockX:!0,element:t._root.hue.picker,wrapper:t._root.hue.slider,onchange(n,i){e.hue&&(t._color.h=i/this.wrapper.offsetHeight*360,this.element.style.backgroundColor=`hsl(${t._color.h}, 100%, 50%)`,o.palette.trigger())}}),opacity:k({lockX:!0,element:t._root.opacity.picker,wrapper:t._root.opacity.slider,onchange(o,n){e.opacity&&(t._color.a=Math.round(n/this.wrapper.offsetHeight*100)/100,this.element.style.background=`rgba(0, 0, 0, ${t._color.a})`,t.components.palette.trigger())}}),selectable:A({elements:t._root.interaction.options,className:"active",onchange(e){t._representation=e.target.getAttribute("data-type").toUpperCase(),t._updateOutput()}})};this.components=o}_bindEvents(){const t=this._root,e=this.options,o=[i(t.interaction.clear,"click",()=>this._clearColor()),i(t.preview.lastColor,"click",()=>this.setHSVA(...this._lastColor.toHSVA())),i(t.interaction.save,"click",()=>{!this.applyColor()&&!e.showAlways&&this.hide()}),i(t.interaction.result,["keyup","input"],t=>{this._recalc=!1,this.setColor(t.target.value,!0)&&!this._initializingActive&&this._emit("change",this._color),t.stopImmediatePropagation()}),i([t.palette.palette,t.palette.picker,t.hue.slider,t.hue.picker,t.opacity.slider,t.opacity.picker],["mousedown","touchstart"],()=>this._recalc=!0),i(window,"resize",()=>this._rePositioningPicker)];if(!e.showAlways){const n=e.closeWithKey;o.push(i(t.button,"click",()=>this.isOpen()?this.hide():this.show()),i(document,"keyup",t=>this.isOpen()&&(t.key===n||t.code===n)&&this.hide()),i(document,["touchstart","mousedown"],e=>{this.isOpen()&&!p(e).some(e=>e===t.app||e===t.button)&&this.hide()},{capture:!0}))}e.adjustableNumbers&&h(t.interaction.result,!1),this._eventBindings=o}_rePositioningPicker(){const t=this._root,e=this._root.app;if(this.options.parent){const o=t.button.getBoundingClientRect();e.style.position="fixed",e.style.marginLeft=`${o.left}px`,e.style.marginTop=`${o.top}px`}const o=t.button.getBoundingClientRect(),n=e.getBoundingClientRect(),i=e.style;n.bottom>window.innerHeight?i.top=`${-n.height-5}px`:o.bottom+n.heightwindow.innerWidth&&l-window.innerWidthwindow.innerWidth&&(a=s.left),i.left=`${a}px`}_updateOutput(){if(this._root.interaction.type()){const t=`to${this._root.interaction.type().getAttribute("data-type")}`;this._root.interaction.result.value="function"==typeof this._color[t]?this._color[t]().toString():""}this._initializingActive||this._emit("change",this._color)}_clearColor(){const t=this._root,e=this.options;e.useAsButton||(t.button.style.color="rgba(0, 0, 0, 0.4)"),t.button.classList.add("clear"),e.showAlways||this.hide(),this._emit("save",null)}_emit(t){for(var e=arguments.length,o=new Array(e>1?e-1:0),n=1;nt(...o,this))}on(t,e){return"function"==typeof e&&"string"==typeof t&&t in this._eventListener&&this._eventListener[t].push(e),this}off(t,e){const o=this._eventListener[t];if(o){const t=o.indexOf(e);~t&&o.splice(t,1)}return this}addSwatch(t){const e=_(t).values;if(e){const t=this._swatchColors,o=this._root,n=w(...e),s=a(``);return o.swatches.appendChild(s),t.push({element:s,hsvaColorObject:n}),this._eventBindings.push(i(s,"click",()=>{this.setHSVA(...n.toHSVA(),!0),this._emit("swatchselect",n)})),!0}return!1}removeSwatch(t){if("number"==typeof t){const e=this._swatchColors[t];if(e){const o=e.element;return this._root.swatches.removeChild(o),this._swatchColors.splice(t,1),!0}}return!1}applyColor(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const e=this._root,o=e.preview,n=e.button,i=this._color.toRGBA().toString();o.lastColor.style.color=i,this.options.useAsButton||(n.style.color=i),n.classList.remove("clear"),this._lastColor=this._color.clone(),this._initializingActive||t||this._emit("save",this._color)}destroy(){this._eventBindings.forEach(t=>s(...t)),Object.keys(this.components).forEach(t=>this.components[t].destroy())}destroyAndRemove(){this.destroy();const t=this._root.root;t.parentElement.removeChild(t)}hide(){return this._root.app.classList.remove("visible"),this}show(){if(!this.options.disabled)return this._root.app.classList.add("visible"),this._rePositioningPicker(),this}isOpen(){return this._root.app.classList.contains("visible")}setHSVA(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:360,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];const s=this._recalc;if(this._recalc=!1,t<0||t>360||e<0||e>100||o<0||o>100||n<0||n>1)return!1;const r=this.components,a=r.hue,c=r.opacity,l=r.palette,p=a.options.wrapper.offsetHeight*(t/360);a.update(0,p);const h=c.options.wrapper.offsetHeight*n;c.update(0,h);const u=l.options.wrapper,d=u.offsetWidth*(e/100),f=u.offsetHeight*(1-o/100);return l.update(d,f),this._color=w(t,e,o,n),this._recalc=s,this._recalc&&this._updateOutput(),i||this.applyColor(),!0}setColor(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(null===t)return this._clearColor(),!0;const o=_(t),n=o.values,i=o.type;if(n){const t=i.toUpperCase(),o=this._root.interaction.options,s=o.find(e=>e.getAttribute("data-type")===t);if(!s.hidden)for(const t of o)t.classList[t===s?"add":"remove"]("active");return this.setHSVA(...n,e)}}setColorRepresentation(t){return t=t.toUpperCase(),!!this._root.interaction.options.find(e=>e.getAttribute("data-type")===t&&!e.click())}getColorRepresentation(){return this._representation}getColor(){return this._color}getRoot(){return this._root}disable(){return this.hide(),this.options.disabled=!0,this._root.button.classList.add("disabled"),this}enable(){return this.options.disabled=!1,this._root.button.classList.remove("disabled"),this}}C.utils={once:(t,e,o,n)=>i(t,e,function t(){o.apply(this,arguments),this.removeEventListener(e,t)},n),on:i,off:s,eventPath:p,createElementFromString:a,adjustableInputNumbers:h,removeAttribute:c,createFromTemplate:l},C.create=(t=>new C(t)),C.version="0.4.2";e.default=C}]).default}); +//# sourceMappingURL=pickr.min.js.map \ No newline at end of file diff --git a/app/js/post/bb-md.js b/app/js/post/bb-md.js index abe94bad..75a88882 100644 --- a/app/js/post/bb-md.js +++ b/app/js/post/bb-md.js @@ -290,10 +290,10 @@ function preview(){ for(let l = 0; l < li.length; l++) { var u=li[l].match(/^1\. (.+)$/); var listUl='
  • '+u[1]+'
  • '; - if(l == 0){ + if(l === 0){ listUl='
      '+listUl; } - if(l==li.length-1){ + if(l===li.length-1){ listUl=listUl+'
    '; } var bb=bb.replace(new RegExp(li[l], ""),listUl); diff --git a/app/js/post/emoji.js b/app/js/post/emoji.js index 85fc4629..c184b157 100644 --- a/app/js/post/emoji.js +++ b/app/js/post/emoji.js @@ -90,7 +90,7 @@ function emojiList(target) { var page = Math.ceil(num / 126); $("#emoji-sum").text(page); var ct = Math.ceil(start / 126); - if (ct == 0) { + if (ct === 0) { var ct = 1; $("#emoji-before").addClass("disabled"); } else { diff --git a/app/js/post/img.js b/app/js/post/img.js index 51310143..0dcd41d2 100644 --- a/app/js/post/img.js +++ b/app/js/post/img.js @@ -106,7 +106,7 @@ function media(b64, type, no) { var start = "https://" + domain + "/api/drive/files/create"; httpreq.open('POST', start, true); httpreq.upload.addEventListener("progress", progshow, false); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; if ($("#nsfw").hasClass("nsfw-avail")) { var nsfw = true; } else { @@ -121,12 +121,12 @@ function media(b64, type, no) { var start = "https://" + domain + "/api/v1/media"; httpreq.open('POST', start, true); httpreq.upload.addEventListener("progress", progshow, false); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.setRequestHeader('Authorization', 'Bearer ' + at); httpreq.send(fd); } httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { var json = httpreq.response; console.log(json); var img = localStorage.getItem("img"); diff --git a/app/js/post/misskeystatus.js b/app/js/post/misskeystatus.js index 77b28b50..6724c2f6 100644 --- a/app/js/post/misskeystatus.js +++ b/app/js/post/misskeystatus.js @@ -1,7 +1,7 @@ //Renpost function renote(id, acct_id, remote) { if ($("#pub_" + id).hasClass("rted")) { - return + return false; } var domain = localStorage.getItem("domain_" + acct_id); var at = localStorage.getItem("acct_"+ acct_id + "_at"); @@ -12,10 +12,10 @@ function renote(id, acct_id, remote) { var httpreq = new XMLHttpRequest(); httpreq.open('POST', start, true); httpreq.setRequestHeader('Content-Type', 'application/json'); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(JSON.stringify({i:at,renoteId:id})); httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { var json = httpreq.response; console.log(json); $("[toot-id=" + id + "]").addClass("rted"); @@ -58,10 +58,10 @@ function reactiontoggle(id,acct_id,tlid){ var httpreq = new XMLHttpRequest(); httpreq.open('POST', start, true); httpreq.setRequestHeader('Content-Type', 'application/json'); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(JSON.stringify({i:at,noteId:id})); httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { var json = httpreq.response; console.log(json); if(json.reactionCounts){ @@ -158,10 +158,10 @@ function reaction(mode,id,acct_id,tlid){ var httpreq = new XMLHttpRequest(); httpreq.open('POST', start, true); httpreq.setRequestHeader('Content-Type', 'application/json'); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(JSON.stringify({i:at,noteId:id,reaction:mode})); httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { $(".fav_"+id).toggleClass("yellow-text"); } } @@ -177,7 +177,7 @@ function vote(acct_id,id,to){ var httpreq = new XMLHttpRequest(); httpreq.open('POST', start, true); httpreq.setRequestHeader('Content-Type', 'application/json'); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(JSON.stringify({i:at,noteId:id,choice:to})); httpreq.onreadystatechange = function() { voterefresh(acct_id,id) diff --git a/app/js/post/post.js b/app/js/post/post.js index e8ee6acc..61255f11 100644 --- a/app/js/post/post.js +++ b/app/js/post/post.js @@ -11,7 +11,7 @@ function sec(){ } function post(mode,postvis) { if($("#toot-post-btn").prop("disabled")){ - return + return false; } var str = $("#textarea").val(); var acct_id = $("#post-acct-sel").val(); @@ -57,13 +57,13 @@ function post(mode,postvis) { buttons: [lang.lang_post_btn1,lang.lang_post_btn2, lang.lang_post_btn3] } dialog.showMessageBox(options, function(arg) { - if(arg==1){ + if(arg===1){ $("#cw-text").show(); $("#cw").addClass("yellow-text"); $("#cw").addClass("cw-avail"); $("#cw-text").val(plus); post("pass"); - }else if(arg==2){ + }else if(arg===2){ post("pass"); } }) @@ -162,10 +162,10 @@ function post(mode,postvis) { httpreq.open('POST', start, true); httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader('Authorization', 'Bearer ' + at); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(JSON.stringify(toot)); httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { if(str.indexOf(localStorage.getItem("stable"))==-1){ localStorage.removeItem("stable") } @@ -234,10 +234,10 @@ function misskeyPost(){ var httpreq = new XMLHttpRequest(); httpreq.open('POST', start, true); httpreq.setRequestHeader('Content-Type', 'application/json'); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(JSON.stringify(toot)); httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { if(str.indexOf(localStorage.getItem("stable"))==-1){ localStorage.removeItem("stable") } diff --git a/app/js/post/status.js b/app/js/post/status.js index 13860500..43301ab9 100644 --- a/app/js/post/status.js +++ b/app/js/post/status.js @@ -13,10 +13,10 @@ function fav(id, acct_id, remote) { httpreq.open('POST', start, true); httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader('Authorization', 'Bearer ' + at); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(); httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { var json = httpreq.response; if(remote!="remote"){ //APIのふぁぼカウントがおかしい @@ -63,10 +63,10 @@ function rt(id, acct_id, remote) { httpreq.open('POST', start, true); httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader('Authorization', 'Bearer ' + at); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(); httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { var json = httpreq.response; console.log(json); if (remote != "remote") { @@ -133,10 +133,10 @@ function follow(acct_id,remote) { httpreq.open('POST', start, true); httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader('Authorization', 'Bearer ' + at); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(JSON.stringify(ent)); httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { var json = httpreq.response; console.log(json); if ($("#his-data").hasClass("following")) { @@ -168,10 +168,10 @@ function block(acct_id) { httpreq.open('POST', start, true); httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader('Authorization', 'Bearer ' + at); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(); httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { if ($("#his-data").hasClass("blocking")) { $("#his-data").removeClass("blocking"); $("#his-block-btn").text(lang.lang_status_block); @@ -210,10 +210,10 @@ function mute(acct_id) { httpreq.open('POST', start, true); httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader('Authorization', 'Bearer ' + at); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(rq); httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { if ($("#his-data").hasClass("muting")) { $("#his-data").removeClass("muting"); $("#his-mute-btn").text(lang.lang_status_mute); @@ -234,7 +234,7 @@ function del(id, acct_id) { var httpreq = new XMLHttpRequest(); httpreq.open('POST', start, true); httpreq.setRequestHeader('Content-Type', 'application/json'); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(JSON.stringify({i:at,noteId:id})); }else{ var start = "https://" + domain + "/api/v1/statuses/" + id; @@ -242,11 +242,11 @@ function del(id, acct_id) { httpreq.open('DELETE', start, true); httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader('Authorization', 'Bearer ' + at); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(); } httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { } } } @@ -300,10 +300,10 @@ function pin(id, acct_id) { httpreq.open('POST', start, true); httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader('Authorization', 'Bearer ' + at); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(); httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { var json = httpreq.response; console.log(json); if ($("[toot-id=" + id + "]").hasClass("pined")) { @@ -326,10 +326,10 @@ function request(id, flag, acct_id) { httpreq.open('POST', start, true); httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader('Authorization', 'Bearer ' + at); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(); httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { var json = httpreq.response; console.log(json); showReq(); @@ -349,10 +349,10 @@ function domainblock(add, flag, acct_id) { httpreq.open('POST', start, true); httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader('Authorization', 'Bearer ' + at); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(); httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { var json = httpreq.response; console.log(json); showDom(); @@ -406,10 +406,10 @@ function pinUser(){ httpreq.open('POST', start, true); httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader('Authorization', 'Bearer ' + at); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(); httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { var json = httpreq.response; console.log(json); if ($("#his-end-btn").hasClass("endorsed")) { diff --git a/app/js/tl/card.js b/app/js/tl/card.js index 4da9d56e..d9e981f3 100644 --- a/app/js/tl/card.js +++ b/app/js/tl/card.js @@ -83,7 +83,7 @@ function additional(acct_id, tlid) { var xmlHttpRequest = new XMLHttpRequest(); xmlHttpRequest.onreadystatechange = function() { - if( this.readyState == 4 && this.status == 200 ) { + if( this.readyState === 4 && this.status === 200 ) { if( this.response){ var json=this.response; var emojis=json.emojis; diff --git a/app/js/tl/datails.js b/app/js/tl/datails.js index eb4ec0bf..1252348c 100644 --- a/app/js/tl/datails.js +++ b/app/js/tl/datails.js @@ -78,10 +78,11 @@ function details(id, acct_id, tlid) { $("#tootmodal").attr("data-user",scn); } context(id, acct_id); + var dom=null; if(!local){ - var dom=scn.replace(/.+@/g,''); + dom=scn.replace(/.+@/g,''); }else{ - var dom=domain; + dom=domain; } beforeToot(id, acct_id, dom); userToot(id, acct_id, uid); @@ -448,7 +449,7 @@ function shot(){ }) } //翻訳 -function trans(tar){ +function trans(tar,to){ var html=$("#toot-this .toot").html(); if(html.match(/^

    (.+)<\/p>$/)){ html = html.match(/^

    (.+)<\/p>$/)[1]; @@ -457,18 +458,21 @@ function trans(tar){ html = html.replace(/

    /g, "\n"); html = html.replace(/<\/p>/g, "\n"); html=$.strip_tags(html); + if(~tar.indexOf("zh")){ + tar="zh"; + } $("#toot-this .additional").text("Loading...(Powered by Google Translate)"); - var exec='https://script.google.com/macros/s/AKfycbz0ETqcUxwNlw961GjErNb7vr_X18N2s1AS5Xu5nFTbYXcdcRM/exec?text='+encodeURIComponent(html)+'&source='+tar+'&target=ja' + var exec='https://script.google.com/macros/s/AKfycbxhwW5tjjop9Irg-y1zr_WsXlCKEzwWG6KuoOt_vVRDfEbRv0c/exec?format=json&text='+encodeURIComponent(html)+'&source='+tar+'&target='+to console.log(exec); fetch(exec, { method: 'GET', }).then(function(response) { - return response.text(); + return response.json(); }).catch(function(error) { todo(error); console.error(error); }).then(function(text) { - $("#toot-this .additional").html(''+text+''); + $("#toot-this .additional").html(''+text.text+''); }); } //ブラウザで開く diff --git a/app/js/tl/date.js b/app/js/tl/date.js index 3ab4d752..505eb54d 100644 --- a/app/js/tl/date.js +++ b/app/js/tl/date.js @@ -15,10 +15,11 @@ function date(str, datetype) { } else { var min = date.getMinutes(); } + var sec=null; if (date.getSeconds() < 10) { - var sec = "0" + date.getSeconds(); + sec = "0" + date.getSeconds(); } else { - var sec = date.getSeconds(); + sec = date.getSeconds(); } if (datetype == "full") { var ret = date.getFullYear() + "/" + month + "/" + date.getDate() + "/ " + @@ -56,10 +57,11 @@ function date(str, datetype) { //特殊フォーマット(インスタンス情報で利用) function crat(str) { var date = new Date(str); + var mnt=null; if(date.getMonth()<9){ - var mnt="0"+(date.getMonth()+1); + mnt="0"+(date.getMonth()+1); }else{ - var mnt=date.getMonth()+1; + mnt=date.getMonth()+1; } if(date.getDate()<10){ var dat="0"+date.getDate(); diff --git a/app/js/tl/dm.js b/app/js/tl/dm.js index 38215ae2..8167bddd 100644 --- a/app/js/tl/dm.js +++ b/app/js/tl/dm.js @@ -32,9 +32,6 @@ function dmParse(obj, mix, acct_id, tlid, popup, mutefilter) { console.log(obj); var templete = ''; if(obj[0]){ - if(tlid==1){ - console.log("testalive:"+"lastunix_"+ tlid+":"+date(obj[0].created_at, 'unix')) - } localStorage.setItem("lastunix_"+ tlid,date(obj[0].created_at, 'unix')); } diff --git a/app/js/tl/filter.js b/app/js/tl/filter.js index 43542eed..bc20ee89 100644 --- a/app/js/tl/filter.js +++ b/app/js/tl/filter.js @@ -192,7 +192,7 @@ function makeNewFilter(){ httpreq.open(method, start, true); httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader('Authorization', 'Bearer ' + at); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(JSON.stringify({ phrase: phr, context: cont, @@ -201,7 +201,7 @@ function makeNewFilter(){ expires_in:time })); httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { var json = httpreq.response; filter(); filterUpdate(acct_id) @@ -283,10 +283,10 @@ function filterDel(id,acct_id){ httpreq.open("DELETE", start, true); httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader('Authorization', 'Bearer ' + at); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(); httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { var json = httpreq.response; filter(); filterUpdate(acct_id) diff --git a/app/js/tl/list.js b/app/js/tl/list.js index 428188bb..ae5d0747 100644 --- a/app/js/tl/list.js +++ b/app/js/tl/list.js @@ -56,12 +56,12 @@ function makeNewList(){ httpreq.open('POST', start, true); httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader('Authorization', 'Bearer ' + at); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(JSON.stringify({ title: text })); httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { var json = httpreq.response; list(); $("#list-add").val("") @@ -166,12 +166,12 @@ function listAdd(id,user,acct_id){ httpreq.open('POST', start, true); httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader('Authorization', 'Bearer ' + at); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(JSON.stringify({ account_ids: [user] })); httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { var json = httpreq.response; hisList(user,acct_id) } @@ -186,12 +186,12 @@ function listRemove(id,user,acct_id){ httpreq.open('DELETE', start, true); httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader('Authorization', 'Bearer ' + at); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(JSON.stringify({ account_ids: [user] })); httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { var json = httpreq.response; hisList(user,acct_id) } diff --git a/app/js/tl/notification.js b/app/js/tl/notification.js index f018f4a9..736b3e19 100644 --- a/app/js/tl/notification.js +++ b/app/js/tl/notification.js @@ -39,10 +39,10 @@ function notfColumn(acct_id, tlid, sys){ var body=""; } - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(body); httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { var json = httpreq.response; var max_id = httpreq.getResponseHeader("link").match(/\?max_id=([0-9]+)/)[1]; if(json[0]){ @@ -391,10 +391,10 @@ function notfmore(tlid) { var body=""; } - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(body); httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { var json = httpreq.response; console.log(json); var max_id = httpreq.getResponseHeader("link").match(/\?max_id=([0-9]+)/)[1]; diff --git a/app/js/tl/parse.js b/app/js/tl/parse.js index 12c7dc23..779f7003 100644 --- a/app/js/tl/parse.js +++ b/app/js/tl/parse.js @@ -2,7 +2,7 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter) { var templete = ''; if(obj[0]){ - if(tlid==1){ + if(tlid===1){ console.log("testalive:"+"lastunix_"+ tlid+":"+date(obj[0].created_at, 'unix')) } localStorage.setItem("lastunix_"+ tlid,date(obj[0].created_at, 'unix')); @@ -84,7 +84,7 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter) { var card = localStorage.getItem("card_" + tlid); if (!sent) { - var sent = 500; + sent = 500; } if (!ltr) { var ltr = 500; @@ -614,8 +614,8 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter) { }); } //日本語じゃない - if(toot.language!="ja"){ - var trans='

    '; + if(toot.language!=lang.language && toot.language){ + var trans=''; }else{ var trans=""; } @@ -673,9 +673,14 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter) { } var result_hide="hide"; } + if(toot.poll.expired){ + var ended=lang.lang_parse_endedvote; + }else{ + var ended=date(toot.poll.expires_at, datetype); + } Object.keys(choices).forEach(function(keyc) { var choice = choices[keyc]; - if(!toot.poll.voted){ + if(!toot.poll.voted && !toot.poll.expired){ var votesel='voteSelMastodon(\''+acct_id+'\',\''+toot.poll.id+'\','+keyc+','+toot.poll.multiple+')'; var voteclass="pointer waves-effect waves-light"; }else{ @@ -686,7 +691,7 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter) { }); poll='
    '+poll+myvote+'' + - date(toot.poll.expires_at, datetype) + '
    '; + ended+ ''; } templete = templete + '
    '+his[0].uses+'toots #' + tag.name + ' '+his[0].accounts+lang.lang_src_people; diff --git a/app/js/tl/tl.js b/app/js/tl/tl.js index 9386dfaa..d13924b4 100644 --- a/app/js/tl/tl.js +++ b/app/js/tl/tl.js @@ -289,7 +289,7 @@ function reload(type, cc, acct_id, tlid, data, mute, delc, voice, mode) { say(obj.content) } var templete = parse([obj], type, acct_id, tlid,"",mute); - if ($("timeline_box_"+tlid+"_box .tl-box").scrollTop() == 0) { + if ($("timeline_box_"+tlid+"_box .tl-box").scrollTop() === 0) { $("#timeline_" + tlid).prepend(templete); }else{ var pool = localStorage.getItem("pool_" + tlid); @@ -578,7 +578,7 @@ function com(type, data) { return "tag/" + data + "?" }else if (type == "list") { return "list/" + data + "?" - }else if (type="dm") { + }else if (type=="dm") { return "direct?" } } diff --git a/app/js/ui/img.js b/app/js/ui/img.js index 7593c77a..50f90f37 100644 --- a/app/js/ui/img.js +++ b/app/js/ui/img.js @@ -222,13 +222,13 @@ function imgCont(type) { } } } - if ($("#" + id + "-image-" + (key * 1 + 1)).length == 0) { + if ($("#" + id + "-image-" + (key * 1 + 1)).length === 0) { $("#image-next").prop("disabled", true); } else { $("#image-next").prop("disabled", false); } console.log("#" + id + "-image-" + (key * 1 - 1)); - if ($("#" + id + "-image-" + (key * 1 - 1)).length == 0) { + if ($("#" + id + "-image-" + (key * 1 - 1)).length === 0) { $("#image-prev").prop("disabled", true); } else { $("#image-prev").prop("disabled", false); @@ -289,7 +289,7 @@ function zoom(z) { 'cursor': 'move' }); //指が触れたか検知 $(this).on('touchmove', function(event) { - if ($(target).data('down') == true) { + if ($(target).data('down') === true) { // スクロール console.log($(target).data('x')); target.scrollLeft($(target).data('scrollLeft') + $(target).data('x') - diff --git a/app/js/ui/layout.js b/app/js/ui/layout.js index 44336976..96f692e2 100644 --- a/app/js/ui/layout.js +++ b/app/js/ui/layout.js @@ -311,7 +311,7 @@ function removeColumn(tlid) { ipc.send('column-del', ""); ipc.on('column-del-reply', function (event, arg) { console.log(arg); - if(arg==1){ + if(arg===1){ localStorage.removeItem("card_" + tlid); obj.splice(tlid, 1); for(var i=0;i { + var rgb='rgb('+rgs[0].toRGBA()[0]+','+rgs[0].toRGBA()[1]+','+rgs[0].toRGBA()[2]+')'; + $("#color-picker"+i+"_value").val(rgb) + }); +} +function customComp(){ + var nameC=$("#custom_name").val(); + if(!nameC){return false;} + var descC=$("#custom_desc").val(); + if(!descC){return false;} + var primaryC=$("#color-picker0_value").val(); + if(!primaryC){return false;} + var secondaryC=$("#color-picker1_value").val(); + if(!secondaryC){return false;} + var textC=$("#color-picker2_value").val(); + if(!textC){return false;} + var accentC=$("#color-picker3_value").val(); + if(!accentC){return false;} + var multi = localStorage.getItem("multi"); + var my=JSON.parse(multi)[0].name; + var json={ + "name": nameC, + "author": my, + "desc": descC, + "base": $("[name=direction]:checked").val(), + "vars": { + "primary": primaryC, + "secondary": secondaryC, + "text": textC + }, + "props": { + "TheDeskAccent": accentC + }, + "id": makeCID() + } + $("#custom_json").val(JSON.stringify(json)); +} +function ctLoad(){ + ipc.send('theme-json-list', ""); + ipc.on('theme-json-list-response', function (event, args) { + console.log(args); + var templete=""; + Object.keys(args).forEach(function(key) { + var theme = args[key]; + var themeid=theme.id + templete = templete+''; + + + }); + $("#custom-sel-sel").html(templete); + templete=''+templete; + $("#custom-edit-sel").html(templete); + $('select').material_select('update'); + }); +} +function customSel(){ + var id=$("#custom-sel-sel").val(); + localStorage.setItem("customtheme-id",id) +} +function custom(){ + var id=$("#custom-edit-sel").val(); + if(id=="add_new"){ + $("#custom_name").val(""); + $("#custom_desc").val(""); + $("#dark").prop("checked", true); + $("#custom_json").val(""); + }else{ + ipc.send('theme-json-request', id); + ipc.on('theme-json-response', function (event, args) { + $("#custom_name").val(args.name); + $("#custom_desc").val(args.desc); + $("#"+args.base).prop("checked", true); + $("#color-picker0-wrap").html('
    ') + pickerDefine(0,rgbToHex(args.vars.primary)) + $("#color-picker1-wrap").html('
    ') + pickerDefine(1,rgbToHex(args.vars.secondary)) + $("#color-picker2-wrap").html('
    ') + pickerDefine(2,rgbToHex(args.vars.text)) + if(args.props){ + if(args.props.TheDeskAccent){ + var accent=args.props.TheDeskAccent; + }else{ + var accent=args.vars.secondary; + } + }else{ + var accent=args.vars.secondary; + } + $("#color-picker3-wrap").html('
    ') + pickerDefine(3,rgbToHex(accent)) + $("#custom_json").val(JSON.stringify(args)); + }); + } +} +function customImp(){ + var json=$("#custom_import").val(); + if(JSON5.parse(json)){ + ipc.send('theme-json-create', json); + }else{ + alert("Error") + } +} +ipc.on('theme-json-create-complete', function (event, args) { + $("#custom_import").val(""); + ctLoad() +}); +//最初に読む +load(); +climute(); +wordmute(); +wordemp(); +checkSpotify(); +voiceSettingLoad(); +oksload(); +npprovider(); +ctLoad() \ No newline at end of file diff --git a/app/js/ui/theme.js b/app/js/ui/theme.js index 18d93523..ca5b65d0 100644 --- a/app/js/ui/theme.js +++ b/app/js/ui/theme.js @@ -11,6 +11,7 @@ function themes(theme) { $("html").removeClass("greentheme"); $("html").removeClass("browntheme"); $("html").removeClass("blacktheme"); + $("html").removeClass("customtheme"); $("html").addClass(theme+"theme"); var font = localStorage.getItem("font"); if(font){ @@ -18,5 +19,10 @@ function themes(theme) { }else{ $("html").css("font-family",""); } + if(theme=="custom"){ + if(localStorage.getItem("customtheme-id")){ + ipc.send('theme-css-request', localStorage.getItem("customtheme-id")); + } + } } themes(); \ No newline at end of file diff --git a/app/js/userdata/prof-edit.js b/app/js/userdata/prof-edit.js index 080871c7..3b6d7bdf 100644 --- a/app/js/userdata/prof-edit.js +++ b/app/js/userdata/prof-edit.js @@ -12,13 +12,13 @@ function profedit() { httpreq.open('PATCH', start, true); httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader('Authorization', 'Bearer ' + at); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(JSON.stringify({ display_name: name, note: des, })); httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { $('#his-data').modal('close'); todc(); } @@ -47,10 +47,10 @@ function imgChange(imgfile, target) { httpreq.open('PATCH', start, true); httpreq.upload.addEventListener("progress", progshow, false); httpreq.setRequestHeader('Authorization', 'Bearer ' + at); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(fd); httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { var json = httpreq.response; console.log(json); $('#his-data').modal('close'); diff --git a/app/js/userdata/showOnTL.js b/app/js/userdata/showOnTL.js index 30f03272..a464d32d 100644 --- a/app/js/userdata/showOnTL.js +++ b/app/js/userdata/showOnTL.js @@ -46,7 +46,7 @@ function udgEx(user,acct_id){ shell.openExternal(url); } }); - return; + return true; } function udg(user, acct_id) { reset(); diff --git a/app/language.js b/app/language.js index 6b0a6d38..060a196e 100644 --- a/app/language.js +++ b/app/language.js @@ -1,5 +1,8 @@ // Create the Application's main menu -function createMenu(lang){ +function templete(lang){ + const electron = require("electron"); + const app = electron.app; + const BrowserWindow = electron.BrowserWindow; const dict={ "application":{ "ja":"アプリケーション", @@ -65,7 +68,14 @@ function createMenu(lang){ const menu = [{ label: dict.application[lang], submenu: [ - { label: dict.about[lang], click: function() { about(); } }, + { label: dict.about[lang], click: function() { + var ver=app.getVersion() + var window = new BrowserWindow({width: 300, height: 460, + "transparent": false, // ウィンドウの背景を透過 + "frame": false, // 枠の無いウィンドウ + "resizable": false }); + window.loadURL('file://' + __dirname + '/about.html?ver='+ver); + } }, { type: "separator" }, { label: dict.quit[lang], accelerator: "Command+Q", click: function() { app.quit(); }} @@ -141,5 +151,5 @@ function delsel(lang){ return options; } -exports.templete = createMenu; +exports.template = templete; exports.delsel = delsel; \ No newline at end of file diff --git a/app/main.js b/app/main.js index 6d652cbf..366088fb 100644 --- a/app/main.js +++ b/app/main.js @@ -13,6 +13,7 @@ const language = require('./language.js'); const Menu=electron.Menu var updatewin=null; const join = require('path').join; +var JSON5 = require('json5'); // アプリケーションをコントロールするモジュール const app = electron.app; // ウィンドウを作成するモジュール @@ -25,6 +26,8 @@ let mainWindow; var info_path = join(app.getPath("userData"), "window-size.json"); var max_info_path = join(app.getPath("userData"), "max-window-size.json"); var lang_path=join(app.getPath("userData"), "language"); +var customcss=join(app.getPath("userData"), "custom.css"); + var tmp_img = join(app.getPath("userData"), "tmp.png"); var window_size; try { @@ -58,6 +61,7 @@ try { } fs.writeFileSync(lang_path,lang); } +console.log("launch:"+lang); // 全てのウィンドウが閉じたら終了 app.on('window-all-closed', function() { if (process.platform != 'darwin') { @@ -163,9 +167,94 @@ ipc.on('native-notf', function(e, args) { }); //言語 ipc.on('lang', function(e, arg) { + console.log("set:"+arg); fs.writeFileSync(lang_path,arg); mainWindow.webContents.send('langres', ""); }) +//CSS +ipc.on('custom-css-create', function(e, arg) { + fs.writeFileSync(customcss,arg); + mainWindow.webContents.send('custom-css-create-complete', ""); +}) +ipc.on('custom-css-request', function(e, arg) { + try { + var css = fs.readFileSync(customcss, 'utf8'); + } catch (e) { + var css=""; + } + mainWindow.webContents.send('custom-css-response', css); +}) +ipc.on('theme-json-create', function(e, arg) { + console.log(arg); + console.log(JSON5.parse(arg)) + var themecss=join(app.getPath("userData"), JSON5.parse(arg)["id"]+".thedesktheme"); + fs.writeFileSync(themecss,JSON.stringify(JSON5.parse(arg))); + if(JSON5.parse(arg)["id"]){ + mainWindow.webContents.send('theme-json-create-complete', ""); + }else{ + mainWindow.webContents.send('theme-json-create-complete', "error"); + } +}) +ipc.on('theme-json-request', function(e, arg) { + var themecss=join(app.getPath("userData"), arg+".thedesktheme"); + var json = JSON.parse(fs.readFileSync(themecss, 'utf8')); + mainWindow.webContents.send('theme-json-response', json); +}) +ipc.on('theme-css-request', function(e, arg) { + var themecss=join(app.getPath("userData"), arg+".thedesktheme"); + try { + var json = JSON.parse(fs.readFileSync(themecss, 'utf8')); + + var primary=json.vars.primary; + var secondary=json.vars.secondary; + var text=json.vars.text; + if(json.base=="light"){ + var drag="rgba(255, 255, 255, 0.8)"; + var beforehover="#757575"; + }else{ + var drag="rgba(0, 0, 0, 0.8)"; + var beforehover="#9e9e9e"; + } + if(json.props){ + if(json.props.TheDeskAccent){ + var emphasized=json.props.TheDeskAccent + }else{ + var emphasized=secondary; + } + }else{ + var emphasized=secondary; + } + + var css=".customtheme {--bg:"+primary+";--drag:"+drag+";"+ + "--color:"+text+";--beforehover:"+beforehover+";--modal:"+primary+";--subcolor:"+secondary+";--box:"+secondary+";--sidebar:"+secondary+";--shared:"+emphasized+";"+ + "--notfbox:"+primary+";--emphasized:"+secondary+";--his-data:"+primary+ + +"--active:"+secondary+";--postbox:"+secondary+";--modalfooter:"+secondary+";}.blacktheme #imagemodal{background: url(\"../img/pixel.svg\");}"; + mainWindow.webContents.send('theme-css-response', css); + } catch (e) { + var css=""; + } + +}) +ipc.on('theme-json-list', function(e, arg) { + fs.readdir(app.getPath("userData"), function(err, files){ + if (err) throw err; + var fileList = files.filter(function(file){ + var tfile=join(app.getPath("userData"), file); + return fs.statSync(tfile).isFile() && /.*\.thedesktheme$/.test(tfile); //絞り込み + }) + var themes=[]; + for(var i=0;i { }); ipc.on('column-del', (e, args) => { - var options=delsel(lang) + console.log(lang); + var options=language.delsel(lang) dialog.showMessageBox(options, function(index) { mainWindow.webContents.send('column-del-reply', index); }) @@ -452,7 +542,7 @@ ipc.on('nano', function (e, x, y) { buttons: ['拒否', '許可','永続的に許可'] } dialog.showMessageBox(options, function(index) { - if(index==2){ + if(index===2){ mainWindow.webContents.send('adobeagree', "true"); } if(index>0){ diff --git a/app/nano.html b/app/nano.html index 9173c5d5..930193eb 100644 --- a/app/nano.html +++ b/app/nano.html @@ -178,10 +178,10 @@ function post(){ httpreq.open('POST', start, true); httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader('Authorization', 'Bearer ' + at); - httpreq.responseType = 'json'; + httpreq.responseType = "json"; httpreq.send(JSON.stringify(toot)); httpreq.onreadystatechange = function() { - if (httpreq.readyState == 4) { + if (httpreq.readyState === 4) { $("#textarea").val(""); } } diff --git a/app/package-lock.json b/app/package-lock.json index ca43211a..eb994e2d 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -1655,6 +1655,21 @@ "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" }, + "json5": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.0.tgz", + "integrity": "sha512-8Mh9h6xViijj36g7Dxi+Y4S6hNGV96vcJZr/SrlHh1LR/pEn/8j/+qIBbs44YKl69Lrfctp4QD+AdWLTMqEZAQ==", + "requires": { + "minimist": "^1.2.0" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + } + } + }, "jsonfile": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", @@ -1947,7 +1962,8 @@ "node-addon-api": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-1.6.2.tgz", - "integrity": "sha512-479Bjw9nTE5DdBSZZWprFryHGjUaQC31y1wHo19We/k0BZlrmhqQitWoUL0cD8+scljCbIUL+E58oRDEakdGGA==" + "integrity": "sha512-479Bjw9nTE5DdBSZZWprFryHGjUaQC31y1wHo19We/k0BZlrmhqQitWoUL0cD8+scljCbIUL+E58oRDEakdGGA==", + "optional": true }, "node-gyp": { "version": "3.8.0", @@ -2119,6 +2135,7 @@ "version": "0.1.3", "resolved": "https://registry.npmjs.org/nowplaying-node/-/nowplaying-node-0.1.3.tgz", "integrity": "sha512-nEvuw93xmgZS7X1XqUaLJXhd4iB54xjTOnYuEEoPMBHHs3QWGECNKvnD0uDBCe269sUK8Z5InX5rPjzf3vRVrw==", + "optional": true, "requires": { "@types/node": "^10.1.2", "node-addon-api": "^1.2.0", diff --git a/app/package.json b/app/package.json index 3e3a34c0..3bdc70b9 100644 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,6 @@ { "name": "thedesk", - "version": "17.0.2", + "version": "17.2.0", "description": "TheDesk is a Mastodon client for PC.", "main": "main.js", "scripts": { @@ -37,6 +37,7 @@ "electron-dl": "^1.11.0", "font-manager": "^0.3.0", "jimp": "^0.2.28", + "json5": "^2.1.0", "node-notifier": "^5.2.1", "sumchecker": "^2.0.2" }, diff --git a/app/view/en/index.html b/app/view/en/index.html index cdd3f769..fbb70f72 100644 --- a/app/view/en/index.html +++ b/app/view/en/index.html @@ -32,7 +32,7 @@ + +

    Preferences

    • @@ -30,21 +34,10 @@
    Languages
    - 日本語(Japanese)/English/Crowdin web translate/ + 日本語(Japanese)/English/Crowdin web translate/
    Import and export of preferences
    -
    Themes
    - - - - - - - - - -
    Popup notification(on Windows)
    Hide to set "0"
    @@ -88,6 +81,72 @@
  • +
    + color_lensThemes +
    +
    +

    Select theme

    + + + + + + + + + + + + +
    + +
    +

    Edit and add custom themes

    +
    + +
    +
    Name
    + +
    About this theme
    +
    +
    Color scheme
    + + + + +
    +
    +
    Primary
    Background color +
    + +
    +
    +
    Secondary
    Background of components +
    + +
    +
    +
    Texts
    Text color +
    + +
    +
    +
    Accent
    Background of boosts +
    + +
    +
    +
    +
    + Share this code with other TheDesk and Misskey. +

    Import of custom themes

    + {{cImpWarn}}
    + +
    +
  • +
  • reorderTimeline Preferences
    @@ -322,7 +381,7 @@ Spotify and NowPlaying Preferences
    - h5>NowPlaying Provider(Windows) +
    NowPlaying Provider(Windows)
    macOS and Linux are not supported. AIMP and iTunes were checked by developer.
    CAD:foobar2000, MusicBee,J. River Media Center, Media Jukebox
    WLM:Last.fm Client, TTPlayer, OpenPandora, Zune.
    For foobar2000, foo_cad plugin is required. And MusicBee requires CAD.
    @@ -337,7 +396,7 @@ -
    +

    Click music_noteicon to NowPlaying
    Account Connection
    TheDesk save your data on thedesk.top server.
    @@ -443,6 +502,7 @@ TheDeskおよびCutls Pは被災地支援のため + \ No newline at end of file diff --git a/app/view/ja/index.html b/app/view/ja/index.html index 8860d5a0..fd02e2af 100644 --- a/app/view/ja/index.html +++ b/app/view/ja/index.html @@ -32,7 +32,7 @@ + +

    設定

    • @@ -30,21 +34,10 @@
    言語
    -
    日本語(Japanese)/English/Crowdin web translate/ + 日本語(Japanese)/English/Crowdin web translate/
    設定のインポートとエクスポート
    -
    テーマの設定
    - - - - - - - - - -
    新規通知のポップアップお知らせの表示秒数
    0に設定すると表示されません
    @@ -88,6 +81,72 @@
  • +
    + color_lensテーマの設定 +
    +
    +

    テーマの選択

    + + + + + + + + + + + + +
    + +
    +

    カスタムテーマの作成・編集

    +
    + +
    +
    名前
    + +
    説明
    +
    +
    色の系統
    + + + + +
    +
    +
    Primary
    全体の背景色など +
    + +
    +
    +
    Secondary
    補助要素に使われる背景色 +
    + +
    +
    +
    Texts
    テキストの色 +
    + +
    +
    +
    Accent
    ブーストの背景色など +
    + +
    +
    +
    +
    + このコードは他のTheDeskなどとシェアできます。このコードをMiASに貼ることはご遠慮ください。 +

    カスタムテーマのインポート

    + MiAS上の80を超えるテーマを張り付けることもできます。
    + +
    +
  • +
  • reorderタイムラインの設定
    @@ -322,7 +381,7 @@ SpotifyとNowPlayingの設定
    - h5>NowPlayingのソース(Windows) +
    NowPlayingのソース(Windows)
    macOSやLinuxでは動作しません。AIMPとiTunes以外未検証です。
    foobar2000, MusicBee,J. River Media Center, Media JukeboxはCADを、Last.fm Client, TTPlayer, OpenPandora, ZuneはWLMを選んでください。
    ただし、foobar2000はfoo_cad pluginが必要です。MusicBeeもCADを有効にする必要があります。
    @@ -337,7 +396,7 @@ -
    +

    music_noteボタンから簡単にNowPlayingができます。
    アカウントの連携
    APIの性質上,thedesk.topへアクセスします。
    @@ -443,6 +502,7 @@ TheDeskおよびCutls Pは被災地支援のため + \ No newline at end of file diff --git a/app/view/make/language/setting.en.json b/app/view/make/language/setting.en.json index 02b382e4..534068c4 100644 --- a/app/view/make/language/setting.en.json +++ b/app/view/make/language/setting.en.json @@ -28,6 +28,18 @@ "savefolder":"Folder to save", "savefolderwarn":"TheDesk uses this value when it try to save pictures or take screenshots.", "absolute":"absolute value", + "themeSel":"Select theme", + "customtheme":"Edit and add custom themes", + "customthemeDirection":"Color scheme", + "primary":"Background color", + "secondarycolor":"Background of components", + "text":"Text color", + "accent":"Background of boosts", + "add_new":"Add new", + "name":"Name", + "desc":"About this theme", + "customShare":"Share this code with other TheDesk and Misskey.", + "customImport":"Import of custom themes", "timeline":"Timeline Preferences", "timemode":"Time format", "relativetime":"Relative format:\"1 minutes ago\",\"3 days ago\"", diff --git a/app/view/make/language/setting.ja.json b/app/view/make/language/setting.ja.json index 90f819ef..c539ace5 100644 --- a/app/view/make/language/setting.ja.json +++ b/app/view/make/language/setting.ja.json @@ -28,6 +28,19 @@ "savefolder":"デフォルトの保存先", "savefolderwarn":"画像ダウンロードやスクリーンショットに影響します。", "absolute":"絶対指定", + "themeSel":"テーマの選択", + "customtheme":"カスタムテーマの作成・編集", + "customthemeDirection":"色の系統", + "primary":"全体の背景色など", + "secondarycolor":"補助要素に使われる背景色", + "text":"テキストの色", + "accent":"ブーストの背景色など", + "add_new":"新規作成", + "name":"名前", + "desc":"説明", + "customShare":"このコードは他のTheDeskなどとシェアできます。このコードをMiASに貼ることはご遠慮ください。", + "customImport":"カスタムテーマのインポート", + "cImpWarn":"MiAS上の80を超えるテーマを張り付けることもできます。", "timeline":"タイムラインの設定", "timemode":"時間表記設定", "relativetime":"相対時間の例:\"1分前\",\"3日前\"", diff --git a/app/view/make/setting.sample.html b/app/view/make/setting.sample.html index af3de7d8..a19bb63d 100644 --- a/app/view/make/setting.sample.html +++ b/app/view/make/setting.sample.html @@ -12,16 +12,20 @@ + + + +

    {{setting}}

    • @@ -34,17 +38,6 @@
      {{backup}}
      -
      {{theme}}
      - - - - - - - - - -
      {{popup}}
      {{popupwarn}}
      @@ -88,6 +81,72 @@
  • +
    + color_lens{{theme}} +
    +
    +

    {{themeSel}}

    + + + + + + + + + + + + +
    + +
    +

    {{customtheme}}

    +
    + +
    +
    {{name}}
    + +
    {{desc}}
    +
    +
    {{customthemeDirection}}
    + + + + +
    +
    +
    Primary
    {{primary}} +
    + +
    +
    +
    Secondary
    {{secondarycolor}} +
    + +
    +
    +
    Texts
    {{text}} +
    + +
    +
    +
    Accent
    {{accent}} +
    + +
    +
    +
    +
    + {{customShare}} +

    {{customImport}}

    + {{cImpWarn}}
    + +
    +
  • +
  • reorder{{timeline}}
    @@ -322,7 +381,7 @@ {{spotify}}
    - h5>{{npProvider}} +
    {{npProvider}}
    {{npPeoviderWarn}}
    @@ -337,7 +396,7 @@ -
    +

    {{spotifynote1}}music_note{{spotifynote2}}
    {{link}}
    {{linkwarn}}
    @@ -443,6 +502,7 @@ TheDeskおよびCutls Pは被災地支援のため + \ No newline at end of file diff --git a/app/view/ps/index.html b/app/view/ps/index.html index 59a0739a..fe4afab2 100644 --- a/app/view/ps/index.html +++ b/app/view/ps/index.html @@ -32,7 +32,7 @@ + +

    crwdns524:0crwdne524:0

    • @@ -30,21 +34,10 @@
    crwdns530:0crwdne530:0
    -
    日本語(Japanese)/English/Crowdin web translate/ + 日本語(Japanese)/English/Crowdin web translate/
    crwdns531:0crwdne531:0
    -
    crwdns534:0crwdne534:0
    - - - - - - - - - -
    crwdns1898:0crwdne1898:0
    crwdns536:0crwdne536:0
    @@ -88,6 +81,72 @@
  • +
    + color_lenscrwdns534:0crwdne534:0 +
    +
    +

    {{themeSel}}

    + + + + + + + + + + + + +
    + +
    +

    {{customtheme}}

    +
    + +
    +
    {{name}}
    + +
    {{desc}}
    +
    +
    {{customthemeDirection}}
    + + + + +
    +
    +
    Primary
    {{primary}} +
    + +
    +
    +
    Secondary
    {{secondarycolor}} +
    + +
    +
    +
    Texts
    {{text}} +
    + +
    +
    +
    Accent
    {{accent}} +
    + +
    +
    +
    +
    + {{customShare}} +

    {{customImport}}

    + {{cImpWarn}}
    + +
    +
  • +
  • reordercrwdns550:0crwdne550:0
    @@ -322,7 +381,7 @@ crwdns624:0crwdne624:0
    - h5>{{npProvider}} +
    {{npProvider}}
    {{npPeoviderWarn}}
    @@ -337,7 +396,7 @@ -
    +

    crwdns625:0crwdne625:0music_notecrwdns626:0crwdne626:0
    crwdns627:0crwdne627:0
    crwdns628:0crwdne628:0
    @@ -443,6 +502,7 @@ TheDeskおよびCutls Pは被災地支援のため + \ No newline at end of file