TheDesk Airi (ver.5)
This commit is contained in:
@@ -48,7 +48,7 @@ function defEmoji(target){
|
||||
var after = now.substr(selin, now.length);
|
||||
newt = before+ emoji.emoji + after;
|
||||
}else{
|
||||
newt = now+emoji.emoji;
|
||||
newt = emoji.emoji+now;
|
||||
}
|
||||
console.log(emoji.emoji);
|
||||
$("#textarea").val(newt);
|
||||
|
@@ -32,7 +32,7 @@ function load() {
|
||||
var list = key * 1 + 1;
|
||||
templete = '<div class="acct" id="acct_' + key + '">' + list +
|
||||
'.<img src="' + acct.prof + '" width="40" height="40"><div class="text">' +
|
||||
acct.name + ' <span class="gray">' + acct.user + '@' + acct.domain +
|
||||
acct.name + ' <span class="gray">' + escapeHTML(acct.user) + '@' + acct.domain +
|
||||
'</span></div><button class="btn waves-effect disTar" onclick="data(\'' +
|
||||
acct.domain +
|
||||
'\')">インスタンスデータ表示</button><button class="btn waves-effect" onclick="refresh(' +
|
||||
|
200
app/js/tl/mix.js
200
app/js/tl/mix.js
@@ -4,10 +4,10 @@ function mixtl(acct_id, tlid) {
|
||||
localStorage.removeItem("morelock")
|
||||
localStorage.setItem("now", type);
|
||||
todo("Integrated TL Loading...(Local)");
|
||||
var domain = localStorage.getItem("domain_" + acct_id);
|
||||
//まずLocal
|
||||
var domain = localStorage.getItem("domain_" + acct_id);
|
||||
var at = localStorage.getItem(domain + "_at");
|
||||
//まずLocal
|
||||
var start = "https://" + domain + "/api/v1/timelines/public?local=true";
|
||||
var start = "https://" + domain + "/api/v1/timelines/public?local=true";
|
||||
fetch(start, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
@@ -19,79 +19,49 @@ function mixtl(acct_id, tlid) {
|
||||
}).catch(function(error) {
|
||||
todo(error);
|
||||
console.error(error);
|
||||
}).then(function(json) {
|
||||
//パースして描画
|
||||
var templete = parse(json, 'mix', acct_id, tlid);
|
||||
$("#timeline_" + tlid).html(templete[0]);
|
||||
}).then(function(jsonL) {
|
||||
var start = "https://" + domain + "/api/v1/timelines/home";
|
||||
fetch(start, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
'Authorization': 'Bearer ' + at
|
||||
},
|
||||
}).then(function(response) {
|
||||
return response.json();
|
||||
}).catch(function(error) {
|
||||
todo(error);
|
||||
console.error(error);
|
||||
}).then(function(jsonH) {
|
||||
var homearr=[];
|
||||
var timeline = jsonL.concat(jsonH);
|
||||
timeline.sort(function(a,b){
|
||||
if(date(a.created_at,"unix")>date(b.created_at,"unix")) return -1;
|
||||
if(date(a.created_at,"unix")<date(b.created_at,"unix")) return 1;
|
||||
return 0;
|
||||
});
|
||||
timeline.splice(20);
|
||||
var templete="";
|
||||
Object.keys(timeline).forEach(function(key) {
|
||||
var pkey=key*1+1;
|
||||
if(pkey<20){
|
||||
if(date(timeline[key].created_at,"unix")!=date(timeline[pkey].created_at,"unix")){
|
||||
templete = templete+parse([timeline[key]], '', acct_id, tlid);
|
||||
}
|
||||
}
|
||||
|
||||
jQuery("time.timeago").timeago();
|
||||
$(window).scrollTop(0);
|
||||
var locals = templete[1];
|
||||
var times = templete[2];
|
||||
todo("Integrated TL Loading...(Home)");
|
||||
//Home
|
||||
var start = "https://" + domain + "/api/v1/timelines/home";
|
||||
fetch(start, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
'Authorization': 'Bearer ' + at
|
||||
},
|
||||
}).then(function(response) {
|
||||
return response.json();
|
||||
}).catch(function(error) {
|
||||
todo(error);
|
||||
console.error(error);
|
||||
}).then(function(obj) {
|
||||
//ホームのオブジェクトをUnix時間で走査
|
||||
if (!$("[toot-id=" + obj[0].id + "]").length) {
|
||||
$("#timeline_" + tlid + " .cvo").first().before(parse([obj[0]], 'home',
|
||||
acct_id));
|
||||
//delete obj[0];
|
||||
}
|
||||
//Localが遅すぎてHomeの全てより過去の場合
|
||||
var unixL=date(json[0].created_at,"unix");
|
||||
var unixH=date(obj[obj.length-1].created_at,"unix");
|
||||
//console.log(unixH+"vs"+unixL)
|
||||
if(unixH < unixL){
|
||||
Object.keys(obj).forEach(function(key) {
|
||||
var skey = obj.length - key - 1;
|
||||
var toot = obj[skey];
|
||||
var id = toot.id;
|
||||
if ($("#timeline_" + tlid + " [toot-id=" + toot.id + "]").length < 1) {
|
||||
//console.log(toot.id);
|
||||
var tarunix = date(toot.created_at, 'unix');
|
||||
var beforekey2;
|
||||
var key2;
|
||||
//console.log(locals)
|
||||
//ホームのオブジェクトに対してLocalのオブジェクトを時間走査
|
||||
Object.keys(times).forEach(function(key2) {
|
||||
if (times[key2] < tarunix) {
|
||||
var local = json[key2].id;
|
||||
//console.log($.strip_tags(toot.content));
|
||||
html = parse(
|
||||
[toot], 'home', acct_id, tlid);
|
||||
$("#timeline_" + tlid + " [toot-id=" + local + "]").before(html);
|
||||
//console.log("#timeline_" + tlid + " [toot-id=" + local + "]");
|
||||
tarunix = 0;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
}else{
|
||||
html = parse(
|
||||
obj, 'home', acct_id, tlid);
|
||||
$("#timeline_" + tlid).html(html);
|
||||
}
|
||||
todc();
|
||||
mixre(acct_id, tlid);
|
||||
});
|
||||
|
||||
$("#timeline_" + tlid).html(templete);
|
||||
mixre(acct_id, tlid);
|
||||
additional(acct_id, tlid);
|
||||
jQuery("time.timeago").timeago();
|
||||
});
|
||||
});
|
||||
todc();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//Streamingに接続
|
||||
function mixre(acct_id, tlid) {
|
||||
var domain = localStorage.getItem("domain_" + acct_id);
|
||||
@@ -181,10 +151,9 @@ function mixmore(tlid) {
|
||||
var domain = localStorage.getItem("domain_" + acct_id);
|
||||
var at = localStorage.getItem(domain + "_at");
|
||||
var sid = $("#timeline_" + tlid + " .cvo").last().attr("toot-id");
|
||||
var len = $("#timeline_" + tlid + " .cvo").length
|
||||
var start = "https://" + domain +
|
||||
"/api/v1/timelines/public?local=true&max_id=" + sid;
|
||||
console.log(start);
|
||||
|
||||
|
||||
var start = "https://" + domain + "/api/v1/timelines/public?local=true&max_id="+sid;
|
||||
fetch(start, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
@@ -196,53 +165,46 @@ function mixmore(tlid) {
|
||||
}).catch(function(error) {
|
||||
todo(error);
|
||||
console.error(error);
|
||||
}).then(function(json) {
|
||||
var templete = parse(json, 'mix', acct_id, tlid);
|
||||
$("#timeline_" + tlid).append(templete[0]);
|
||||
var locals = templete[1];
|
||||
todo("Integrated TL MoreLoading...(Home)");
|
||||
console.log(sid);
|
||||
var start = "https://" + domain + "/api/v1/timelines/home?max_id=" + sid;
|
||||
fetch(start, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
'Authorization': 'Bearer ' + at
|
||||
},
|
||||
}).then(function(response) {
|
||||
return response.json();
|
||||
}).catch(function(error) {
|
||||
todo(error);
|
||||
console.error(error);
|
||||
}).then(function(obj) {
|
||||
if ($("[toot-id=" + obj[0].id + "]").length < 1) {
|
||||
$("#timeline_" + tlid + " .cvo").eq(len).before(parse([obj[0]], 'home',
|
||||
acct_id)+'<div class="divider"></div>');
|
||||
//delete obj[0];
|
||||
}
|
||||
Object.keys(obj).forEach(function(key) {
|
||||
var skey = obj.length - key - 1;
|
||||
var toot = obj[skey];
|
||||
var id = toot.id;
|
||||
var tarunix = date(toot.created_at, 'unix');
|
||||
var beforekey2;
|
||||
var key2;
|
||||
Object.keys(locals).forEach(function(key2) {
|
||||
if ($("[toot-id=" + toot.id + "]").length <1) {
|
||||
if (key2 > tarunix) {
|
||||
var local = locals[key2];
|
||||
$("#timeline_" + tlid + " [toot-id=" + local + "]").after(parse([toot], 'home',
|
||||
acct_id, tlid));
|
||||
tarunix = 2147483647;
|
||||
}
|
||||
}).then(function(jsonL) {
|
||||
var start = "https://" + domain + "/api/v1/timelines/home?max_id="+sid;
|
||||
fetch(start, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
'Authorization': 'Bearer ' + at
|
||||
},
|
||||
}).then(function(response) {
|
||||
return response.json();
|
||||
}).catch(function(error) {
|
||||
todo(error);
|
||||
console.error(error);
|
||||
}).then(function(jsonH) {
|
||||
var homearr=[];
|
||||
var timeline = jsonL.concat(jsonH);
|
||||
timeline.sort(function(a,b){
|
||||
if(date(a.created_at,"unix")>date(b.created_at,"unix")) return -1;
|
||||
if(date(a.created_at,"unix")<date(b.created_at,"unix")) return 1;
|
||||
return 0;
|
||||
});
|
||||
timeline.splice(20);
|
||||
var templete="";
|
||||
Object.keys(timeline).forEach(function(key) {
|
||||
var pkey=key*1+1;
|
||||
if(pkey<20){
|
||||
if(date(timeline[key].created_at,"unix")!=date(timeline[pkey].created_at,"unix")){
|
||||
templete = templete+parse([timeline[key]], '', acct_id, tlid);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$("#timeline_" + tlid).append(templete);
|
||||
mixre(acct_id, tlid);
|
||||
additional(acct_id, tlid);
|
||||
jQuery("time.timeago").timeago();
|
||||
todc();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -80,6 +80,56 @@ function notf(acct_id, tlid, sys) {
|
||||
console.error('WebSocket Error ' + error);
|
||||
};
|
||||
}
|
||||
//一定のスクロールで発火
|
||||
function notfmore(tlid) {
|
||||
var multi = localStorage.getItem("column");
|
||||
var obj = JSON.parse(multi);
|
||||
var acct_id = obj[tlid].domain;
|
||||
if (!type) {
|
||||
var type = obj[tlid].type;
|
||||
}else{
|
||||
var data;
|
||||
}
|
||||
var sid = $("#timeline_" + tlid + " .cvo").last().attr("toot-id");
|
||||
console.log(sid);
|
||||
if (localStorage.getItem("morelock") != sid) {
|
||||
localStorage.setItem("morelock", sid);
|
||||
localStorage.setItem("now", type);
|
||||
todo("Notfication TL MoreLoading");
|
||||
var domain = localStorage.getItem("domain_" + acct_id);
|
||||
var at = localStorage.getItem(domain + "_at");
|
||||
var start = "https://" + domain + "/api/v1/notifications"+
|
||||
"max_id=" + sid;
|
||||
fetch(start, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
'Authorization': 'Bearer ' + at
|
||||
},
|
||||
}).then(function(response) {
|
||||
return response.json();
|
||||
}).catch(function(error) {
|
||||
todo(error);
|
||||
console.error(error);
|
||||
}).then(function(json) {
|
||||
var templete="";
|
||||
Object.keys(json).forEach(function(key) {
|
||||
var obj = json[key];
|
||||
if(obj.type!="follow"){
|
||||
templete = templete+parse([obj], '', acct_id, tlid, -1);
|
||||
}else{
|
||||
templete = templete+userparse([obj.account], '', acct_id, tlid, -1);
|
||||
}
|
||||
|
||||
});
|
||||
$("#timeline_" + tlid).append(templete);
|
||||
additional(acct_id, tlid);
|
||||
jQuery("time.timeago").timeago();
|
||||
localStorage.removeItem("morelock")
|
||||
todc();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//通知トグルボタン
|
||||
function notfToggle(acct, tlid) {
|
||||
|
249
app/js/tl/old-mix.js
Normal file
249
app/js/tl/old-mix.js
Normal file
@@ -0,0 +1,249 @@
|
||||
//Integrated TL
|
||||
function mixtl(acct_id, tlid) {
|
||||
var type = "mix";
|
||||
localStorage.removeItem("morelock")
|
||||
localStorage.setItem("now", type);
|
||||
todo("Integrated TL Loading...(Local)");
|
||||
var domain = localStorage.getItem("domain_" + acct_id);
|
||||
var at = localStorage.getItem(domain + "_at");
|
||||
//まずLocal
|
||||
var start = "https://" + domain + "/api/v1/timelines/public?local=true";
|
||||
fetch(start, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
'Authorization': 'Bearer ' + at
|
||||
},
|
||||
}).then(function(response) {
|
||||
return response.json();
|
||||
}).catch(function(error) {
|
||||
todo(error);
|
||||
console.error(error);
|
||||
}).then(function(json) {
|
||||
//パースして描画
|
||||
var templete = parse(json, 'mix', acct_id, tlid);
|
||||
$("#timeline_" + tlid).html(templete[0]);
|
||||
|
||||
jQuery("time.timeago").timeago();
|
||||
$(window).scrollTop(0);
|
||||
var locals = templete[1];
|
||||
var times = templete[2];
|
||||
todo("Integrated TL Loading...(Home)");
|
||||
//Home
|
||||
var start = "https://" + domain + "/api/v1/timelines/home";
|
||||
fetch(start, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
'Authorization': 'Bearer ' + at
|
||||
},
|
||||
}).then(function(response) {
|
||||
return response.json();
|
||||
}).catch(function(error) {
|
||||
todo(error);
|
||||
console.error(error);
|
||||
}).then(function(obj) {
|
||||
//ホームのオブジェクトをUnix時間で走査
|
||||
if (!$("[toot-id=" + obj[0].id + "]").length) {
|
||||
$("#timeline_" + tlid + " .cvo").first().before(parse([obj[0]], 'home',
|
||||
acct_id));
|
||||
//delete obj[0];
|
||||
}
|
||||
//Localが遅すぎてHomeの全てより過去の場合
|
||||
var unixL=date(json[0].created_at,"unix");
|
||||
var unixH=date(obj[obj.length-1].created_at,"unix");
|
||||
//console.log(unixH+"vs"+unixL)
|
||||
if(unixH < unixL){
|
||||
Object.keys(obj).forEach(function(key) {
|
||||
var skey = obj.length - key - 1;
|
||||
var toot = obj[key];
|
||||
console.log(toot);
|
||||
var id = toot.id;
|
||||
if ($("#timeline_" + tlid + " [toot-id=" + toot.id + "]").length < 1) {
|
||||
//console.log(toot.id);
|
||||
var tarunix = date(toot.created_at, 'unix');
|
||||
var beforekey2;
|
||||
var key2;
|
||||
//console.log(locals)
|
||||
//ホームのオブジェクトに対してLocalのオブジェクトを時間走査
|
||||
Object.keys(times).forEach(function(key2) {
|
||||
if (times[key2] < tarunix) {
|
||||
var local = json[key2].id;
|
||||
//console.log($.strip_tags(toot.content));
|
||||
html = parse(
|
||||
[toot], 'home', acct_id, tlid);
|
||||
$("#timeline_" + tlid + " [toot-id=" + local + "]").before(html);
|
||||
//console.log("#timeline_" + tlid + " [toot-id=" + local + "]");
|
||||
tarunix = 0;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
}else{
|
||||
html = parse(
|
||||
obj, 'home', acct_id, tlid);
|
||||
$("#timeline_" + tlid).html(html);
|
||||
}
|
||||
todc();
|
||||
mixre(acct_id, tlid);
|
||||
additional(acct_id, tlid);
|
||||
jQuery("time.timeago").timeago();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
//Streamingに接続
|
||||
function mixre(acct_id, tlid) {
|
||||
var domain = localStorage.getItem("domain_" + acct_id);
|
||||
var at = localStorage.getItem(domain + "_at");
|
||||
var type = "mix";
|
||||
localStorage.setItem("now", type);
|
||||
var startHome = "wss://" + domain +
|
||||
"/api/v1/streaming/?stream=user&access_token=" + at;
|
||||
|
||||
var startLocal = "wss://" + domain +
|
||||
"/api/v1/streaming/?stream=public:local&access_token=" + at;
|
||||
var wshid = websocketHome.length;
|
||||
var wslid = websocketLocal.length;
|
||||
websocketHome[wshid] = new WebSocket(startHome);
|
||||
websocketLocal[wslid] = new WebSocket(startLocal);
|
||||
websocketHome[wshid].onopen = function(mess) {
|
||||
console.log("Connect Streaming API(Home)");
|
||||
$("#notice_icon_" + tlid).removeClass("red-text");
|
||||
}
|
||||
websocketLocal[wslid].onopen = function(mess) {
|
||||
console.log("Connect Streaming API(Local)");
|
||||
$("#notice_icon_" + tlid).removeClass("red-text");
|
||||
}
|
||||
websocketLocal[wslid].onmessage = function(mess) {
|
||||
console.log("Receive Streaming API:");
|
||||
|
||||
var obj = JSON.parse(JSON.parse(mess.data).payload);
|
||||
console.log(obj);
|
||||
var type = JSON.parse(mess.data).event;
|
||||
if (type == "delete") {
|
||||
$("[toot-id=" + JSON.parse(mess.data).payload + "]").hide();
|
||||
$("[toot-id=" + JSON.parse(mess.data).payload + "]").remove();
|
||||
} else if (type == "update") {
|
||||
var templete = parse([obj], '', acct_id, tlid);
|
||||
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();
|
||||
todc();
|
||||
}
|
||||
}
|
||||
websocketHome[wshid].onmessage = function(mess) {
|
||||
console.log("Receive Streaming API:(Home)");
|
||||
|
||||
var obj = JSON.parse(JSON.parse(mess.data).payload);
|
||||
console.log(obj);
|
||||
var type = JSON.parse(mess.data).event;
|
||||
if (type == "delete") {
|
||||
$("[toot-id=" + JSON.parse(mess.data).payload + "]").hide();
|
||||
$("[toot-id=" + JSON.parse(mess.data).payload + "]").remove();
|
||||
} else if (type == "update") {
|
||||
var templete = parse([obj], '', acct_id, tlid);
|
||||
if (obj.visibility != "public" || obj.account.acct != obj.account.username) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
websocketLocal[wslid].onerror = function(error) {
|
||||
console.error('WebSocket Error ' + error);
|
||||
};
|
||||
websocketHome[wshid].onerror = function(error) {
|
||||
console.error('WebSocket Error ' + error);
|
||||
};
|
||||
}
|
||||
|
||||
//ある程度のスクロールで発火
|
||||
function mixmore(tlid) {
|
||||
var multi = localStorage.getItem("column");
|
||||
var obj = JSON.parse(multi);
|
||||
var acct_id = obj[tlid].domain;
|
||||
todo("Integrated TL MoreLoading...(Local)");
|
||||
var domain = localStorage.getItem("domain_" + acct_id);
|
||||
var at = localStorage.getItem(domain + "_at");
|
||||
var sid = $("#timeline_" + tlid + " .cvo").last().attr("toot-id");
|
||||
var len = $("#timeline_" + tlid + " .cvo").length
|
||||
var start = "https://" + domain +
|
||||
"/api/v1/timelines/public?local=true&max_id=" + sid;
|
||||
console.log(start);
|
||||
fetch(start, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
'Authorization': 'Bearer ' + at
|
||||
},
|
||||
}).then(function(response) {
|
||||
return response.json();
|
||||
}).catch(function(error) {
|
||||
todo(error);
|
||||
console.error(error);
|
||||
}).then(function(json) {
|
||||
var templete = parse(json, 'mix', acct_id, tlid);
|
||||
$("#timeline_" + tlid).append(templete[0]);
|
||||
var locals = templete[1];
|
||||
todo("Integrated TL MoreLoading...(Home)");
|
||||
console.log(sid);
|
||||
var start = "https://" + domain + "/api/v1/timelines/home?max_id=" + sid;
|
||||
fetch(start, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
'Authorization': 'Bearer ' + at
|
||||
},
|
||||
}).then(function(response) {
|
||||
return response.json();
|
||||
}).catch(function(error) {
|
||||
todo(error);
|
||||
console.error(error);
|
||||
}).then(function(obj) {
|
||||
if ($("[toot-id=" + obj[0].id + "]").length < 1) {
|
||||
$("#timeline_" + tlid + " .cvo").eq(len).before(parse([obj[0]], 'home',
|
||||
acct_id)+'<div class="divider"></div>');
|
||||
//delete obj[0];
|
||||
}
|
||||
Object.keys(obj).forEach(function(key) {
|
||||
var skey = obj.length - key - 1;
|
||||
var toot = obj[skey];
|
||||
var id = toot.id;
|
||||
var tarunix = date(toot.created_at, 'unix');
|
||||
var beforekey2;
|
||||
var key2;
|
||||
Object.keys(locals).forEach(function(key2) {
|
||||
if ($("[toot-id=" + toot.id + "]").length <1) {
|
||||
if (key2 > tarunix) {
|
||||
var local = locals[key2];
|
||||
$("#timeline_" + tlid + " [toot-id=" + local + "]").after(parse([toot], 'home',
|
||||
acct_id, tlid));
|
||||
tarunix = 2147483647;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
additional(acct_id, tlid);
|
||||
jQuery("time.timeago").timeago();
|
||||
todc();
|
||||
});
|
||||
});
|
||||
|
||||
}
|
@@ -130,12 +130,6 @@ function parse(obj, mix, acct_id, tlid, popup) {
|
||||
}
|
||||
}
|
||||
var id = toot.id;
|
||||
//Integratedである場合はUnix時間をキーに配列を生成しておく
|
||||
if (mix == "mix") {
|
||||
local[date(obj[key].created_at, 'unix')] = toot.id;
|
||||
times.push(date(obj[key].created_at, 'unix'));
|
||||
var divider = '<div class="divider"></div>';
|
||||
}
|
||||
if (mix == "home") {
|
||||
var home = "Home TLより"
|
||||
var divider = '<div class="divider"></div>';
|
||||
@@ -169,7 +163,7 @@ function parse(obj, mix, acct_id, tlid, popup) {
|
||||
}
|
||||
if (toot.spoiler_text && cw) {
|
||||
var content = toot.content;
|
||||
var spoil = toot.spoiler_text;
|
||||
var spoil = escapeHTML(toot.spoiler_text);
|
||||
var spoiler = "cw cw_hide_" + toot.id;
|
||||
var api_spoil = "gray";
|
||||
var spoiler_show = '<a href="#" onclick="cw_show(\'' + toot.id +
|
||||
@@ -187,7 +181,7 @@ function parse(obj, mix, acct_id, tlid, popup) {
|
||||
'\')" class="nex parsed">続き…</a><br>';
|
||||
} else {
|
||||
var content = toot.content;
|
||||
var spoil = toot.spoiler_text;
|
||||
var spoil = escapeHTML(toot.spoiler_text);
|
||||
var spoiler = "";
|
||||
var spoiler_show = "";
|
||||
}
|
||||
@@ -218,7 +212,7 @@ function parse(obj, mix, acct_id, tlid, popup) {
|
||||
'" class="emoji-img">';
|
||||
var regExp = new RegExp(":" + shortcode + ":", "g");
|
||||
content = content.replace(regExp, emoji_url);
|
||||
spoil = toot.spoiler_text.replace(regExp, emoji_url);
|
||||
spoil = spoil.replace(regExp, emoji_url);
|
||||
});
|
||||
}
|
||||
var mediack = toot.media_attachments[0];
|
||||
@@ -439,7 +433,7 @@ function userparse(obj, auth, acct_id, tlid, popup) {
|
||||
}
|
||||
var memory = localStorage.getItem("notice-mem");
|
||||
if (popup >= 0 && obj.length < 5 && noticetext != memory) {
|
||||
Materialize.toast(toot.display_name+"にフォローされました", popup * 1000);
|
||||
Materialize.toast(escapeHTML(toot.display_name)+"にフォローされました", popup * 1000);
|
||||
$(".notf-icon_" + tlid).addClass("red-text");
|
||||
localStorage.setItem("notice-mem", noticetext);
|
||||
noticetext = "";
|
||||
@@ -453,7 +447,7 @@ function userparse(obj, auth, acct_id, tlid, popup) {
|
||||
'<img src="' + toot.avatar + '" width="40" class="prof-img" user="' + toot
|
||||
.acct + '"></a></div>' +
|
||||
'<div style="flex-grow:3; overflow: hidden;white-space: nowrap;text-overflow: ellipsis;user-select:auto; cursor:text;"><big>' +
|
||||
toot.display_name + '</big></div>' +
|
||||
escapeHTML(toot.display_name) + '</big></div>' +
|
||||
'<div class="sml gray" style="overflow: hidden;white-space: nowrap;text-overflow: ellipsis;user-select:auto; cursor:text;"> @' +
|
||||
toot.acct + locked + '</div>' +
|
||||
'</div>' + auth +
|
||||
|
@@ -182,6 +182,9 @@ function moreload(type, tlid) {
|
||||
if (type == "mix") {
|
||||
mixmore(tlid);
|
||||
return;
|
||||
}else if (type == "notf") {
|
||||
notfmore(tlid);
|
||||
return;
|
||||
}
|
||||
localStorage.setItem("now", type);
|
||||
todo(cap(type) + " TL MoreLoading");
|
||||
@@ -205,6 +208,7 @@ function moreload(type, tlid) {
|
||||
$("#timeline_" + tlid).append(templete);
|
||||
additional(acct_id, tlid);
|
||||
jQuery("time.timeago").timeago();
|
||||
localStorage.removeItem("morelock")
|
||||
todc();
|
||||
});
|
||||
}
|
||||
|
@@ -47,12 +47,14 @@ function xpand() {
|
||||
if ($("#sidebar").hasClass("xed")) {
|
||||
$(".side-label").show();
|
||||
$("#sidebar").css('width', '75px');
|
||||
$("#sidebar").css('min-width', '75px');
|
||||
$("#sidebar .big-menu i").addClass('big-icon');
|
||||
$("#sidebar").removeClass("xed");
|
||||
$("#x-btn").text("keyboard_arrow_right");
|
||||
localStorage.removeItem("xed");
|
||||
} else {
|
||||
$("#sidebar").css('width', '24px');
|
||||
$("#sidebar").css('min-width', '24px');
|
||||
$("#sidebar").addClass("xed");
|
||||
$("#sidebar .big-menu i").removeClass('big-icon');
|
||||
$(".side-label").hide();
|
||||
|
@@ -25,7 +25,7 @@ function scrollck() {
|
||||
}
|
||||
}
|
||||
//続きを読むトリガー
|
||||
var scrt = $(this).find(".tl").height() - 1500;
|
||||
var scrt = $(this).find(".tl").height() - $(window).height();
|
||||
var scr = $(this).scrollTop();
|
||||
if (scr > scrt) {
|
||||
moreload('', tlid);
|
||||
|
@@ -211,6 +211,7 @@ load();
|
||||
climute();
|
||||
wordmute();
|
||||
wordemp();
|
||||
checkSpotify();
|
||||
function climute(){
|
||||
//クライアントミュート
|
||||
var cli = localStorage.getItem("client_mute");
|
||||
|
76
app/js/ui/spotify.js
Normal file
76
app/js/ui/spotify.js
Normal file
@@ -0,0 +1,76 @@
|
||||
function spotifyConnect(){
|
||||
var auth = "https://accounts.spotify.com/authorize?client_id=0f18e54abe0b4aedb4591e353d3aff69&redirect_uri=https://thedesk.top/spotify-connect&response_type=code&scope=user-read-currently-playing";
|
||||
const {
|
||||
shell
|
||||
} = require('electron');
|
||||
|
||||
shell.openExternal(auth);
|
||||
var electron = require("electron");
|
||||
var ipc = electron.ipcRenderer;
|
||||
ipc.send('quit', 'go');
|
||||
|
||||
}
|
||||
function spotifyDisconnect(){
|
||||
localStorage.removeItem("spotify");
|
||||
localStorage.removeItem("spotify-refresh");
|
||||
checkSpotify();
|
||||
}
|
||||
function checkSpotify(){
|
||||
if(localStorage.getItem("spotify")){
|
||||
$("#spotify-enable").addClass("disabled");
|
||||
$("#spotify-disable").removeClass("disabled");
|
||||
}else{
|
||||
$("#spotify-enable").removeClass("disabled");
|
||||
$("#spotify-disable").addClass("disabled");
|
||||
}
|
||||
console.log(localStorage.getItem("spotify-refresh"));
|
||||
}
|
||||
function nowplaying(){
|
||||
var start = "https://thedesk.top/now-playing?at="+localStorage.getItem("spotify")+"&rt="+localStorage.getItem("spotify-refresh");
|
||||
var at = localStorage.getItem("spotify");
|
||||
fetch(start, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
}
|
||||
}).then(function(response) {
|
||||
return response.json();
|
||||
}).catch(function(error) {
|
||||
todo(error);
|
||||
console.error(error);
|
||||
}).then(function(json) {
|
||||
console.log(json);
|
||||
var item=json.item;
|
||||
var content=localStorage.getItem("np-temp");
|
||||
if(!content){
|
||||
var content="#NowPlaying {song} / {album} / {artist}\n{url} #Spotify-with-TheDesk";
|
||||
}
|
||||
var regExp = new RegExp("{song}", "g");
|
||||
content = content.replace(regExp, item.name);
|
||||
var regExp = new RegExp("{album}", "g");
|
||||
content = content.replace(regExp, item.album.name);
|
||||
var regExp = new RegExp("{artist}", "g");
|
||||
content = content.replace(regExp, item.artists[0].name);
|
||||
var regExp = new RegExp("{url}", "g");
|
||||
content = content.replace(regExp, item.href);
|
||||
$("#textarea").val(content);
|
||||
});
|
||||
}
|
||||
function spotifySave(){
|
||||
var temp=$("#np-temp").val();
|
||||
localStorage.setItem("np-temp", temp);
|
||||
Materialize.toast("NowPlaying文章を更新しました。", 3000);
|
||||
}
|
||||
if(location.search){
|
||||
var m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=(.+)/);
|
||||
var mode=m[1];
|
||||
var codex=m[2];
|
||||
if(mode=="spotify"){
|
||||
var coder=codex.split(":");
|
||||
localStorage.setItem("spotify", coder[0]);
|
||||
localStorage.setItem("spotify-refresh", coder[1]);
|
||||
}else{
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user