2018-01-28 23:22:43 +11:00
|
|
|
//設定(setting.html)で読む
|
2019-03-15 22:12:11 +11:00
|
|
|
var envView = new Vue({
|
2019-12-14 02:48:34 +11:00
|
|
|
el: '#envView',
|
2019-05-19 17:39:30 +10:00
|
|
|
data: { config: envConstruction },
|
2019-03-15 22:12:11 +11:00
|
|
|
methods: {
|
2020-05-06 00:36:31 +10:00
|
|
|
complete: function (i, val) {
|
2021-04-01 18:54:34 +11:00
|
|
|
var ls = envView.config[i]
|
2021-04-15 06:02:33 +10:00
|
|
|
let header = ls.text.head
|
2021-04-01 18:54:34 +11:00
|
|
|
if (!ls.data) {
|
|
|
|
ls = [ls]
|
|
|
|
} else {
|
|
|
|
ls = ls.data
|
|
|
|
}
|
|
|
|
for (var j = 0; j < ls.length; j++) {
|
|
|
|
var id = ls[j].id
|
|
|
|
localStorage.setItem(ls[j].storage, val)
|
2019-03-16 16:05:04 +11:00
|
|
|
}
|
2021-04-09 17:35:40 +10:00
|
|
|
if (ls[0].id == 'ha') {
|
2019-12-14 02:48:34 +11:00
|
|
|
hardwareAcceleration(val)
|
2019-03-15 22:12:11 +11:00
|
|
|
}
|
2021-04-09 17:35:40 +10:00
|
|
|
if (ls[0].id == 'webview') {
|
|
|
|
postMessage(['webviewSetting', val], '*')
|
|
|
|
}
|
|
|
|
if (ls[0].id == 'ua_setting') {
|
2019-12-14 02:48:34 +11:00
|
|
|
useragent(val)
|
2019-10-26 03:16:33 +11:00
|
|
|
}
|
2021-04-09 17:35:40 +10:00
|
|
|
if (ls[0].id == 'frame') {
|
2020-03-19 15:17:02 +11:00
|
|
|
frameSet(val)
|
|
|
|
}
|
2021-04-15 06:02:33 +10:00
|
|
|
M.toast({ html: `Updated: ${header}`, displayLength: 3000 })
|
2019-12-14 02:48:34 +11:00
|
|
|
return true
|
2020-05-06 00:36:31 +10:00
|
|
|
},
|
|
|
|
},
|
2019-12-14 02:48:34 +11:00
|
|
|
})
|
2019-03-15 22:12:11 +11:00
|
|
|
var tlView = new Vue({
|
2019-12-14 02:48:34 +11:00
|
|
|
el: '#tlView',
|
2019-05-19 17:39:30 +10:00
|
|
|
data: { config: tlConstruction },
|
2019-03-15 22:12:11 +11:00
|
|
|
methods: {
|
2020-05-06 00:36:31 +10:00
|
|
|
complete: function (i, val) {
|
2019-12-14 02:48:34 +11:00
|
|
|
var ls = tlView.config[i]
|
2021-04-15 06:02:33 +10:00
|
|
|
let header = ls.text.head
|
2019-06-26 01:33:32 +10:00
|
|
|
if (val) {
|
2019-12-14 02:48:34 +11:00
|
|
|
localStorage.setItem(ls.storage, val)
|
2019-06-26 01:33:32 +10:00
|
|
|
} else {
|
|
|
|
if (!ls.data) {
|
2019-12-14 02:48:34 +11:00
|
|
|
ls = [ls]
|
2019-06-26 01:33:32 +10:00
|
|
|
} else {
|
2019-12-14 02:48:34 +11:00
|
|
|
ls = ls.data
|
2019-06-26 01:33:32 +10:00
|
|
|
}
|
|
|
|
for (var j = 0; j < ls.length; j++) {
|
2019-12-14 02:48:34 +11:00
|
|
|
var id = ls[j].id
|
|
|
|
var val = $('#' + id).val()
|
|
|
|
localStorage.setItem(ls[j].storage, val)
|
2019-06-26 01:33:32 +10:00
|
|
|
}
|
2019-03-16 16:05:04 +11:00
|
|
|
}
|
2021-04-15 06:02:33 +10:00
|
|
|
M.toast({ html: `Updated: ${header}`, displayLength: 3000 })
|
2019-12-14 02:48:34 +11:00
|
|
|
return true
|
2020-05-06 00:36:31 +10:00
|
|
|
},
|
|
|
|
},
|
2019-12-14 02:48:34 +11:00
|
|
|
})
|
2019-03-15 22:12:11 +11:00
|
|
|
var postView = new Vue({
|
2019-12-14 02:48:34 +11:00
|
|
|
el: '#postView',
|
|
|
|
data: {
|
|
|
|
config: postConstruction,
|
|
|
|
kirishima: localStorage.getItem('kirishima'),
|
2020-05-06 00:36:31 +10:00
|
|
|
quoters: localStorage.getItem('quoters'),
|
2019-12-14 02:48:34 +11:00
|
|
|
},
|
2019-03-15 22:12:11 +11:00
|
|
|
methods: {
|
2020-05-06 00:36:31 +10:00
|
|
|
complete: function (i, val) {
|
2019-12-14 02:48:34 +11:00
|
|
|
var ls = postView.config[i]
|
2021-04-15 06:02:33 +10:00
|
|
|
let header = ls.text.head
|
2019-06-26 01:33:32 +10:00
|
|
|
if (val) {
|
2019-12-14 02:48:34 +11:00
|
|
|
localStorage.setItem(ls.storage, val)
|
2019-06-26 01:33:32 +10:00
|
|
|
} else {
|
|
|
|
if (!ls.data) {
|
2019-12-14 02:48:34 +11:00
|
|
|
ls = [ls]
|
2019-06-26 01:33:32 +10:00
|
|
|
} else {
|
2019-12-14 02:48:34 +11:00
|
|
|
ls = ls.data
|
2019-06-26 01:33:32 +10:00
|
|
|
}
|
|
|
|
for (var j = 0; j < ls.length; j++) {
|
2019-12-14 02:48:34 +11:00
|
|
|
M.toast({ html: 'Complete', displayLength: 3000 })
|
|
|
|
var id = ls[j].id
|
|
|
|
var val = $('#' + id).val()
|
|
|
|
localStorage.setItem(ls[j].storage, val)
|
2019-06-26 01:33:32 +10:00
|
|
|
}
|
2019-03-16 16:05:04 +11:00
|
|
|
}
|
2021-04-15 06:02:33 +10:00
|
|
|
M.toast({ html: `Updated: ${header}`, displayLength: 3000 })
|
2019-12-14 02:48:34 +11:00
|
|
|
return true
|
2020-05-06 00:36:31 +10:00
|
|
|
},
|
|
|
|
},
|
2019-12-14 02:48:34 +11:00
|
|
|
})
|
2018-01-28 23:22:43 +11:00
|
|
|
//設定ボタン押した。
|
|
|
|
function settings() {
|
2019-12-14 02:48:34 +11:00
|
|
|
var fontd = $('#font').val()
|
2019-05-19 17:39:30 +10:00
|
|
|
if (fontd) {
|
2019-12-14 02:48:34 +11:00
|
|
|
if (fontd != localStorage.getItem('font')) {
|
2020-06-12 21:58:10 +10:00
|
|
|
M.toast({ html: lang.lang_setting_font.replace('{{set}}', fontd), displayLength: 3000 })
|
2018-07-05 11:26:07 +10:00
|
|
|
}
|
2019-12-14 02:48:34 +11:00
|
|
|
localStorage.setItem('font', fontd)
|
|
|
|
themes()
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2019-12-14 02:48:34 +11:00
|
|
|
if (localStorage.getItem('font')) {
|
|
|
|
localStorage.removeItem('font')
|
2020-06-12 22:06:12 +10:00
|
|
|
M.toast({ html: lang.lang_setting_font.replace('{{set}}', '"default"'), displayLength: 3000 })
|
2019-12-14 02:48:34 +11:00
|
|
|
themes()
|
2018-07-07 03:51:48 +10:00
|
|
|
}
|
2018-07-05 11:26:07 +10:00
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
//読み込み時の設定ロード
|
|
|
|
function load() {
|
2021-01-12 16:44:57 +11:00
|
|
|
var currentLang = lang.language
|
|
|
|
console.log(currentLang)
|
|
|
|
$(`#langsel-sel`).val(currentLang)
|
|
|
|
$('#langsel-sel').formSelect()
|
2019-12-14 02:48:34 +11:00
|
|
|
var max = envView.config.length
|
2019-05-19 17:39:30 +10:00
|
|
|
for (var i = 0; i < max; i++) {
|
2019-12-14 02:48:34 +11:00
|
|
|
var ls = envView.config[i].storage
|
2021-04-01 18:54:34 +11:00
|
|
|
if (ls) {
|
|
|
|
if (localStorage.getItem(ls)) {
|
|
|
|
envView.config[i].setValue = localStorage.getItem(ls)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ls = envView.config[i].data
|
|
|
|
for (var j = 0; j < ls.length; j++) {
|
|
|
|
envView.config[i].data[j].setValue = localStorage.getItem(ls[j].storage)
|
|
|
|
}
|
2019-03-19 02:24:46 +11:00
|
|
|
}
|
2019-03-15 22:12:11 +11:00
|
|
|
}
|
2019-12-14 02:48:34 +11:00
|
|
|
var max = tlView.config.length
|
2019-05-19 17:39:30 +10:00
|
|
|
for (var i = 0; i < max; i++) {
|
2019-12-14 02:48:34 +11:00
|
|
|
var ls = tlView.config[i].storage
|
2019-06-26 01:33:32 +10:00
|
|
|
if (ls) {
|
|
|
|
if (localStorage.getItem(ls)) {
|
2019-12-14 02:48:34 +11:00
|
|
|
tlView.config[i].setValue = localStorage.getItem(ls)
|
2019-06-26 01:33:32 +10:00
|
|
|
}
|
|
|
|
} else {
|
2019-12-14 02:48:34 +11:00
|
|
|
ls = tlView.config[i].data
|
2019-06-26 01:33:32 +10:00
|
|
|
for (var j = 0; j < ls.length; j++) {
|
2019-08-29 02:33:06 +10:00
|
|
|
if (localStorage.getItem(tlView.config[i].data[j].storage)) {
|
2019-12-14 02:48:34 +11:00
|
|
|
tlView.config[i].data[j].setValue = localStorage.getItem(tlView.config[i].data[j].storage)
|
2019-08-29 02:33:06 +10:00
|
|
|
}
|
2019-06-26 01:33:32 +10:00
|
|
|
}
|
2019-03-19 02:24:46 +11:00
|
|
|
}
|
2019-03-15 22:12:11 +11:00
|
|
|
}
|
2019-12-14 02:48:34 +11:00
|
|
|
var max = postView.config.length
|
2019-05-19 17:39:30 +10:00
|
|
|
for (var i = 0; i < max; i++) {
|
2019-12-14 02:48:34 +11:00
|
|
|
var ls = postView.config[i].storage
|
2019-06-26 01:33:32 +10:00
|
|
|
if (ls) {
|
|
|
|
if (localStorage.getItem(ls)) {
|
2019-12-14 02:48:34 +11:00
|
|
|
postView.config[i].setValue = localStorage.getItem(ls)
|
2019-06-26 01:33:32 +10:00
|
|
|
}
|
|
|
|
} else {
|
2019-12-14 02:48:34 +11:00
|
|
|
ls = postView.config[i].data
|
2019-06-26 01:33:32 +10:00
|
|
|
for (var j = 0; j < ls.length; j++) {
|
2019-12-14 02:48:34 +11:00
|
|
|
postView.config[i].data[j].setValue = localStorage.getItem(ls[j].storage)
|
2019-06-26 01:33:32 +10:00
|
|
|
}
|
2019-03-19 02:24:46 +11:00
|
|
|
}
|
2019-03-15 22:12:11 +11:00
|
|
|
}
|
2019-12-14 02:48:34 +11:00
|
|
|
if (localStorage.getItem('imas')) {
|
|
|
|
$('.imas').removeClass('hide')
|
2018-04-16 23:58:14 +10:00
|
|
|
}
|
2019-12-14 02:48:34 +11:00
|
|
|
if (localStorage.getItem('kirishima')) {
|
|
|
|
$('.kirishima').removeClass('hide')
|
2018-07-30 03:35:29 +10:00
|
|
|
}
|
2019-12-14 02:48:34 +11:00
|
|
|
var theme = localStorage.getItem('theme')
|
2018-01-28 23:22:43 +11:00
|
|
|
if (!theme) {
|
2019-12-14 02:48:34 +11:00
|
|
|
var theme = 'white'
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
2019-12-14 02:48:34 +11:00
|
|
|
$('#' + theme).prop('checked', true)
|
|
|
|
var font = localStorage.getItem('font')
|
2018-07-05 11:26:07 +10:00
|
|
|
if (!font) {
|
2019-12-14 02:48:34 +11:00
|
|
|
var font = ''
|
|
|
|
}
|
|
|
|
$('#font').val(font)
|
2020-09-09 00:35:30 +10:00
|
|
|
$('#c1-file').text(localStorage.getItem('custom1') != 'null' ? localStorage.getItem('custom1') : '')
|
|
|
|
$('#c2-file').text(localStorage.getItem('custom2') != 'null' ? localStorage.getItem('custom2') : '')
|
|
|
|
$('#c3-file').text(localStorage.getItem('custom3') != 'null' ? localStorage.getItem('custom3') : '')
|
|
|
|
$('#c4-file').text(localStorage.getItem('custom4') != 'null' ? localStorage.getItem('custom4') : '')
|
2019-12-14 02:48:34 +11:00
|
|
|
var cvol = localStorage.getItem('customVol')
|
2019-09-17 01:59:25 +10:00
|
|
|
if (cvol) {
|
2019-12-14 02:48:34 +11:00
|
|
|
$('#soundvol').val(cvol * 100)
|
|
|
|
$('#soundVolVal').text(cvol * 100)
|
2019-09-17 01:59:25 +10:00
|
|
|
}
|
2019-05-26 21:42:52 +10:00
|
|
|
//$("#log").val(localStorage.getItem("errors"))
|
2020-05-06 00:36:31 +10:00
|
|
|
$('#lastFmUser').val(localStorage.getItem('lastFmUser'))
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
2019-09-17 01:59:25 +10:00
|
|
|
function customVol() {
|
2019-12-14 02:48:34 +11:00
|
|
|
var cvol = $('#soundvol').val()
|
|
|
|
$('#soundVolVal').text(cvol)
|
|
|
|
localStorage.setItem('customVol', cvol / 100)
|
|
|
|
var sound = localStorage.getItem('favSound')
|
|
|
|
if (sound == 'default') {
|
|
|
|
var file = '../../source/notif.wav'
|
2019-11-04 03:10:06 +11:00
|
|
|
} else {
|
2019-12-14 02:48:34 +11:00
|
|
|
if (sound == 'c1') {
|
|
|
|
var file = localStorage.getItem('custom1')
|
|
|
|
} else if (sound == 'c2') {
|
|
|
|
var file = localStorage.getItem('custom2')
|
|
|
|
} else if (sound == 'c3') {
|
|
|
|
var file = localStorage.getItem('custom3')
|
|
|
|
} else if (sound == 'c4') {
|
|
|
|
var file = localStorage.getItem('custom4')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
request = new XMLHttpRequest()
|
|
|
|
request.open('GET', file, true)
|
|
|
|
request.responseType = 'arraybuffer'
|
|
|
|
request.onload = playSound
|
|
|
|
request.send()
|
2019-09-17 01:59:25 +10:00
|
|
|
}
|
2019-03-08 05:19:26 +11:00
|
|
|
|
2019-05-19 17:39:30 +10:00
|
|
|
function climute() {
|
2018-03-11 01:22:59 +11:00
|
|
|
//クライアントミュート
|
2019-12-14 02:48:34 +11:00
|
|
|
var cli = localStorage.getItem('client_mute')
|
|
|
|
var obj = JSON.parse(cli)
|
2019-05-19 17:39:30 +10:00
|
|
|
if (!obj) {
|
2019-12-14 02:48:34 +11:00
|
|
|
$('#mute-cli').html(lang.lang_setting_nomuting)
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
|
|
|
if (!obj[0]) {
|
2019-12-14 02:48:34 +11:00
|
|
|
$('#mute-cli').html(lang.lang_setting_nomuting)
|
|
|
|
return
|
2018-03-11 01:22:59 +11:00
|
|
|
}
|
2019-12-14 02:48:34 +11:00
|
|
|
var templete
|
2020-05-06 00:36:31 +10:00
|
|
|
Object.keys(obj).forEach(function (key) {
|
2019-12-14 02:48:34 +11:00
|
|
|
var cli = obj[key]
|
|
|
|
var list = key * 1 + 1
|
|
|
|
templete =
|
|
|
|
'<div class="acct" id="acct_' +
|
|
|
|
key +
|
|
|
|
'">' +
|
|
|
|
list +
|
|
|
|
'.' +
|
|
|
|
escapeHTML(cli) +
|
|
|
|
'<button class="btn waves-effect red disTar" onclick="cliMuteDel(' +
|
|
|
|
key +
|
|
|
|
')">' +
|
|
|
|
lang.lang_del +
|
|
|
|
'</button><br></div>'
|
|
|
|
$('#mute-cli').append(templete)
|
|
|
|
})
|
2019-05-19 17:39:30 +10:00
|
|
|
}
|
2018-03-11 01:22:59 +11:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
function cliMuteDel(key) {
|
2019-12-14 02:48:34 +11:00
|
|
|
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)
|
|
|
|
climute()
|
2018-03-11 01:22:59 +11:00
|
|
|
}
|
|
|
|
|
2019-05-19 17:39:30 +10:00
|
|
|
function wordmute() {
|
2019-12-14 02:48:34 +11:00
|
|
|
var word = localStorage.getItem('word_mute')
|
|
|
|
var obj = JSON.parse(word)
|
2019-11-04 03:10:06 +11:00
|
|
|
if (!obj) {
|
2019-12-14 02:48:34 +11:00
|
|
|
obj = []
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-12-14 02:48:34 +11:00
|
|
|
$('#wordmute').chips({
|
2020-05-06 00:36:31 +10:00
|
|
|
data: obj,
|
2019-12-14 02:48:34 +11:00
|
|
|
})
|
2018-03-11 01:22:59 +11:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
function wordmuteSave() {
|
2019-12-14 02:48:34 +11:00
|
|
|
var word = M.Chips.getInstance($('#wordmute')).chipsData
|
|
|
|
var json = JSON.stringify(word)
|
|
|
|
localStorage.setItem('word_mute', json)
|
2018-03-11 01:22:59 +11:00
|
|
|
}
|
|
|
|
|
2019-05-19 17:39:30 +10:00
|
|
|
function wordemp() {
|
2019-12-14 02:48:34 +11:00
|
|
|
var word = localStorage.getItem('word_emp')
|
|
|
|
var obj = JSON.parse(word)
|
2019-11-04 03:10:06 +11:00
|
|
|
if (!obj) {
|
2019-12-14 02:48:34 +11:00
|
|
|
obj = []
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-12-14 02:48:34 +11:00
|
|
|
$('#wordemp').chips({
|
2020-05-06 00:36:31 +10:00
|
|
|
data: obj,
|
2019-12-14 02:48:34 +11:00
|
|
|
})
|
2018-03-11 01:22:59 +11:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
function wordempSave() {
|
2019-12-14 02:48:34 +11:00
|
|
|
var word = M.Chips.getInstance($('#wordemp')).chipsData
|
|
|
|
var json = JSON.stringify(word)
|
|
|
|
localStorage.setItem('word_emp', json)
|
2018-05-26 05:00:04 +10:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
function notftest() {
|
2019-12-14 02:48:34 +11:00
|
|
|
var os = localStorage.getItem('platform')
|
2019-05-19 17:39:30 +10:00
|
|
|
var options = {
|
2019-12-14 02:48:34 +11:00
|
|
|
body: lang.lang_setting_notftest + '(' + lang.lang_setting_notftestprof + ')',
|
2020-05-06 00:36:31 +10:00
|
|
|
icon: localStorage.getItem('prof_0'),
|
2019-12-14 02:48:34 +11:00
|
|
|
}
|
|
|
|
var n = new Notification('TheDesk' + lang.lang_setting_notftest, options)
|
2018-06-12 01:44:28 +10:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
function oks(no) {
|
2019-12-14 02:48:34 +11:00
|
|
|
var txt = $('#oks-' + no).val()
|
|
|
|
localStorage.setItem('oks-' + no, txt)
|
|
|
|
M.toast({ html: lang.lang_setting_ksref, displayLength: 3000 })
|
2018-06-12 01:44:28 +10:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
function oksload() {
|
2019-12-14 02:48:34 +11:00
|
|
|
if (localStorage.getItem('oks-1')) {
|
|
|
|
$('#oks-1').val(localStorage.getItem('oks-1'))
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-12-14 02:48:34 +11:00
|
|
|
if (localStorage.getItem('oks-2')) {
|
|
|
|
$('#oks-2').val(localStorage.getItem('oks-2'))
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-12-14 02:48:34 +11:00
|
|
|
if (localStorage.getItem('oks-3')) {
|
|
|
|
$('#oks-3').val(localStorage.getItem('oks-3'))
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2018-08-05 02:26:34 +10:00
|
|
|
}
|
2021-01-12 16:44:57 +11:00
|
|
|
function changeLang() {
|
|
|
|
const lang = $('#langsel-sel').val()
|
|
|
|
console.log(lang)
|
2021-04-09 17:35:40 +10:00
|
|
|
if (lang) postMessage(['lang', lang], '*')
|
2018-09-12 02:49:41 +10:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
function exportSettings() {
|
2019-12-14 02:48:34 +11:00
|
|
|
var exp = exportSettingsCore()
|
2020-05-06 00:36:31 +10:00
|
|
|
$('#imp-exp').val(JSON5.stringify(exp))
|
2019-06-22 02:06:32 +10:00
|
|
|
Swal.fire({
|
2021-04-15 06:02:33 +10:00
|
|
|
title: 'Warning',
|
|
|
|
text: lang.lang_setting_exportwarn,
|
2019-12-14 02:48:34 +11:00
|
|
|
type: 'warning',
|
2019-06-22 02:06:32 +10:00
|
|
|
showCancelButton: true,
|
|
|
|
confirmButtonText: lang.lang_yesno,
|
2020-05-06 00:36:31 +10:00
|
|
|
cancelButtonText: lang.lang_no,
|
|
|
|
}).then((result) => {
|
2019-06-22 02:06:32 +10:00
|
|
|
if (result.value) {
|
2019-12-14 02:48:34 +11:00
|
|
|
postMessage(['exportSettings', ''], '*')
|
2019-06-22 02:06:32 +10:00
|
|
|
}
|
2019-12-14 02:48:34 +11:00
|
|
|
})
|
2019-06-15 03:01:38 +10:00
|
|
|
}
|
|
|
|
function exportSettingsCore() {
|
2019-12-14 02:48:34 +11:00
|
|
|
var exp = {}
|
2019-06-15 03:01:38 +10:00
|
|
|
//Accounts
|
2019-12-14 02:48:34 +11:00
|
|
|
var multi = localStorage.getItem('multi')
|
|
|
|
var acct = JSON.parse(multi)
|
|
|
|
exp.accts = acct
|
2019-06-15 03:01:38 +10:00
|
|
|
//Columns
|
2019-12-14 02:48:34 +11:00
|
|
|
var multi = localStorage.getItem('column')
|
|
|
|
var column = JSON.parse(multi)
|
|
|
|
exp.columns = column
|
2019-06-15 03:01:38 +10:00
|
|
|
//Themes
|
2019-12-14 02:48:34 +11:00
|
|
|
var config = {}
|
|
|
|
config.theme = localStorage.getItem('theme')
|
2019-06-15 03:01:38 +10:00
|
|
|
//Other configs
|
2019-12-14 02:48:34 +11:00
|
|
|
var max = envView.config.length
|
2019-06-15 03:01:38 +10:00
|
|
|
for (var i = 0; i < max; i++) {
|
2019-12-14 02:48:34 +11:00
|
|
|
var ls = envView.config[i].storage
|
|
|
|
config[ls] = localStorage.getItem(ls)
|
2019-06-15 03:01:38 +10:00
|
|
|
}
|
2019-12-14 02:48:34 +11:00
|
|
|
var max = tlView.config.length
|
2019-06-15 03:01:38 +10:00
|
|
|
for (var i = 0; i < max; i++) {
|
2019-12-14 02:48:34 +11:00
|
|
|
var ls = tlView.config[i].storage
|
|
|
|
config[ls] = localStorage.getItem(ls)
|
2019-06-15 03:01:38 +10:00
|
|
|
}
|
2019-12-14 02:48:34 +11:00
|
|
|
var max = postView.config.length
|
2019-06-15 03:01:38 +10:00
|
|
|
for (var i = 0; i < max; i++) {
|
2019-12-14 02:48:34 +11:00
|
|
|
var ls = postView.config[i].storage
|
|
|
|
config[ls] = localStorage.getItem(ls)
|
2019-06-15 03:01:38 +10:00
|
|
|
}
|
|
|
|
//Font
|
2019-12-14 02:48:34 +11:00
|
|
|
config.font = localStorage.getItem('font')
|
|
|
|
exp.config = config
|
2019-06-15 03:01:38 +10:00
|
|
|
//keysc
|
2020-05-06 00:36:31 +10:00
|
|
|
exp.ksc = [localStorage.getItem('oks-1'), localStorage.getItem('oks-2'), localStorage.getItem('oks-3')]
|
2019-06-15 03:01:38 +10:00
|
|
|
//climu
|
2019-12-14 02:48:34 +11:00
|
|
|
var cli = localStorage.getItem('client_mute')
|
|
|
|
var climu = JSON.parse(cli)
|
|
|
|
exp.clientMute = climu
|
2019-06-15 03:01:38 +10:00
|
|
|
//wordmu
|
2019-12-14 02:48:34 +11:00
|
|
|
var wdm = localStorage.getItem('word_mute')
|
|
|
|
var wordmu = JSON.parse(wdm)
|
|
|
|
exp.wordMute = wordmu
|
2019-06-15 03:01:38 +10:00
|
|
|
//spotify
|
2019-12-14 02:48:34 +11:00
|
|
|
exp.spotifyArtwork = localStorage.getItem('artwork')
|
|
|
|
var content = localStorage.getItem('np-temp')
|
|
|
|
if (content || content == '' || content == 'null') {
|
|
|
|
exp.spotifyTemplete = content
|
2019-06-15 03:01:38 +10:00
|
|
|
} else {
|
2019-12-14 02:48:34 +11:00
|
|
|
exp.spotifyTemplete = null
|
2019-06-15 03:01:38 +10:00
|
|
|
}
|
|
|
|
//tags
|
2019-12-14 02:48:34 +11:00
|
|
|
var tagarr = localStorage.getItem('tag')
|
|
|
|
var favtag = JSON.parse(tagarr)
|
2021-01-09 23:58:34 +11:00
|
|
|
//plugins
|
|
|
|
var plugins = localStorage.getItem('plugins')
|
|
|
|
var plugin = JSON.parse(plugins)
|
|
|
|
exp.plugins = plugin
|
|
|
|
|
|
|
|
exp.revisons = 2.2
|
2019-12-14 02:48:34 +11:00
|
|
|
exp.meta = {}
|
|
|
|
exp.meta.date = new Date()
|
|
|
|
exp.meta.thedesk = localStorage.getItem('ver')
|
|
|
|
exp.meta.platform = localStorage.getItem('platform')
|
|
|
|
return exp
|
2018-08-05 02:26:34 +10:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
function importSettings() {
|
2019-06-22 02:06:32 +10:00
|
|
|
Swal.fire({
|
2021-04-15 06:02:33 +10:00
|
|
|
title: 'Warning',
|
|
|
|
text: lang.lang_setting_importwarn,
|
2019-12-14 02:48:34 +11:00
|
|
|
type: 'warning',
|
2019-06-22 02:06:32 +10:00
|
|
|
showCancelButton: true,
|
|
|
|
confirmButtonText: lang.lang_yesno,
|
2020-05-06 00:36:31 +10:00
|
|
|
cancelButtonText: lang.lang_no,
|
|
|
|
}).then((result) => {
|
2019-06-22 02:06:32 +10:00
|
|
|
if (result.value) {
|
2021-04-15 06:45:14 +10:00
|
|
|
if ($('#imp-exp').val()) {
|
|
|
|
importSettingsCore(JSON5.parse($('#imp-exp').val()))
|
|
|
|
return false
|
|
|
|
}
|
2019-12-14 02:48:34 +11:00
|
|
|
postMessage(['importSettings', ''], '*')
|
2019-06-22 02:06:32 +10:00
|
|
|
}
|
2019-12-14 02:48:34 +11:00
|
|
|
})
|
2019-06-15 03:01:38 +10:00
|
|
|
}
|
2019-08-29 02:20:47 +10:00
|
|
|
function importSettingsCore(obj) {
|
2019-06-15 03:01:38 +10:00
|
|
|
if (obj) {
|
2019-12-14 02:48:34 +11:00
|
|
|
localStorage.clear()
|
|
|
|
localStorage.setItem('multi', JSON.stringify(obj.accts))
|
2019-06-15 03:01:38 +10:00
|
|
|
for (var key = 0; key < obj.accts.length; key++) {
|
2019-12-14 02:48:34 +11:00
|
|
|
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)
|
2021-01-19 06:06:13 +11:00
|
|
|
localStorage.setItem('acct_' + key + '_rt', acct.rt ? acct.rt : null)
|
2019-12-14 02:48:34 +11:00
|
|
|
}
|
|
|
|
localStorage.setItem('column', JSON.stringify(obj.columns))
|
2019-06-15 03:01:38 +10:00
|
|
|
if (obj.config) {
|
2019-08-29 02:20:47 +10:00
|
|
|
//Version 2~
|
2019-12-14 02:48:34 +11:00
|
|
|
var max = envView.config.length
|
2019-06-15 03:01:38 +10:00
|
|
|
for (var i = 0; i < max; i++) {
|
2019-12-14 02:48:34 +11:00
|
|
|
var ls = envView.config[i].storage
|
2019-06-15 03:01:38 +10:00
|
|
|
if (obj.config[ls]) {
|
2019-12-14 02:48:34 +11:00
|
|
|
localStorage.setItem(ls, obj.config[ls])
|
2018-08-05 02:26:34 +10:00
|
|
|
}
|
2019-06-15 03:01:38 +10:00
|
|
|
}
|
2019-12-14 02:48:34 +11:00
|
|
|
var max = tlView.config.length
|
2019-06-15 03:01:38 +10:00
|
|
|
for (var i = 0; i < max; i++) {
|
2019-12-14 02:48:34 +11:00
|
|
|
var ls = tlView.config[i].storage
|
2019-06-15 03:01:38 +10:00
|
|
|
if (obj.config[ls]) {
|
2019-12-14 02:48:34 +11:00
|
|
|
localStorage.setItem(ls, obj.config[ls])
|
2018-08-05 02:26:34 +10:00
|
|
|
}
|
2019-06-15 03:01:38 +10:00
|
|
|
}
|
2019-12-14 02:48:34 +11:00
|
|
|
var max = postView.config.length
|
2019-06-15 03:01:38 +10:00
|
|
|
for (var i = 0; i < max; i++) {
|
2019-12-14 02:48:34 +11:00
|
|
|
var ls = postView.config[i].storage
|
2019-06-15 03:01:38 +10:00
|
|
|
if (obj.config[ls]) {
|
2019-12-14 02:48:34 +11:00
|
|
|
localStorage.setItem(ls, obj.config[ls])
|
2018-08-05 02:26:34 +10:00
|
|
|
}
|
|
|
|
}
|
2019-06-15 03:01:38 +10:00
|
|
|
} else {
|
|
|
|
//Version 1
|
2019-12-14 02:48:34 +11:00
|
|
|
localStorage.setItem('theme', obj.theme)
|
2019-06-15 03:01:38 +10:00
|
|
|
if (obj.width) {
|
2019-12-14 02:48:34 +11:00
|
|
|
localStorage.setItem('width', obj.width)
|
2019-06-15 03:01:38 +10:00
|
|
|
}
|
|
|
|
if (obj.font) {
|
2019-12-14 02:48:34 +11:00
|
|
|
localStorage.setItem('font', obj.font)
|
2019-06-15 03:01:38 +10:00
|
|
|
}
|
|
|
|
if (obj.size) {
|
2019-12-14 02:48:34 +11:00
|
|
|
localStorage.setItem('size', obj.size)
|
2019-06-15 03:01:38 +10:00
|
|
|
}
|
2019-12-14 02:48:34 +11:00
|
|
|
themes(obj.theme)
|
2019-06-15 03:01:38 +10:00
|
|
|
if (obj.imgheight) {
|
2019-12-14 02:48:34 +11:00
|
|
|
localStorage.setItem('img-height', obj.imgheight)
|
2019-06-15 03:01:38 +10:00
|
|
|
}
|
2019-12-14 02:48:34 +11:00
|
|
|
localStorage.setItem('mainuse', obj.mainuse)
|
2019-06-15 03:01:38 +10:00
|
|
|
if (obj.cw) {
|
2019-12-14 02:48:34 +11:00
|
|
|
localStorage.setItem('cwtext', obj.cw)
|
2019-06-15 03:01:38 +10:00
|
|
|
}
|
2019-12-14 02:48:34 +11:00
|
|
|
localStorage.setItem('vis', obj.vis)
|
2019-06-15 03:01:38 +10:00
|
|
|
//End
|
|
|
|
}
|
|
|
|
if (obj.ksc[0]) {
|
2019-12-14 02:48:34 +11:00
|
|
|
localStorage.setItem('oks-1', obj.ksc[0])
|
2019-06-15 03:01:38 +10:00
|
|
|
}
|
|
|
|
if (obj.ksc[1]) {
|
2019-12-14 02:48:34 +11:00
|
|
|
localStorage.setItem('oks-2', obj.ksc[1])
|
2019-06-15 03:01:38 +10:00
|
|
|
}
|
|
|
|
if (obj.ksc[2]) {
|
2019-12-14 02:48:34 +11:00
|
|
|
localStorage.setItem('oks-3', obj.ksc[2])
|
2019-06-15 03:01:38 +10:00
|
|
|
}
|
|
|
|
if (obj.clientMute) {
|
2019-12-14 02:48:34 +11:00
|
|
|
localStorage.setItem('client_mute', JSON.stringify(obj.clientMute))
|
2019-06-15 03:01:38 +10:00
|
|
|
}
|
|
|
|
if (obj.wordMute) {
|
2019-12-14 02:48:34 +11:00
|
|
|
localStorage.setItem('word_mute', JSON.stringify(obj.wordMute))
|
2019-06-15 03:01:38 +10:00
|
|
|
}
|
|
|
|
if (obj.favoriteTags) {
|
2019-12-14 02:48:34 +11:00
|
|
|
localStorage.setItem('tag', JSON.stringify(obj.favoriteTags))
|
2019-06-15 03:01:38 +10:00
|
|
|
}
|
|
|
|
|
2019-12-14 02:48:34 +11:00
|
|
|
localStorage.setItem('np-temp', obj.spotifyTemplete)
|
2019-06-15 03:01:38 +10:00
|
|
|
for (var i = 0; i < obj.columns.length; i++) {
|
2019-12-14 02:48:34 +11:00
|
|
|
localStorage.setItem('card_' + i, 'true')
|
|
|
|
localStorage.removeItem('catch_' + i)
|
2019-06-15 03:01:38 +10:00
|
|
|
}
|
2019-12-14 02:48:34 +11:00
|
|
|
location.href = 'index.html'
|
2019-06-15 03:01:38 +10:00
|
|
|
} else {
|
2019-06-22 02:06:32 +10:00
|
|
|
Swal.fire({
|
2019-12-14 02:48:34 +11:00
|
|
|
type: 'error',
|
2020-05-06 00:36:31 +10:00
|
|
|
title: 'Error',
|
2019-12-14 02:48:34 +11:00
|
|
|
})
|
2019-06-15 03:01:38 +10:00
|
|
|
}
|
2018-09-06 02:47:27 +10:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
function savefolder() {
|
2019-12-14 02:48:34 +11:00
|
|
|
postMessage(['sendSinmpleIpc', 'savefolder'], '*')
|
2018-12-09 05:46:01 +11:00
|
|
|
}
|
|
|
|
|
2019-05-19 17:39:30 +10:00
|
|
|
function font() {
|
2019-12-14 02:48:34 +11:00
|
|
|
postMessage(['sendSinmpleIpc', 'fonts'], '*')
|
2019-06-15 03:01:38 +10:00
|
|
|
}
|
|
|
|
function fontList(arg) {
|
2019-12-14 02:48:34 +11:00
|
|
|
$('#fonts').removeClass('hide')
|
2019-06-15 03:01:38 +10:00
|
|
|
for (var i = 0; i < arg.length; i++) {
|
2019-12-14 02:48:34 +11:00
|
|
|
var font = arg[i]
|
2020-05-06 00:36:31 +10:00
|
|
|
$('#fonts').append('<div class="font pointer" style="font-family:' + font + '" onclick="insertFont(\'' + font + '\')">' + font + '</div>')
|
2019-06-15 03:01:38 +10:00
|
|
|
}
|
2018-12-09 05:46:01 +11:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
function insertFont(name) {
|
2019-12-14 02:48:34 +11:00
|
|
|
$('#font').val(name)
|
2019-03-08 05:19:26 +11:00
|
|
|
}
|
2020-09-09 00:35:30 +10:00
|
|
|
function copyColor(from, to) {
|
|
|
|
let props = [
|
|
|
|
'background', 'subcolor', 'text', 'accent',
|
|
|
|
'modal', 'modalFooter', 'third', 'forth',
|
|
|
|
'bottom', 'emphasized', 'postbox', 'active',
|
|
|
|
'selected', 'selectedWithShared'
|
|
|
|
]
|
|
|
|
let i = 0
|
|
|
|
let color
|
|
|
|
for (tag of props) {
|
2020-11-28 09:07:16 +11:00
|
|
|
if (tag == from) {
|
2020-09-09 00:35:30 +10:00
|
|
|
let used = $(`#use-color_${i}`).prop('checked')
|
2020-11-28 09:07:16 +11:00
|
|
|
if (!used) {
|
2020-09-09 00:35:30 +10:00
|
|
|
Swal.fire({
|
|
|
|
type: 'error',
|
|
|
|
title: 'Not checked',
|
|
|
|
})
|
|
|
|
break
|
|
|
|
}
|
|
|
|
color = $(`#color-picker${i}_value`).val()
|
|
|
|
break
|
|
|
|
}
|
|
|
|
i++
|
|
|
|
}
|
2020-11-28 09:07:16 +11:00
|
|
|
if (!color) return false
|
2020-09-09 00:35:30 +10:00
|
|
|
for (tag of props) {
|
2020-11-28 09:07:16 +11:00
|
|
|
if (tag == to) {
|
2020-09-09 00:35:30 +10:00
|
|
|
$(`#color-picker${i}_value`).val(color)
|
|
|
|
$(`#use-color_${i}`).prop('checked', true)
|
|
|
|
break
|
|
|
|
}
|
|
|
|
i++
|
|
|
|
}
|
2019-03-08 05:19:26 +11:00
|
|
|
}
|
2021-04-15 06:45:14 +10:00
|
|
|
function customComp(preview) {
|
2019-12-14 02:48:34 +11:00
|
|
|
var nameC = $('#custom_name').val()
|
2021-04-15 06:45:14 +10:00
|
|
|
if (!nameC && !preview) {
|
2019-12-14 02:48:34 +11:00
|
|
|
return false
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-12-14 02:48:34 +11:00
|
|
|
var descC = $('#custom_desc').val()
|
2020-09-09 00:35:30 +10:00
|
|
|
var bgC = $('#color-picker0_value').val()
|
|
|
|
var subcolorC = $('#color-picker2_value').val()
|
|
|
|
var textC = $('#color-picker1_value').val()
|
|
|
|
var accentC = $('#color-picker3_value').val()
|
2019-12-14 02:48:34 +11:00
|
|
|
var multi = localStorage.getItem('multi')
|
2020-09-09 00:35:30 +10:00
|
|
|
let advanced = [
|
|
|
|
'modal', 'modalFooter', 'third', 'forth',
|
|
|
|
'bottom', 'emphasized', 'postbox', 'active',
|
|
|
|
'selected', 'selectedWithShared'
|
|
|
|
]
|
|
|
|
var advanceTheme = {}
|
|
|
|
let i = 4
|
|
|
|
for (tag of advanced) {
|
|
|
|
let used = $(`#use-color_${i}`).prop('checked')
|
|
|
|
if (used) {
|
|
|
|
advanceTheme[tag] = $(`#color-picker${i}_value`).val()
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2020-09-09 00:35:30 +10:00
|
|
|
i++
|
2019-10-09 03:14:27 +11:00
|
|
|
}
|
2019-11-04 03:10:06 +11:00
|
|
|
|
2019-12-14 02:48:34 +11:00
|
|
|
var my = JSON.parse(multi)[0].name
|
|
|
|
var id = $('#custom-edit-sel').val()
|
2020-09-09 00:35:30 +10:00
|
|
|
const defaults = [
|
2020-11-28 09:07:16 +11:00
|
|
|
'black', 'blue', 'brown', 'green', 'indigo', 'polar', 'snow', 'white'
|
2020-09-09 00:35:30 +10:00
|
|
|
]
|
|
|
|
if (id == 'add_new' || defaults.includes(id)) {
|
2019-12-14 02:48:34 +11:00
|
|
|
id = makeCID()
|
2019-03-08 07:18:49 +11:00
|
|
|
}
|
2021-04-15 06:45:14 +10:00
|
|
|
if (!preview) localStorage.setItem('customtheme-id', id)
|
2019-05-19 17:39:30 +10:00
|
|
|
var json = {
|
2019-11-04 03:10:06 +11:00
|
|
|
name: nameC,
|
|
|
|
author: my,
|
|
|
|
desc: descC,
|
2019-12-14 02:48:34 +11:00
|
|
|
base: $('[name=direction]:checked').val(),
|
2020-09-09 00:35:30 +10:00
|
|
|
primary: {
|
|
|
|
background: bgC,
|
|
|
|
subcolor: subcolorC,
|
2020-05-06 00:36:31 +10:00
|
|
|
text: textC,
|
2020-09-09 00:35:30 +10:00
|
|
|
accent: accentC
|
2019-03-08 05:19:26 +11:00
|
|
|
},
|
2020-09-09 00:35:30 +10:00
|
|
|
advanced: advanceTheme,
|
2020-05-06 00:36:31 +10:00
|
|
|
id: id,
|
2020-09-09 00:35:30 +10:00
|
|
|
version: '2'
|
2019-12-14 02:48:34 +11:00
|
|
|
}
|
|
|
|
$('#custom_json').val(JSON.stringify(json))
|
2021-04-15 06:45:14 +10:00
|
|
|
if (preview) {
|
|
|
|
postMessage(['themeCSSPreview', json], '*')
|
|
|
|
} else {
|
|
|
|
$('#custom-edit-sel').val(id)
|
|
|
|
$('select').formSelect()
|
2020-09-09 00:35:30 +10:00
|
|
|
Swal.fire({
|
2021-04-15 06:45:14 +10:00
|
|
|
type: 'success',
|
|
|
|
title: 'Saved',
|
2020-09-09 00:35:30 +10:00
|
|
|
})
|
2021-04-15 06:45:14 +10:00
|
|
|
postMessage(['themeJsonCreate', JSON.stringify(json)], '*')
|
|
|
|
}
|
|
|
|
|
2019-03-08 07:18:49 +11:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
function deleteIt() {
|
2019-12-14 02:48:34 +11:00
|
|
|
var id = $('#custom-sel-sel').val()
|
|
|
|
$('#custom_name').val('')
|
|
|
|
$('#custom_desc').val('')
|
|
|
|
$('#dark').prop('checked', true)
|
|
|
|
$('#custom_json').val('')
|
2020-09-09 00:35:30 +10:00
|
|
|
for (var i = 0; i <= 13; i++) {
|
|
|
|
if (i >= 4) $(`#use-color_${i}`).prop('checked', false)
|
2019-12-14 02:48:34 +11:00
|
|
|
$('#color-picker' + i + '_value').val('')
|
2019-10-09 03:14:27 +11:00
|
|
|
}
|
2020-09-09 00:35:30 +10:00
|
|
|
postMessage(['themeJsonDelete', id + '.thedesktheme'], '*')
|
2019-03-08 05:19:26 +11:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
function ctLoad() {
|
2019-12-14 02:48:34 +11:00
|
|
|
postMessage(['sendSinmpleIpc', 'theme-json-list'], '*')
|
2019-06-15 03:01:38 +10:00
|
|
|
}
|
|
|
|
function ctLoadCore(args) {
|
2020-09-09 00:35:30 +10:00
|
|
|
var template = ''
|
|
|
|
var editTemplate = ''
|
2020-05-06 00:36:31 +10:00
|
|
|
Object.keys(args).forEach(function (key) {
|
2019-12-14 02:48:34 +11:00
|
|
|
var theme = args[key]
|
|
|
|
var themeid = theme.id
|
2020-09-09 00:35:30 +10:00
|
|
|
template = template + `<option value="${themeid}">${theme.name}${theme.compatible ? `(${lang.lang_setting_compat})` : ''}</option>`
|
|
|
|
if (!theme.compatible) editTemplate = editTemplate + `<option value="${themeid}">${theme.name}</option>`
|
2019-12-14 02:48:34 +11:00
|
|
|
})
|
2020-09-09 00:35:30 +10:00
|
|
|
$('#custom-sel-sel').html(template)
|
|
|
|
editTemplate = '<option value="add_new">' + $('#edit-selector').attr('data-add') + '</option>' + editTemplate
|
|
|
|
$('#custom-edit-sel').html(editTemplate)
|
|
|
|
$('#custom-sel-sel').val(localStorage.getItem('customtheme-id'))
|
2019-12-14 02:48:34 +11:00
|
|
|
$('select').formSelect()
|
2019-03-08 05:19:26 +11:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
function customSel() {
|
2019-12-14 02:48:34 +11:00
|
|
|
var id = $('#custom-sel-sel').val()
|
|
|
|
localStorage.setItem('customtheme-id', id)
|
2020-09-09 00:35:30 +10:00
|
|
|
themes(id)
|
2019-03-08 05:19:26 +11:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
function custom() {
|
2019-12-14 02:48:34 +11:00
|
|
|
var id = $('#custom-edit-sel').val()
|
|
|
|
if (id == 'add_new') {
|
|
|
|
$('#custom_name').val('')
|
|
|
|
$('#custom_desc').val('')
|
|
|
|
$('#dark').prop('checked', true)
|
|
|
|
$('#custom_json').val('')
|
2020-09-09 00:35:30 +10:00
|
|
|
for (var i = 0; i <= 13; i++) {
|
|
|
|
if (i >= 4) $(`#use-color_${i}`).prop('checked', false)
|
2019-12-14 02:48:34 +11:00
|
|
|
$('#color-picker' + i + '_value').val('')
|
2019-10-09 03:14:27 +11:00
|
|
|
}
|
2019-12-14 02:48:34 +11:00
|
|
|
$('#delTheme').addClass('disabled')
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2019-12-14 02:48:34 +11:00
|
|
|
$('#delTheme').removeClass('disabled')
|
2020-09-09 00:35:30 +10:00
|
|
|
postMessage(['themeJsonRequest', id + '.thedesktheme'], '*')
|
2019-03-08 05:19:26 +11:00
|
|
|
}
|
|
|
|
}
|
2019-10-10 01:00:46 +11:00
|
|
|
function customConnect(raw) {
|
2019-12-14 02:48:34 +11:00
|
|
|
var args = raw[0]
|
2020-09-09 00:35:30 +10:00
|
|
|
$('#custom_name').val(`${args.name} ${args.default ? 'Customed' : ''}`)
|
|
|
|
$('#custom_desc').val(args.default ? 'TheDesk default theme with some changes by user' : args.desc)
|
2019-12-14 02:48:34 +11:00
|
|
|
$('#' + args.base).prop('checked', true)
|
2020-09-09 00:35:30 +10:00
|
|
|
//Background
|
|
|
|
$('#color-picker0_value').val(args.primary.background)
|
2019-10-09 03:14:27 +11:00
|
|
|
//Text
|
2020-09-09 00:35:30 +10:00
|
|
|
$('#color-picker1_value').val(args.primary.text)
|
|
|
|
//Subcolor
|
|
|
|
$('#color-picker2_value').val(args.primary.subcolor)
|
|
|
|
//Accent
|
|
|
|
$('#color-picker3_value').val(args.primary.accent)
|
|
|
|
let advanced = [
|
|
|
|
'modal', 'modalFooter', 'third', 'forth',
|
|
|
|
'bottom', 'emphasized', 'postbox', 'active',
|
|
|
|
'selected', 'selectedWithShared'
|
|
|
|
]
|
|
|
|
let i = 4
|
|
|
|
for (tag of advanced) {
|
|
|
|
if (args.advanced[tag]) {
|
|
|
|
$(`#color-picker${i}_value`).val(args.advanced[tag])
|
|
|
|
|
2019-06-15 03:01:38 +10:00
|
|
|
}
|
2020-09-09 00:35:30 +10:00
|
|
|
$(`#use-color_${i}`).prop('checked', true)
|
|
|
|
i++
|
|
|
|
}
|
|
|
|
$('#custom_json').val(raw[1])
|
2020-11-28 09:07:16 +11:00
|
|
|
if (args.default) {
|
2020-09-09 00:35:30 +10:00
|
|
|
$('#delTheme').addClass('disabled')
|
2019-06-15 03:01:38 +10:00
|
|
|
}
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
function customImp() {
|
2019-12-14 02:48:34 +11:00
|
|
|
var json = $('#custom_import').val()
|
2019-05-19 17:39:30 +10:00
|
|
|
if (JSON5.parse(json)) {
|
2019-12-14 02:48:34 +11:00
|
|
|
postMessage(['themeJsonCreate', json], '*')
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2019-06-22 02:06:32 +10:00
|
|
|
Swal.fire({
|
2019-12-14 02:48:34 +11:00
|
|
|
type: 'error',
|
2020-05-06 00:36:31 +10:00
|
|
|
title: 'Error',
|
2019-12-14 02:48:34 +11:00
|
|
|
})
|
2019-03-08 05:19:26 +11:00
|
|
|
}
|
|
|
|
}
|
2019-11-04 03:10:06 +11:00
|
|
|
function advanced() {
|
2019-12-14 02:48:34 +11:00
|
|
|
$('.advanced').toggleClass('hide')
|
|
|
|
$('#pickers').toggleClass('advanceTheme')
|
2019-10-09 03:14:27 +11:00
|
|
|
}
|
2019-06-15 03:01:38 +10:00
|
|
|
function clearCustomImport() {
|
2019-12-14 02:48:34 +11:00
|
|
|
$('#custom_import').val('')
|
2019-06-15 03:01:38 +10:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
function hardwareAcceleration(had) {
|
2019-12-14 02:48:34 +11:00
|
|
|
postMessage(['ha', had], '*')
|
2019-03-09 23:17:54 +11:00
|
|
|
}
|
2019-11-04 03:10:06 +11:00
|
|
|
function useragent(val) {
|
2019-12-14 02:48:34 +11:00
|
|
|
postMessage(['ua', val], '*')
|
2019-10-26 03:16:33 +11:00
|
|
|
}
|
2020-03-19 15:17:02 +11:00
|
|
|
function frameSet(val) {
|
|
|
|
postMessage(['frameSet', val], '*')
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
function customSound(key) {
|
2019-12-14 02:48:34 +11:00
|
|
|
postMessage(['customSound', key], '*')
|
2019-06-15 03:01:38 +10:00
|
|
|
}
|
|
|
|
function customSoundSave(key, file) {
|
2019-12-14 02:48:34 +11:00
|
|
|
localStorage.setItem('custom' + key, file)
|
2020-09-08 19:49:55 +10:00
|
|
|
$(`#c${key}-file`).text(file)
|
2019-04-15 01:45:04 +10:00
|
|
|
}
|
2020-11-28 09:07:16 +11:00
|
|
|
function pluginLoad() {
|
|
|
|
$('#plugin-edit-sel').val('add_new')
|
|
|
|
$(".plugin_delete").addClass('disabled')
|
|
|
|
var template = ''
|
|
|
|
var pgns = localStorage.getItem('plugins')
|
|
|
|
var args = JSON.parse(pgns ? pgns : '[]')
|
|
|
|
Object.keys(args).forEach(function (key) {
|
|
|
|
var theme = args[key]
|
|
|
|
var themeid = theme.id
|
2021-04-02 12:56:01 +11:00
|
|
|
template = template + `<option value="${themeid}">${getMeta(theme.content).data.name}</option>`
|
2020-11-28 09:07:16 +11:00
|
|
|
})
|
|
|
|
template = '<option value="add_new">' + $('#plugin-selector').attr('data-add') + '</option>' + template
|
|
|
|
$('#plugin-edit-sel').html(template)
|
|
|
|
$('select').formSelect()
|
|
|
|
}
|
|
|
|
function pluginEdit() {
|
|
|
|
var id = $('#plugin-edit-sel').val()
|
|
|
|
$('#plugin').attr('data-id', id)
|
|
|
|
if (id == 'add_new') {
|
2021-04-02 12:56:01 +11:00
|
|
|
editor.setValue('', -1)
|
2020-11-28 09:07:16 +11:00
|
|
|
$(".plugin_delete").addClass('disabled')
|
|
|
|
} else {
|
|
|
|
$(".plugin_delete").removeClass('disabled')
|
|
|
|
var pgns = localStorage.getItem('plugins')
|
|
|
|
var args = JSON.parse(pgns ? pgns : '[]')
|
|
|
|
Object.keys(args).forEach(function (key) {
|
|
|
|
var plugin = args[key]
|
|
|
|
var targetId = plugin.id
|
2021-04-02 12:56:01 +11:00
|
|
|
if (targetId == id) editor.setValue(plugin.content, -1)
|
2020-11-28 09:07:16 +11:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function completePlugin(comp) {
|
|
|
|
var pgns = localStorage.getItem('plugins')
|
|
|
|
var args = JSON.parse(pgns ? pgns : '[]')
|
|
|
|
var id = $('#plugin').attr('data-id')
|
2021-04-09 17:35:40 +10:00
|
|
|
|
2021-04-02 12:56:01 +11:00
|
|
|
var inputPlugin = editor.getValue()
|
2020-11-28 09:07:16 +11:00
|
|
|
var meta = getMeta(inputPlugin)
|
2021-04-02 12:56:01 +11:00
|
|
|
if (!meta.data) {
|
2020-11-28 09:07:16 +11:00
|
|
|
Swal.fire({
|
|
|
|
icon: 'error',
|
2021-04-15 06:02:33 +10:00
|
|
|
title: 'Syntax Error',
|
|
|
|
text: `error on line ${meta.location.start.line}`,
|
2021-04-02 12:56:01 +11:00
|
|
|
text: meta,
|
2020-11-28 09:07:16 +11:00
|
|
|
})
|
|
|
|
return false
|
|
|
|
}
|
2021-04-02 12:56:01 +11:00
|
|
|
if (!meta.data.name || !meta.data.version || !meta.data.event || !meta.data.author) {
|
2020-11-28 09:07:16 +11:00
|
|
|
Swal.fire({
|
|
|
|
icon: 'error',
|
2021-04-15 06:02:33 +10:00
|
|
|
title: 'Meta data error',
|
2021-04-02 12:56:01 +11:00
|
|
|
title: 'Syntax Error of META DATA',
|
2020-11-28 09:07:16 +11:00
|
|
|
})
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if (id == 'add_new') {
|
|
|
|
id = makeCID()
|
|
|
|
args.push({
|
|
|
|
id: id,
|
|
|
|
content: inputPlugin
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
Object.keys(args).forEach(function (key) {
|
|
|
|
var plugin = args[key]
|
|
|
|
var targetId = plugin.id
|
|
|
|
if (targetId == id) args[key].content = inputPlugin
|
|
|
|
})
|
|
|
|
}
|
|
|
|
var ss = args
|
|
|
|
localStorage.setItem('plugins', JSON.stringify(ss))
|
2021-04-09 17:35:40 +10:00
|
|
|
if (comp) return false
|
2020-11-28 09:07:16 +11:00
|
|
|
$('#plugin').attr('data-id', 'add_new')
|
2021-04-02 12:56:01 +11:00
|
|
|
editor.setValue('', -1)
|
2020-11-28 09:07:16 +11:00
|
|
|
pluginLoad()
|
|
|
|
}
|
2021-04-02 12:56:01 +11:00
|
|
|
function testExecTrg() {
|
|
|
|
var inputPlugin = editor.getValue()
|
|
|
|
var meta = getMeta(inputPlugin)
|
|
|
|
if (meta.location) {
|
|
|
|
Swal.fire({
|
|
|
|
icon: 'error',
|
2021-04-15 06:02:33 +10:00
|
|
|
title: 'Error',
|
|
|
|
text: `error on line ${meta.location.start.line}`,
|
2021-04-02 12:56:01 +11:00
|
|
|
text: meta,
|
|
|
|
})
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
testExec(inputPlugin)
|
|
|
|
}
|
2020-11-28 09:07:16 +11:00
|
|
|
async function deletePlugin() {
|
|
|
|
const alert = await Swal.fire({
|
|
|
|
title: 'delete',
|
|
|
|
icon: 'warning',
|
|
|
|
showCancelButton: true
|
|
|
|
})
|
|
|
|
if (!alert) return false
|
2021-04-02 12:56:01 +11:00
|
|
|
editor.setValue('', -1)
|
2020-11-28 09:07:16 +11:00
|
|
|
var pgns = localStorage.getItem('plugins')
|
|
|
|
var args = JSON.parse(pgns ? pgns : '[]')
|
|
|
|
var id = $('#plugin').attr('data-id')
|
|
|
|
$('#plugin').attr('data-id', 'add_new')
|
|
|
|
var ss = []
|
|
|
|
Object.keys(args).forEach(function (key) {
|
|
|
|
var plugin = args[key]
|
|
|
|
var targetId = plugin.id
|
|
|
|
if (targetId != id) ss.push(plugin)
|
|
|
|
})
|
|
|
|
localStorage.setItem('plugins', JSON.stringify(ss))
|
|
|
|
pluginLoad()
|
|
|
|
}
|
|
|
|
function execEditPlugin() {
|
|
|
|
completePlugin(true)
|
|
|
|
var id = $('#plugin').attr('data-id')
|
2021-04-02 12:56:01 +11:00
|
|
|
var inputPlugin = editor.getValue()
|
|
|
|
var meta = getMeta(inputPlugin).data
|
2020-11-28 09:07:16 +11:00
|
|
|
execPlugin(id, meta.event, { acct_id: 0, id: null })
|
|
|
|
}
|
2020-05-06 00:36:31 +10:00
|
|
|
window.onload = function () {
|
2019-03-15 22:12:11 +11:00
|
|
|
//最初に読む
|
2019-12-14 02:48:34 +11:00
|
|
|
load()
|
|
|
|
climute()
|
|
|
|
wordmute()
|
|
|
|
wordemp()
|
|
|
|
checkSpotify()
|
|
|
|
voiceSettingLoad()
|
|
|
|
oksload()
|
|
|
|
ctLoad()
|
2020-11-28 09:07:16 +11:00
|
|
|
pluginLoad()
|
2020-05-06 19:02:14 +10:00
|
|
|
$('body').addClass(localStorage.getItem('platform'))
|
2019-12-14 02:48:34 +11:00
|
|
|
}
|
2019-10-05 02:57:53 +10:00
|
|
|
//設定画面で未読マーカーは要らない
|
|
|
|
function asReadEnd() {
|
2019-12-14 02:48:34 +11:00
|
|
|
postMessage(['asReadComp', ''], '*')
|
2019-10-05 02:57:53 +10:00
|
|
|
}
|
2019-11-04 03:10:06 +11:00
|
|
|
function checkupd() {
|
2020-05-06 00:36:31 +10:00
|
|
|
if (localStorage.getItem('winstore') == 'brewcask' || localStorage.getItem('winstore') == 'snapcraft' || localStorage.getItem('winstore') == 'winstore') {
|
2019-12-15 02:52:07 +11:00
|
|
|
var winstore = true
|
|
|
|
} else {
|
|
|
|
var winstore = false
|
|
|
|
}
|
2019-12-14 02:48:34 +11:00
|
|
|
var ver = localStorage.getItem('ver')
|
|
|
|
var start = 'https://thedesk.top/ver.json'
|
2019-10-20 22:04:00 +11:00
|
|
|
fetch(start, {
|
2020-05-06 00:36:31 +10:00
|
|
|
method: 'GET',
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2020-05-06 00:36:31 +10:00
|
|
|
.then(function (response) {
|
2019-11-04 03:10:06 +11:00
|
|
|
if (!response.ok) {
|
2020-05-06 00:36:31 +10:00
|
|
|
response.text().then(function (text) {
|
2019-12-14 02:48:34 +11:00
|
|
|
setLog(response.url, response.status, text)
|
|
|
|
})
|
2019-10-20 22:04:00 +11:00
|
|
|
}
|
2019-12-14 02:48:34 +11:00
|
|
|
return response.json()
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2020-05-06 00:36:31 +10:00
|
|
|
.catch(function (error) {
|
2019-12-14 02:48:34 +11:00
|
|
|
todo(error)
|
|
|
|
setLog(start, 'JSON', error)
|
|
|
|
console.error(error)
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2020-05-06 00:36:31 +10:00
|
|
|
.then(function (mess) {
|
2019-12-14 02:48:34 +11:00
|
|
|
console.table(mess)
|
2019-11-04 03:10:06 +11:00
|
|
|
if (mess) {
|
2019-12-14 02:48:34 +11:00
|
|
|
var platform = localStorage.getItem('platform')
|
|
|
|
if (platform == 'darwin') {
|
|
|
|
var newest = mess.desk_mac
|
2019-11-04 03:10:06 +11:00
|
|
|
} else {
|
2019-12-14 02:48:34 +11:00
|
|
|
var newest = mess.desk
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
|
|
|
if (newest == ver) {
|
|
|
|
Swal.fire({
|
2019-12-14 02:48:34 +11:00
|
|
|
type: 'info',
|
2021-04-15 06:02:33 +10:00
|
|
|
text: lang.lang_setting_noupd,
|
2020-05-06 00:36:31 +10:00
|
|
|
html: ver,
|
2019-12-14 02:48:34 +11:00
|
|
|
})
|
|
|
|
} else if (ver.indexOf('beta') != -1 || winstore) {
|
2019-11-04 03:10:06 +11:00
|
|
|
Swal.fire({
|
2019-12-14 02:48:34 +11:00
|
|
|
type: 'info',
|
2021-04-15 06:02:33 +10:00
|
|
|
text: lang.lang_setting_thisisbeta,
|
2020-05-06 00:36:31 +10:00
|
|
|
html: ver,
|
2019-12-14 02:48:34 +11:00
|
|
|
})
|
2019-11-04 03:10:06 +11:00
|
|
|
} else {
|
2019-12-14 02:48:34 +11:00
|
|
|
localStorage.removeItem('new-ver-skip')
|
|
|
|
location.href = 'index.html'
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-10-20 22:04:00 +11:00
|
|
|
}
|
2019-12-14 02:48:34 +11:00
|
|
|
})
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2020-05-06 00:36:31 +10:00
|
|
|
function lastFmSet() {
|
|
|
|
if ($('#lastFmUser').val()) {
|
|
|
|
localStorage.setItem('lastFmUser', $('#lastFmUser').val())
|
|
|
|
} else {
|
|
|
|
localStorage.removeItem('lastFmUser')
|
|
|
|
}
|
|
|
|
M.toast({ html: 'Complete: last.fm', displayLength: 3000 })
|
|
|
|
}
|
2020-09-09 00:35:30 +10:00
|
|
|
|
|
|
|
function stopVideo() { return false }
|