//左下のメッセージ
var todcTrigger = null
function todo(mes) {
clearInterval(todcTrigger)
$('#message').text(mes)
$('#message').fadeIn()
todcTrigger = setTimeout(todc, 4000)
}
function todc() {
$('#message').fadeOut()
}
//reverse
function bottomReverse() {
$('#bottom').toggleClass('reverse')
$('.leftside').toggleClass('reverse')
if ($('#bottom').hasClass('reverse')) {
localStorage.removeItem('reverse')
} else {
localStorage.setItem('reverse', 'true')
}
}
function tips(mode) {
postMessage(['sendSinmpleIpc', 'endmem'], '*')
clearInterval(clockint)
clearInterval(spotStart)
if (mode == 'ver') {
tipsToggle()
$('#tips-text').html(
' ' +
localStorage.getItem('ver') +
' {' +
gitHash.slice(0, 7) +
'} [supervisor_account1+]'
)
localStorage.setItem('tips', 'ver')
} else if (mode == 'clock') {
tipsToggle()
localStorage.setItem('tips', 'clock')
clock()
} else if (mode == 'memory') {
tipsToggle()
localStorage.setItem('tips', 'memory')
startmem()
} else if (mode == 'trend') {
tipsToggle()
localStorage.setItem('tips', 'trend')
trendTagonTip()
} else if (mode == 'spotify') {
tipsToggle()
localStorage.setItem('tips', 'spotify')
spotifytips()
} else if (mode == 'itunes') {
tipsToggle()
localStorage.setItem('tips', 'itunes')
itunestips()
}
}
//メモリ
function startmem() {
postMessage(['sendSinmpleIpc', 'startmem'], '*')
}
function renderMem(use, cpu, total, core, uptime) {
let day = Math.floor(uptime / 60 / 60 / 24)
let hour = Math.floor(uptime / 60 /60 % 24)
if(hour < 10) hour = '0' + hour
let min = Math.floor(uptime / 60 % 60)
if(min < 10) min = '0' + min
let sec = Math.floor(uptime % 60)
if(sec < 10) sec = '0' + sec
let time = `${day ? day + ' days ' : ''}${hour ? hour + ':' : ''}${min}:${sec}`
//Intel
cpu = cpu.replace('Intel(R)', '').replace('(TM)', '').replace(' CPU', '')
//AMD
cpu = cpu.replace('AMD ', '').replace(/\s[0-9]{1,3}-Core\sProcessor/, '')
$('#tips-text').html(
`${escapeHTML(cpu)} x ${core}
RAM: ${Math.floor(use / 1024 / 1024 / 102.4) / 10}/${Math.floor(total / 1024 / 1024 / 102.4) / 10}GB(${Math.floor((use / total) * 100)}%) UP:${time}`
)
}
//トレンドタグ
function trendTagonTip() {
$('.trendtag').remove()
var domain = 'imastodon.net'
var at = localStorage.getItem('acct_' + acct_id + '_at')
var start = 'https://' + domain + '/api/v1/trend_tags'
fetch(start, {
method: 'GET',
headers: {
'content-type': 'application/json',
Authorization: 'Bearer ' + at
}
})
.then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text)
})
}
return response.json()
})
.catch(function(error) {
todo(error)
setLog(start, 'JSON', error)
console.error(error)
})
.then(function(json) {
if (json) {
var tags = ''
json = json.score
Object.keys(json).forEach(function(tag) {
tags =
tags +
`
#${escapeHTML(tag)}
TL
Toot
`
})
$('#tips-text').html(
'