2018-01-28 23:22:43 +11:00
|
|
|
//設定(setting.html)で読む
|
2019-03-15 22:12:11 +11:00
|
|
|
var envView = new Vue({
|
|
|
|
el: '#envView',
|
|
|
|
data: {config:envConstruction},
|
|
|
|
methods: {
|
|
|
|
complete: function (i,val) {
|
|
|
|
var ls=envView.config[i].storage;
|
|
|
|
Materialize.toast("Complete", 3000);
|
2019-03-16 16:05:04 +11:00
|
|
|
if(!val){
|
|
|
|
var id=envView.config[i].id;
|
|
|
|
var val=$("#"+id).val()
|
|
|
|
}
|
2019-03-15 22:12:11 +11:00
|
|
|
localStorage.setItem(ls,val)
|
|
|
|
if(ls=="ha"){
|
|
|
|
hardwareAcceleration(val)
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
var tlView = new Vue({
|
|
|
|
el: '#tlView',
|
|
|
|
data: {config:tlConstruction},
|
|
|
|
methods: {
|
|
|
|
complete: function (i,val) {
|
|
|
|
var ls=tlView.config[i].storage;
|
2019-03-16 16:05:04 +11:00
|
|
|
if(!val){
|
|
|
|
var id=tlView.config[i].id;
|
|
|
|
var val=$("#"+id).val()
|
|
|
|
}
|
2019-03-15 22:12:11 +11:00
|
|
|
Materialize.toast("Complete", 3000);
|
|
|
|
localStorage.setItem(ls,val)
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
var postView = new Vue({
|
|
|
|
el: '#postView',
|
|
|
|
data: {config:postConstruction,kirishima:localStorage.getItem('kirishima')},
|
|
|
|
methods: {
|
|
|
|
complete: function (i,val) {
|
|
|
|
var ls=postView.config[i].storage;
|
|
|
|
Materialize.toast("Complete", 3000);
|
2019-03-16 16:05:04 +11:00
|
|
|
if(!val){
|
|
|
|
var id=postView.config[i].id;
|
|
|
|
var val=$("#"+id).val()
|
|
|
|
}
|
2019-03-15 22:12:11 +11:00
|
|
|
localStorage.setItem(ls,val)
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2018-01-28 23:22:43 +11:00
|
|
|
//設定ボタン押した。
|
|
|
|
function settings() {
|
|
|
|
var cd = $("[name=theme]:checked").val();
|
2018-07-07 03:51:48 +10:00
|
|
|
var ct = $("[for="+cd+"]").html();
|
2019-03-08 05:19:26 +11:00
|
|
|
if(cd=="custom" && !$("#custom-sel-sel").val()){
|
|
|
|
var theme = localStorage.getItem("theme");
|
|
|
|
if (!theme) {
|
|
|
|
var theme = "white";
|
|
|
|
}
|
|
|
|
$("#" + theme).prop("checked", true);
|
|
|
|
}else{
|
|
|
|
if (cd != localStorage.getItem("theme")) {
|
|
|
|
Materialize.toast(lang.lang_setting_theme.replace("{{set}}" ,ct), 3000);
|
|
|
|
}
|
|
|
|
//テーマはこの場で設定
|
|
|
|
themes(cd);
|
|
|
|
localStorage.setItem("theme", cd);
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
2018-07-05 11:26:07 +10:00
|
|
|
var fontd = $("#font").val();
|
|
|
|
if(fontd){
|
|
|
|
if (fontd != localStorage.getItem("font")) {
|
2019-01-26 14:24:26 +11:00
|
|
|
Materialize.toast(lang.lang_setting_font.replace("{{set}}" ,fontd), 3000);
|
2018-07-05 11:26:07 +10:00
|
|
|
}
|
|
|
|
localStorage.setItem("font", fontd);
|
|
|
|
themes();
|
|
|
|
}else{
|
2018-07-07 03:51:48 +10:00
|
|
|
if(localStorage.getItem("font")){
|
|
|
|
localStorage.removeItem("font");
|
2019-01-26 14:24:26 +11:00
|
|
|
Materialize.toast(lang.lang_setting_font.replace("{{set}}" ,lang.lang_setting_default), 3000);
|
2018-07-07 03:51:48 +10:00
|
|
|
themes();
|
|
|
|
}
|
2018-07-05 11:26:07 +10:00
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
//読み込み時の設定ロード
|
|
|
|
function load() {
|
2019-03-15 22:12:11 +11:00
|
|
|
var max=envView.config.length;
|
|
|
|
for(var i=0;i<max;i++){
|
|
|
|
var ls=envView.config[i].storage;
|
2019-03-19 02:24:46 +11:00
|
|
|
if(localStorage.getItem(ls)){
|
|
|
|
envView.config[i].setValue=localStorage.getItem(ls)
|
|
|
|
}
|
2019-03-15 22:12:11 +11:00
|
|
|
}
|
|
|
|
var max=tlView.config.length;
|
|
|
|
for(var i=0;i<max;i++){
|
|
|
|
var ls=tlView.config[i].storage;
|
2019-03-19 02:24:46 +11:00
|
|
|
if(localStorage.getItem(ls)){
|
|
|
|
tlView.config[i].setValue=localStorage.getItem(ls)
|
|
|
|
}
|
2019-03-15 22:12:11 +11:00
|
|
|
}
|
|
|
|
var max=postView.config.length;
|
|
|
|
for(var i=0;i<max;i++){
|
|
|
|
var ls=postView.config[i].storage;
|
2019-03-19 02:24:46 +11:00
|
|
|
if(localStorage.getItem(ls)){
|
|
|
|
postView.config[i].setValue=localStorage.getItem(ls)
|
|
|
|
}
|
2019-03-15 22:12:11 +11:00
|
|
|
}
|
2018-07-07 03:51:48 +10:00
|
|
|
if(localStorage.getItem("imas")){
|
2018-04-16 23:58:14 +10:00
|
|
|
$(".imas").removeClass("hide");
|
|
|
|
}
|
2018-07-30 03:35:29 +10:00
|
|
|
if(localStorage.getItem("kirishima")){
|
|
|
|
$(".kirishima").removeClass("hide");
|
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
var theme = localStorage.getItem("theme");
|
|
|
|
if (!theme) {
|
|
|
|
var theme = "white";
|
|
|
|
}
|
|
|
|
$("#" + theme).prop("checked", true);
|
2018-07-05 11:26:07 +10:00
|
|
|
var font = localStorage.getItem("font");
|
|
|
|
if (!font) {
|
|
|
|
var font = "";
|
|
|
|
}
|
|
|
|
$("#font").val(font);
|
2019-04-15 01:45:04 +10:00
|
|
|
$("#c1-file").text(localStorage.getItem("custom1"))
|
|
|
|
$("#c2-file").text(localStorage.getItem("custom2"));
|
|
|
|
$("#c3-file").text(localStorage.getItem("custom3"));
|
|
|
|
$("#c4-file").text(localStorage.getItem("custom4"));
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
2019-03-08 05:19:26 +11:00
|
|
|
|
2018-03-11 01:22:59 +11:00
|
|
|
function climute(){
|
|
|
|
//クライアントミュート
|
|
|
|
var cli = localStorage.getItem("client_mute");
|
|
|
|
var obj = JSON.parse(cli);
|
|
|
|
if(!obj){
|
2019-01-26 14:24:26 +11:00
|
|
|
$("#mute-cli").html(lang.lang_setting_nomuting);
|
2018-03-11 01:22:59 +11:00
|
|
|
}else{
|
|
|
|
if(!obj[0]){
|
2019-01-26 14:24:26 +11:00
|
|
|
$("#mute-cli").html(lang.lang_setting_nomuting);
|
2018-03-11 01:22:59 +11:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
var templete;
|
|
|
|
Object.keys(obj).forEach(function(key) {
|
|
|
|
var cli = obj[key];
|
|
|
|
var list = key * 1 + 1;
|
|
|
|
templete = '<div class="acct" id="acct_' + key + '">' + list +
|
|
|
|
'.' +
|
|
|
|
cli + '<button class="btn waves-effect red disTar" onclick="cliMuteDel(' +
|
2019-01-26 14:24:26 +11:00
|
|
|
key + ')">'+lang.lang_del+'</button><br></div>';
|
2018-03-11 01:22:59 +11:00
|
|
|
$("#mute-cli").append(templete);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function cliMuteDel(key){
|
|
|
|
var cli = localStorage.getItem("client_mute");
|
|
|
|
var obj = JSON.parse(cli);
|
|
|
|
obj.splice(key, 1);
|
|
|
|
var json = JSON.stringify(obj);
|
|
|
|
localStorage.setItem("client_mute", json);
|
|
|
|
mute();
|
|
|
|
}
|
|
|
|
|
|
|
|
function wordmute(){
|
|
|
|
var word = localStorage.getItem("word_mute");
|
|
|
|
var obj = JSON.parse(word);
|
|
|
|
$('#wordmute').material_chip({
|
|
|
|
data: obj,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
function wordmuteSave(){
|
|
|
|
var word=$('#wordmute').material_chip('data');
|
|
|
|
var json = JSON.stringify(word);
|
|
|
|
localStorage.setItem("word_mute", json);
|
|
|
|
}
|
|
|
|
|
|
|
|
function wordemp(){
|
|
|
|
var word = localStorage.getItem("word_emp");
|
|
|
|
var obj = JSON.parse(word);
|
|
|
|
$('#wordemp').material_chip({
|
|
|
|
data: obj,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
function wordempSave(){
|
|
|
|
var word=$('#wordemp').material_chip('data');
|
|
|
|
var json = JSON.stringify(word);
|
|
|
|
localStorage.setItem("word_emp", json);
|
2018-05-26 05:00:04 +10:00
|
|
|
}
|
|
|
|
function notftest(){
|
2018-08-05 02:26:34 +10:00
|
|
|
var electron = require("electron");
|
2018-05-26 05:00:04 +10:00
|
|
|
var ipc = electron.ipcRenderer;
|
|
|
|
var os = electron.remote.process.platform;
|
|
|
|
var options = {
|
2019-01-26 14:24:26 +11:00
|
|
|
body: lang.lang_setting_notftest+'('+lang.lang_setting_notftestprof+')',
|
2018-05-26 05:00:04 +10:00
|
|
|
icon: localStorage.getItem("prof_0")
|
|
|
|
};
|
|
|
|
if(os=="darwin"){
|
2019-01-26 14:24:26 +11:00
|
|
|
var n = new Notification('TheDesk'+lang.lang_setting_notftest, options);
|
2018-05-26 05:00:04 +10:00
|
|
|
}else{
|
2019-01-26 14:24:26 +11:00
|
|
|
ipc.send('native-notf', ['TheDesk'+lang.lang_setting_notftest,lang.lang_setting_notftest+'('+lang.lang_setting_notftestprof+')',localStorage.getItem('prof_0'),"",""]);
|
2018-05-26 05:00:04 +10:00
|
|
|
}
|
|
|
|
|
2018-06-12 01:44:28 +10:00
|
|
|
}
|
|
|
|
function oks(no){
|
|
|
|
var txt=$("#oks-"+no).val();
|
|
|
|
localStorage.setItem("oks-"+no, txt);
|
2019-01-26 14:24:26 +11:00
|
|
|
Materialize.toast(lang.lang_setting_ksref, 3000);
|
2018-06-12 01:44:28 +10:00
|
|
|
}
|
|
|
|
function oksload(){
|
|
|
|
if(localStorage.getItem("oks-1")){$("#oks-1").val(localStorage.getItem("oks-1"))}
|
|
|
|
if(localStorage.getItem("oks-2")){$("#oks-2").val(localStorage.getItem("oks-2"))}
|
|
|
|
if(localStorage.getItem("oks-3")){$("#oks-3").val(localStorage.getItem("oks-3"))}
|
2018-08-05 02:26:34 +10:00
|
|
|
}
|
2018-09-12 02:49:41 +10:00
|
|
|
function changelang(lang){
|
|
|
|
var electron = require("electron");
|
|
|
|
var ipc = electron.ipcRenderer;
|
|
|
|
ipc.send('lang',lang);
|
|
|
|
ipc.on('langres', function (event, arg) {
|
|
|
|
location.href="../"+lang+"/setting.html"
|
|
|
|
});
|
|
|
|
}
|
2018-08-05 02:26:34 +10:00
|
|
|
function exportSettings(){
|
2019-01-26 14:24:26 +11:00
|
|
|
if(!confirm(lang.lang_setting_exportwarn)){
|
2018-08-05 02:26:34 +10:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
var electron = require("electron");
|
|
|
|
var remote=electron.remote;
|
|
|
|
var dialog=remote.dialog;
|
|
|
|
var ipc = electron.ipcRenderer;
|
|
|
|
dialog.showSaveDialog(null, {
|
|
|
|
title: 'Export',
|
|
|
|
properties: ['openFile', 'createDirectory'],
|
2019-03-15 22:12:11 +11:00
|
|
|
defaultPath: "export.thedeskconfigv2"
|
2018-08-05 02:26:34 +10:00
|
|
|
}, (savedFiles) => {
|
|
|
|
console.log(savedFiles);
|
|
|
|
if(!savedFiles){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
var exp={};
|
|
|
|
//Accounts
|
|
|
|
var multi = localStorage.getItem("multi");
|
|
|
|
var acct = JSON.parse(multi);
|
|
|
|
exp.accts=acct;
|
|
|
|
//Columns
|
|
|
|
var multi = localStorage.getItem("column");
|
|
|
|
var column = JSON.parse(multi);
|
|
|
|
exp.columns=column;
|
|
|
|
//Themes
|
2019-03-15 22:12:11 +11:00
|
|
|
var config={};
|
|
|
|
config.theme=localStorage.getItem("theme");
|
|
|
|
//Other configs
|
|
|
|
var max=envView.config.length;
|
|
|
|
for(var i=0;i<max;i++){
|
|
|
|
var ls=envView.config[i].storage;
|
|
|
|
config[ls]=localStorage.getItem(ls)
|
|
|
|
}
|
|
|
|
var max=tlView.config.length;
|
|
|
|
for(var i=0;i<max;i++){
|
|
|
|
var ls=tlView.config[i].storage;
|
|
|
|
config[ls]=localStorage.getItem(ls)
|
|
|
|
}
|
|
|
|
var max=postView.config.length;
|
|
|
|
for(var i=0;i<max;i++){
|
|
|
|
var ls=postView.config[i].storage;
|
|
|
|
config[ls]=localStorage.getItem(ls)
|
|
|
|
}
|
2018-08-05 02:26:34 +10:00
|
|
|
//Font
|
2019-03-15 22:12:11 +11:00
|
|
|
config.font=localStorage.getItem("font");
|
|
|
|
exp.config=config;
|
2018-08-05 02:26:34 +10:00
|
|
|
//keysc
|
|
|
|
exp.ksc=[
|
|
|
|
localStorage.getItem("oks-1"),
|
|
|
|
localStorage.getItem("oks-2"),
|
|
|
|
localStorage.getItem("oks-3")
|
|
|
|
];
|
|
|
|
//climu
|
|
|
|
var cli = localStorage.getItem("client_mute");
|
|
|
|
var climu = JSON.parse(cli);
|
|
|
|
exp.clientMute=climu;
|
|
|
|
//wordmu
|
|
|
|
var wdm = localStorage.getItem("word_mute");
|
|
|
|
var wordmu = JSON.parse(wdm);
|
|
|
|
exp.wordMute=wordmu;
|
|
|
|
//spotify
|
|
|
|
exp.spotifyArtwork=localStorage.getItem("artwork")
|
2018-08-29 20:17:34 +10:00
|
|
|
var content=localStorage.getItem("np-temp");
|
|
|
|
if(content || content=="" || content=="null"){
|
|
|
|
exp.spotifyTemplete=content;
|
|
|
|
}else{
|
|
|
|
exp.spotifyTemplete=null;
|
|
|
|
}
|
2018-08-05 02:26:34 +10:00
|
|
|
//tags
|
|
|
|
var tagarr = localStorage.getItem("tag");
|
|
|
|
var favtag = JSON.parse(tagarr);
|
|
|
|
exp.favoriteTags=favtag;
|
|
|
|
console.log(exp);
|
|
|
|
ipc.send('export', [savedFiles,JSON.stringify(exp)]);
|
|
|
|
alert("Done.")
|
|
|
|
//cards
|
|
|
|
//lang
|
|
|
|
});
|
|
|
|
}
|
|
|
|
function importSettings(){
|
2019-01-26 14:24:26 +11:00
|
|
|
if(!confirm(lang.lang_setting_importwarn)){
|
2018-08-05 02:26:34 +10:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
var electron = require("electron");
|
|
|
|
var remote=electron.remote;
|
|
|
|
var dialog=remote.dialog;
|
|
|
|
var ipc = electron.ipcRenderer;
|
|
|
|
dialog.showOpenDialog(null, {
|
|
|
|
title: 'Import',
|
|
|
|
properties: ['openFile'],
|
|
|
|
filters: [
|
2019-03-15 22:12:11 +11:00
|
|
|
{name: 'TheDesk Config', extensions: ['thedeskconfig','thedeskconfigv2']},
|
2018-08-05 02:26:34 +10:00
|
|
|
]
|
|
|
|
}, (fileNames) => {
|
|
|
|
console.log(fileNames);
|
|
|
|
if(!fileNames){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
ipc.send('import', fileNames[0]);
|
|
|
|
ipc.on('config', function (event, arg) {
|
|
|
|
var obj = JSON.parse(arg);
|
|
|
|
if(obj){
|
|
|
|
localStorage.clear();
|
|
|
|
localStorage.setItem("multi",JSON.stringify(obj.accts));
|
|
|
|
for(var key=0;key<obj.accts.length;key++){
|
|
|
|
var acct=obj.accts[key];
|
|
|
|
localStorage.setItem("name_" + key, acct.name);
|
|
|
|
localStorage.setItem("user_" + key, acct.user);
|
|
|
|
localStorage.setItem("user-id_" + key, acct.id);
|
|
|
|
localStorage.setItem("prof_" + key, acct.prof);
|
|
|
|
localStorage.setItem("domain_" + key, acct.domain);
|
|
|
|
localStorage.setItem("acct_"+ key + "_at", acct.at);
|
|
|
|
}
|
|
|
|
localStorage.setItem("column",JSON.stringify(obj.columns));
|
2019-03-15 22:12:11 +11:00
|
|
|
if(obj.config){
|
|
|
|
//Version 2
|
|
|
|
var max=envView.config.length;
|
|
|
|
for(var i=0;i<max;i++){
|
|
|
|
var ls=envView.config[i].storage;
|
|
|
|
if(obj.config[ls]){
|
|
|
|
localStorage.setItem(ls,obj.config[ls])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var max=tlView.config.length;
|
|
|
|
for(var i=0;i<max;i++){
|
|
|
|
var ls=tlView.config[i].storage;
|
|
|
|
if(obj.config[ls]){
|
|
|
|
localStorage.setItem(ls,obj.config[ls])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var max=postView.config.length;
|
|
|
|
for(var i=0;i<max;i++){
|
|
|
|
var ls=postView.config[i].storage;
|
|
|
|
if(obj.config[ls]){
|
|
|
|
localStorage.setItem(ls,obj.config[ls])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
//Version 1
|
|
|
|
localStorage.setItem("theme",obj.theme);
|
|
|
|
if(obj.width){
|
|
|
|
console.log(obj.width)
|
|
|
|
localStorage.setItem("width",obj.width);
|
|
|
|
}
|
|
|
|
if(obj.font){
|
|
|
|
localStorage.setItem("font",obj.font);
|
|
|
|
}
|
|
|
|
if(obj.size){
|
|
|
|
localStorage.setItem("size",obj.size);
|
|
|
|
}
|
|
|
|
themes(obj.theme);
|
|
|
|
if(obj.imgheight){
|
|
|
|
localStorage.setItem("img-height",obj.imgheight);
|
|
|
|
}
|
|
|
|
localStorage.setItem("mainuse",obj.mainuse);
|
|
|
|
if(obj.cw){
|
|
|
|
localStorage.setItem("cwtext",obj.cw);
|
|
|
|
}
|
|
|
|
localStorage.setItem("vis",obj.vis);
|
|
|
|
//End
|
2018-08-05 02:26:34 +10:00
|
|
|
}
|
|
|
|
if(obj.ksc[0]){
|
|
|
|
localStorage.setItem("oks-1",obj.ksc[0]);
|
|
|
|
}
|
|
|
|
if(obj.ksc[1]){
|
|
|
|
localStorage.setItem("oks-2",obj.ksc[1]);
|
|
|
|
}
|
|
|
|
if(obj.ksc[2]){
|
|
|
|
localStorage.setItem("oks-3",obj.ksc[2]);
|
|
|
|
}
|
|
|
|
if(obj.clientMute){
|
|
|
|
localStorage.setItem("client_mute",JSON.stringify(obj.clientMute));
|
|
|
|
}
|
|
|
|
if(obj.wordMute){
|
|
|
|
localStorage.setItem("word_mute",JSON.stringify(obj.wordMute));
|
|
|
|
}
|
|
|
|
if(obj.favoriteTags){
|
|
|
|
localStorage.setItem("tag",JSON.stringify(obj.favoriteTags));
|
|
|
|
}
|
2018-08-29 20:17:34 +10:00
|
|
|
|
2018-08-05 02:26:34 +10:00
|
|
|
localStorage.setItem("np-temp",obj.spotifyTemplete);
|
|
|
|
for(var i=0;i<obj.columns.length;i++){
|
|
|
|
localStorage.setItem("card_" + i,"true");
|
|
|
|
localStorage.removeItem("catch_" + i);
|
|
|
|
}
|
2019-03-21 15:39:30 +11:00
|
|
|
location.href="index.html";
|
2018-08-05 02:26:34 +10:00
|
|
|
}else{
|
|
|
|
alert("Error.")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
//cards
|
|
|
|
//lang
|
|
|
|
});
|
2018-09-06 02:47:27 +10:00
|
|
|
}
|
|
|
|
function savefolder(){
|
|
|
|
var electron = require("electron");
|
|
|
|
var remote=electron.remote;
|
|
|
|
var dialog=remote.dialog;
|
|
|
|
dialog.showOpenDialog(null, {
|
|
|
|
title: 'Save folder',
|
|
|
|
properties: ['openDirectory'],
|
|
|
|
}, (fileNames) => {
|
|
|
|
localStorage.setItem("savefolder",fileNames[0]);
|
|
|
|
});
|
2018-12-09 05:46:01 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
function font(){
|
|
|
|
var electron = require("electron");
|
|
|
|
var ipc = electron.ipcRenderer;
|
|
|
|
ipc.send('fonts', []);
|
|
|
|
ipc.on('font-list', function (event, arg) {
|
|
|
|
$("#fonts").removeClass("hide");
|
|
|
|
for( var i=0; i<arg.length; i++) {
|
|
|
|
var font=arg[i];
|
|
|
|
$("#fonts").append('<div class="font pointer" style="font-family:'+font.family+'" onclick="insertFont(\''+font.family+'\')">'+font.family+"</div>")
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
function insertFont(name){
|
|
|
|
$("#font").val(name);
|
2019-03-08 05:19:26 +11:00
|
|
|
}
|
|
|
|
$(".color-picker").each(function(i, elem) {
|
|
|
|
pickerDefine(i,"fff");
|
|
|
|
});
|
|
|
|
function pickerDefine(i,color){
|
|
|
|
var pickr = new Pickr({
|
|
|
|
el: '#color-picker'+i,
|
|
|
|
default: color,
|
|
|
|
showAlways: true,
|
|
|
|
appendToBody: true,
|
|
|
|
closeWithKey: 'Escape',
|
|
|
|
comparison: false,
|
|
|
|
components: {
|
|
|
|
preview: true, // Left side color comparison
|
|
|
|
opacity: false, // Opacity slider
|
|
|
|
hue: true, // Hue slider
|
2019-03-08 07:18:49 +11:00
|
|
|
interaction: {
|
|
|
|
rgba: false, // rgba option (red green blue and alpha)
|
|
|
|
input: true, // input / output element
|
|
|
|
}
|
2019-03-08 05:19:26 +11:00
|
|
|
},
|
|
|
|
strings: {
|
|
|
|
save: 'Save', // Default for save button
|
|
|
|
clear: 'Clear' // Default for clear button
|
|
|
|
}
|
|
|
|
});
|
|
|
|
pickr.on('change', (...args) => {
|
2019-03-08 07:18:49 +11:00
|
|
|
var rgb='rgb('+args[0].toRGBA()[0]+','+args[0].toRGBA()[1]+','+args[0].toRGBA()[2]+')';
|
|
|
|
$("#color-picker"+i+"_value").val(rgb)
|
|
|
|
});
|
2019-03-08 05:19:26 +11:00
|
|
|
}
|
|
|
|
function customComp(){
|
|
|
|
var nameC=$("#custom_name").val();
|
|
|
|
if(!nameC){return false;}
|
|
|
|
var descC=$("#custom_desc").val();
|
|
|
|
var primaryC=$("#color-picker0_value").val();
|
2019-03-08 07:18:49 +11:00
|
|
|
if(!primaryC){primaryC="rgb(255,255,255)"}
|
2019-03-08 05:19:26 +11:00
|
|
|
var secondaryC=$("#color-picker1_value").val();
|
2019-03-08 07:18:49 +11:00
|
|
|
if(!secondaryC){secondaryC="rgb(255,255,255)"}
|
2019-03-08 05:19:26 +11:00
|
|
|
var textC=$("#color-picker2_value").val();
|
2019-03-08 07:18:49 +11:00
|
|
|
if(!textC){textC="rgb(255,255,255)"}
|
2019-03-08 05:19:26 +11:00
|
|
|
var accentC=$("#color-picker3_value").val();
|
2019-03-08 07:18:49 +11:00
|
|
|
if(!accentC){accentC="rgb(255,255,255)"}
|
2019-03-08 05:19:26 +11:00
|
|
|
var multi = localStorage.getItem("multi");
|
|
|
|
var my=JSON.parse(multi)[0].name;
|
2019-03-08 07:18:49 +11:00
|
|
|
var id=$("#custom-edit-sel").val();
|
|
|
|
if(id=="add_new"){
|
|
|
|
id=makeCID();
|
|
|
|
}
|
2019-03-08 05:19:26 +11:00
|
|
|
var json={
|
|
|
|
"name": nameC,
|
|
|
|
"author": my,
|
|
|
|
"desc": descC,
|
|
|
|
"base": $("[name=direction]:checked").val(),
|
|
|
|
"vars": {
|
|
|
|
"primary": primaryC,
|
|
|
|
"secondary": secondaryC,
|
|
|
|
"text": textC
|
|
|
|
},
|
|
|
|
"props": {
|
|
|
|
"TheDeskAccent": accentC
|
|
|
|
},
|
2019-03-08 07:18:49 +11:00
|
|
|
"id": id
|
2019-03-08 05:19:26 +11:00
|
|
|
}
|
|
|
|
$("#custom_json").val(JSON.stringify(json));
|
2019-03-08 07:18:49 +11:00
|
|
|
themes();
|
|
|
|
$("#custom_name").val("");
|
|
|
|
$("#custom_desc").val("");
|
|
|
|
$("#dark").prop("checked", true);
|
|
|
|
$("#custom_json").val("");
|
|
|
|
$("#color-picker0-wrap").html('<div class="color-picker" id="color-picker0"></div>')
|
|
|
|
$("#color-picker1-wrap").html('<div class="color-picker" id="color-picker1"></div>')
|
|
|
|
$("#color-picker2-wrap").html('<div class="color-picker" id="color-picker2"></div>')
|
|
|
|
$("#color-picker3-wrap").html('<div class="color-picker" id="color-picker3"></div>')
|
|
|
|
$("#color-picker0_value").val("");
|
|
|
|
$("#color-picker1_value").val("");
|
|
|
|
$("#color-picker2_value").val("");
|
|
|
|
$("#color-picker3_value").val("");
|
|
|
|
pickerDefine(0,"fff");
|
|
|
|
pickerDefine(1,"fff");
|
|
|
|
pickerDefine(2,"fff");
|
|
|
|
pickerDefine(3,"fff");
|
|
|
|
ipc.send('theme-json-create', JSON.stringify(json));
|
|
|
|
}
|
|
|
|
function deleteIt(){
|
|
|
|
var id=$("#custom-sel-sel").val();
|
|
|
|
$("#custom_name").val("");
|
|
|
|
$("#custom_desc").val("");
|
|
|
|
$("#dark").prop("checked", true);
|
|
|
|
$("#custom_json").val("");
|
|
|
|
$("#color-picker0-wrap").html('<div class="color-picker" id="color-picker0"></div>')
|
|
|
|
$("#color-picker1-wrap").html('<div class="color-picker" id="color-picker1"></div>')
|
|
|
|
$("#color-picker2-wrap").html('<div class="color-picker" id="color-picker2"></div>')
|
|
|
|
$("#color-picker3-wrap").html('<div class="color-picker" id="color-picker3"></div>')
|
|
|
|
$("#color-picker0_value").val("");
|
|
|
|
$("#color-picker1_value").val("");
|
|
|
|
$("#color-picker2_value").val("");
|
|
|
|
$("#color-picker3_value").val("");
|
|
|
|
pickerDefine(0,"fff");
|
|
|
|
pickerDefine(1,"fff");
|
|
|
|
pickerDefine(2,"fff");
|
|
|
|
pickerDefine(3,"fff");
|
|
|
|
ipc.on('theme-json-delete-complete', function (event, args) {
|
|
|
|
ctLoad()
|
|
|
|
});
|
|
|
|
ipc.send('theme-json-delete', id);
|
2019-03-08 05:19:26 +11:00
|
|
|
}
|
|
|
|
function ctLoad(){
|
|
|
|
ipc.send('theme-json-list', "");
|
|
|
|
ipc.on('theme-json-list-response', function (event, args) {
|
|
|
|
console.log(args);
|
|
|
|
var templete="";
|
|
|
|
Object.keys(args).forEach(function(key) {
|
|
|
|
var theme = args[key];
|
|
|
|
var themeid=theme.id
|
|
|
|
templete = templete+'<option value="'+themeid+'">' + theme.name +'</option>';
|
|
|
|
});
|
2019-03-08 07:18:49 +11:00
|
|
|
if(args[0]){
|
|
|
|
localStorage.setItem("customtheme-id",args[0].id)
|
|
|
|
}
|
2019-03-08 05:19:26 +11:00
|
|
|
$("#custom-sel-sel").html(templete);
|
|
|
|
templete='<option value="add_new">'+$("#edit-selector").attr("data-add")+'</option>'+templete;
|
|
|
|
$("#custom-edit-sel").html(templete);
|
|
|
|
$('select').material_select('update');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
function customSel(){
|
|
|
|
var id=$("#custom-sel-sel").val();
|
|
|
|
localStorage.setItem("customtheme-id",id)
|
|
|
|
}
|
|
|
|
function custom(){
|
|
|
|
var id=$("#custom-edit-sel").val();
|
|
|
|
if(id=="add_new"){
|
|
|
|
$("#custom_name").val("");
|
|
|
|
$("#custom_desc").val("");
|
|
|
|
$("#dark").prop("checked", true);
|
|
|
|
$("#custom_json").val("");
|
2019-03-08 07:18:49 +11:00
|
|
|
$("#color-picker0-wrap").html('<div class="color-picker" id="color-picker0"></div>')
|
|
|
|
$("#color-picker1-wrap").html('<div class="color-picker" id="color-picker1"></div>')
|
|
|
|
$("#color-picker2-wrap").html('<div class="color-picker" id="color-picker2"></div>')
|
|
|
|
$("#color-picker3-wrap").html('<div class="color-picker" id="color-picker3"></div>')
|
|
|
|
$("#color-picker0_value").val("");
|
|
|
|
$("#color-picker1_value").val("");
|
|
|
|
$("#color-picker2_value").val("");
|
|
|
|
$("#color-picker3_value").val("");
|
|
|
|
pickerDefine(0,"fff");
|
|
|
|
pickerDefine(1,"fff");
|
|
|
|
pickerDefine(2,"fff");
|
|
|
|
pickerDefine(3,"fff");
|
|
|
|
$("#delTheme").addClass("disabled")
|
2019-03-08 05:19:26 +11:00
|
|
|
}else{
|
2019-03-08 07:18:49 +11:00
|
|
|
$("#delTheme").removeClass("disabled")
|
2019-03-08 05:19:26 +11:00
|
|
|
ipc.send('theme-json-request', id);
|
|
|
|
ipc.on('theme-json-response', function (event, args) {
|
2019-03-08 07:18:49 +11:00
|
|
|
console.log(args);
|
2019-03-08 05:19:26 +11:00
|
|
|
$("#custom_name").val(args.name);
|
|
|
|
$("#custom_desc").val(args.desc);
|
|
|
|
$("#"+args.base).prop("checked", true);
|
|
|
|
$("#color-picker0-wrap").html('<div class="color-picker" id="color-picker0"></div>')
|
|
|
|
pickerDefine(0,rgbToHex(args.vars.primary))
|
2019-03-08 07:18:49 +11:00
|
|
|
$("#color-picker0_value").val(args.vars.primary);
|
2019-03-08 05:19:26 +11:00
|
|
|
$("#color-picker1-wrap").html('<div class="color-picker" id="color-picker1"></div>')
|
|
|
|
pickerDefine(1,rgbToHex(args.vars.secondary))
|
2019-03-08 07:18:49 +11:00
|
|
|
$("#color-picker1_value").val(args.vars.secondary);
|
2019-03-08 05:19:26 +11:00
|
|
|
$("#color-picker2-wrap").html('<div class="color-picker" id="color-picker2"></div>')
|
2019-03-08 07:18:49 +11:00
|
|
|
$("#color-picker2_value").val(args.vars.text);
|
2019-03-08 05:19:26 +11:00
|
|
|
pickerDefine(2,rgbToHex(args.vars.text))
|
|
|
|
if(args.props){
|
|
|
|
if(args.props.TheDeskAccent){
|
|
|
|
var accent=args.props.TheDeskAccent;
|
|
|
|
}else{
|
|
|
|
var accent=args.vars.secondary;
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
var accent=args.vars.secondary;
|
|
|
|
}
|
|
|
|
$("#color-picker3-wrap").html('<div class="color-picker" id="color-picker3"></div>')
|
|
|
|
pickerDefine(3,rgbToHex(accent))
|
|
|
|
$("#custom_json").val(JSON.stringify(args));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function customImp(){
|
|
|
|
var json=$("#custom_import").val();
|
|
|
|
if(JSON5.parse(json)){
|
|
|
|
ipc.send('theme-json-create', json);
|
|
|
|
}else{
|
|
|
|
alert("Error")
|
|
|
|
}
|
|
|
|
}
|
2019-03-15 22:12:11 +11:00
|
|
|
function hardwareAcceleration(had){
|
2019-03-09 23:17:54 +11:00
|
|
|
console.log("ha");
|
|
|
|
ipc.send('ha', had);
|
|
|
|
}
|
2019-03-08 07:18:49 +11:00
|
|
|
|
2019-03-08 05:19:26 +11:00
|
|
|
ipc.on('theme-json-create-complete', function (event, args) {
|
|
|
|
$("#custom_import").val("");
|
|
|
|
ctLoad()
|
|
|
|
});
|
2019-04-15 01:45:04 +10:00
|
|
|
function customSound(key){
|
|
|
|
var electron = require("electron");
|
|
|
|
var remote=electron.remote;
|
|
|
|
var dialog=remote.dialog;
|
|
|
|
dialog.showOpenDialog(null, {
|
|
|
|
title: 'Custom sound',
|
|
|
|
properties: ['openFile'],
|
|
|
|
filters: [
|
|
|
|
{name: 'Audio', extensions: ['mp3','aac','wav','flac','m4a']},
|
|
|
|
{name: 'All', extensions: ['*']},
|
|
|
|
]
|
|
|
|
}, (fileNames) => {
|
|
|
|
localStorage.setItem("custom"+key,fileNames[0]);
|
|
|
|
$("#c1-file").text(fileNames[0])
|
|
|
|
});
|
|
|
|
}
|
2019-03-15 22:12:11 +11:00
|
|
|
window.onload = function() {
|
|
|
|
//最初に読む
|
2019-03-08 05:19:26 +11:00
|
|
|
load();
|
|
|
|
climute();
|
|
|
|
wordmute();
|
|
|
|
wordemp();
|
|
|
|
checkSpotify();
|
|
|
|
voiceSettingLoad();
|
|
|
|
oksload();
|
|
|
|
npprovider();
|
2019-03-15 22:12:11 +11:00
|
|
|
ctLoad()
|
|
|
|
};
|