196 lines
5.0 KiB
JavaScript
Raw Normal View History

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