2018-01-28 23:22:43 +11:00
|
|
|
|
//左下のメッセージ
|
2019-05-19 17:39:30 +10:00
|
|
|
|
var todcTrigger = null;
|
|
|
|
|
function todo(mes) {
|
2018-09-14 02:25:43 +10:00
|
|
|
|
clearInterval(todcTrigger);
|
2018-01-28 23:22:43 +11:00
|
|
|
|
$('#message').text(mes);
|
|
|
|
|
$('#message').fadeIn();
|
2019-05-19 17:39:30 +10:00
|
|
|
|
todcTrigger = setTimeout(todc, 4000);
|
2018-01-28 23:22:43 +11:00
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
|
function todc() {
|
2018-01-28 23:22:43 +11:00
|
|
|
|
$('#message').fadeOut();
|
|
|
|
|
}
|
2018-09-11 04:59:44 +10:00
|
|
|
|
//reverse
|
2019-05-19 17:39:30 +10:00
|
|
|
|
function bottomReverse() {
|
2018-09-11 04:59:44 +10:00
|
|
|
|
$("#bottom").toggleClass("reverse");
|
|
|
|
|
$(".leftside").toggleClass("reverse");
|
2019-05-19 17:39:30 +10:00
|
|
|
|
if ($("#bottom").hasClass("reverse")) {
|
2018-09-11 04:59:44 +10:00
|
|
|
|
localStorage.removeItem("reverse")
|
2019-05-19 17:39:30 +10:00
|
|
|
|
} else {
|
|
|
|
|
localStorage.setItem("reverse", "true")
|
2018-09-11 04:59:44 +10:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
|
function tips(mode) {
|
2018-07-28 07:25:12 +10:00
|
|
|
|
var electron = require("electron");
|
|
|
|
|
var ipc = electron.ipcRenderer;
|
|
|
|
|
ipc.send('endmem', "");
|
|
|
|
|
clearInterval(clockint);
|
2018-07-29 17:37:54 +10:00
|
|
|
|
clearInterval(spotStart);
|
2019-05-19 17:39:30 +10:00
|
|
|
|
if (mode == "ver") {
|
2018-07-28 07:25:12 +10:00
|
|
|
|
tipsToggle()
|
2019-05-19 17:39:30 +10:00
|
|
|
|
$("#tips-text").html('<img src="../../img/desk.png" width="20" onclick="todo(\'!TheDesk! It\\\'s a nice client!\')"><span style="font-size:20px">TheDesk</span> ' + localStorage.getItem("ver") + '[<i class="material-icons" style="font-size:1.2rem;top: 3px;position: relative;">supervisor_account</i><span id="persons">1+</span>]')
|
|
|
|
|
localStorage.setItem("tips", "ver")
|
|
|
|
|
} else if (mode == "clock") {
|
2018-07-28 07:25:12 +10:00
|
|
|
|
tipsToggle()
|
2019-05-19 17:39:30 +10:00
|
|
|
|
localStorage.setItem("tips", "clock")
|
2018-07-28 07:25:12 +10:00
|
|
|
|
clock()
|
2019-05-19 17:39:30 +10:00
|
|
|
|
} else if (mode == "memory") {
|
2018-07-28 07:25:12 +10:00
|
|
|
|
tipsToggle()
|
2019-05-19 17:39:30 +10:00
|
|
|
|
localStorage.setItem("tips", "memory")
|
2018-07-28 07:25:12 +10:00
|
|
|
|
startmem();
|
2019-05-19 17:39:30 +10:00
|
|
|
|
} else if (mode == "trend") {
|
2018-07-28 07:25:12 +10:00
|
|
|
|
tipsToggle()
|
2019-05-19 17:39:30 +10:00
|
|
|
|
localStorage.setItem("tips", "trend")
|
2018-07-28 07:25:12 +10:00
|
|
|
|
trendTagonTip()
|
2019-05-19 17:39:30 +10:00
|
|
|
|
} else if (mode == "spotify") {
|
2018-07-29 17:37:54 +10:00
|
|
|
|
tipsToggle()
|
2019-05-19 17:39:30 +10:00
|
|
|
|
localStorage.setItem("tips", "spotify")
|
|
|
|
|
var json = nowplaying("spotifytips")
|
2018-07-29 17:37:54 +10:00
|
|
|
|
spotifytips(json)
|
2018-07-28 07:25:12 +10:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//メモリ
|
2019-05-19 17:39:30 +10:00
|
|
|
|
function startmem() {
|
2018-07-28 07:25:12 +10:00
|
|
|
|
var electron = require("electron");
|
|
|
|
|
var ipc = electron.ipcRenderer;
|
|
|
|
|
ipc.send('startmem', "");
|
|
|
|
|
ipc.on('memory', function (event, arg) {
|
2019-05-19 17:39:30 +10:00
|
|
|
|
var use = arg[0];
|
|
|
|
|
var cpu = arg[1];
|
|
|
|
|
var total = arg[2]
|
|
|
|
|
$("#tips-text").html(escapeHTML(cpu) + "<br>Memory:" + Math.floor(use / 1024 / 1024 / 102.4) / 10 + "/" + Math.floor(total / 1024 / 1024 / 102.4) / 10 + "GB(" + Math.floor(use / total * 100) + "%)")
|
2018-07-28 07:25:12 +10:00
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
//トレンドタグ
|
2019-05-19 17:39:30 +10:00
|
|
|
|
function trendTagonTip() {
|
|
|
|
|
$(".trendtag").remove();
|
|
|
|
|
var domain = "imastodon.net"
|
|
|
|
|
var at = localStorage.getItem("acct_" + acct_id + "_at");
|
|
|
|
|
var start = "https://" + domain + "/api/v1/trend_tags"
|
2018-07-28 07:25:12 +10:00
|
|
|
|
fetch(start, {
|
|
|
|
|
method: 'GET',
|
|
|
|
|
headers: {
|
|
|
|
|
'content-type': 'application/json',
|
|
|
|
|
'Authorization': 'Bearer ' + at
|
|
|
|
|
},
|
2019-05-19 17:39:30 +10:00
|
|
|
|
}).then(function (response) {
|
2018-07-28 07:25:12 +10:00
|
|
|
|
return response.json();
|
2019-05-19 17:39:30 +10:00
|
|
|
|
}).catch(function (error) {
|
2018-07-28 07:25:12 +10:00
|
|
|
|
todo(error);
|
|
|
|
|
console.error(error);
|
2019-05-19 17:39:30 +10:00
|
|
|
|
}).then(function (json) {
|
2018-07-28 07:25:12 +10:00
|
|
|
|
if (json) {
|
2019-05-19 17:39:30 +10:00
|
|
|
|
var tags = "";
|
|
|
|
|
json = json.score;
|
|
|
|
|
Object.keys(json).forEach(function (tag) {
|
|
|
|
|
tags = tags + '<a onclick="tagShow(\'' + tag + '\')" class="pointer">#' + escapeHTML(tag) + '</a><span class="hide" data-tag="' + tag + '"> <a onclick="tagTL(\'tag\',\'' + tag + '\',false,\'add\')" class="pointer" title="#' + tag + 'のタイムライン">TL</a> <a onclick="show();brInsert(\'#' + tag + '\')" class="pointer" title="#' + tag + 'でトゥート">Toot</a></span><br>';
|
|
|
|
|
});
|
|
|
|
|
$("#tips-text").html('<div class="trendtag">トレンドタグ<i class="material-icons pointer" onclick="trendTagonTip()" style="font-size:12px">refresh</i>:<br>' + tags + '</div>');
|
|
|
|
|
trendTagonTipInterval()
|
|
|
|
|
} else {
|
|
|
|
|
$("#tips-text").html("");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2018-07-28 07:25:12 +10:00
|
|
|
|
}
|
2018-07-29 17:37:54 +10:00
|
|
|
|
//Spotify
|
2019-05-19 17:39:30 +10:00
|
|
|
|
function spotifytips() {
|
|
|
|
|
var start = "https://thedesk.top/now-playing?at=" + localStorage.getItem("spotify") + "&rt=" + localStorage.getItem("spotify-refresh");
|
|
|
|
|
var at = localStorage.getItem("spotify");
|
|
|
|
|
if (at) {
|
|
|
|
|
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) {
|
|
|
|
|
var ms = json.progress_ms;
|
|
|
|
|
var last = 1000 - ms % 1000;
|
|
|
|
|
var item = json.item;
|
|
|
|
|
var img = item.album.images[0].url;
|
|
|
|
|
var artisttxt = "";
|
|
|
|
|
for (i = 0; i < item.artists.length; i++) {
|
|
|
|
|
if (i > 0) {
|
|
|
|
|
artisttxt = artisttxt + "," + item.artists[i].name;
|
|
|
|
|
} else {
|
|
|
|
|
artisttxt = item.artists[0].name;
|
2018-07-29 17:37:54 +10:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
|
artisttxt = escapeHTML(artisttxt);
|
2018-07-29 17:37:54 +10:00
|
|
|
|
sleep(last);
|
2019-05-19 17:39:30 +10:00
|
|
|
|
var tms = item.duration_ms;
|
|
|
|
|
var per = ms / item.duration_ms * 100;
|
|
|
|
|
ms = ms / 1000;
|
|
|
|
|
tms = tms / 1000;
|
|
|
|
|
var s = Math.round(ms) % 60;
|
|
|
|
|
if (s < 10) {
|
|
|
|
|
s = "0" + s;
|
2018-07-29 17:37:54 +10:00
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
|
var m = (Math.round(ms) - Math.round(ms) % 60) / 60;
|
|
|
|
|
var ts = Math.round(tms) % 60;
|
|
|
|
|
if (ts < 10) {
|
|
|
|
|
ts = "0" + ts;
|
2018-07-29 17:37:54 +10:00
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
|
var tm = (Math.round(tms) - Math.round(tms) % 60) / 60;
|
|
|
|
|
$("#tips-text").html('<div id="spot-box"><i class="material-icons pointer" onclick="spotifytips()" style="font-size:12px">refresh</i><img src="' + img + '" width="20" id="spot-img">' + escapeHTML(item.name) + '<span class="gray sml" id="spot-art">' + artisttxt + '</span><span id="spot-m">' + m + '</span>:<span id="spot-s">' + s + '</span>/' + tm + ":" + ts + '</span></div><div class="progress grey"><div class="determinate spotify-prog grey lighten-2" style="width: ' + per + '%" data-s="' + Math.round(ms) + '" data-total="' + item.duration_ms + '"></div></div>');
|
|
|
|
|
spotint = setInterval(spotStart, 1000);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
alert(lang.lang_spotify_acct);
|
|
|
|
|
}
|
2018-07-29 17:37:54 +10:00
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
|
function spotStart() {
|
|
|
|
|
var total = $(".spotify-prog").attr("data-total");
|
|
|
|
|
var s = $(".spotify-prog").attr("data-s");
|
|
|
|
|
var news = s * 1 + 1;
|
|
|
|
|
var per = news * 100000 / total;
|
|
|
|
|
var ns = news % 60;
|
|
|
|
|
var nm = (news - ns) / 60;
|
|
|
|
|
if (ns < 10) {
|
|
|
|
|
ns = "0" + ns;
|
2018-07-29 17:37:54 +10:00
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
|
if (per >= 100) {
|
2018-07-29 17:37:54 +10:00
|
|
|
|
clearInterval(spotStart);
|
|
|
|
|
spotifytips()
|
2019-05-19 17:39:30 +10:00
|
|
|
|
} else {
|
2018-07-29 17:37:54 +10:00
|
|
|
|
$("#spot-m").text(nm);
|
|
|
|
|
$("#spot-s").text(ns);
|
2019-05-19 17:39:30 +10:00
|
|
|
|
}
|
|
|
|
|
$(".spotify-prog").attr("data-s", news);
|
|
|
|
|
$(".spotify-prog").css("width", per + "%");
|
2018-07-29 17:37:54 +10:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-28 07:25:12 +10:00
|
|
|
|
|
2019-05-19 17:39:30 +10:00
|
|
|
|
function trendTagonTipInterval() {
|
|
|
|
|
setTimeout(trendTagonTip, 6000000);
|
2018-07-28 07:25:12 +10:00
|
|
|
|
}
|
|
|
|
|
//時計
|
|
|
|
|
var clockint;
|
2019-05-19 17:39:30 +10:00
|
|
|
|
function clock() {
|
|
|
|
|
var now = new Date();
|
|
|
|
|
var last = 1000 - now.getTime() % 1000;
|
2018-07-28 07:25:12 +10:00
|
|
|
|
sleep(last);
|
2019-05-19 17:39:30 +10:00
|
|
|
|
clockint = setInterval(clockStart, 1000);
|
2018-07-28 07:25:12 +10:00
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
|
function clockStart() {
|
2018-07-28 07:25:12 +10:00
|
|
|
|
var nowTime = new Date(); // 現在日時を得る
|
|
|
|
|
var nowHour = nowTime.getHours(); // 時を抜き出す
|
2019-05-19 17:39:30 +10:00
|
|
|
|
if (nowHour < 10) { nowHour = "0" + nowHour }
|
|
|
|
|
var nowMin = nowTime.getMinutes(); // 分を抜き出す
|
|
|
|
|
if (nowMin < 10) { nowMin = "0" + nowMin }
|
|
|
|
|
var nowSec = nowTime.getSeconds(); // 秒を抜き出す
|
|
|
|
|
if (nowSec < 10) { nowSec = "0" + nowSec }
|
|
|
|
|
var msg = nowTime.getFullYear() + "/" + (nowTime.getMonth() + 1) + "/" + nowTime.getDate() + '<span style="font-size:20px; font-family:Open Sans">' + nowHour + ":" + nowMin + ":" + nowSec + "</span>";
|
2018-07-28 07:25:12 +10:00
|
|
|
|
$("#tips-text").html(msg);
|
|
|
|
|
}
|
|
|
|
|
function sleep(waitMsec) {
|
|
|
|
|
var startMsec = new Date();
|
|
|
|
|
while (new Date() - startMsec < waitMsec);
|
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
|
function tipsToggle() {
|
2018-07-28 07:25:12 +10:00
|
|
|
|
$("#tips").toggleClass("hide");
|
|
|
|
|
$("#tips-menu").toggleClass("hide");
|
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
|
if (localStorage.getItem("tips")) {
|
2018-07-28 07:25:12 +10:00
|
|
|
|
tips(localStorage.getItem("tips"));
|
|
|
|
|
}
|