thedesk/app/js/platform/end.js

189 lines
5.0 KiB
JavaScript
Raw Permalink Normal View History

2019-11-25 00:26:19 +11:00
'use strict'
2018-01-28 23:22:43 +11:00
//プラットフォーム別 最後に読むやつ
2019-11-09 00:52:54 +11:00
//リンクを外部で開くか内部で出すか
2019-05-19 17:39:30 +10:00
$(document).on('click', 'a', e => {
2019-11-09 00:52:54 +11:00
var $a = $(e.target)
var url = $a.attr('href')
2019-05-19 17:39:30 +10:00
if (!url) {
2019-11-09 00:52:54 +11:00
var url = $a.parent().attr('href')
2019-05-19 17:39:30 +10:00
}
2019-11-09 00:52:54 +11:00
var urls = []
2019-05-19 17:39:30 +10:00
if (url) {
2019-11-09 00:52:54 +11:00
urls = url.match(/https?:\/\/(.+)/)
2018-04-07 14:31:09 +10:00
//トゥートのURLぽかったら
2019-11-25 01:53:35 +11:00
var toot = url.match(/https:\/\/([^+_]+)\/@([a-zA-Z0-9_]+)\/([0-9]+)/)
2019-11-09 00:52:54 +11:00
if (!toot) {
2019-07-13 00:16:27 +10:00
//Pleroma対策
2019-11-09 00:52:54 +11:00
toot = url.match(/https:\/\/([^+_]+)\/users\/([a-zA-Z0-9_]+)\/statuses\/([0-9]+)/)
2019-07-13 00:16:27 +10:00
}
2018-05-12 04:12:25 +10:00
//タグのURLぽかったら
2019-11-09 00:52:54 +11:00
var tags = []
tags = url.match(/https:\/\/([^+_]+)\/tags\/([_a-zA-Z0-9\&=+\%]+)/)
2018-05-12 04:12:25 +10:00
//メンションっぽかったら
2019-11-09 00:52:54 +11:00
var ats = []
ats = url.match(/https:\/\/([^+_]+)\/@([_a-zA-Z0-9\&=+\%]+)/)
2019-05-19 17:39:30 +10:00
if (toot) {
if (toot[1]) {
2019-11-09 00:52:54 +11:00
var acct_id = $a.parent().attr('data-acct')
2019-05-19 17:39:30 +10:00
if (!acct_id) {
2019-11-09 00:52:54 +11:00
acct_id = 0
2018-04-09 00:17:33 +10:00
}
2019-11-09 00:52:54 +11:00
$a.parent().addClass('loadp')
$a.parent().text('Loading...')
detEx(url, acct_id)
2018-04-07 14:31:09 +10:00
}
2019-05-19 17:39:30 +10:00
} else if (tags) {
if (tags[2]) {
2019-11-09 00:52:54 +11:00
var acct_id = $a.parent().attr('data-acct')
2019-05-19 17:39:30 +10:00
if (!acct_id) {
2019-11-09 00:52:54 +11:00
acct_id = 0
2019-04-14 02:42:18 +10:00
}
2019-05-19 17:39:30 +10:00
tl('tag', decodeURI(tags[2]), acct_id, 'add')
2018-05-12 04:12:25 +10:00
}
2019-05-19 17:39:30 +10:00
} else if (ats) {
if (ats[2]) {
2019-04-04 03:07:07 +11:00
//Quesdon判定
2019-11-09 00:52:54 +11:00
if (!~ats[2].indexOf('@')) {
udgEx(url, 'main')
2018-06-12 01:44:28 +10:00
return false
2019-05-19 17:39:30 +10:00
} else {
2019-11-09 00:52:54 +11:00
postMessage(['openUrl', url], '*')
2018-06-12 01:44:28 +10:00
}
2018-09-11 04:59:44 +10:00
}
2018-02-18 05:44:20 +11:00
} else {
2019-05-19 17:39:30 +10:00
//hrefがhttp/httpsならブラウザで
if (urls) {
if (urls[0]) {
2019-11-09 00:52:54 +11:00
if (~url.indexOf('thedeks.top')) {
2019-05-19 17:39:30 +10:00
//alert("If you recieve this alert, let the developer(Cutls@kirishima.cloud) know it with a screenshot.");
2019-11-09 00:52:54 +11:00
url = 'https://thedesk.top'
2019-05-19 17:39:30 +10:00
}
2019-11-09 00:52:54 +11:00
postMessage(['openUrl', url], '*')
2019-05-19 17:39:30 +10:00
} else {
2019-11-09 00:52:54 +11:00
location.href = url
2019-05-19 17:39:30 +10:00
}
} else {
2019-11-09 00:52:54 +11:00
location.href = url
2019-05-19 17:39:30 +10:00
}
2018-02-18 05:44:20 +11:00
}
2018-02-26 00:37:04 +11:00
}
2019-11-09 00:52:54 +11:00
return false
})
2019-05-19 17:39:30 +10:00
//よく使うライブラリ
2018-12-09 05:46:01 +11:00
2019-05-19 17:39:30 +10:00
//コピー
function execCopy(string) {
2019-11-09 00:52:54 +11:00
postMessage(['copy', string], '*')
return true
2019-05-19 17:39:30 +10:00
}
2018-04-17 03:10:35 +10:00
function progshow(e) {
if (e.lengthComputable) {
2019-11-09 00:52:54 +11:00
var percent = e.loaded / e.total
console.log('Progress: ' + percent * 100)
$('#imgsel').hide()
2019-05-19 17:39:30 +10:00
if (percent < 1) {
2019-11-09 00:52:54 +11:00
$('#imgup').text(Math.floor(percent * 100) + '%')
2019-05-19 17:39:30 +10:00
} else {
2019-11-09 00:52:54 +11:00
$('#imgup').text(lang.lang_progress)
2019-05-19 17:39:30 +10:00
}
2018-04-17 03:10:35 +10:00
}
2019-05-19 17:39:30 +10:00
}
function opendev() {
2019-11-09 00:52:54 +11:00
var webview = document.getElementById('webview')
webview.openDevTools()
2018-09-11 04:59:44 +10:00
/*webview.sendInputEvent({
2018-09-10 03:06:00 +10:00
type: "keyDown",
2018-09-11 04:59:44 +10:00
keyCode: '2'
2018-09-10 03:06:00 +10:00
});
2018-09-11 04:59:44 +10:00
*/
2019-02-28 04:02:23 +11:00
}
2019-09-17 01:59:25 +10:00
var soundFile
2019-04-15 01:45:04 +10:00
function playSound() {
2019-11-09 00:52:54 +11:00
window.AudioContext = window.AudioContext || window.webkitAudioContext
if (soundFile) {
2019-09-17 01:59:25 +10:00
soundFile.stop()
}
2019-11-25 00:26:19 +11:00
var context = new AudioContext()
2019-11-09 00:52:54 +11:00
context.createBufferSource().start(0)
context.decodeAudioData(request.response, function(buf) {
2019-09-17 01:59:25 +10:00
//console.log("Playing:" , source)
2019-11-09 00:52:54 +11:00
source.buffer = buf
source.loop = false
})
source = context.createBufferSource()
volumeControl = context.createGain()
source.connect(volumeControl)
volumeControl.connect(context.destination)
var cvol = localStorage.getItem('customVol')
2019-09-17 01:59:25 +10:00
if (cvol) {
vol = cvol
2019-11-09 00:52:54 +11:00
} else {
2019-09-17 01:59:25 +10:00
vol = 0.8
}
volumeControl.gain.value = vol
2019-11-09 00:52:54 +11:00
source.start(0)
soundFile = source
2019-06-16 00:07:18 +10:00
}
2019-06-26 00:26:15 +10:00
function nano() {
2019-11-09 00:52:54 +11:00
postMessage(['nano', null], '*')
2019-06-26 00:26:15 +10:00
}
2019-11-09 00:52:54 +11:00
onmessage = function(e) {
if (e.data[0] == 'details') {
2019-06-22 02:06:32 +10:00
details(e.data[1][0], e.data[1][1])
2019-11-09 00:52:54 +11:00
} else if (e.data[0] == 'udg') {
2019-06-22 02:06:32 +10:00
udg(e.data[1][0], e.data[1][1])
2019-11-09 00:52:54 +11:00
} else if (e.data[0] == 'media') {
2019-06-22 02:06:32 +10:00
media(e.data[1][0], e.data[1][1], e.data[1][2])
2019-11-09 00:52:54 +11:00
} else if (e.data[0] == 'post') {
post('pass')
} else if (e.data[0] == 'toastSaved') {
var show = `${lang.lang_img_DLDone}${
e.data[1][0]
}<button class="btn-flat toast-action" onclick="openFinder(${e.data[1][1]}')">Show</button>`
M.toast({ html: show, displayLength: 5000 })
} else if (e.data[0] == 'parseColumn') {
parseColumn(e.data[1])
2019-11-09 00:52:54 +11:00
} else if (e.data[0] == 'exportSettingsCore') {
2019-08-29 02:20:47 +10:00
var exp = exportSettingsCore()
2019-11-09 00:52:54 +11:00
postMessage(['exportSettingsCoreComplete', [e.data[1], exp]], '*')
} else if (e.data[0] == 'importSettingsCore') {
2019-08-29 02:20:47 +10:00
importSettingsCore(e.data[1])
2019-11-09 00:52:54 +11:00
} else if (e.data[0] == 'fontList') {
2019-06-22 02:06:32 +10:00
fontList(e.data[1])
2019-11-09 00:52:54 +11:00
} else if (e.data[0] == 'customSoundSave') {
2019-06-22 02:06:32 +10:00
customSoundSave(e.data[1][0], e.data[1][1])
2019-11-09 00:52:54 +11:00
} else if (e.data[0] == 'ctLoadCore') {
2019-06-22 02:06:32 +10:00
ctLoadCore(e.data[1])
2019-11-09 00:52:54 +11:00
} else if (e.data[0] == 'ctLoad') {
2019-06-22 02:06:32 +10:00
ctLoad()
2019-11-09 00:52:54 +11:00
} else if (e.data[0] == 'customConnect') {
2019-06-22 02:06:32 +10:00
customConnect(e.data[1])
2019-11-09 00:52:54 +11:00
} else if (e.data[0] == 'clearCustomImport') {
2019-06-22 02:06:32 +10:00
clearCustomImport()
2019-11-09 00:52:54 +11:00
} else if (e.data[0] == 'npCore') {
npCore(e.data[1])
} else if (e.data[0] == 'renderMem') {
2019-06-22 02:06:32 +10:00
renderMem(e.data[1][0], e.data[1][1], e.data[1][2])
2019-11-09 00:52:54 +11:00
} else if (e.data[0] == 'updateProg') {
updateProg(e.data[1])
} else if (e.data[0] == 'updateMess') {
updateMess(e.data[1])
} else if (e.data[0] == 'renderAbout') {
renderAbout(e.data[1])
} else if (e.data[0] == 'asRead') {
2019-09-22 20:55:59 +10:00
asRead()
2019-11-09 00:52:54 +11:00
} else if (e.data[0] == 'asReadEnd') {
2019-09-22 20:55:59 +10:00
asReadEnd()
2019-11-09 00:52:54 +11:00
} else if (e.data[0] == 'logData') {
$('#logs').val(e.data[1])
var obj = document.getElementById('logs')
obj.scrollTop = obj.scrollHeight
} else if (e.data[0] == 'alert') {
2019-06-22 02:06:32 +10:00
Swal.fire({
type: 'info',
title: e.data[1]
})
}
2019-11-09 00:52:54 +11:00
}