add theme and fix for macOS

This commit is contained in:
Cutls
2019-03-08 03:19:26 +09:00
parent b4674c8b09
commit 7950042eb6
48 changed files with 814 additions and 201 deletions

View File

@@ -70,7 +70,7 @@ function defEmoji(target){
$("#textarea").focus();
var selin = $("#textarea").prop('selectionStart');
if(!selin){
selin=0;
selin=0;
}
localStorage.setItem("cursor", selin);
}

View File

@@ -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",

View File

@@ -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":"引用",

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;

View File

@@ -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; i<l; i++){
r += c[Math.floor(Math.random()*cl)];
}
return r;
}
function rgbToHex(color)
{
// HEXに変換したものを代入する変数
var hex = '';
// 第1引数がHEXのとき変換処理は必要ないのでそのままreturn
// IE8の場合はjQueryのcss()関数でHEXを返すので除外
if (color.match(/^#[a-f\d]{3}$|^#[a-f\d]{6}$/i))
{
return color;
}
// 正規表現
var regex = color.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
// 正規表現でマッチしたとき
if (regex)
{
var rgb =
[
// RGBからHEXへ変換
parseInt(regex[1]).toString(16),
parseInt(regex[2]).toString(16),
parseInt(regex[3]).toString(16)
];
for (var i = 0; i < rgb.length; ++i)
{
// rgb(1,1,1)のようなときHEXに変換すると1桁になる
// 1桁のときは前に0を足す
if (rgb[i].length == 1)
{
rgb[i] = '0' + rgb[i];
}
hex += rgb[i];
}
return hex;
}
console.error('第1引数はRGB形式で入力');
}

2
app/js/platform/pickr.js Normal file

File diff suppressed because one or more lines are too long

View File

@@ -290,10 +290,10 @@ function preview(){
for(let l = 0; l < li.length; l++) {
var u=li[l].match(/^1\. (.+)$/);
var listUl='<li>'+u[1]+'</li>';
if(l == 0){
if(l === 0){
listUl='<ol>'+listUl;
}
if(l==li.length-1){
if(l===li.length-1){
listUl=listUl+'</ol>';
}
var bb=bb.replace(new RegExp(li[l], ""),listUl);

View File

@@ -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 {

View File

@@ -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");

View File

@@ -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)

View File

@@ -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")
}

View File

@@ -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")) {

View File

@@ -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;

View File

@@ -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>(.+)<\/p>$/)){
html = html.match(/^<p>(.+)<\/p>$/)[1];
@@ -457,18 +458,21 @@ function trans(tar){
html = html.replace(/<p>/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('<span class="gray">'+text+'</span>');
$("#toot-this .additional").html('<span class="gray">'+text.text+'</span>');
});
}
//ブラウザで開く

View File

@@ -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();

View File

@@ -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'));
}

View File

@@ -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)

View File

@@ -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)
}

View File

@@ -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];

View File

