From dd81771ccf9d8a9523e9817a6b3947eb866aa471 Mon Sep 17 00:00:00 2001 From: cutls Date: Mon, 30 Jul 2018 20:03:49 +0900 Subject: [PATCH] TheDesk Akane (16.0.0) --- app/acct.html | 80 ---- app/acct.sample.html | 1 + app/index.sample.html | 6 +- app/js/common/sha256.js | 33 ++ app/js/lang/lang.js | 9 + app/js/lang/parse.lang.js | 41 +++ app/js/login/instance.js | 7 +- app/js/login/manager.js | 118 ++++-- app/js/platform/end.js | 3 + app/js/post/bb-md.js | 8 +- app/js/post/img.js | 33 +- app/js/post/misskeystatus.js | 120 ++++++ app/js/post/post.js | 82 ++++- app/js/post/status.js | 44 ++- app/js/post/use-txtbox.js | 2 +- app/js/tl/card.js | 3 + app/js/tl/datails.js | 315 +++++++++++----- app/js/tl/misskeyparse.js | 685 +++++++++++++++++++++++++++++++++++ app/js/tl/notification.js | 119 ++++-- app/js/tl/parse.js | 10 +- app/js/tl/tl.js | 323 ++++++++++++----- app/js/userdata/his-data.js | 319 +++++++++++----- app/js/userdata/showOnTL.js | 124 +++++++ app/language/index.en.json | 2 +- app/language/setting.en.json | 1 + app/language/setting.ja.json | 1 + app/setting.html | 345 ------------------ app/setting.sample.html | 2 +- app/update.html | 91 ----- 29 files changed, 2070 insertions(+), 857 deletions(-) create mode 100644 app/js/common/sha256.js create mode 100644 app/js/post/misskeystatus.js create mode 100644 app/js/tl/misskeyparse.js diff --git a/app/acct.html b/app/acct.html index 84883120..e69de29b 100644 --- a/app/acct.html +++ b/app/acct.html @@ -1,80 +0,0 @@ - - - -Account Manager - TheDesk - - - - - - - - - - - - - - - - - - - - -Back
-
List of accounts
-
-
-
Add an account

