2019-11-09 00:52:54 +11:00
|
|
|
var electron = require('electron')
|
|
|
|
const shell = electron.shell
|
|
|
|
var ipc = electron.ipcRenderer
|
2020-03-06 03:51:06 +11:00
|
|
|
//title bar
|
|
|
|
window.addEventListener('DOMContentLoaded', () => {
|
2020-05-10 14:26:07 +10:00
|
|
|
document.title = 'TheDesk'
|
2020-04-29 16:08:42 +10:00
|
|
|
ipc.send('acsCheck', '')
|
2020-03-06 03:51:06 +11:00
|
|
|
})
|
|
|
|
|
2019-10-26 03:16:33 +11:00
|
|
|
onmessage = function(e) {
|
2019-11-09 00:52:54 +11:00
|
|
|
if (e.data[0] == 'openUrl') {
|
|
|
|
urls = e.data[1].match(/https?:\/\/(.+)/)
|
2019-10-26 03:16:33 +11:00
|
|
|
if (urls) {
|
2019-11-09 00:52:54 +11:00
|
|
|
shell.openExternal(e.data[1])
|
2019-10-26 03:16:33 +11:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
} else if (e.data[0] == 'sendSinmpleIpc') {
|
|
|
|
ipc.send(e.data[1], '')
|
|
|
|
} else if (e.data[0] == 'dialogStore') {
|
|
|
|
ipc.send('dialogStore', e.data[1])
|
|
|
|
} else if (e.data[0] == 'bmpImage') {
|
|
|
|
ipc.send('bmp-image', e.data[1])
|
2019-12-14 03:54:40 +11:00
|
|
|
} else if (e.data[0] == 'resizeImage') {
|
|
|
|
ipc.send('resize-image', e.data[1])
|
|
|
|
} else if (e.data[0] == 'stampImage') {
|
|
|
|
ipc.send('stamp-image', e.data[1])
|
2019-11-09 00:52:54 +11:00
|
|
|
} else if (e.data[0] == 'dialogCW') {
|
|
|
|
ipc.send('dialogCW', e.data[1])
|
|
|
|
} else if (e.data[0] == 'nativeNotf') {
|
|
|
|
console.log(e.data[1])
|
|
|
|
ipc.send('native-notf', e.data[1])
|
|
|
|
} else if (e.data[0] == 'dialogClient') {
|
|
|
|
ipc.send('dialogClient', e.data[1])
|
|
|
|
} else if (e.data[0] == 'generalDL') {
|
|
|
|
ipc.send('general-dl', e.data[1])
|
|
|
|
} else if (e.data[0] == 'openFinder') {
|
2020-05-11 19:42:52 +10:00
|
|
|
ipc.send('openFinder', e.data[1])
|
2019-11-09 00:52:54 +11:00
|
|
|
} else if (e.data[0] == 'columnDel') {
|
|
|
|
ipc.send('column-del', e.data[1])
|
|
|
|
} else if (e.data[0] == 'lang') {
|
|
|
|
ipc.send('lang', e.data[1])
|
|
|
|
} else if (e.data[0] == 'exportSettings') {
|
|
|
|
ipc.send('exportSettings', e.data[1])
|
|
|
|
} else if (e.data[0] == 'exportSettingsCoreComplete') {
|
|
|
|
ipc.send('export', e.data[1])
|
|
|
|
} else if (e.data[0] == 'importSettings') {
|
|
|
|
ipc.send('importSettings', e.data[1])
|
|
|
|
} else if (e.data[0] == 'customSound') {
|
|
|
|
ipc.send('customSound', e.data[1])
|
|
|
|
} else if (e.data[0] == 'themeJsonDelete') {
|
|
|
|
ipc.send('theme-json-delete', e.data[1])
|
|
|
|
} else if (e.data[0] == 'themeJsonCreate') {
|
|
|
|
ipc.send('theme-json-create', e.data[1])
|
|
|
|
} else if (e.data[0] == 'themeJsonRequest') {
|
|
|
|
ipc.send('theme-json-request', e.data[1])
|
|
|
|
} else if (e.data[0] == 'ha') {
|
|
|
|
ipc.send('ha', e.data[1])
|
2021-04-09 17:35:40 +10:00
|
|
|
} else if (e.data[0] == 'webviewSetting') {
|
|
|
|
ipc.send('webview', e.data[1])
|
2020-03-19 15:17:02 +11:00
|
|
|
} else if (e.data[0] == 'frameSet') {
|
|
|
|
ipc.send('frameSet', e.data[1])
|
2019-11-09 00:52:54 +11:00
|
|
|
} else if (e.data[0] == 'ua') {
|
|
|
|
ipc.send('ua', e.data[1])
|
|
|
|
} else if (e.data[0] == 'aboutData') {
|
|
|
|
ipc.send('aboutData', '')
|
|
|
|
} else if (e.data[0] == 'itunes') {
|
|
|
|
console.log('NowPlaying')
|
|
|
|
ipc.send('itunes', e.data[1])
|
|
|
|
} else if (e.data[0] == 'themeCSSRequest') {
|
2021-04-15 06:45:14 +10:00
|
|
|
ipc.send('theme-css-request', e.data)
|
|
|
|
} else if (e.data[0] == 'themeCSSPreview') {
|
|
|
|
ipc.send('theme-css-request', e.data)
|
2019-11-09 00:52:54 +11:00
|
|
|
} else if (e.data[0] == 'customCSSRequest') {
|
|
|
|
ipc.send('custom-css-request', e.data[1])
|
|
|
|
} else if (e.data[0] == 'downloadButton') {
|
|
|
|
ipc.send('download-btn', e.data[1])
|
|
|
|
} else if (e.data[0] == 'nano') {
|
|
|
|
ipc.send('nano', null)
|
|
|
|
} else if (e.data[0] == 'asReadComp') {
|
|
|
|
ipc.send('sendMarkersComplete', null)
|
|
|
|
} else if (e.data[0] == 'copy') {
|
|
|
|
ipc.send('copy', e.data[1])
|
|
|
|
} else if (e.data[0] == 'log') {
|
|
|
|
ipc.send('log', e.data[1])
|
2021-04-09 17:35:40 +10:00
|
|
|
} else if (e.data[0] == 'twitterLogin') {
|
|
|
|
ipc.send('twitterLogin', e.data[1])
|
2021-04-18 05:24:52 +10:00
|
|
|
} else if (e.data[0] == 'textareaContextMenu') {
|
|
|
|
ipc.send('textareaContextMenu', e.data[1])
|
2019-10-26 03:16:33 +11:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
}
|
2019-06-15 01:51:41 +10:00
|
|
|
//version.js
|
2019-11-09 00:52:54 +11:00
|
|
|
ipc.send('getPlatform', '')
|
|
|
|
ipc.on('platform', function(event, args) {
|
|
|
|
localStorage.setItem('platform', args[0])
|
|
|
|
localStorage.setItem('bit', args[1])
|
|
|
|
localStorage.setItem('about', JSON.stringify([args[2], args[3], args[4], args[5]]))
|
|
|
|
})
|
2019-06-15 01:51:41 +10:00
|
|
|
|
2019-11-09 00:52:54 +11:00
|
|
|
ipc.on('reload', function(event, arg) {
|
|
|
|
location.reload()
|
|
|
|
})
|
2019-06-15 00:17:16 +10:00
|
|
|
//Native Notf
|
2019-11-09 00:52:54 +11:00
|
|
|
ipc.on('shownotf', function(event, args) {
|
|
|
|
if (args['type'] == 'toot') {
|
|
|
|
postMessage(['details', [id, acct_id]], '*')
|
|
|
|
} else if (args['type'] == 'userdata') {
|
|
|
|
postMessage(['udg', [user, acct_id]], '*')
|
2019-10-26 03:16:33 +11:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
})
|
2019-06-26 00:26:15 +10:00
|
|
|
|
2019-06-15 02:10:32 +10:00
|
|
|
//first.js
|
2019-11-09 00:52:54 +11:00
|
|
|
ipc.on('custom-css-response', function(event, arg) {
|
|
|
|
if (arg == '') {
|
|
|
|
return false
|
2019-10-26 03:16:33 +11:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
var styleNode = document.createElement('style')
|
|
|
|
styleNode.setAttribute('type', 'text/css')
|
2019-06-15 02:10:32 +10:00
|
|
|
|
2019-11-09 00:52:54 +11:00
|
|
|
var content = document.createTextNode(arg)
|
|
|
|
styleNode.append(content)
|
|
|
|
document.getElementsByTagName('head')[0].append(styleNode)
|
|
|
|
})
|
|
|
|
ipc.on('theme-css-response', function(event, arg) {
|
|
|
|
if (arg == '') {
|
|
|
|
return false
|
2019-10-26 03:16:33 +11:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
var styleNode = document.createElement('style')
|
|
|
|
styleNode.setAttribute('type', 'text/css')
|
2019-06-15 02:10:32 +10:00
|
|
|
|
2019-11-09 00:52:54 +11:00
|
|
|
var content = document.createTextNode(arg)
|
|
|
|
styleNode.append(content)
|
|
|
|
document.getElementsByTagName('head')[0].append(styleNode)
|
|
|
|
})
|
2019-06-15 02:10:32 +10:00
|
|
|
//img.js
|
2019-11-09 00:52:54 +11:00
|
|
|
ipc.on('bmp-img-comp', function(event, b64) {
|
2019-12-14 03:54:40 +11:00
|
|
|
if (b64[2]) {
|
|
|
|
var stamped = true
|
|
|
|
} else {
|
|
|
|
var stamped = false
|
|
|
|
}
|
|
|
|
postMessage(['media', [b64[0], 'image/png', b64[1], stamped]], '*')
|
|
|
|
})
|
|
|
|
ipc.on('resizeJudgement', function(event, b64) {
|
|
|
|
var resize = localStorage.getItem('uploadCrop') * 1
|
|
|
|
if (resize > 0) {
|
|
|
|
var element = new Image()
|
|
|
|
var width
|
|
|
|
element.onload = function() {
|
|
|
|
var width = element.naturalWidth
|
|
|
|
var height = element.naturalHeight
|
|
|
|
if (width > resize || height > resize) {
|
2020-05-11 19:42:52 +10:00
|
|
|
ipc.send('resize-image', [b64[0], resize])
|
2019-12-14 03:54:40 +11:00
|
|
|
} else {
|
|
|
|
postMessage(['media', [b64[0], 'image/png', b64[1]]], '*')
|
|
|
|
}
|
|
|
|
}
|
2020-05-11 19:42:52 +10:00
|
|
|
element.src = 'data:image/png;base64,' + b64[0]
|
2019-12-14 03:54:40 +11:00
|
|
|
} else {
|
|
|
|
postMessage(['media', [b64[0], 'image/png', b64[1]]], '*')
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
})
|
2019-06-15 02:32:59 +10:00
|
|
|
//ui,img.js
|
2019-11-09 00:52:54 +11:00
|
|
|
ipc.on('general-dl-prog', function(event, arg) {
|
|
|
|
console.log('Progress: ' + arg)
|
|
|
|
})
|
|
|
|
ipc.on('general-dl-message', function(event, arg) {
|
2020-05-11 19:42:52 +10:00
|
|
|
var argC = arg.replace(/\\/g, '\\\\')
|
2019-11-09 00:52:54 +11:00
|
|
|
console.log('saved')
|
|
|
|
postMessage(['toastSaved', [arg, argC]], '*')
|
|
|
|
})
|
2019-06-15 03:01:38 +10:00
|
|
|
//setting.js
|
2019-11-09 00:52:54 +11:00
|
|
|
ipc.on('langres', function(event, arg) {
|
|
|
|
location.href = '../' + arg + '/setting.html'
|
|
|
|
})
|
|
|
|
ipc.on('exportSettingsFile', function(event, arg) {
|
|
|
|
postMessage(['exportSettingsCore', arg], '*')
|
|
|
|
})
|
|
|
|
ipc.on('exportAllComplete', function(event, arg) {
|
|
|
|
postMessage(['alert', 'Complete'], '*')
|
|
|
|
})
|
|
|
|
ipc.on('config', function(event, arg) {
|
|
|
|
postMessage(['importSettingsCore', arg], '*')
|
|
|
|
})
|
|
|
|
ipc.on('savefolder', function(event, arg) {
|
|
|
|
localStorage.setItem('savefolder', arg)
|
|
|
|
})
|
|
|
|
ipc.on('font-list', function(event, arg) {
|
|
|
|
postMessage(['fontList', arg], '*')
|
|
|
|
})
|
|
|
|
ipc.on('customSoundRender', function(event, args) {
|
|
|
|
postMessage(['customSoundSave', [args[0], args[1]]], '*')
|
|
|
|
})
|
|
|
|
ipc.on('theme-json-list-response', function(event, args) {
|
|
|
|
postMessage(['ctLoadCore', args], '*')
|
|
|
|
})
|
|
|
|
ipc.on('theme-json-delete-complete', function(event, args) {
|
|
|
|
postMessage(['ctLoad', ''], '*')
|
|
|
|
})
|
|
|
|
ipc.on('theme-json-response', function(event, args) {
|
|
|
|
postMessage(['customConnect', args], '*')
|
|
|
|
})
|
|
|
|
ipc.on('theme-json-create-complete', function(event, args) {
|
2020-09-09 00:35:30 +10:00
|
|
|
if(args != '') alert(args)
|
2019-11-09 00:52:54 +11:00
|
|
|
postMessage(['clearCustomImport', ''], '*')
|
|
|
|
postMessage(['ctLoad', ''], '*')
|
|
|
|
})
|
2019-06-15 03:10:11 +10:00
|
|
|
//spotify.js
|
2019-11-09 00:52:54 +11:00
|
|
|
ipc.on('itunes-np', function(event, arg) {
|
|
|
|
postMessage(['npCore', arg], '*')
|
|
|
|
})
|
2019-06-15 03:10:11 +10:00
|
|
|
//tips.js
|
2019-11-09 00:52:54 +11:00
|
|
|
ipc.on('memory', function(event, arg) {
|
|
|
|
var use = arg[0]
|
|
|
|
var cpu = arg[1]
|
|
|
|
var total = arg[2]
|
2020-09-26 22:02:48 +10:00
|
|
|
postMessage(['renderMem', [use, cpu, total, arg[3], arg[4]]], '*')
|
2019-11-09 00:52:54 +11:00
|
|
|
})
|
2019-10-31 03:00:06 +11:00
|
|
|
//log
|
2019-11-09 00:52:54 +11:00
|
|
|
ipc.on('logData', function(event, args) {
|
|
|
|
postMessage(['logData', args], '*')
|
|
|
|
})
|
2019-06-15 03:23:41 +10:00
|
|
|
//update.html
|
2019-11-09 00:52:54 +11:00
|
|
|
ipc.on('prog', function(event, arg) {
|
|
|
|
postMessage(['updateProg', arg], '*')
|
|
|
|
})
|
|
|
|
ipc.on('mess', function(event, arg) {
|
|
|
|
postMessage(['updateMess', arg], '*')
|
|
|
|
})
|
2020-04-29 16:08:42 +10:00
|
|
|
//misc
|
2019-11-09 00:52:54 +11:00
|
|
|
ipc.on('asRead', function(event, arg) {
|
|
|
|
postMessage(['asRead', ''], '*')
|
|
|
|
})
|
|
|
|
ipc.on('asReadEnd', function(event, arg) {
|
|
|
|
postMessage(['asReadEnd', ''], '*')
|
|
|
|
})
|
2020-04-29 16:08:42 +10:00
|
|
|
ipc.on('accessibility', function(event, arg) {
|
|
|
|
postMessage(['accessibility', 'true'], '*')
|
|
|
|
})
|
2021-04-09 17:35:40 +10:00
|
|
|
ipc.on('twitterLoginComplete', function(event, arg) {
|
|
|
|
postMessage(['twitterLoginComplete', ''], '*')
|
|
|
|
})
|
2021-04-18 05:24:52 +10:00
|
|
|
ipc.on('alert', function(event, arg) {
|
|
|
|
postMessage(['alert', arg], '*')
|
|
|
|
})
|
|
|
|
ipc.on('customUrl', function(event, args) {
|
|
|
|
postMessage(['customUrl', args], '*')
|
|
|
|
})
|