@@ -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='<div class="action pin"><a onclick="trans(\''+toot.language+'\')" class="waves-effect waves-dark btn-flat" style="padding:0" title="'+lang.lang_parse_trans+'"><i class="material-icons">g_translate</i></a></div>';
if(toot.language!=lang.language && toot.language){
var trans='<div class="action pin"><a onclick="trans(\''+toot.language+'\',\''+lang.language+'\')" class="waves-effect waves-dark btn-flat" style="padding:0" title="'+lang.lang_parse_trans+'"><i class="material-icons">g_translate</i></a></div>';
}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='<div class="vote_'+acct_id+'_'+toot.poll.id+'">'+poll+myvote+'<span class="cbadge cbadge-hover" title="' + date(toot.poll.expires_at, 'absolute') +
'"><i class="fa fa-calendar-times-o"></i>' +
date(toot.poll.expires_at, datetype) + '</span></div>';
ended+ '</span></div>';
}
templete = templete + '<div id="pub_' + toot.id + '" class="cvo ' +
boostback + ' ' + fav_app + ' ' + rt_app + ' ' + pin_app +
@@ -905,7 +910,7 @@ function client(name) {
buttons: [lang.lang_parse_clientno,lang.lang_parse_clientemp, lang.lang_parse_clientmute]
}
dialog.showMessageBox(options, function(arg) {
if(arg==1){
if(arg===1){
var cli = localStorage.getItem("client_emp");
var obj = JSON.parse(cli);
if(!obj){
@@ -933,7 +938,7 @@ function client(name) {
}
var json = JSON.stringify(obj);
localStorage.setItem("client_emp", json);
}else if(arg==2){
}else if(arg===2){
var cli = localStorage.getItem("client_mute");
var obj = JSON.parse(cli);
if(!obj){

View File

@@ -70,7 +70,7 @@ function voteMastodon(acct_id,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({choices:choice}));
httpreq.onreadystatechange = function() {
voteMastodonrefresh(acct_id,id)

View File

@@ -116,7 +116,7 @@ function graphDraw(tag){
var two=50-(his[2].uses/max*50);
var one=50-(his[1].uses/max*50);
var zero=50-(his[0].uses/max*50);
if(max==0){
if(max===0){
tags = '<br><br><svg version="1.1" viewbox="0 0 60 50" width="60" height="50">'+
'</svg><span style="font-size:200%">'+his[0].uses+'</span>toots&nbsp;<a onclick="tl(\'tag\',\'' + tag.name + '\',\'' + acct_id +
'\',\'add\')" class="pointer">#' + tag.name + '</a>&nbsp;'+his[0].accounts+lang.lang_src_people;

View File

@@ -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?"
}
}

View File

@@ -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') -

View File

@@ -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<obj.length;i++){

View File

@@ -10,7 +10,7 @@ function scrollck() {
$(".tl-box").each(function(i, elem) {
var tlid = $(this).attr('tlid');
//一番上ならためていた新しいトゥートを表示
if ($(this).scrollTop() == 0) {
if ($(this).scrollTop() === 0) {
var pool = localStorage.getItem("pool_" + tlid);
if (pool) {
$("#timeline_" + tlid).prepend(pool);

View File

@@ -10,13 +10,20 @@ function settings() {
var cd = $("[name=theme]:checked").val();
var ct = $("[for="+cd+"]").html();
if (cd != localStorage.getItem("theme")) {
Materialize.toast(lang.lang_setting_theme.replace("{{set}}" ,ct), 3000);
if(cd=="custom" && !$("#custom-sel-sel").val()){
var theme = localStorage.getItem("theme");
if (!theme) {
var theme = "white";
}
$("#" + theme).prop("checked", true);
}else{
if (cd != localStorage.getItem("theme")) {
Materialize.toast(lang.lang_setting_theme.replace("{{set}}" ,ct), 3000);
}
//テーマはこの場で設定
themes(cd);
localStorage.setItem("theme", cd);
}
//テーマはこの場で設定
themes(cd);
localStorage.setItem("theme", cd);
var nd = $("[name=nsfw]:checked").val();
var nt = $("[for=n_"+nd+"]").text();
if (nd != localStorage.getItem("nsfw")) {
@@ -435,16 +442,9 @@ function load() {
var sect = "nothing";
}
$("#sec-" + sect).prop("checked", true);
}
//最初に読む
load();
climute();
wordmute();
wordemp();
checkSpotify();
voiceSettingLoad();
oksload();
npprovider();
function climute(){
//クライアントミュート
var cli = localStorage.getItem("client_mute");
@@ -723,4 +723,140 @@ function font(){
}
function insertFont(name){
$("#font").val(name);
}
}
$(".color-picker").each(function(i, elem) {
pickerDefine(i,"fff");
});
function pickerDefine(i,color){
var pickr = new Pickr({
el: '#color-picker'+i,
default: color,
showAlways: true,
appendToBody: true,
closeWithKey: 'Escape',
comparison: false,
components: {
preview: true, // Left side color comparison
opacity: false, // Opacity slider
hue: true, // Hue slider
},
strings: {
save: 'Save', // Default for save button
clear: 'Clear' // Default for clear button
}
});
pickr.on('change', (...args) => {
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+'<option value="'+themeid+'">' + theme.name +'</option>';
});
$("#custom-sel-sel").html(templete);
templete='<option value="add_new">'+$("#edit-selector").attr("data-add")+'</option>'+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('<div class="color-picker" id="color-picker0"></div>')
pickerDefine(0,rgbToHex(args.vars.primary))
$("#color-picker1-wrap").html('<div class="color-picker" id="color-picker1"></div>')
pickerDefine(1,rgbToHex(args.vars.secondary))
$("#color-picker2-wrap").html('<div class="color-picker" id="color-picker2"></div>')
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('<div class="color-picker" id="color-picker3"></div>')
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()

View File

@@ -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();

View File

@@ -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');

View File

@@ -46,7 +46,7 @@ function udgEx(user,acct_id){
shell.openExternal(url);
}
});
return;
return true;
}
function udg(user, acct_id) {
reset();