-
-
-
- -
- Check if TheDesk is not working on Windows, you want to login Pleroma instance.
- -
-
-
-
- Supports -
-
-
-
Main an account
-
Select an account -
- - -
-
- -Instance data by instances.social API
-
-@
-Domain:
-Federated instances:
-Toots:
-Users:Users
-Connection:%
-Mastodon version:
- - - - - \ No newline at end of file diff --git a/app/acct.sample.html b/app/acct.sample.html index 89c5b531..7d22352c 100644 --- a/app/acct.sample.html +++ b/app/acct.sample.html @@ -75,6 +75,7 @@ Instance data by instances.so {{ver}}:
+ \ No newline at end of file diff --git a/app/index.sample.html b/app/index.sample.html index 3048ebda..010bcbd7 100644 --- a/app/index.sample.html +++ b/app/index.sample.html @@ -26,7 +26,7 @@ + @@ -785,6 +786,7 @@ var lang="{{lang}}"; + diff --git a/app/js/common/sha256.js b/app/js/common/sha256.js new file mode 100644 index 00000000..c0db22db --- /dev/null +++ b/app/js/common/sha256.js @@ -0,0 +1,33 @@ +/* + A JavaScript implementation of the SHA family of hashes, as + defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding + HMAC implementation as defined in FIPS PUB 198a + + Copyright 2008-2018 Brian Turek, 1998-2009 Paul Johnston & Contributors + Distributed under the BSD License + See http://caligatio.github.com/jsSHA/ for more information +*/ +'use strict';(function(I){function w(c,a,d){var l=0,b=[],g=0,f,n,k,e,h,q,y,p,m=!1,t=[],r=[],u,z=!1;d=d||{};f=d.encoding||"UTF8";u=d.numRounds||1;if(u!==parseInt(u,10)||1>u)throw Error("numRounds must a integer >= 1");if(0===c.lastIndexOf("SHA-",0))if(q=function(b,a){return A(b,a,c)},y=function(b,a,l,f){var g,e;if("SHA-224"===c||"SHA-256"===c)g=(a+65>>>9<<4)+15,e=16;else throw Error("Unexpected error in SHA-2 implementation");for(;b.length<=g;)b.push(0);b[a>>>5]|=128<<24-a%32;a=a+l;b[g]=a&4294967295; +b[g-1]=a/4294967296|0;l=b.length;for(a=0;a>>3;g=e/4-1;if(eb/8){for(;a.length<=g;)a.push(0);a[g]&=4294967040}for(b=0;b<=g;b+=1)t[b]=a[b]^909522486,r[b]=a[b]^1549556828;n=q(t,n);l=h;m=!0};this.update=function(a){var c,f,e,d=0,p=h>>>5;c=k(a,b,g);a=c.binLen;f=c.value;c=a>>>5;for(e=0;e>> +5);g=a%h;z=!0};this.getHash=function(a,f){var d,h,k,q;if(!0===m)throw Error("Cannot call getHash after setting HMAC key");k=C(f);switch(a){case "HEX":d=function(a){return D(a,e,k)};break;case "B64":d=function(a){return E(a,e,k)};break;case "BYTES":d=function(a){return F(a,e)};break;case "ARRAYBUFFER":try{h=new ArrayBuffer(0)}catch(v){throw Error("ARRAYBUFFER not supported by this environment");}d=function(a){return G(a,e)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER"); +}q=y(b.slice(),g,l,p(n));for(h=1;h>>2]>>>8*(3+b%4*-1),l+="0123456789abcdef".charAt(g>>>4&15)+"0123456789abcdef".charAt(g&15);return d.outputUpper?l.toUpperCase():l}function E(c,a,d){var l="",b=a/8,g,f,n;for(g=0;g>>2]:0,n=g+2>>2]:0,n=(c[g>>>2]>>>8*(3+g%4*-1)&255)<<16|(f>>>8*(3+(g+1)%4*-1)&255)<<8|n>>>8*(3+(g+2)%4*-1)&255,f=0;4>f;f+=1)8*g+6*f<=a?l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(n>>> +6*(3-f)&63):l+=d.b64Pad;return l}function F(c,a){var d="",l=a/8,b,g;for(b=0;b>>2]>>>8*(3+b%4*-1)&255,d+=String.fromCharCode(g);return d}function G(c,a){var d=a/8,l,b=new ArrayBuffer(d),g;g=new Uint8Array(b);for(l=0;l>>2]>>>8*(3+l%4*-1)&255;return b}function C(c){var a={outputUpper:!1,b64Pad:"=",shakeLen:-1};c=c||{};a.outputUpper=c.outputUpper||!1;!0===c.hasOwnProperty("b64Pad")&&(a.b64Pad=c.b64Pad);if("boolean"!==typeof a.outputUpper)throw Error("Invalid outputUpper formatting option"); +if("string"!==typeof a.b64Pad)throw Error("Invalid b64Pad formatting option");return a}function B(c,a){var d;switch(a){case "UTF8":case "UTF16BE":case "UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE");}switch(c){case "HEX":d=function(a,b,c){var f=a.length,d,k,e,h,q;if(0!==f%2)throw Error("String of HEX type must be in byte increments");b=b||[0];c=c||0;q=c>>>3;for(d=0;d>>1)+q;for(e=h>>>2;b.length<=e;)b.push(0);b[e]|=k<<8*(3+h%4*-1)}return{value:b,binLen:4*f+c}};break;case "TEXT":d=function(c,b,d){var f,n,k=0,e,h,q,m,p,r;b=b||[0];d=d||0;q=d>>>3;if("UTF8"===a)for(r=3,e=0;ef?n.push(f):2048>f?(n.push(192|f>>>6),n.push(128|f&63)):55296>f||57344<=f?n.push(224|f>>>12,128|f>>>6&63,128|f&63):(e+=1,f=65536+((f&1023)<<10|c.charCodeAt(e)&1023),n.push(240|f>>>18,128|f>>>12&63,128|f>>>6&63,128|f&63)),h=0;h>>2;b.length<=m;)b.push(0);b[m]|=n[h]<<8*(r+p%4*-1);k+=1}else if("UTF16BE"===a||"UTF16LE"===a)for(r=2,n="UTF16LE"===a&&!0||"UTF16LE"!==a&&!1,e=0;e>>8);p=k+q;for(m=p>>>2;b.length<=m;)b.push(0);b[m]|=f<<8*(r+p%4*-1);k+=2}return{value:b,binLen:8*k+d}};break;case "B64":d=function(a,b,c){var f=0,d,k,e,h,q,m,p;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");k=a.indexOf("=");a=a.replace(/\=/g, +"");if(-1!==k&&k/g) || []) .join(''); var tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>?/gi, diff --git a/app/js/post/bb-md.js b/app/js/post/bb-md.js index c9b22b7b..c9b9c7f0 100644 --- a/app/js/post/bb-md.js +++ b/app/js/post/bb-md.js @@ -32,6 +32,9 @@ function mdCheck(){ }else{ $("#trendtag").html(""); } + if(domain=="misskey.xyz"){ + Materialize.toast(lang_bbmd_misskey[lang], 5000); + } if(idata[domain+"_letters"]){ $("#textarea").attr("data-length", idata[domain+"_letters"]) }else{ @@ -104,8 +107,11 @@ if(localStorage.getItem("md")=="hide"){ } //PHPのnl2brと同様 function nl2br(str) { + if(!str){ + return ""; + } str = str.replace(/\r\n/g, "
"); - str = str.replace(/(\n|\r)/g, "
"); + str = str.replace(/(\n|\r)/g, "
"); return str; } //テキストボックスで選択したやつをタグで囲む(BB版) diff --git a/app/js/post/img.js b/app/js/post/img.js index e86e53f4..a49577e6 100644 --- a/app/js/post/img.js +++ b/app/js/post/img.js @@ -101,20 +101,37 @@ function media(b64, type, no) { var acct_id = $("#post-acct-sel").val(); var domain = localStorage.getItem("domain_" + acct_id); var at = localStorage.getItem("acct_"+ acct_id + "_at"); - var start = "https://" + domain + "/api/v1/media"; var httpreq = new XMLHttpRequest(); - httpreq.open('POST', start, true); - httpreq.upload.addEventListener("progress", progshow, false); - httpreq.setRequestHeader('Authorization', 'Bearer ' + at); - httpreq.responseType = 'json'; - httpreq.send(fd); + if(domain=="misskey.xyz"){ + var start = "https://" + domain + "/api/drive/files/create"; + httpreq.open('POST', start, true); + httpreq.upload.addEventListener("progress", progshow, false); + httpreq.responseType = 'json'; + if ($("#nsfw").hasClass("nsfw-avail")) { + var nsfw = true; + } else { + var nsfw = false; + } + var previewer="url" + fd.append('i', at); + //fd.append('isSensitive', nsfw); + httpreq.send(fd); + }else{ + var previewer="preview_url" + var start = "https://" + domain + "/api/v1/media"; + httpreq.open('POST', start, true); + httpreq.upload.addEventListener("progress", progshow, false); + httpreq.responseType = 'json'; + httpreq.setRequestHeader('Authorization', 'Bearer ' + at); + httpreq.send(fd); + } httpreq.onreadystatechange = function() { if (httpreq.readyState == 4) { var json = httpreq.response; console.log(json); var img = localStorage.getItem("img"); - if (json.type=="image") { - var html = ''; + if (json.type.indexOf("image")!=-1) { + var html = ''; $('#preview').append(html); } else { $('#preview').append(lang_postimg_previewdis[lang]); diff --git a/app/js/post/misskeystatus.js b/app/js/post/misskeystatus.js new file mode 100644 index 00000000..8e23644b --- /dev/null +++ b/app/js/post/misskeystatus.js @@ -0,0 +1,120 @@ +//Renpost +function renote(id, acct_id, remote) { + if ($("#pub_" + id).hasClass("rted")) { + return + } + var domain = localStorage.getItem("domain_" + acct_id); + var at = localStorage.getItem("acct_"+ acct_id + "_at"); + var start = "https://" + domain + "/api/notes/create"; + if(domain!="misskey.xyz"){ + return false; + } + var httpreq = new XMLHttpRequest(); + httpreq.open('POST', start, true); + httpreq.setRequestHeader('Content-Type', 'application/json'); + httpreq.responseType = 'json'; + httpreq.send(JSON.stringify({i:at,renoteId:id})); + httpreq.onreadystatechange = function() { + if (httpreq.readyState == 4) { + var json = httpreq.response; + console.log(json); + $("[toot-id=" + id + "]").addClass("rted"); + $(".rt_"+id).toggleClass("teal-text"); + } + } +} +//Renote +function renoteqt(id, acct_id) { + localStorage.setItem("nohide",true); + show(); + $("#reply").val("renote_"+id); + $("#rec").text("Renote"); + $("#post-acct-sel").val(acct_id); + $("#post-acct-sel").prop("disabled", true); + $('select').material_select(); + $("#textarea").attr("placeholder",lang_misskeyparse_qt[lang]); + $("#textarea").focus(); +} +//Reply +function misskeyreply(id, acct_id) { + localStorage.setItem("nohide",true); + show(); + $("#reply").val(id); + $("#rec").text("Renote"); + $("#post-acct-sel").val(acct_id); + $("#post-acct-sel").prop("disabled", true); + $('select').material_select(); + $("#textarea").attr("placeholder",lang_misskeyparse_qt[lang]); + $("#textarea").focus(); +} +//Reaction +function reactiontoggle(id,acct_id,tlid){ + var domain = localStorage.getItem("domain_" + acct_id); + var at = localStorage.getItem("acct_"+ acct_id + "_at"); + var start = "https://" + domain + "/api/notes/show"; + if(domain!="misskey.xyz"){ + return false; + } + var httpreq = new XMLHttpRequest(); + httpreq.open('POST', start, true); + httpreq.setRequestHeader('Content-Type', 'application/json'); + httpreq.responseType = 'json'; + httpreq.send(JSON.stringify({i:at,noteId:id})); + httpreq.onreadystatechange = function() { + if (httpreq.readyState == 4) { + var json = httpreq.response; + console.log(json); + if(json.reactionCounts){ + var reactions=["like","love","laugh","hmm","surprise","congrats","angry","confused","pudding"]; + for(var i=0;i' + date(toot.createdAt, + datetype) + + ''+icon+'
' + dis_name + + "(@" + toot.user.username + + ")"; + var notice = noticetext; + var memory = localStorage.getItem("notice-mem"); + if (popup >= 0 && obj.length < 5 && noticetext != memory) { + if (toot.type == "reply") { + $(".notf-reply_" + acct_id).text($(".notf-reply_" + acct_id+":eq(0)").text()*1+1); + $(".notf-reply_" + acct_id).removeClass("hide") + }else if (toot.type == "renote" || toot.type=="quote") { + $(".notf-bt_" + acct_id).text($(".notf-bt_" + acct_id+":eq(0)").text()*1+1); + $(".notf-bt_" + acct_id).removeClass("hide") + }else if (toot.type == "reaction") { + $(".notf-fav_" + acct_id).text($(".notf-fav_" + acct_id+":eq(0)").text()*1+1); + $(".notf-fav_" + acct_id).removeClass("hide") + } + var domain = localStorage.getItem("domain_" + acct_id); + if(popup>0){ + Materialize.toast("["+domain+"]"+escapeHTML(toot.user.name)+what, popup * 1000); + } + if(native=="yes"){ + var electron = require("electron"); + var ipc = electron.ipcRenderer; + var os = electron.remote.process.platform; + var options = { + body: toot.user.name+"(" + toot.user.username +")"+what+"\n\n"+$.strip_tags(toot.note.text), + icon: toot.user.avatarUrl + }; + if(os=="darwin"){ + var n = new Notification('TheDesk:'+domain, options); + }else{ + ipc.send('native-notf', ['TheDesk:'+domain,toot.user.name+"(" + toot.account.acct +")"+what+"\n\n"+$.strip_tags(toot.note.text),toot.user.avatarUrl]); + } + } + $(".notf-icon_" + acct_id).addClass("red-text"); + localStorage.setItem("notice-mem", noticetext); + noticetext = ""; + } + var if_notf='data-notfIndv="'+acct_id+"_"+toot.id+'"'; + var toot = toot.note; + var dis_name=escapeHTML(toot.user.name); + }else{ + var if_notf=""; + if (toot.renote) { + var rebtxt = lang_parse_btedsimple[lang]; + var rticon = "fa-retweet light-blue-text"; + var notice = ''+ dis_name + "(@" + toot.user.username + + ")
"; + var boostback = "shared"; + var uniqueid=toot.id; + var toot = toot.renote; + var dis_name=escapeHTML(toot.user.name); + var uniqueid=toot.id; + var actemojick=false + } else { + var uniqueid=toot.id; + var notice = ""; + var boostback = ""; + //ユーザー強調 + if(toot.user.host){ + var fullname=toot.user.username+"@"+toot.user.host; + }else{ + var domain = localStorage.getItem("domain_" + acct_id); + var fullname=toot.user.username+"@"+domain; + } + if(useremp){ + Object.keys(useremp).forEach(function(key10) { + var user = useremp[key10]; + if(user==fullname){ + boostback = "emphasized"; + } + }); + } + } + } + var id = toot.id; + if (mix == "home") { + var home = "" + var divider = '
'; + } else { + var home = ""; + var divider = '
'; + } + /* + if (toot.account.locked) { + var locked = ' '; + } else { + var locked = ""; + } + */ + if (!toot.app) { + if(toot.viaMobile){ + var via = 'Mobile'; + }else{ + var via = 'Unknown'; + } + } else { + var via = toot.app.name; + //強調チェック + Object.keys(emp).forEach(function(key6) { + var cli = emp[key6]; + if(cli == via){ + boostback = "emphasized"; + } + }); + //ミュートチェック + Object.keys(mute).forEach(function(key7) { + var cli = mute[key7]; + if(cli == via){ + boostback = "hide"; + } + }); + } + if ((toot.cw || toot.cw=="") && cw) { + var content = toot.text; + var spoil = escapeHTML(toot.cw); + var spoiler = "cw cw_hide_" + toot.id; + var api_spoil = "gray"; + var spoiler_show = ''+lang_parse_cwshow[lang]+'
'; + } else { + var ct1 = nl2br(toot.text).split('
').length -2; + var ct2 = nl2br(toot.text).split('
').length -2; + if(ct1>ct2){ var ct= ct1; }else{ var ct= ct2; } + if ((sent < ct && $.mb_strlen($.strip_tags(toot.text)) > 5) || ($.strip_tags(toot.text).length > ltr && $.mb_strlen($.strip_tags(toot.text)) > 5)) { + var content = ''+lang_parse_fulltext[lang]+'
' + toot.text + var spoil = '' + $.mb_substr($.strip_tags( + toot.text), 0, 100) + + ''+lang_parse_autofold[lang]+''; + var spoiler = "cw cw_hide_" + toot.id; + var spoiler_show = ''+lang_parse_more[lang]+'
'; + } else { + var content = toot.text; + if(toot.cw){ + var spoil = escapeHTML(toot.cw); + }else{ + var spoil=""; + } + + var spoiler = ""; + var spoiler_show = ""; + } + } + var analyze = ''; + var viewer = ""; + var hasmedia = ""; + var youtube = ""; + if(toot.emojis){ + var emojick = toot.emojis[0]; + }else{ + var emojick=false; + } + //デフォ絵文字 + if(content){ + content=content.replace(/(http(s)?:\/\/[\x21-\x7e]+)/gi, "$1") + content=twemoji.parse(content); + }else{ + content=""; + } + + if(dis_name){ + dis_name=twemoji.parse(dis_name); + } + if(spoil){ + spoil=twemoji.parse(spoil); + } + if(noticetext){ + noticetext=twemoji.parse(noticetext); + } + if(notice){ + notice=twemoji.parse(notice); + } + var mediack = toot.media[0]; + //メディアがあれば + var media_ids=""; + if (mediack) { + hasmedia = "hasmedia"; + var cwdt = 100 / toot.media.length; + Object.keys(toot.media).forEach(function(key2) { + var media = toot.media[key2]; + var purl = media.url; + media_ids=media_ids+media.id+","; + var url = media.url; + if (media.isSensitive && nsfw) { + var sense = "sensitive" + } else { + var sense = "" + } + viewer = viewer + ''; + }); + media_ids = media_ids.slice(0, -1) ; + } else { + viewer = ""; + hasmedia = "nomedia"; + } + var menck = toot.reply; + var mentions = ""; + //メンションであれば + if (menck) { + mentions = '
@' + menck.user.username + '
'; + } + var tagck = toot.tags[0]; + var tags = ""; + //タグであれば + if (tagck) { + Object.keys(toot.tags).forEach(function(key4) { + var tag = toot.tags[key4]; + var tags = '#' + tag + '#' + tag + ':TL Toot '+ + 'Pin '; + content=content.replace("#"+tag,tags); + }); + //tags = '
' + tags + '
'; + } + //公開範囲を取得 + var vis = ""; + var visen = toot.visibility; + if (visen == "public") { + var vis = + 'public'; + var can_rt = ""; + } else if (visen == "home") { + var vis = + 'lock_open'; + var can_rt = ""; + } else if (visen == "followers") { + var vis = + 'people'; + var can_rt = ""; + } else if (visen == "private") { + var vis = + 'lock'; + var can_rt = ""; + } else if (visen == "specified") { + var vis = + 'mail'; + var can_rt = "hide"; + } + if (toot.user.username == localStorage.getItem("user_" + acct_id)) { + var if_mine = ""; + var mine_via="type-b"; + } else { + var if_mine = "hide"; + var mine_via=""; + } + if (toot.myReaction) { + var if_fav = " yellow-text"; + var fav_app = "faved"; + } else { + var if_fav = ""; + var fav_app = ""; + } + var if_rt = ""; + var rt_app = ""; + /* + if (toot.reblogged) { + var if_rt = "teal-text"; + var rt_app = "rted"; + } else { + var if_rt = ""; + var rt_app = ""; + } + */ + //アバター + var avatar = toot.user.avatarUrl; + //ワードミュート + if(wordmute){ + Object.keys(wordmute).forEach(function(key8) { + var worde = wordmute[key8]; + if(worde){ + if(worde.tag){ + var word=worde.tag; + }else{ + var word=worde + } + var regExp = new RegExp( word, "g" ) ; + if($.strip_tags(content).match(regExp)){ + boostback = "hide by_filter"; + } + } + }); + } + //ワード強調 + if(wordemp){ + Object.keys(wordemp).forEach(function(key9) { + var word = wordemp[key9]; + if(word){ + var word=word.tag; + var regExp = new RegExp( word, "g" ) ; + content=content.replace(regExp,''+word+""); + } + }); + } + //Reactions + if(toot.reactionCounts){ + if(toot.reactionCounts.like){ + var like=toot.reactionCounts.like; + var likehide=""; + }else{ + var like=0; + var likehide="hide"; + } + if(toot.reactionCounts.love){ + var love=toot.reactionCounts.love; + var lovehide=""; + }else{ + var love=0; + var lovehide="hide"; + } + if(toot.reactionCounts.laugh){ + var laugh=toot.reactionCounts.laugh; + var laughhide=""; + }else{ + var laugh=0; + var laughhide="hide"; + } + if(toot.reactionCounts.hmm){ + var hmm=toot.reactionCounts.hmm; + var hmmhide=""; + }else{ + var hmm=0; + var hmmhide="hide"; + } + if(toot.reactionCounts.surprise){ + var surprise=toot.reactionCounts.surprise; + var suphide=""; + }else{ + var suphide="hide"; + var surprise=0; + } + if(toot.reactionCounts.congrats){ + var congrats=toot.reactionCounts.congrats; + var conghide=""; + }else{ + var congrats=0; + var conghide="hide"; + } + if(toot.reactionCounts.angry){ + var angry=toot.reactionCounts.angry; + var anghide=""; + }else{ + var angry=0; + var anghide="hide"; + } + if(toot.reactionCounts.confused){ + var confhide=""; + var confused=toot.reactionCounts.confused; + }else{ + var confused=0; + var confhide="hide"; + } + if(toot.reactionCounts.pudding){ + var pudding=toot.reactionCounts.pudding; + var pudhide=""; + }else{ + var pudding=0; + var pudhide="hide"; + } + var fullhide=""; + }else{ + var like=0;var love=0;var laugh=0;var hmm=0;var surprise=0;var congrats=0;var angry=0;var confused=0;var pudding=0; + var likehide="hide";var lovehide="hide";var laughhide="hide";var hmmhide="hide";var suphide="hide";var conghide="hide";var anghide="hide";var confhide="hide";var pudhide="hide"; + var fullhide="hide"; + } + if(toot.myReaction){ + var reacted=toot.myReaction; + }else{ + var reacted=""; + } + content=nl2br(content); + var trans=""; + templete = templete + '
' + + '
' + notice + home + + '
' + + '' + + '
' + + dis_name + + ' @' + + toot.user.username + '
' + + '
' + + date(toot.createdAt, datetype) + '' + + '
' + + '
' + content + + '' + spoil + spoiler_show + + '' + + '' + viewer + '' + + '
' + + '
'+ + '
' + + '
'+vis+'
'+ + '' + + '
' + + '
' + + '
' + + '
' + + '
' + + '
' + +''+trans+ + 'via ' + + via + + ''+ + '
' + + '' + + '
' + + ''; + }); + return templete; +} + +//オブジェクトパーサー(ユーザーデータ) +function misskeyUserparse(obj, auth, acct_id, tlid, popup) { + if(popup > 0 || popup==-1){ + + }else{ + var obj = obj.users; + } + var templete = ''; + var datetype = localStorage.getItem("datetype"); + Object.keys(obj).forEach(function(key) { + var toot = obj[key]; + var locked = ""; + if (auth) { + var auth = 'person_add'; + } else { + var auth = ""; + } + var ftxt=lang_parse_followed[lang]; + if(popup > 0 || popup==-1){ + var notftext='' + date(toot.createdAt, + datetype) + + ''+ftxt+'
'; + var toot = toot.user; + }else{ + var notftext=""; + } + var memory = localStorage.getItem("notice-mem"); + if (popup >= 0 && obj.length < 5 && notftext != memory) { + Materialize.toast(escapeHTML(toot.name)+":"+ftxt, popup * 1000); + $(".notf-icon_" + tlid).addClass("red-text"); + localStorage.setItem("notice-mem", notftext); + notftext = ""; + } + if(toot.name){ + var dis_name=escapeHTML(toot.name); + dis_name=twemoji.parse(dis_name); + }else{ + var dis_name=toot.name; + } + console.log(dis_name) + templete = templete + + '
' + + notftext + + '
' + + '
' + + dis_name + '' + + ' @' + + toot.username + auth +'' + + '
' + + '
' + + '
Follows:' + + toot.followingCount + + '
Followers:' + toot.followersCount + + '
' + + '
' + + '
' + + ''; + + }); + return templete; +} \ No newline at end of file diff --git a/app/js/tl/notification.js b/app/js/tl/notification.js index 7927dfbe..1d86cd62 100644 --- a/app/js/tl/notification.js +++ b/app/js/tl/notification.js @@ -3,20 +3,33 @@ function notf(acct_id, tlid, sys) { todo("Notifications Loading..."); var native=localStorage.getItem("nativenotf"); + var at = localStorage.getItem("acct_"+ acct_id + "_at"); if(!native){ native="yes"; } var domain = localStorage.getItem("domain_" + acct_id); - var at = localStorage.getItem("acct_"+ acct_id + "_at"); - var start = "https://" + domain + "/api/v1/notifications"; - fetch(start, { - method: 'GET', - headers: { - 'content-type': 'application/json', - 'Authorization': 'Bearer ' + at - }, - //body: JSON.stringify({}) - }).then(function(response) { + if(domain=="misskey.xyz"){ + var start = "https://" + domain + "/api/i/notifications"; + var i={ + method: 'POST', + headers: { + 'content-type': 'application/json', + }, + body:JSON.stringify({ + i:at + }) + } + }else{ + var start = "https://" + domain + "/api/v1/notifications"; + var i={ + method: 'GET', + headers: { + 'content-type': 'application/json', + 'Authorization': 'Bearer ' + at + }, + } + } + fetch(start, i).then(function(response) { return response.json(); }).catch(function(error) { todo(error); @@ -25,7 +38,6 @@ function notf(acct_id, tlid, sys) { if(json[0]){ var templete=""; var lastnotf=localStorage.getItem("lastnotf_" + acct_id); - console.log(domain); localStorage.setItem("lastnotf_" + acct_id,json[0].id); Object.keys(json).forEach(function(key) { var obj = json[key]; @@ -54,9 +66,18 @@ function notf(acct_id, tlid, sys) { var mute=[]; } if(obj.type!="follow"){ - templete = templete+parse([obj], 'notf', acct_id, 'notf', -1, mute); + if(domain=="misskey.xyz"){ + templete = templete+misskeyParse([obj], 'notf', acct_id, 'notf', -1, mute); + }else{ + templete = templete+parse([obj], 'notf', acct_id, 'notf', -1, mute); + } }else{ - templete = templete+userparse([obj.account], 'notf', acct_id, 'notf', -1); + if(domain=="misskey.xyz"){ + templete = templete+misskeyUserparse([obj], 'notf', acct_id, 'notf', -1, mute); + }else{ + templete = templete+userparse([obj.account], 'notf', acct_id, 'notf', -1); + } + } }); @@ -71,8 +92,13 @@ function notf(acct_id, tlid, sys) { $("#notf-box").addClass("fetched"); todc(); }); - var start = "wss://" + domain + "/api/v1/streaming/?stream=user&access_token=" + + if(domain!="misskey.xyz"){ + var start = "wss://" + domain + "/api/v1/streaming/?stream=user&access_token=" + at; + }else{ + var start = "wss://" + domain + "/?i=" + + at; + } console.log(start); var wsid = websocketNotf.length; @@ -85,15 +111,30 @@ function notf(acct_id, tlid, sys) { } websocketNotf[wsid].onmessage = function(mess) { console.log("Receive Streaming API(Notf):"+acct_id); - + var popup = localStorage.getItem("popup"); + if (!popup) { + popup = 0; + } + if(domain=="misskey.xyz"){ + console.log(JSON.parse(mess.data)); + if (JSON.parse(mess.data).type == "notification") { + var obj = JSON.parse(mess.data).body; + console.log(obj); + if(obj.type!="follow"){ + templete = misskeyParse([obj], 'notf', acct_id, 'notf', popup); + }else{ + templete = misskeyUserparse([obj], 'notf', acct_id, 'notf', popup); + } + if(!$("div[data-notfIndv=" + acct_id +"_"+obj.id+"]").length){ + $("div[data-notf=" + acct_id +"]").prepend(templete); + } + jQuery("time.timeago").timeago(); + } + }else{ var obj = JSON.parse(JSON.parse(mess.data).payload); console.log(obj); var type = JSON.parse(mess.data).event; if (type == "notification") { - var popup = localStorage.getItem("popup"); - if (!popup) { - popup = 0; - } var templete=""; localStorage.setItem("lastnotf_" + acct_id,obj.id); if(obj.type!="follow"){ @@ -109,7 +150,7 @@ function notf(acct_id, tlid, sys) { $("[toot-id=" + obj + "]").hide(); $("[toot-id=" + obj + "]").remove(); } - + } } websocketNotf[wsid].onerror = function(error) { console.error('WebSocket Error ' + error); @@ -133,8 +174,30 @@ function notfmore(tlid) { todo("Notfication TL MoreLoading"); var domain = localStorage.getItem("domain_" + acct_id); var at = localStorage.getItem("acct_"+ acct_id + "_at"); - var start = "https://" + domain + "/api/v1/notifications"+ - "max_id=" + sid; + + if(domain=="misskey.xyz"){ + var start = "https://" + domain + "/api/i/notifications"; + var i={ + method: 'POST', + headers: { + 'content-type': 'application/json', + }, + body:JSON.stringify({ + i:at, + untilId:sid + }) + } + }else{ + var start = "https://" + domain + "/api/v1/notifications"+ + "max_id=" + sid; + var i={ + method: 'GET', + headers: { + 'content-type': 'application/json', + 'Authorization': 'Bearer ' + at + }, + } + } fetch(start, { method: 'GET', headers: { @@ -151,9 +214,17 @@ function notfmore(tlid) { Object.keys(json).forEach(function(key) { var obj = json[key]; if(obj.type!="follow"){ - templete = templete+parse([obj], '', acct_id, tlid, -1); + if(domain=="misskey.xyz"){ + templete = templete+misskeyParse([obj], '', acct_id, tlid, -1); + }else{ + templete = templete+parse([obj], '', acct_id, tlid, -1); + } }else{ - templete = templete+userparse([obj.account], '', acct_id, tlid, -1); + if(domain=="misskey.xyz"){ + templete = templete+misskeyUserparse([obj], '', acct_id, tlid, -1); + }else{ + templete = templete+userparse([obj.account], '', acct_id, tlid, -1); + } } }); diff --git a/app/js/tl/parse.js b/app/js/tl/parse.js index 7fb246cd..9d3e0678 100644 --- a/app/js/tl/parse.js +++ b/app/js/tl/parse.js @@ -633,16 +633,16 @@ function userparse(obj, auth, acct_id, tlid, popup) { var notftext='' + date(toot.created_at, datetype) + - ''+ftxt+'。
'; + ''+ftxt+'
'; }else{ var notftext=""; } var memory = localStorage.getItem("notice-mem"); - if (popup >= 0 && obj.length < 5 && noticetext != memory) { - Materialize.toast(escapeHTML(toot.display_name)+"に"+ftxt, popup * 1000); + if (popup >= 0 && obj.length < 5 && notftext != memory) { + Materialize.toast(escapeHTML(toot.display_name)+":"+ftxt, popup * 1000); $(".notf-icon_" + tlid).addClass("red-text"); - localStorage.setItem("notice-mem", noticetext); - noticetext = ""; + localStorage.setItem("notice-mem", notftext); + notftext = ""; } var dis_name=escapeHTML(toot.display_name); if(toot.emojis){ diff --git a/app/js/tl/tl.js b/app/js/tl/tl.js index 225ef0f2..6c107800 100644 --- a/app/js/tl/tl.js +++ b/app/js/tl/tl.js @@ -31,7 +31,7 @@ function tl(type, data, acct_id, tlid, delc, voice) { var type = "local"; } } - if (type == "mix") { + if (type == "mix" && domain != "misskey.xyz") { //Integratedなら飛ばす $("#notice_" + tlid).text("Integrated TL(" + localStorage.getItem( "user_" + acct_id) + "@" + domain + ")"); @@ -71,31 +71,63 @@ function tl(type, data, acct_id, tlid, delc, voice) { $("#notice_" + tlid).text("Glance TL(" + domain + ")"); } $("#notice_icon_" + tlid).text(icon(type)); - var url=com(type, data); - if(type=="tag"){ - var tag = localStorage.getItem("tag-range"); - if(tag=="local"){ - url=url+"local=true"; + if(domain=="misskey.xyz"){ + var url=misskeycom(type, data); + var start = "https://" + domain + "/api/notes/"+url; + var method="POST"; + var req={}; + if(type!="noauth"){ + req.i=at; } + if(type=="local-media"||type=="pub-media"){ + req.mediaOnly=true; + } + if(type=="tag"){ + req.tag=data; + } + if(type=="list"){ + req.listId=data; + } + req.limit=20; + var i={ + method: method, + headers: hdr, + body: JSON.stringify(req), + } + }else{ + var url=com(type, data); + if(type=="tag"){ + var tag = localStorage.getItem("tag-range"); + if(tag=="local"){ + url=url+"local=true"; + } + } + var start = "https://" + domain + "/api/v1/timelines/" + url; + var method="GET"; + var i={ + method: method, + headers: hdr + }; } - var start = "https://" + domain + "/api/v1/timelines/" + url; + console.log(start); - fetch(start, { - method: 'GET', - headers: hdr, - }).then(function(response) { + fetch(start, i).then(function(response) { return response.json(); }).catch(function(error) { todo(error); console.error(error); }).then(function(json) { + console.log(json); if(localStorage.getItem("filter_"+ acct_id)!="undefined"){ var mute=getFilterType(JSON.parse(localStorage.getItem("filter_"+ acct_id)),type); }else{ var mute=[]; } - - var templete = parse(json, type, acct_id, tlid, "", mute); + if(domain=="misskey.xyz"){ + var templete = misskeyParse(json, type, acct_id, tlid, "", mute); + }else{ + var templete = parse(json, type, acct_id, tlid, "", mute); + } $("#timeline_" + tlid).html(templete); additional(acct_id, tlid); jQuery("time.timeago").timeago(); @@ -113,40 +145,70 @@ function reload(type, cc, acct_id, tlid, data, mute, delc, voice) { var domain = localStorage.getItem("domain_" + acct_id); var at = localStorage.getItem("acct_"+ acct_id + "_at"); localStorage.setItem("now", type); - if (type == "home") { - var start = "wss://" + domain + - "/api/v1/streaming/?stream=user&access_token=" + at; - } else if (type == "pub") { - var start = "wss://" + domain + - "/api/v1/streaming/?stream=public&access_token=" + at; - } else if (type == "pub-media") { - var start = "wss://" + domain + - "/api/v1/streaming/?stream=public:media&access_token=" + at; - } else if (type == "local") { - var start = "wss://" + domain + - "/api/v1/streaming/?stream=public:local&access_token=" + at; - } else if (type == "local-media") { - var start = "wss://" + domain + - "/api/v1/streaming/?stream=public:local:media&only_media=true&access_token=" + at; - } else if (type == "tag") { - if(type=="tag"){ - var tag = localStorage.getItem("tag-range"); - if(tag=="local"){ - data=data+"&local=true"; - } + if(domain=="misskey.xyz"){ + if (type == "home") { + var start = "wss://" + domain + + "/?i=" + at; + } else if (type == "pub") { + var start = "wss://" + domain + + "/global-timeline?i=" + at; + } else if (type == "pub-media") { + var start = "wss://" + domain + + "/global-timeline?i=" + at; + } else if (type == "local") { + var start = "wss://" + domain + + "/local-timeline?i=" + at; + } else if (type == "local-media") { + var start = "wss://" + domain + + "/local-timeline?i=" + at; + } else if (type == "mix") { + var start = "wss://" + domain + + "/hybrid-timeline?i=" + at; + } else if (type == "tag") { + Materialize.toast(lang_misskeyparse_tagnostr[lang], 1000); + } else if (type == "noauth") { + var start = "wss://" + acct_id + + "/local-timeline?i=" + at; + } else if (type=="list"){ + Materialize.toast(lang_misskeyparse_listnostr[lang], 1000); + } + }else{ + if (type == "home") { + var start = "wss://" + domain + + "/api/v1/streaming/?stream=user&access_token=" + at; + } else if (type == "pub") { + var start = "wss://" + domain + + "/api/v1/streaming/?stream=public&access_token=" + at; + } else if (type == "pub-media") { + var start = "wss://" + domain + + "/api/v1/streaming/?stream=public:media&access_token=" + at; + } else if (type == "local") { + var start = "wss://" + domain + + "/api/v1/streaming/?stream=public:local&access_token=" + at; + } else if (type == "local-media") { + var start = "wss://" + domain + + "/api/v1/streaming/?stream=public:local:media&only_media=true&access_token=" + at; + } else if (type == "tag") { + if(type=="tag"){ + var tag = localStorage.getItem("tag-range"); + if(tag=="local"){ + data=data+"&local=true"; + } + } + var start = "wss://" + domain + + "/api/v1/streaming/?stream=hashtag&tag=" + data +"&access_token=" + at; + } else if (type == "noauth") { + var start = "wss://" + acct_id + + "/api/v1/streaming/?stream=public:local"; + } else if (type=="list"){ + var start = "wss://" + domain + + "/api/v1/streaming/?stream=list&list=" + data +"&access_token=" + at; + } else if (type=="dm"){ + var start = "wss://" + domain + + "/api/v1/streaming/?stream=direct&access_token=" + at; } - var start = "wss://" + domain + - "/api/v1/streaming/?stream=hashtag&tag=" + data +"&access_token=" + at; - } else if (type == "noauth") { - var start = "wss://" + acct_id + - "/api/v1/streaming/?stream=public:local"; - } else if (type=="list"){ - var start = "wss://" + domain + - "/api/v1/streaming/?stream=list&list=" + data +"&access_token=" + at; - } else if (type=="dm"){ - var start = "wss://" + domain + - "/api/v1/streaming/?stream=direct&access_token=" + at; } + console.log(start); var wsid = websocket.length; websocket[wsid] = new WebSocket(start); @@ -157,29 +219,14 @@ function reload(type, cc, acct_id, tlid, data, mute, delc, voice) { } websocket[wsid].onmessage = function(mess) { console.log(tlid + ":Receive Streaming API:"); - console.log(mess); - - - var typeA = JSON.parse(mess.data).event; - if (typeA == "delete") { - var obj = JSON.parse(mess.data).payload; - if(delc=="true"){ - $("#timeline_"+tlid+" [toot-id=" + JSON.parse(mess.data).payload + "]").addClass("emphasized"); - $("#timeline_"+tlid+" [toot-id=" + JSON.parse(mess.data).payload + "]").addClass("by_delcatch"); - }else{ - $("[toot-id=" + JSON.parse(mess.data).payload + "]").hide(); - $("[toot-id=" + JSON.parse(mess.data).payload + "]").remove(); - } - - } else if (typeA == "update") { - var obj = JSON.parse(JSON.parse(mess.data).payload); - console.log(obj); - if($("#timeline_" + tlid +" [toot-id=" + obj.id + "]").length < 1){ - console.log("speech:"+voice); + console.log(JSON.parse(mess.data)); + if(domain=="misskey.xyz"){ + if (JSON.parse(mess.data).type == "note") { + var obj = JSON.parse(mess.data).body; if(voice){ say(obj.content) - } - var templete = parse([obj], type, acct_id, tlid,"",mute); + } + var templete = misskeyParse([obj], type, acct_id, tlid,"",mute); var pool = localStorage.getItem("pool_" + tlid); if (pool) { pool = templete + pool; @@ -187,22 +234,52 @@ function reload(type, cc, acct_id, tlid, data, mute, delc, voice) { pool = templete } localStorage.setItem("pool_" + tlid, pool); - scrollck(); - - additional(acct_id, tlid); jQuery("time.timeago").timeago(); - }else{ - todo("二重取得発生中"); } - - todc(); - }else if(typeA=="filters_changed"){ - filterUpdate(acct_id); - } - websocket[wsid].onclose = function(mess) { - console.log("Close Streaming API:" + type); + }else{ + var typeA = JSON.parse(mess.data).event; + if (typeA == "delete") { + var obj = JSON.parse(mess.data).payload; + if(delc=="true"){ + $("#timeline_"+tlid+" [toot-id=" + JSON.parse(mess.data).payload + "]").addClass("emphasized"); + $("#timeline_"+tlid+" [toot-id=" + JSON.parse(mess.data).payload + "]").addClass("by_delcatch"); + }else{ + $("[toot-id=" + JSON.parse(mess.data).payload + "]").hide(); + $("[toot-id=" + JSON.parse(mess.data).payload + "]").remove(); + } + + } else if (typeA == "update") { + var obj = JSON.parse(JSON.parse(mess.data).payload); + console.log(obj); + if($("#timeline_" + tlid +" [toot-id=" + obj.id + "]").length < 1){ + if(voice){ + say(obj.content) + } + var templete = parse([obj], type, acct_id, tlid,"",mute); + var pool = localStorage.getItem("pool_" + tlid); + if (pool) { + pool = templete + pool; + } else { + pool = templete + } + localStorage.setItem("pool_" + tlid, pool); + + scrollck(); + + additional(acct_id, tlid); + jQuery("time.timeago").timeago(); + }else{ + todo("二重取得発生中"); + } + + todc(); + }else if(typeA=="filters_changed"){ + filterUpdate(acct_id); + } } + + } websocket[wsid].onerror = function(error) { console.error('WebSocket Error ' + error); @@ -231,10 +308,10 @@ function moreload(type, tlid) { var sid = $("#timeline_" + tlid + " .cvo").last().attr("unique-id"); if (localStorage.getItem("morelock") != sid) { localStorage.setItem("morelock", sid); - if (type == "mix") { + if (type == "mix" && domain!="misskey.xyz") { mixmore(tlid,"integrated"); return; - }else if (type == "plus") { + }else if (type == "plus" && domain!="misskey.xyz") { mixmore(tlid,"plus"); return; }else if (type == "notf") { @@ -243,23 +320,68 @@ function moreload(type, tlid) { } localStorage.setItem("now", type); todo(cap(type) + " TL MoreLoading"); - var domain = localStorage.getItem("domain_" + acct_id); - var at = localStorage.getItem("acct_"+ acct_id + "_at"); - var start = "https://" + domain + "/api/v1/timelines/" + com(type,data) + - "max_id=" + sid; - fetch(start, { - method: 'GET', - headers: { + if(type!="noauth"){ + var hdr={ 'content-type': 'application/json', 'Authorization': 'Bearer ' + at - }, - }).then(function(response) { + }; + var domain = localStorage.getItem("domain_" + acct_id); + var at = localStorage.getItem("acct_"+ acct_id + "_at"); + }else{ + var hdr={ + 'content-type': 'application/json' + }; + domain=acct_id; + } + if(domain=="misskey.xyz"){ + hdr={ + 'content-type': 'application/json' + }; + var url=misskeycom(type, data); + var start = "https://" + domain + "/api/notes/"+url; + var method="POST"; + var req={}; + if(type!="noauth"){ + req.i=at; + } + if(type=="local-media"||type=="pub-media"){ + req.mediaOnly=true; + } + if(type=="tag"){ + req.tag=data; + } + if(type=="list"){ + req.listId=data; + } + req.untilId=sid; + req.limit=20; + var i={ + method: method, + headers: hdr, + body: JSON.stringify(req), + } + }else{ + var start = "https://" + domain + "/api/v1/timelines/" + com(type,data) + + "max_id=" + sid; + var method="GET"; + var i={ + method: method, + headers: hdr + }; + } + + + fetch(start, i).then(function(response) { return response.json(); }).catch(function(error) { todo(error); console.error(error); }).then(function(json) { - var templete = parse(json, '', acct_id, tlid,"",mute); + if(domain=="misskey.xyz"){ + var templete = misskeyParse(json, '', acct_id, tlid,"",mute); + }else{ + var templete = parse(json, '', acct_id, tlid,"",mute); + } $("#timeline_" + tlid).append(templete); additional(acct_id, tlid); jQuery("time.timeago").timeago(); @@ -390,6 +512,25 @@ function com(type, data) { return "direct?" } } +function misskeycom(type, data) { + if (type == "home") { + return "timeline" + }else if (type == "mix") { + return "hybrid-timeline" + } else if (type == "local" || type == "noauth") { + return "local-timeline" + } else if (type == "local-media") { + return "local-timeline" + } else if (type == "pub") { + return "global-timeline" + } else if (type == "pub-media") { + return "global-timeline" + } else if (type == "tag") { + return "search_by_tag" + }else if (type == "list") { + return "user-list-timeline" + } +} //TLのアイコン function icon(type) { @@ -407,5 +548,7 @@ function icon(type) { return "subject" }else if (type == "dm") { return "mail" + }else if (type == "mix") { + return "share" } } \ No newline at end of file diff --git a/app/js/userdata/his-data.js b/app/js/userdata/his-data.js index 945ff291..a62f9aa6 100644 --- a/app/js/userdata/his-data.js +++ b/app/js/userdata/his-data.js @@ -9,27 +9,49 @@ function utl(user, more, acct_id) { if (user == "--now") { var user = $('#his-data').attr("user-id"); } - if (more) { - var sid = $("#his-tl .cvo").last().attr("toot-id"); - var plus = "?max_id=" + sid; - } else { - var plus = ""; + if(domain!="misskey.xyz"){ + if (more) { + var sid = $("#his-tl .cvo").last().attr("toot-id"); + var plus = "?max_id=" + sid; + } else { + var plus = ""; + } + var start = "https://" + domain + "/api/v1/accounts/" + user + "/statuses" + + plus; + var i={ + method: 'GET', + headers: { + 'content-type': 'application/json', + 'Authorization': 'Bearer ' + at + } + } + }else{ + var req={i:at} + if (more) { + var sid = $("#his-tl .cvo").last().attr("toot-id"); + req.maxId=sid; + } + req.userId=user; + var start = "https://" + domain + "/api/users/notes" + var i={ + method: 'POST', + headers: { + 'content-type': 'application/json', + }, + body:JSON.stringify(req) + } } - var start = "https://" + domain + "/api/v1/accounts/" + user + "/statuses" + - plus - fetch(start, { - method: 'GET', - headers: { - 'content-type': 'application/json', - 'Authorization': 'Bearer ' + at - }, - }).then(function(response) { + fetch(start, i).then(function(response) { return response.json(); }).catch(function(error) { todo(error); console.error(error); }).then(function(json) { - var templete = parse(json, '', acct_id); + if(domain=="misskey.xyz"){ + var templete = misskeyParse(json, '', acct_id); + }else{ + var templete = parse(json, '', acct_id); + } if(!json[0]){ templete=lang_details_nodata[lang]+"
"; } @@ -38,7 +60,11 @@ function utl(user, more, acct_id) { if (more) { $("#his-tl-contents").append(templete); } else { - pinutl(templete,user, acct_id) + if(domain!="misskey.xyz"){ + pinutl(templete,user, acct_id) + }else{ + $("#his-tl-contents").html(templete); + } } jQuery("time.timeago").timeago(); }); @@ -89,28 +115,49 @@ function flw(user, more, acct_id) { if (user == "--now") { var user = $('#his-data').attr("user-id"); } - if (more) { - var sid = $("#his-follow-list .cvo").last().attr("user-id"); - var plus = "?max_id=" + sid; - } else { - var plus = ""; + if(domain=="misskey.xyz"){ + var req={i:at} + if (more) { + var sid = $("#his-follow-list .cvo").last().attr("user-id"); + req.maxId=sid; + } + req.userId=user; + var start = "https://" + domain + "/api/users/following" + var i={ + method: 'POST', + headers: { + 'content-type': 'application/json', + }, + body:JSON.stringify(req) + } + }else{ + if (more) { + var sid = $("#his-follow-list .cvo").last().attr("user-id"); + var plus = "?max_id=" + sid; + } else { + var plus = ""; + } + var start = "https://" + domain + "/api/v1/accounts/" + user + "/following" + + plus + var i={ + method: 'GET', + headers: { + 'content-type': 'application/json', + } + } } - var start = "https://" + domain + "/api/v1/accounts/" + user + "/following" + - plus - fetch(start, { - method: 'GET', - headers: { - 'content-type': 'application/json', - 'Authorization': 'Bearer ' + at - }, - }).then(function(response) { + fetch(start,i).then(function(response) { return response.json(); }).catch(function(error) { todo(error); console.error(error); }).then(function(json) { - var templete = userparse(json,'',acct_id); - if(!json[0]){ + if(domain=="misskey.xyz"){ + var templete = misskeyUserparse(json,'',acct_id); + }else{ + var templete = userparse(json,'',acct_id); + } + if(templete==""){ templete=lang_details_nodata[lang]+"
"; } if (more) { @@ -133,28 +180,49 @@ function fer(user, more, acct_id) { if (user == "--now") { var user = $('#his-data').attr("user-id"); } - if (more) { - var sid = $("#his-follower-list .cvo").last().attr("user-id"); - var plus = "?max_id=" + sid; - } else { - var plus = ""; + if(domain=="misskey.xyz"){ + var req={i:at} + if (more) { + var sid = $("#his-follower-list .cvo").last().attr("user-id"); + req.maxId=sid; + } + req.userId=user; + var start = "https://" + domain + "/api/users/followers" + var i={ + method: 'POST', + headers: { + 'content-type': 'application/json', + }, + body:JSON.stringify(req) + } + }else{ + if (more) { + var sid = $("#his-follower-list .cvo").last().attr("user-id"); + var plus = "?max_id=" + sid; + } else { + var plus = ""; + } + var start = "https://" + domain + "/api/v1/accounts/" + user + "/followers" + + plus + var i={ + method: 'GET', + headers: { + 'content-type': 'application/json', + } + } } - var start = "https://" + domain + "/api/v1/accounts/" + user + "/followers" + - plus; - fetch(start, { - method: 'GET', - headers: { - 'content-type': 'application/json', - 'Authorization': 'Bearer ' + at - }, - }).then(function(response) { + fetch(start, i).then(function(response) { return response.json(); }).catch(function(error) { todo(error); console.error(error); }).then(function(json) { - var templete = userparse(json,'',acct_id); - if(!json[0]){ + if(domain=="misskey.xyz"){ + var templete = misskeyUserparse(json,'',acct_id); + }else{ + var templete = userparse(json,'',acct_id); + } + if(templete==""){ templete=lang_details_nodata[lang]+"
"; } if (more) { @@ -174,26 +242,48 @@ function showFav(more, acct_id) { } var domain = localStorage.getItem("domain_" + acct_id); var at = localStorage.getItem("acct_"+ acct_id + "_at"); - if (more) { - var sid = $("#his-fav-list .cvo").last().attr("toot-id"); - var plus = "?max_id=" + sid; - } else { - var plus = ""; + if(domain!="misskey.xyz"){ + if (more) { + var sid = $("#his-fav-list .cvo").last().attr("toot-id"); + var plus = "?max_id=" + sid; + } else { + var plus = ""; + } + var start = "https://" + domain + "/api/v1/favourites" + plus + var i={ + method: 'GET', + headers: { + 'content-type': 'application/json', + 'Authorization': 'Bearer ' + at + } + } + }else{ + var req={i:at} + if (more) { + var sid = $("#his-fav-list .cvo").last().attr("toot-id"); + req.maxId=sid; + } + var start = "https://" + domain + "/api/i/favorites" + var i={ + method: 'POST', + headers: { + 'content-type': 'application/json', + }, + body:JSON.stringify(req) + } } - var start = "https://" + domain + "/api/v1/favourites" + plus - fetch(start, { - method: 'GET', - headers: { - 'content-type': 'application/json', - 'Authorization': 'Bearer ' + at - }, - }).then(function(response) { + + fetch(start, i).then(function(response) { return response.json(); }).catch(function(error) { todo(error); console.error(error); }).then(function(json) { - var templete = parse(json, '', acct_id); + if(domain!="misskey.xyz"){ + var templete = parse(json, '', acct_id); + }else{ + var templete = misskeyParse(json, '', acct_id); + } if(!json[0]){ templete=lang_details_nodata[lang]+"
"; } @@ -213,20 +303,37 @@ function showMut(more, acct_id) { } var domain = localStorage.getItem("domain_" + acct_id); var at = localStorage.getItem("acct_"+ acct_id + "_at"); - if (more) { - var sid = $("#his-muting-list .cvo").last().attr("user-id"); - var plus = "?max_id=" + sid; - } else { - var plus = ""; + if(domain=="misskey.xyz"){ + var req={i:at} + if (more) { + var sid = $("#his-muting-list .cvo").last().attr("user-id"); + req.maxId=sid; + } + var start = "https://" + domain + "/api/mute/list" + var i={ + method: 'POST', + headers: { + 'content-type': 'application/json', + }, + body:JSON.stringify(req) + } + }else{ + if (more) { + var sid = $("#his-muting-list .cvo").last().attr("user-id"); + var plus = "?max_id=" + sid; + } else { + var plus = ""; + } + var start = "https://" + domain + "/api/v1/mutes" + plus + var i={ + method: 'GET', + headers: { + 'content-type': 'application/json', + } + } } - var start = "https://" + domain + "/api/v1/mutes" + plus - fetch(start, { - method: 'GET', - headers: { - 'content-type': 'application/json', - 'Authorization': 'Bearer ' + at - }, - }).then(function(response) { + + fetch(start,i).then(function(response) { return response.json(); }).catch(function(error) { todo(error); @@ -251,6 +358,10 @@ function showBlo(more, acct_id) { var acct_id = $('#his-data').attr("use-acct"); } var domain = localStorage.getItem("domain_" + acct_id); + if(domain=="misskey.xyz"){ + $("#his-blocking-list-contents").html(lang_hisdata_notonmisskey[lang]+"
"); + return false; + } var at = localStorage.getItem("acct_"+ acct_id + "_at"); if (more) { var sid = $("#his-blocking-list .cvo").last().attr("user-id"); @@ -286,31 +397,53 @@ function showBlo(more, acct_id) { //フォロリクリスト function showReq(more, acct_id) { + if (!acct_id) { var acct_id = $('#his-data').attr("use-acct"); } var domain = localStorage.getItem("domain_" + acct_id); var at = localStorage.getItem("acct_"+ acct_id + "_at"); - if (more) { - var sid = $("#his-request-list .cvo").last().attr("user-id"); - var plus = "?max_id=" + sid; - } else { - var plus = ""; + if(domain=="misskey.xyz"){ + var req={i:at} + if (more) { + var sid = $("#his-request-list .cvo").last().attr("user-id"); + req.maxId=sid; + } + var start = "https://" + domain + "/following/requests/list" + var i={ + method: 'POST', + headers: { + 'content-type': 'application/json', + }, + body:JSON.stringify(req) + } + }else{ + if (more) { + var sid = $("#his-request-list .cvo").last().attr("user-id"); + var plus = "?max_id=" + sid; + } else { + var plus = ""; + } + var start = "https://" + domain + "/api/v1/follow_requests" + plus + var i={ + method: 'GET', + headers: { + 'content-type': 'application/json', + } + } } - var start = "https://" + domain + "/api/v1/follow_requests" + plus - fetch(start, { - method: 'GET', - headers: { - 'content-type': 'application/json', - 'Authorization': 'Bearer ' + at - }, - }).then(function(response) { + fetch(start,i).then(function(response) { return response.json(); }).catch(function(error) { todo(error); console.error(error); }).then(function(json) { - var templete = userparse(json, 'true',acct_id); + if(domain="misskey.xyz"){ + var templete = userparse(json, 'true',acct_id); + }else{ + var templete = misskeyUserparse(json, 'true',acct_id); + } + if(!json[0]){ templete=lang_details_nodata[lang]+"
"; } @@ -329,6 +462,10 @@ function showDom(more, acct_id) { var acct_id = $('#his-data').attr("use-acct"); } var domain = localStorage.getItem("domain_" + acct_id); + if(domain=="misskey.xyz"){ + $("#his-domain-list-contents").html(lang_hisdata_notonmisskey[lang]+"
"); + return false; + } var at = localStorage.getItem("acct_"+ acct_id + "_at"); if (more) { var sid = $("#his-domain-list .cvo").last().attr("user-id"); @@ -376,6 +513,10 @@ function showFrl(more, acct_id) { var acct_id = $('#his-data').attr("use-acct"); } var domain = localStorage.getItem("domain_" + acct_id); + if(domain=="misskey.xyz"){ + $("#his-follow-recom-contents").html(lang_hisdata_notonmisskey[lang]+"
"); + return false; + } var at = localStorage.getItem("acct_"+ acct_id + "_at"); if (more) { var sid = $("#his-follow-recom-list .cvo").last().attr("user-id"); diff --git a/app/js/userdata/showOnTL.js b/app/js/userdata/showOnTL.js index 786d7dc0..b054c9a6 100644 --- a/app/js/userdata/showOnTL.js +++ b/app/js/userdata/showOnTL.js @@ -21,6 +21,7 @@ function udgEx(user,acct_id){ } console.log(user); var domain = localStorage.getItem("domain_" + acct_id); + if(domain=="misskey.xyz"){ return false; } var at = localStorage.getItem("acct_"+ acct_id + "_at"); var start = "https://" + domain + "/api/v1/search?resolve=true&q="+user fetch(start, { @@ -48,6 +49,10 @@ function udg(user, acct_id) { } todo("User Data Loading..."); var domain = localStorage.getItem("domain_" + acct_id); + if(domain=="misskey.xyz"){ + misskeyUdg(user, acct_id) + return; + } var at = localStorage.getItem("acct_"+ acct_id + "_at"); var start = "https://" + domain + "/api/v1/accounts/" + user; console.log(start); @@ -177,6 +182,125 @@ function udg(user, acct_id) { todc(); }); } +function misskeyUdg(user, acct_id) { + reset(); + if (!user) { + user = localStorage.getItem("user-id_"+acct_id); + console.log(user); + } + todo("User Data Loading..."); + var domain = localStorage.getItem("domain_" + acct_id); + if(domain!="misskey.xyz"){ + udg(user, acct_id) + return; + } + var at = localStorage.getItem("acct_"+ acct_id + "_at"); + var start = "https://" + domain + "/api/users/show"; + console.log(user); + fetch(start, { + method: 'POST', + headers: { + 'content-type': 'application/json', + }, + body: JSON.stringify({ + i:at, + userId:user + }) + }).then(function(response) { + return response.json(); + }).catch(function(error) { + todo(error); + console.error(error); + }).then(function(json) { + console.log(json); + //一つ前のユーザーデータ + if (!localStorage.getItem("history")){ + $("#his-history-btn").prop("disabled",true); + }else{ + $("#his-history-btn").prop("disabled",false); + $('#his-data').attr("history", localStorage.getItem("history")); + } + $('#his-data').modal('open'); + $('#his-data').attr("user-id", user); + $('#his-data').attr("use-acct", acct_id); + if(json.host){ + //Remote + $('#his-data').attr("remote", "false"); + var fullname=json.username+"@"+json.host; + }else{ + $('#his-data').attr("remote", "false"); + var fullname=json.acct+"@"+domain; + } + utl(json.id, '', acct_id); + flw(json.id, '', acct_id); + fer(json.id, '', acct_id); + if(json.name){ + var dis_name=escapeHTML(json.name); + dis_name=twemoji.parse(dis_name); + }else{ + var dis_name=json.name + } + $("#his-name").html(dis_name); + $("#his-acct").text(json.username); + $("#his-acct").attr("fullname",fullname); + $("#his-prof").attr("src", json.avatarUrl); + $('#his-data').css('background-image', 'url(' + json.bannerUrl + ')'); + $("#his-sta").text(json.notesCount); + $("#his-follow").text(json.followingCount); + $("#his-follower").text(json.followersCount); + $("#his-since").text(crat(json.createdAt)); + var note=json.description; + $("#his-des").html(twemoji.parse(note)); + if(json.isCat){ + $("#his-bot").html("Cat"+twemoji.parse("😺")); + } + $('#his-data').css('background-size', 'cover'); + localStorage.setItem("history" , user); + //自分の時 + if (json.username == localStorage.getItem("user_"+acct_id) && !json.host) { + //showFav('', acct_id); + //showMut('', acct_id); + //showReq('', acct_id); + showFrl('', acct_id); + $("#his-name-val").val(json.name); + var des = json.note; + des = nl2br(des) + des = $.strip_tags(des); + $("#his-des-val").val(des); + $("#his-follow-btn").hide(); + $("#his-block-btn").hide(); + $("#his-mute-btn").hide(); + $("#his-notf-btn").hide(); + $("#his-domain-btn").hide(); + $("#his-emp-btn").hide(); + $(".only-my-data").show(); + $(".only-his-data").hide(); + } else { + if (json.isFollowing) { + //自分がフォローしている + $("#his-data").addClass("following"); + $("#his-follow-btn").text(lang_status_unfollow[lang]); + hisList(user,acct_id); + }else{ + $("#his-follow-btn").text(lang_status_follow[lang]); + } + if (json.isFollowed) { + //フォローされてる + $("#his-relation").text(lang_showontl_followed[lang]); + } + $("#his-block-btn").hide(); + if (json.isMuted) { + $("#his-data").addClass("muting"); + $("#his-mute-btn").text(lang_status_unmute[lang]); + }else{ + $("#his-mute-btn").text(lang_status_mute[lang]); + } + $(".only-my-data").hide(); + $(".only-his-data").show(); + } + todc(); + }); +} //一つ前のユーザーデータ表示 function historyShow(){ var acct_id=$('#his-data').attr("use-acct"); diff --git a/app/language/index.en.json b/app/language/index.en.json index 1e549763..5ef5ca23 100644 --- a/app/language/index.en.json +++ b/app/language/index.en.json @@ -59,7 +59,7 @@ "timeline":"Timeline", "operateOtherAcct":"Cross-account", "list":"List", - "makeNew":"Make a list", + "makeNew":"Save", "blocks":"Blocks", "mutes":"Mutes", "block":"Block", diff --git a/app/language/setting.en.json b/app/language/setting.en.json index 8590c249..150bece1 100644 --- a/app/language/setting.en.json +++ b/app/language/setting.en.json @@ -118,6 +118,7 @@ "keyrow":"Show next or previous image", "keyzoom":"Mousewheel:Zoom a image", "reset":"Reset(Danger)", + "resetconfirm":"Delete all data. You cannot undo. Continue?", "about":"About TheDesk", "hp":"Website", "support":"Support", diff --git a/app/language/setting.ja.json b/app/language/setting.ja.json index fd1bcda5..7736cdec 100644 --- a/app/language/setting.ja.json +++ b/app/language/setting.ja.json @@ -118,6 +118,7 @@ "keyrow":"イメージビューワー起動時に画像切り替え", "keyzoom":"マウスホイール:イメージビューワー時に拡大縮小", "reset":"初期化", + "resetconfirm":"全てのデータを削除します。この操作は取り消せません。", "about":"このソフトについて", "hp":"公式HP", "support":"支援", diff --git a/app/setting.html b/app/setting.html index b66a7d96..e69de29b 100644 --- a/app/setting.html +++ b/app/setting.html @@ -1,345 +0,0 @@ - - - - Settings - TheDesk - - - - - - - - - - - - - - -

Preferences

- -
-undoBack -
-
Keyboard shortcuts -
  • Ctrl+1-9:Jump to n(1-9)th column
  • -
  • N:Open toot box
  • -
  • X:Toggle toot box
  • -
  • Ctrl+Enter:Post
  • -
  • Ctrl+E:Make all notifications read
  • -
  • Esc:Hide toot box
  • -
  • F5:Super Reload
  • -
  • Ctrl+Shift+C:Clear toot box
  • -
  • Ctrl+Shift+S:Preferences
  • -
  • Ctrl+Shift+M:Account Manager
  • -
  • Ctrl+Shift+N:NowPlaying(Spotify)
  • -
  • Ctrl+Shift+P:Show profile of selecting
  • -
  • ←/→:Show next or previous image
  • -
  • Mousewheel:Zoom a image
  • -
    -以下Markdownに対応したインスタンスのみ。 -
    -
  • Ctrl+B/I/S/U:太字/斜字/取り消し/下線
  • -
  • Shift+Enter:全角スペースを入れて改行
  • -
  • Shift+Space:ゼロ幅スペース
  • -以下アスタルテにログインしている場合のみ -
    -
  • Ctrl+R: -アスタルテ暇人ランキングを開く -

  • -
    -

    - -webWebsite -trending_upSupport(Enty) -listHelp/Docs(Constructing) -GitHub -Developer: Cutls@kirishima.cloud -Give me a sushi! -
    -Check update
    -OSS License
    -Copyright © TheDesk 2018 All Rights Reserved. - TheDesk LICENSE (Latest Ver.) -
    Developer: Cutls P( - @Cutls@kirishima.cloud) -
    -

    -TheDeskおよびCutls Pは被災地支援のためのマストドン研究会をログイン機能提供等の形で応援しています。
    -タグタイムラインを開く:#被災地支援のためのマストドン研究会
    - - - - - - - - \ No newline at end of file diff --git a/app/setting.sample.html b/app/setting.sample.html index 92f46f44..28b7ee35 100644 --- a/app/setting.sample.html +++ b/app/setting.sample.html @@ -316,7 +316,7 @@ アスタルテ暇人ランキングを開く
    -

    +

    web{{hp}} trending_up{{support}}(Enty) diff --git a/app/update.html b/app/update.html index 88f3dc4b..e69de29b 100644 --- a/app/update.html +++ b/app/update.html @@ -1,91 +0,0 @@ - - - -Update - TheDesk - - - - - - - - - - -
    Latest TheDesk[TheDesk ]
    -
    -Current version
    -TheDesk will be quit TheDesk after downloading.
    - -

    -
    -
    -

    - Delivered by Amazon Web Services(S3/CloudFront)
    - Visit a releasenote of GitHub

    - Skip this uodate(until next TL loading/until next version)
    - Quit
    - About TheDesk
    - Some problems? Please download on TheDesk HP - - -