From cd7423646215b2572748093bb802b591bf7ddee5 Mon Sep 17 00:00:00 2001 From: cutls Date: Sat, 9 Nov 2019 14:30:28 +0900 Subject: [PATCH] test itunes --- app/js/ui/img.js | 1 + app/js/ui/tips.js | 63 ++++++++++++++++++++++++++++++++- app/view/make/index.sample.html | 4 +-- 3 files changed, 65 insertions(+), 3 deletions(-) diff --git a/app/js/ui/img.js b/app/js/ui/img.js index 639d5070..2ed1f19f 100644 --- a/app/js/ui/img.js +++ b/app/js/ui/img.js @@ -95,6 +95,7 @@ function imageXhr(id, key, murl) { 'loadend', function(event) { var total = event.total + $('#imgbyte').text(Math.floor(total/1024)) var now = event.loaded var per = (now / total) * 100 $('#imgprog').text(Math.floor(per)) diff --git a/app/js/ui/tips.js b/app/js/ui/tips.js index 0e417611..c5999afb 100644 --- a/app/js/ui/tips.js +++ b/app/js/ui/tips.js @@ -53,6 +53,10 @@ function tips(mode) { tipsToggle() localStorage.setItem('tips', 'spotify') spotifytips() + } else if (mode == 'itunes') { + tipsToggle() + localStorage.setItem('tips', 'itunes') + itunestips() } } //メモリ @@ -236,7 +240,64 @@ function spotStart() { $('.spotify-prog').attr('data-s', news) $('.spotify-prog').css('width', per + '%') } - +//iTunes +function spotifytips() { + if (spotint) clearInterval(spotint) + 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 + } + } + artisttxt = escapeHTML(artisttxt) + sleep(last) + 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 + } + var m = (Math.round(ms) - (Math.round(ms) % 60)) / 60 + var ts = Math.round(tms) % 60 + if (ts < 10) { + ts = '0' + ts + } + var tm = (Math.round(tms) - (Math.round(tms) % 60)) / 60 + var html = ` +
+
+ refresh + send +
+
+ +
+
+ ${escapeHTML(item.name)} +
+
+ ${artisttxt} +
+
+ ${m}:${s}/${tm}:${ts} +
+
+
+
+
+
` + $('#tips-text').html(html) + spotint = setInterval(spotStart, 1000) +} function trendTagonTipInterval() { setTimeout(trendTagonTip, 6000000) } diff --git a/app/view/make/index.sample.html b/app/view/make/index.sample.html index 3e8d3125..277e13ca 100644 --- a/app/view/make/index.sample.html +++ b/app/view/make/index.sample.html @@ -694,7 +694,7 @@