TheDesk Airi (ver.5)
This commit is contained in:
@@ -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