Compare commits

...

9 Commits

Author SHA1 Message Date
cutls
8eadb8287d today shinchoku 2020-08-31 00:23:55 +09:00
cutls
541ebbbb19 today shinchoku 2020-07-21 12:44:53 +09:00
cutls
d92a9ae1ae today shinchoku 2020-07-21 09:06:58 +09:00
cutls
47749dde7b readme 2020-07-12 03:49:48 +09:00
cutls
78a8c2bdce Today shinchoku 2020-07-12 00:48:15 +09:00
cutls
2c54e43e37 Shinchoku 2020-07-10 22:33:12 +09:00
cutls
fba3b99b54 it 2020-07-10 14:22:26 +09:00
cutls
489d95f23f fix 2020-07-10 14:21:24 +09:00
cutls
5d01dafeb3 WIP: ditch jQuery and duplicated funcs 2020-07-10 14:16:39 +09:00
31 changed files with 8723 additions and 4229 deletions

View File

@ -1,3 +1,18 @@
# rewrite-overallブランチへようこそ🎃
このブランチはコードを最初から全部読み直して書き直そうという途方もなく壮大なプロジェクトです。
1周目では、
* 脱jQuery
* 脱onclick
* 脱コールバック地獄
* 重複してるやつや使ってないやつを消す
という極めて当たり前のやつをやっていきます。
# 以下いつものREADME
<img src="https://thedesk.top/img/top.png" width="300" align="left"> <img src="https://thedesk.top/img/top.png" width="300" align="left">
<img src="https://thedesk.top/img/desk.png" width="150" align="right"> <img src="https://thedesk.top/img/desk.png" width="150" align="right">

View File

@ -1,5 +1,5 @@
//@ts-check
//このソフトについて //このソフトについて
function about() { function about() {
postMessage(["sendSinmpleIpc", "about"], "*") postMessage(["sendSinmpleIpc", "about"], "*")
} }
document.getElementById('onClickAbout').addEventListener('click', about)

38
app/js/common/api.js Normal file
View File

@ -0,0 +1,38 @@
async function getApi(start, at) {
let json = {}
let response = null
response = await fetch(start, {
method: 'GET',
headers: {
'content-type': 'application/json',
'Authorization': `Bearer ${at}`
}
})
if (!response.ok) {
response.text().then(function (text) {
setLog(response.url, response.status, text)
})
}
json = await response.json()
return json
}
async function postApi(url, body, at, ideKey) {
let json = {}
let response = null
response = await fetch(url, {
method: 'POST',
headers: {
'content-type': 'application/json',
'Authorization': `Bearer ${at}`,
'Idempotency-Key': ideKey
},
body: JSON.stringify(body)
})
if (!response.ok) {
response.text().then(function (text) {
setLog(response.url, response.status, text)
})
}
json = await response.json()
return json
}

View File

@ -1,4 +1,4 @@
var digitCharacters = [ const digitCharacters = [
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
"K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
@ -10,16 +10,16 @@ var digitCharacters = [
"|", "}", "~", "|", "}", "~",
]; ];
function decode83(str) { function decode83(str) {
var value = 0; let value = 0;
for (var i = 0; i < str.length; i++) { for (let i = 0; i < str.length; i++) {
var c = str[i]; const c = str[i];
var digit = digitCharacters.indexOf(c); const digit = digitCharacters.indexOf(c);
value = value * 83 + digit; value = value * 83 + digit;
} }
return value; return value;
} }
function linearTosRGB(value) { function linearTosRGB(value) {
var v = Math.max(0, Math.min(1, value)); const v = Math.max(0, Math.min(1, value));
if (v <= 0.0031308) { if (v <= 0.0031308) {
return Math.round(v * 12.92 * 255 + 0.5); return Math.round(v * 12.92 * 255 + 0.5);
} }
@ -28,7 +28,7 @@ function linearTosRGB(value) {
} }
} }
function sRGBToLinear(value) { function sRGBToLinear(value) {
var v = value / 255; const v = value / 255;
if (v <= 0.04045) { if (v <= 0.04045) {
return v / 12.92; return v / 12.92;
} }
@ -37,18 +37,18 @@ function sRGBToLinear(value) {
} }
} }
function decodeDC(value) { function decodeDC(value) {
var intR = value >> 16; const intR = value >> 16;
var intG = (value >> 8) & 255; const intG = (value >> 8) & 255;
var intB = value & 255; const intB = value & 255;
return [sRGBToLinear(intR), sRGBToLinear(intG), sRGBToLinear(intB)]; return [sRGBToLinear(intR), sRGBToLinear(intG), sRGBToLinear(intB)];
}; };
function sign(n) { return (n < 0 ? -1 : 1); } function sign(n) { return (n < 0 ? -1 : 1); }
function signPow(val, exp) { return sign(val) * Math.pow(Math.abs(val), exp); } function signPow(val, exp) { return sign(val) * Math.pow(Math.abs(val), exp); }
function decodeDC2(value, maximumValue) { function decodeDC2(value, maximumValue) {
var quantR = Math.floor(value / (19 * 19)); const quantR = Math.floor(value / (19 * 19));
var quantG = Math.floor(value / 19) % 19; const quantG = Math.floor(value / 19) % 19;
var quantB = value % 19; const quantB = value % 19;
var rgb = [ const rgb = [
signPow((quantR - 9) / 9, 2.0) * maximumValue, signPow((quantR - 9) / 9, 2.0) * maximumValue,
signPow((quantG - 9) / 9, 2.0) * maximumValue, signPow((quantG - 9) / 9, 2.0) * maximumValue,
signPow((quantB - 9) / 9, 2.0) * maximumValue, signPow((quantB - 9) / 9, 2.0) * maximumValue,
@ -61,45 +61,45 @@ function decodeblur(blurhash, width, height, punch) {
console.error('too short blurhash'); console.error('too short blurhash');
return null; return null;
} }
var sizeFlag = decode83(blurhash[0]); const sizeFlag = decode83(blurhash[0]);
var numY = Math.floor(sizeFlag / 9) + 1; const numY = Math.floor(sizeFlag / 9) + 1;
var numX = (sizeFlag % 9) + 1; const numX = (sizeFlag % 9) + 1;
var quantisedMaximumValue = decode83(blurhash[1]); const quantisedMaximumValue = decode83(blurhash[1]);
var maximumValue = (quantisedMaximumValue + 1) / 166; const maximumValue = (quantisedMaximumValue + 1) / 166;
if (blurhash.length !== 4 + 2 * numX * numY) { if (blurhash.length !== 4 + 2 * numX * numY) {
console.error('blurhash length mismatch', blurhash.length, 4 + 2 * numX * numY); console.error('blurhash length mismatch', blurhash.length, 4 + 2 * numX * numY);
return null; return null;
} }
var colors = new Array(numX * numY); let colors = new Array(numX * numY);
for (var i = 0; i < colors.length; i++) { for (let i = 0; i < colors.length; i++) {
if (i === 0) { if (i === 0) {
var value = decode83(blurhash.substring(2, 6)); const value = decode83(blurhash.substring(2, 6));
colors[i] = decodeDC(value); colors[i] = decodeDC(value);
} }
else { else {
var value = decode83(blurhash.substring(4 + i * 2, 6 + i * 2)); const value = decode83(blurhash.substring(4 + i * 2, 6 + i * 2));
colors[i] = decodeDC2(value, maximumValue * punch); colors[i] = decodeDC2(value, maximumValue * punch);
} }
} }
var bytesPerRow = width * 4; const bytesPerRow = width * 4;
var pixels = new Uint8ClampedArray(bytesPerRow * height); let pixels = new Uint8ClampedArray(bytesPerRow * height);
for (var y = 0; y < height; y++) { for (var y = 0; y < height; y++) {
for (var x = 0; x < width; x++) { for (var x = 0; x < width; x++) {
var r = 0; var r = 0;
var g = 0; var g = 0;
var b = 0; var b = 0;
for (var j = 0; j < numY; j++) { for (let j = 0; j < numY; j++) {
for (var i = 0; i < numX; i++) { for (let i = 0; i < numX; i++) {
var basis = Math.cos(Math.PI * x * i / width) * Math.cos(Math.PI * y * j / height); let basis = Math.cos(Math.PI * x * i / width) * Math.cos(Math.PI * y * j / height);
var color = colors[i + j * numX]; let color = colors[i + j * numX];
r += color[0] * basis; r += color[0] * basis;
g += color[1] * basis; g += color[1] * basis;
b += color[2] * basis; b += color[2] * basis;
} }
} }
var intR = linearTosRGB(r); const intR = linearTosRGB(r);
var intG = linearTosRGB(g); const intG = linearTosRGB(g);
var intB = linearTosRGB(b); const intB = linearTosRGB(b);
pixels[4 * x + 0 + y * bytesPerRow] = intR; pixels[4 * x + 0 + y * bytesPerRow] = intR;
pixels[4 * x + 1 + y * bytesPerRow] = intG; pixels[4 * x + 1 + y * bytesPerRow] = intG;
pixels[4 * x + 2 + y * bytesPerRow] = intB; pixels[4 * x + 2 + y * bytesPerRow] = intB;
@ -109,9 +109,9 @@ function decodeblur(blurhash, width, height, punch) {
return pixels; return pixels;
} }
function parseBlur(blur) { function parseBlur(blur) {
var canvas = document.getElementById('canvas'); const canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d'); const ctx = canvas.getContext('2d');
var pixels = decodeblur(blur, 32, 32) const pixels = decodeblur(blur, 32, 32)
const imageData = new ImageData(pixels, 32, 32); const imageData = new ImageData(pixels, 32, 32);
ctx.putImageData(imageData, 0, 0); ctx.putImageData(imageData, 0, 0);

View File

@ -1,26 +1,19 @@
selectedColumn = 0 let selectedColumn = 0
selectedToot = 0 let selectedToot = 0
$(function($) { $(function ($) {
//キーボードショートカット //キーボードショートカット
$(window).keydown(function(e) { $(window).keydown(function (e) {
var hasFocus = $('input').is(':focus') const hasFocus = isFocused('input')
var hasFocus2 = $('textarea').is(':focus') const hasFocus2 = isFocused('textarea')
if (document.getElementById('webview')) { const postBox = document.querySelector('#textarea')
if ($('#webviewsel:checked').val()) { let wv = false
var wv = false
} else {
var wv = true
}
} else {
var wv = true
}
//Enter //Enter
if (e.keyCode === 13) { if (e.keyCode === 13) {
if ($('#src').is(':focus')) { if (isFocused('#src')) {
src() src()
return false return false
} }
if ($('#list-add').is(':focus')) { if (isFocused('#list-add')) {
makeNewList() makeNewList()
return false return false
} }
@ -92,7 +85,7 @@ $(function($) {
} }
//X:開閉 //X:開閉
if (e.keyCode === 88) { if (e.keyCode === 88) {
if (!$('#post-box').hasClass('appear')) { if (!document.querySelector('#post-box').classList.contains('appear')) {
show() show()
$('textarea').focus() $('textarea').focus()
} else { } else {
@ -102,10 +95,10 @@ $(function($) {
} }
//N:新トゥート //N:新トゥート
if (e.keyCode === 78) { if (e.keyCode === 78) {
if (!$('#post-box').hasClass('appear')) { if (!document.querySelector('#post-box').classList.contains('appear')) {
show() show()
} }
$('textarea').focus() postBox.focus()
return false return false
} }
//Ctrl+E:全ての通知未読を既読にする //Ctrl+E:全ての通知未読を既読にする
@ -153,7 +146,7 @@ $(function($) {
//数字:TL //数字:TL
if (event.metaKey || event.ctrlKey) { if (event.metaKey || event.ctrlKey) {
if (e.keyCode >= 49 && e.keyCode <= 57) { if (e.keyCode >= 49 && e.keyCode <= 57) {
var kz = e.keyCode - 49 const kz = e.keyCode - 49
goColumn(kz) goColumn(kz)
return false return false
} }
@ -161,7 +154,7 @@ $(function($) {
//矢印:選択 //矢印:選択
if (e.code == 'ArrowLeft') { if (e.code == 'ArrowLeft') {
//left //left
if ($('#imagemodal').hasClass('open')) { if (document.querySelector('#imagemodal').classList.contains('open')) {
imgCont('prev') imgCont('prev')
return false return false
} }
@ -172,7 +165,7 @@ $(function($) {
return false return false
} else if (e.code == 'ArrowUp') { } else if (e.code == 'ArrowUp') {
//up //up
if ($('#imagemodal').hasClass('open')) { if (document.querySelector('#imagemodal').classList.contains('open')) {
return false return false
} }
if (selectedToot > 0) { if (selectedToot > 0) {
@ -182,7 +175,7 @@ $(function($) {
return false return false
} else if (e.code == 'ArrowRight') { } else if (e.code == 'ArrowRight') {
//right //right
if ($('#imagemodal').hasClass('open')) { if (document.querySelector('#imagemodal').classList.contains('open')) {
imgCont('next') imgCont('next')
return false return false
} }
@ -193,7 +186,7 @@ $(function($) {
return false return false
} else if (e.code == 'ArrowDown') { } else if (e.code == 'ArrowDown') {
//down //down
if ($('#imagemodal').hasClass('open')) { if (document.querySelector('#imagemodal').classList.contains('open')) {
return false return false
} }
selectedToot++ selectedToot++
@ -210,24 +203,21 @@ $(function($) {
} }
} }
//選択時 //選択時
const selectedId = document.querySelector('.selectedToot').getAttribute('unique-id')
const selectedAcctIds = document.querySelector(`#timeline_${selectedColumn}`).getAttribute('data-acct')
if (e.keyCode == 70) { if (e.keyCode == 70) {
var id = $('.selectedToot').attr('unique-id') fav(selectedId, selectedAcctIds, false)
var acct_id = $('#timeline_' + selectedColumn).attr('data-acct')
fav(id, acct_id, false)
return false return false
} }
if (e.keyCode == 66) { if (e.keyCode == 66) {
var id = $('.selectedToot').attr('unique-id') rt(selectedId, selectedAcctIds, false)
var acct_id = $('#timeline_' + selectedColumn).attr('data-acct')
rt(id, acct_id, false)
return false return false
} }
if (e.keyCode == 82) { if (e.keyCode == 82) {
var id = $('.selectedToot').attr('unique-id') const target = document.querySelector('.selectedToot .rep-btn')
var acct_id = $('#timeline_' + selectedColumn).attr('data-acct') const ats_cm = target.getAttribute('data-men')
var ats_cm = $('.selectedToot .rep-btn').attr('data-men') const mode = target.getAttribute('data-visen')
var mode = $('.selectedToot .rep-btn').attr('data-visen') re(selectedId, ats_cm, selectedAcctIds, mode)
re(id, ats_cm, acct_id, mode)
return false return false
} }
} }
@ -237,9 +227,10 @@ $(function($) {
//C+S+(No):ワンクリ //C+S+(No):ワンクリ
if ((event.metaKey || event.ctrlKey) && event.shiftKey) { if ((event.metaKey || event.ctrlKey) && event.shiftKey) {
if (e.keyCode >= 49 && e.keyCode <= 51) { if (e.keyCode >= 49 && e.keyCode <= 51) {
var no = e.keyCode - 48 const no = e.keyCode - 48
if (localStorage.getItem('oks-' + no)) { const oks = localStorage.getItem('oks-' + no)
$('#textarea').val($('#textarea').val() + localStorage.getItem('oks-' + no)) if (oks) {
postBox.value = postBox.value + oks
} }
return false return false
} }
@ -248,28 +239,29 @@ $(function($) {
} }
}) })
//クリアボタン //クリアボタン
$('#clear').click(function() { document.getElementById('clear').addEventListener('click', clear)
clear()
})
}) })
//選択する //選択する
function tootSelector(column, toot) { function tootSelector(column, toot) {
$('.cvo').removeClass('selectedToot') const selectedToot = document.querySelector('.selectedToot')
$('#timeline_' + column + ' .cvo') let rect = {top: 0}
.eq(toot) if (selectedToot) {
.addClass('selectedToot') selectedToot.classList.remove('selectedToot')
var scr = $('.tl-box[tlid=' + column + ']').scrollTop() rect = selectedToot.getBoundingClientRect()
var elem = $('.selectedToot').offset().top }
var top = elem - $('.tl-box').height() + scr document.querySelectorAll(`#timeline_${column} .cvo`)[toot].classList.add('selectedToot')
const scr = document.querySelector(`#tlBox${column}`).scrollTop
const elem = rect.top + document.body.scrollTop
let top = elem - getHeight('.tl-box') + scr
if (top > 0) { if (top > 0) {
top = top + $('.selectedToot').height() top = top + getHeight('.selectedToot')
if (top > scr) { if (top > scr) {
$('.tl-box[tlid=' + column + ']').animate({ scrollTop: top }) $(`#tlBox${column}`).animate({ scrollTop: top })
} }
} else if (elem < 0) { } else if (elem < 0) {
var to = scr + elem - $('.selectedToot').height() const to = scr + elem - getHeight('.selectedToot')
if (to < scr) { if (to < scr) {
$('.tl-box[tlid=' + column + ']').animate({ scrollTop: to }) $(`#tlBox${column}`).animate({ scrollTop: to })
} }
} }
} }

View File

@ -1,7 +1,8 @@
//モーダル・ドロップダウンの各種設定 //モーダル・ドロップダウンの各種設定
$(document).ready(function () { $(document).ready(function () {
// the "href" attribute of the modal trigger must specify the modal ID that wants to be triggered // the "href" attribute of the modal trigger must specify the modal ID that wants to be triggered
$('.modal').modal({ const modals = document.querySelectorAll('.modal')
M.Modal.init(modals, {
inDuration: 300, inDuration: 300,
outDuration: 225, outDuration: 225,
constrainWidth: false, // Does not change width of dropdown to that of the activator constrainWidth: false, // Does not change width of dropdown to that of the activator
@ -10,8 +11,9 @@ $(document).ready(function () {
belowOrigin: false, // Displays dropdown below the button belowOrigin: false, // Displays dropdown below the button
alignment: 'left', // Displays dropdown with edge aligned to the left of button alignment: 'left', // Displays dropdown with edge aligned to the left of button
stopPropagation: false stopPropagation: false
}); })
$('.dropdown-trigger').dropdown({ const dropdown = document.querySelectorAll('.modal')
M.Dropdown.init(dropdown, {
inDuration: 300, inDuration: 300,
outDuration: 225, outDuration: 225,
constrainWidth: false, // Does not change width of dropdown to that of the activator constrainWidth: false, // Does not change width of dropdown to that of the activator
@ -20,10 +22,10 @@ $(document).ready(function () {
belowOrigin: false, // Displays dropdown below the button belowOrigin: false, // Displays dropdown below the button
alignment: 'left', // Displays dropdown with edge aligned to the left of button alignment: 'left', // Displays dropdown with edge aligned to the left of button
stopPropagation: false // Stops event propagation stopPropagation: false // Stops event propagation
} })
); M.Collapsible.init(document.querySelectorAll('.collapsible'));
$('.collapsible').collapsible(); const videoModal = document.querySelectorAll('#videomodal')
$('#videomodal').modal({ M.Modal.init(videoModal, {
onCloseEnd: stopVideo onCloseEnd: stopVideo
}); })
}); })

View File

@ -1,31 +1,31 @@
var sha256 = function sha256(ascii) { const sha256 = function sha256(ascii) {
function rightRotate(value, amount) { function rightRotate(value, amount) {
return (value >>> amount) | (value << (32 - amount)); return (value >>> amount) | (value << (32 - amount));
}; };
var mathPow = Math.pow; const mathPow = Math.pow;
var maxWord = mathPow(2, 32); const maxWord = mathPow(2, 32);
var lengthProperty = 'length' const lengthProperty = 'length'
var i, j; // Used as a counter across the whole file let i, j; // Used as a counter across the whole file
var result = '' let result = ''
var words = []; let words = [];
var asciiBitLength = ascii[lengthProperty] * 8; const asciiBitLength = ascii[lengthProperty] * 8;
//* caching results is optional - remove/add slash from front of this line to toggle //* caching results is optional - remove/add slash from front of this line to toggle
// Initial hash value: first 32 bits of the fractional parts of the square roots of the first 8 primes // Initial hash value: first 32 bits of the fractional parts of the square roots of the first 8 primes
// (we actually calculate the first 64, but extra values are just ignored) // (we actually calculate the first 64, but extra values are just ignored)
var hash = sha256.h = sha256.h || []; let hash = sha256.h = sha256.h || [];
// Round constants: first 32 bits of the fractional parts of the cube roots of the first 64 primes // Round constants: first 32 bits of the fractional parts of the cube roots of the first 64 primes
var k = sha256.k = sha256.k || []; let k = sha256.k = sha256.k || [];
var primeCounter = k[lengthProperty]; let primeCounter = k[lengthProperty];
/*/ /*/
var hash = [], k = []; var hash = [], k = [];
var primeCounter = 0; var primeCounter = 0;
//*/ //*/
var isComposite = {}; let isComposite = {};
for (var candidate = 2; primeCounter < 64; candidate++) { for (let candidate = 2; primeCounter < 64; candidate++) {
if (!isComposite[candidate]) { if (!isComposite[candidate]) {
for (i = 0; i < 313; i += candidate) { for (i = 0; i < 313; i += candidate) {
isComposite[i] = candidate; isComposite[i] = candidate;
@ -47,21 +47,21 @@ var sha256 = function sha256(ascii) {
// process each chunk // process each chunk
for (j = 0; j < words[lengthProperty];) { for (j = 0; j < words[lengthProperty];) {
var w = words.slice(j, j += 16); // The message is expanded into 64 words as part of the iteration let w = words.slice(j, j += 16); // The message is expanded into 64 words as part of the iteration
var oldHash = hash; const oldHash = hash;
// This is now the undefinedworking hash", often labelled as variables a...g // This is now the undefinedworking hash", often labelled as variables a...g
// (we have to truncate as well, otherwise extra entries at the end accumulate // (we have to truncate as well, otherwise extra entries at the end accumulate
hash = hash.slice(0, 8); hash = hash.slice(0, 8);
for (i = 0; i < 64; i++) { for (i = 0; i < 64; i++) {
var i2 = i + j; const i2 = i + j;
// Expand the message into 64 words // Expand the message into 64 words
// Used below if // Used below if
var w15 = w[i - 15], w2 = w[i - 2]; const w15 = w[i - 15], w2 = w[i - 2];
// Iterate // Iterate
var a = hash[0], e = hash[4]; const a = hash[0], e = hash[4];
var temp1 = hash[7] const temp1 = hash[7]
+ (rightRotate(e, 6) ^ rightRotate(e, 11) ^ rightRotate(e, 25)) // S1 + (rightRotate(e, 6) ^ rightRotate(e, 11) ^ rightRotate(e, 25)) // S1
+ ((e & hash[5]) ^ ((~e) & hash[6])) // ch + ((e & hash[5]) ^ ((~e) & hash[6])) // ch
+ k[i] + k[i]
@ -74,7 +74,7 @@ var sha256 = function sha256(ascii) {
) | 0 ) | 0
); );
// This is only used once, so *could* be moved below, but it only saves 4 bytes and makes things unreadble // This is only used once, so *could* be moved below, but it only saves 4 bytes and makes things unreadble
var temp2 = (rightRotate(a, 2) ^ rightRotate(a, 13) ^ rightRotate(a, 22)) // S0 const temp2 = (rightRotate(a, 2) ^ rightRotate(a, 13) ^ rightRotate(a, 22)) // S0
+ ((a & hash[1]) ^ (a & hash[2]) ^ (hash[1] & hash[2])); // maj + ((a & hash[1]) ^ (a & hash[2]) ^ (hash[1] & hash[2])); // maj
hash = [(temp1 + temp2) | 0].concat(hash); // We don't bother trimming off the extra ones, they're harmless as long as we're truncating when we do the slice() hash = [(temp1 + temp2) | 0].concat(hash); // We don't bother trimming off the extra ones, they're harmless as long as we're truncating when we do the slice()
@ -88,7 +88,7 @@ var sha256 = function sha256(ascii) {
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
for (j = 3; j + 1; j--) { for (j = 3; j + 1; j--) {
var b = (hash[i] >> (j * 8)) & 255; const b = (hash[i] >> (j * 8)) & 255;
result += ((b < 16) ? 0 : '') + b.toString(16); result += ((b < 16) ? 0 : '') + b.toString(16);
} }
} }

View File

@ -36,7 +36,7 @@
return inWords($.timeago.datetime(timestamp)); return inWords($.timeago.datetime(timestamp));
} }
}; };
var $t = $.timeago; const $t = $.timeago;
$.extend($.timeago, { $.extend($.timeago, {
settings: { settings: {
refreshMillis: 60000, refreshMillis: 60000,
@ -72,9 +72,9 @@
throw 'timeago allowPast and allowFuture settings can not both be set to false.'; throw 'timeago allowPast and allowFuture settings can not both be set to false.';
} }
var $l = this.settings.strings; const $l = this.settings.strings;
var prefix = $l.prefixAgo; let prefix = $l.prefixAgo;
var suffix = $l.suffixAgo; let suffix = $l.suffixAgo;
if (this.settings.allowFuture) { if (this.settings.allowFuture) {
if (distanceMillis < 0) { if (distanceMillis < 0) {
prefix = $l.prefixFromNow; prefix = $l.prefixFromNow;
@ -86,19 +86,19 @@
return this.settings.strings.inPast; return this.settings.strings.inPast;
} }
var seconds = Math.abs(distanceMillis) / 1000; const seconds = Math.abs(distanceMillis) / 1000;
var minutes = seconds / 60; const minutes = seconds / 60;
var hours = minutes / 60; const hours = minutes / 60;
var days = hours / 24; const days = hours / 24;
var years = days / 365; const years = days / 365;
function substitute(stringOrFunction, number) { function substitute(stringOrFunction, number) {
var string = $.isFunction(stringOrFunction) ? stringOrFunction(number, distanceMillis) : stringOrFunction; const string = $.isFunction(stringOrFunction) ? stringOrFunction(number, distanceMillis) : stringOrFunction;
var value = ($l.numbers && $l.numbers[number]) || number; const value = ($l.numbers && $l.numbers[number]) || number;
return string.replace(/%d/i, value); return string.replace(/%d/i, value);
} }
var words = seconds < 45 && substitute($l.seconds, Math.round(seconds)) || const words = seconds < 45 && substitute($l.seconds, Math.round(seconds)) ||
seconds < 90 && substitute($l.minute, 1) || seconds < 90 && substitute($l.minute, 1) ||
minutes < 45 && substitute($l.minutes, Math.round(minutes)) || minutes < 45 && substitute($l.minutes, Math.round(minutes)) ||
minutes < 90 && substitute($l.hour, 1) || minutes < 90 && substitute($l.hour, 1) ||
@ -110,13 +110,13 @@
years < 1.5 && substitute($l.year, 1) || years < 1.5 && substitute($l.year, 1) ||
substitute($l.years, Math.round(years)); substitute($l.years, Math.round(years));
var separator = $l.wordSeparator || ""; const separator = $l.wordSeparator || "";
if ($l.wordSeparator === undefined) { separator = " "; } if ($l.wordSeparator === undefined) { separator = " "; }
return $.trim([prefix, words, suffix].join(separator)); return $.trim([prefix, words, suffix].join(separator));
}, },
parse: function (iso8601) { parse: function (iso8601) {
var s = $.trim(iso8601); let s = $.trim(iso8601);
s = s.replace(/\.\d+/, ""); // remove milliseconds s = s.replace(/\.\d+/, ""); // remove milliseconds
s = s.replace(/-/, "/").replace(/-/, "/"); s = s.replace(/-/, "/").replace(/-/, "/");
s = s.replace(/T/, " ").replace(/Z/, " UTC"); s = s.replace(/T/, " ").replace(/Z/, " UTC");
@ -125,7 +125,7 @@
return new Date(s); return new Date(s);
}, },
datetime: function (elem) { datetime: function (elem) {
var iso8601 = $t.isTime(elem) ? $(elem).attr("datetime") : $(elem).attr("title"); const iso8601 = $t.isTime(elem) ? $(elem).attr("datetime") : $(elem).attr("title");
return $t.parse(iso8601); return $t.parse(iso8601);
}, },
isTime: function (elem) { isTime: function (elem) {
@ -137,18 +137,18 @@
// functions that can be called via $(el).timeago('action') // functions that can be called via $(el).timeago('action')
// init is default when no action is given // init is default when no action is given
// functions are called with context of a single element // functions are called with context of a single element
var functions = { const functions = {
init: function () { init: function () {
functions.dispose.call(this); functions.dispose.call(this);
var refresh_el = $.proxy(refresh, this); const refresh_el = $.proxy(refresh, this);
refresh_el(); refresh_el();
var $s = $t.settings; const $s = $t.settings;
if ($s.refreshMillis > 0) { if ($s.refreshMillis > 0) {
this._timeagoInterval = setInterval(refresh_el, $s.refreshMillis); this._timeagoInterval = setInterval(refresh_el, $s.refreshMillis);
} }
}, },
update: function (timestamp) { update: function (timestamp) {
var date = (timestamp instanceof Date) ? timestamp : $t.parse(timestamp); const date = (timestamp instanceof Date) ? timestamp : $t.parse(timestamp);
$(this).data('timeago', { datetime: date }); $(this).data('timeago', { datetime: date });
if ($t.settings.localeTitle) { if ($t.settings.localeTitle) {
$(this).attr("title", date.toLocaleString()); $(this).attr("title", date.toLocaleString());
@ -168,7 +168,7 @@
}; };
$.fn.timeago = function (action, options) { $.fn.timeago = function (action, options) {
var fn = action ? functions[action] : functions.init; const fn = action ? functions[action] : functions.init;
if (!fn) { if (!fn) {
throw new Error("Unknown function name '" + action + "' for timeago"); throw new Error("Unknown function name '" + action + "' for timeago");
} }
@ -180,7 +180,7 @@
}; };
function refresh() { function refresh() {
var $s = $t.settings; const $s = $t.settings;
//check if it's still visible //check if it's still visible
if ($s.autoDispose && !$.contains(document.documentElement, this)) { if ($s.autoDispose && !$.contains(document.documentElement, this)) {
@ -189,7 +189,7 @@
return this; return this;
} }
var data = prepareData(this); const data = prepareData(this);
if (!isNaN(data.datetime)) { if (!isNaN(data.datetime)) {
if ($s.cutoff === 0 || Math.abs(distance(data.datetime)) < $s.cutoff) { if ($s.cutoff === 0 || Math.abs(distance(data.datetime)) < $s.cutoff) {
@ -207,7 +207,7 @@
element = $(element); element = $(element);
if (!element.data("timeago")) { if (!element.data("timeago")) {
element.data("timeago", { datetime: $t.datetime(element) }); element.data("timeago", { datetime: $t.datetime(element) });
var text = $.trim(element.text()); const text = $.trim(element.text());
if ($t.settings.localeTitle) { if ($t.settings.localeTitle) {
element.attr("title", element.data('timeago').datetime.toLocaleString()); element.attr("title", element.data('timeago').datetime.toLocaleString());
} else if (text.length > 0 && !($t.isTime(element) && element.attr("title"))) { } else if (text.length > 0 && !($t.isTime(element) && element.attr("title"))) {

View File

@ -1,41 +1,15 @@
//バージョンチェッカー //バージョンチェッカー
function verck(ver, jp) { async function verck(ver) {
console.log('%c Welcome😊 ' + ver, 'color: red;font-size:200%;') console.log('%c Welcome😊 ' + ver, 'color: red;font-size:200%;')
$('body').addClass(localStorage.getItem('platform')) document.querySelector('body').classList.add(localStorage.getItem('platform'))
var date = new Date() const date = new Date()
var showVer = false let showVer = false
if (localStorage.getItem('ver') != ver && localStorage.getItem('winstore')) { if (localStorage.getItem('ver') != ver && localStorage.getItem('winstore')) {
//ちょっと削除とリンク解析の都合上アレ(s)
//対象外のアプデ:storageが20の最初まで"Usamin (18.6.5)"
if (!localStorage.getItem('usamin_18_6_5_flag')) {
localStorage.setItem('usamin_18_6_5_flag', true)
var multi = localStorage.getItem('column')
var obj = JSON.parse(multi)
for (var i = 0; i < obj.length; i++) {
localStorage.removeItem('card_' + i)
}
}
//ちょっと削除とリンク解析の都合上アレ(e)
showVer = true showVer = true
console.log('%c Thank you for your update🎉', 'color: red;font-size:200%;') console.log('%c Thank you for your update🎉', 'color: red;font-size:200%;')
$(document).ready(function() {
if (localStorage.getItem('winstore') && !pwa) { if (localStorage.getItem('winstore') && !pwa) {
$('#releasenote').modal('open') openRN()
} }
verp = ver.replace('(', '')
verp = verp.replace('.', '-')
verp = verp.replace('.', '-')
verp = verp.replace('[', '-')
verp = verp.replace(']', '')
verp = verp.replace(')', '')
verp = verp.replace(' ', '_')
console.log('%c ' + verp, 'color: red;font-size:200%;')
if (lang.language == 'ja') {
$('#release-' + verp).show()
} else {
$('#release-en').show()
}
})
} }
localStorage.setItem('ver', ver) localStorage.setItem('ver', ver)
if (!showVer) { if (!showVer) {
@ -45,88 +19,72 @@ function verck(ver, jp) {
!localStorage.getItem('showSupportMe') !localStorage.getItem('showSupportMe')
) { ) {
if (date.getMonth() == 11) { if (date.getMonth() == 11) {
var yrs = date.getFullYear() + 1 yrs = date.getFullYear() + 1
var nextmonth = yrs * 100 + 1 nextmonth = yrs * 100 + 1
} else { } else {
var yrs = date.getFullYear() yrs = date.getFullYear()
var nextmonth = yrs * 100 + date.getMonth() + 2 nextmonth = yrs * 100 + date.getMonth() + 2
} }
if (lang.language != 'ja') { if (lang.language != 'ja') {
$('#support-btm-ja').addClass('hide') document.querySelector('#support-btm-ja').classList.add('hide')
$('#support-btm-en').removeClass('hide') document.querySelector('#support-btm-en').classList.remove('hide')
} }
localStorage.setItem('showSupportMe', nextmonth) localStorage.setItem('showSupportMe', nextmonth)
$('#support-btm').removeClass('hide') document.querySelector('#support-btm').classList.remove('hide')
$('#support-btm').animate( document.querySelector('#support-btm').animate([
{ {
bottom: '0' bottom: '-500px'
}, },
{ {
duration: 300 bottom: '0'
} }
) ], 300);
} }
} }
var platform = localStorage.getItem('platform') const platform = localStorage.getItem('platform')
console.log('Your platform:' + platform) console.log('Your platform:' + platform)
if (!localStorage.getItem('winstore') && !pwa) { if (!localStorage.getItem('winstore') && !pwa) {
$('#start').css('display', 'flex') document.querySelector('#start').style.display = 'flex'
} }
let winstore = false
if ( if (
localStorage.getItem('winstore') == 'brewcask' || localStorage.getItem('winstore') == 'brewcask' ||
localStorage.getItem('winstore') == 'snapcraft' || localStorage.getItem('winstore') == 'snapcraft' ||
localStorage.getItem('winstore') == 'winstore' localStorage.getItem('winstore') == 'winstore'
) { ) {
var winstore = true winstore = true
} else { } else {
var winstore = false winstore = false
} }
var l = 5 const l = 5
// 生成する文字列に含める文字セット // 生成する文字列に含める文字セット
var c = 'abcdefghijklmnopqrstuvwxyz0123456789' const c = 'abcdefghijklmnopqrstuvwxyz0123456789'
var cl = c.length const cl = c.length
var r = '' let r = ''
for (var i = 0; i < l; i++) { for (var i = 0; i < l; i++) {
r += c[Math.floor(Math.random() * cl)] r += c[Math.floor(Math.random() * cl)]
} }
var start = 'https://thedesk.top/ver.json' const start = 'https://thedesk.top/ver.json'
fetch(start, { let mess
method: 'GET' try {
}) mess = await getApi(start, null)
.then(function(response) { } catch {
if (!response.ok) { return false
response.text().then(function(text) {
setLog(response.url, response.status, text)
})
} }
return response.json()
})
.catch(function(error) {
todo(error)
setLog(start, 'JSON', error)
setLog(start, 'JSON', error)
console.error(error)
})
.then(function(mess) {
console.table(mess) console.table(mess)
if (mess) { if (mess) {
//askjp_jp_ua: 2019年10月24日、mstdn.jpによるユーザーエージェントアクセス制限 let newest = null
if (jp && mess.jp_ua && !localStorage.getItem('askjp_jp_ua')) {
localStorage.setItem('askjp_jp_ua', true)
$('#askjp_jp_ua').removeClass('hide')
}
var platform = localStorage.getItem('platform')
if (platform == 'darwin') { if (platform == 'darwin') {
var newest = mess.desk_mac newest = mess.desk_mac
} else { } else {
var newest = mess.desk newest = mess.desk
} }
if (newest == ver) { if (newest == ver) {
todo(lang.lang_version_usever.replace('{{ver}}', mess.desk)) todo(lang.lang_version_usever.replace('{{ver}}', mess.desk))
//betaかWinstoreならアプデチェックしない //betaかWinstoreならアプデチェックしない
} else if (ver.indexOf('beta') != -1 || winstore) { } else if (ver.indexOf('beta') != -1 || winstore) {
//skipped
} else { } else {
localStorage.removeItem('instance')
if (localStorage.getItem('new-ver-skip')) { if (localStorage.getItem('new-ver-skip')) {
if (localStorage.getItem('next-ver') != newest) { if (localStorage.getItem('next-ver') != newest) {
postMessage(['sendSinmpleIpc', 'update'], '*') postMessage(['sendSinmpleIpc', 'update'], '*')
@ -139,201 +97,146 @@ function verck(ver, jp) {
} }
} }
} }
}) let lni = localStorage.getItem('last-notice-id')
if (!localStorage.getItem('last-notice-id')) { if (!lni) {
localStorage.setItem('last-notice-id', 0) localStorage.setItem('last-notice-id', 0)
lni = 0
} }
var start = 'https://thedesk.top/notice/index.php?since_id=' + localStorage.getItem('last-notice-id') const getNotice = 'https://thedesk.top/notice/index.php?since_id=' + lni
fetch(start, { let notices
method: 'GET', try {
cors: true notices = await getApi(getNotice, null)
}) } catch {
.then(function(response) { return false
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text)
})
} }
return response.json() if (notices.length < 1) {
})
.catch(function(error) {
todo(error)
setLog(start, 'JSON', error)
console.error(error)
})
.then(function(mess) {
if (mess.length < 1) {
return false return false
} else { } else {
var last = localStorage.getItem('last-notice-id') localStorage.setItem('last-notice-id', notices[0].ID)
localStorage.setItem('last-notice-id', mess[0].ID) for (i = 0; i < notices.length; i++) {
for (i = 0; i < mess.length; i++) { var obj = notices[i]
var obj = mess[i] if (obj.ID * 1 <= lni) {
if (obj.ID * 1 <= last) {
break break
} else { } else {
if (obj.type == 'textv2') { toastInterpret(obj)
if (~obj.languages.indexOf(lang.language)) {
var showVer = true
if (obj.toot != '') {
var toot =
'<button class="btn-flat toast-action" onclick="detEx(\'' +
obj.toot +
"','main')\">Show</button>"
} else {
var toot = ''
}
if (obj.ver != '') {
if (obj.ver == ver) {
showVer = true
} else {
showVer = false
}
}
if (obj.domain != '') {
var multi = localStorage.getItem('multi')
if (multi) {
showVer = false
var accts = JSON.parse(multi)
Object.keys(accts).forEach(function(key) {
var acct = accts[key]
if (acct.domain == obj.domain) {
showVer = true
}
})
}
}
if (showVer) {
M.toast({
html:
escapeHTML(obj.text) +
toot +
'<span class="sml grey-text">(スライドして消去)</span>',
displayLength: 86400
})
} }
} }
} }
}
}
}
})
} }
var infostreaming = false let infostreaming = false
function infowebsocket() { function infowebsocket() {
infows = new WebSocket('wss://thedesk.top/ws/') infows = new WebSocket('wss://thedesk.top/ws/')
infows.onopen = function(mess) { infows.onopen = function (mess) {
console.log([tlid, ':Connect Streaming Info:', mess]) console.log([tlid, ':Connect Streaming Info:', mess])
infostreaming = true infostreaming = true
} }
infows.onmessage = function(mess) { infows.onmessage = function (mess) {
console.log([tlid, ':Receive Streaming:', JSON.parse(mess.data)]) console.log([tlid, ':Receive Streaming:', JSON.parse(mess.data)])
var obj = JSON.parse(mess.data) const obj = JSON.parse(mess.data)
if (obj.type != 'counter') {
if (obj.type == 'textv2') {
if (~obj.languages.indexOf(lang.language)) {
localStorage.setItem('last-notice-id', obj.id) localStorage.setItem('last-notice-id', obj.id)
var showVer = true if (obj.type != 'counter') {
if (obj.toot != '') { toastInterpret(obj)
var toot =
'<button class="btn-flat toast-action" onclick="detEx(\'' +
obj.toot +
"','main')\">Show</button>"
} else { } else {
var toot = '' const people = document.querySelector('#persons')
} if(people) {
if (obj.ver != '') { people.innerText = obj.text
if (obj.ver == ver) {
showVer = true
} else {
showVer = false
}
}
if (obj.domain != '') {
var multi = localStorage.getItem('multi')
if (multi) {
showVer = false
var accts = JSON.parse(multi)
Object.keys(accts).forEach(function(key) {
var acct = accts[key]
if (acct.domain == obj.domain) {
showVer = true
}
})
}
}
if (showVer) {
console.log(obj.text)
console.log(escapeHTML(obj.text))
M.toast({
html:
escapeHTML(obj.text) +
toot +
'<span class="sml grey-text">(スライドして消去)</span>',
displayLength: 86400
})
} }
} }
} }
} else { infows.onerror = function (error) {
$('#persons').text(obj.text)
}
}
infows.onerror = function(error) {
infostreaming = false infostreaming = false
console.error('Error closing:info') console.error('Error closing:info')
console.error(error) console.error(error)
return false return false
} }
infows.onclose = function() { infows.onclose = function () {
infostreaming = false infostreaming = false
console.error('Closing:info') console.error('Closing:info')
} }
} }
setInterval(function() { setInterval(function () {
if (!infostreaming) { if (!infostreaming) {
console.log('try to connect to base-streaming') console.log('try to connect to base-streaming')
infowebsocket() infowebsocket()
} }
}, 10000) }, 10000)
function openRN() { async function toastInterpret(obj) {
$('#releasenote').modal('open') if (obj.type == 'textv2') {
if (lang.language == 'ja') { if (~obj.languages.indexOf(lang.language)) {
verp = ver.replace('(', '') let showVer = true
verp = verp.replace('.', '-') let toot = null
verp = verp.replace('.', '-') if (obj.toot != '') {
verp = verp.replace('[', '-') toot = `<button class="btn-flat toast-action" data-toot="${obj.toot}">Show</button>`
verp = verp.replace(']', '') }
verp = verp.replace(')', '') if (obj.ver == ver) {
verp = verp.replace(' ', '_') showVer = true
$('#release-' + verp).show()
} else { } else {
$('#release-en').show() showVer = false
}
if (obj.domain != '') {
const multi = localStorage.getItem('multi')
if (multi) {
showVer = false
const accts = JSON.parse(multi)
const keys = Object.keys(accts)
for (let i = 0; i < accts.length; i++) {
const key = keys[i]
const acct = accts[key]
if (acct.domain == obj.domain) {
showVer = true
break
}
}
}
}
if (showVer) {
M.toast({
html: `${escapeHTML(obj.text)} ${toot} <span class="sml grey-text">(スライドして消去)</span>`,
displayLength: 86400
})
await sleep(500)
const targets = document.querySelectorAll('.toast-action')
for (let j = 0; j < targets.length; j++) {
const target = targets[j]
const toot = target.getAttribute('data-toot')
target.addEventListener('click', () => detEx(toot, 'main'))
}
}
}
} }
} }
function closeSupport() { function openRN() {
$('#support-btm').animate( console.log(kirishima)
M.Modal.getInstance(document.querySelector('#releasenote')).open()
if (lang.language == 'ja') {
verp = ver.replace('(', '').replace('.', '-').replace('.', '-').replace('[', '-').replace(']', '').replace(')', '').replace(' ', '_')
showElm(`#release-${verp}`)
} else {
showElm('#release-en')
}
}
async function closeSupport() {
document.querySelector('#support-btm').animate([
{ {
bottom: '-300px' bottom: '0'
}, },
{ {
duration: 300, bottom: '-300px'
complete: function() {
$('#support-btm').addClass('hide')
} }
} ], 300);
) await sleep(300)
document.querySelector('#support-btm').classList.add('hide')
} }
function storeDialog(platform, ver) { function storeDialog(platform, ver) {
if($('body').hasClass('accessibility')) return false if (document.querySelector('body').classList.contain('accessibility')) return false
let mes = false
if (platform == 'win32') { if (platform == 'win32') {
var mes = lang.lang_version_platform mes = lang.lang_version_platform
} else if (platform == 'linux') { } else if (platform == 'linux') {
var mes = lang.lang_version_platform_linux mes = lang.lang_version_platform_linux
} else if (platform == 'darwin') { } else if (platform == 'darwin') {
var mes = lang.lang_version_platform_mac mes = lang.lang_version_platform_mac
} else {
var mes = false
} }
if (mes) { if (mes) {
Swal.fire({ Swal.fire({
@ -354,52 +257,22 @@ function storeDialog(platform, ver) {
} }
localStorage.setItem('ver', ver) localStorage.setItem('ver', ver)
showVer = true showVer = true
if(pwa) return false if (pwa) return false
console.log('%c Thank you for your update🎉', 'color: red;font-size:200%;') console.log('%c Thank you for your update🎉', 'color: red;font-size:200%;')
$(document).ready(function() { openRN()
$('#releasenote').modal('open')
verp = ver.replace('(', '')
verp = verp.replace('.', '-')
verp = verp.replace('.', '-')
verp = verp.replace('[', '-')
verp = verp.replace(']', '')
verp = verp.replace(')', '')
verp = verp.replace(' ', '_')
console.log('%c ' + verp, 'color: red;font-size:200%;')
if (lang.language == 'ja') {
$('#release-' + verp).show()
} else {
$('#release-en').show()
}
})
}) })
} else { } else {
localStorage.setItem('ver', ver) localStorage.setItem('ver', ver)
showVer = true showVer = true
console.log('%c Thank you for your update🎉', 'color: red;font-size:200%;') console.log('%c Thank you for your update🎉', 'color: red;font-size:200%;')
$(document).ready(function() { openRN()
if(pwa) return false
$('#releasenote').modal('open')
verp = ver.replace('(', '')
verp = verp.replace('.', '-')
verp = verp.replace('.', '-')
verp = verp.replace('[', '-')
verp = verp.replace(']', '')
verp = verp.replace(')', '')
verp = verp.replace(' ', '_')
console.log('%c ' + verp, 'color: red;font-size:200%;')
if (lang.language == 'ja') {
$('#release-' + verp).show()
} else {
$('#release-en').show()
}
})
} }
} }
function closeStart() { function closeStart() {
$('#start').css('display', 'none') $('#start').css('display', 'none')
var platform = localStorage.getItem('platform') document.querySelector('#start').style.display = 'none'
var ver = localStorage.getItem('ver') const platform = localStorage.getItem('platform')
const ver = localStorage.getItem('ver')
storeDialog(platform, ver) storeDialog(platform, ver)
} }

View File

@ -1,5 +1,5 @@
var defaultemojiList = ['activity', 'flag', 'food', 'nature', 'object', 'people', 'place', 'symbol'] const defaultemojiList = ['activity', 'flag', 'food', 'nature', 'object', 'people', 'place', 'symbol']
var defaultemoji = { const defaultemoji = {
activity: activity, activity: activity,
flag: flag, flag: flag,
food: food, food: food,
@ -9,8 +9,18 @@ var defaultemoji = {
place: place, place: place,
symbol: symbol symbol: symbol
} }
let defaultemojiname = {
activity: 'Activities',
flag: 'Flags',
food: 'Foods',
nature: 'Nature',
object: 'Tools',
people: 'People',
place: 'Places',
symbol: 'Symbols'
}
if (lang == 'ja') { if (lang == 'ja') {
var defaultemojiname = { defaultemojiname = {
activity: '活動', activity: '活動',
flag: '国旗', flag: '国旗',
food: '食べ物', food: '食べ物',
@ -20,32 +30,22 @@ if (lang == 'ja') {
place: '場所', place: '場所',
symbol: '記号' symbol: '記号'
} }
} else {
var defaultemojiname = {
activity: 'Activities',
flag: 'Flags',
food: 'Foods',
nature: 'Nature',
object: 'Tools',
people: 'People',
place: 'Places',
symbol: 'Symbols'
}
} }
function defaultEmoji(target) { function defaultEmoji(target) {
var announcement = false let announcement = false
if ($('#media').val() == 'announcement') { if (document.querySelector('#media').value == 'announcement') {
announcement = true announcement = true
} }
var json = defaultemoji[target] const json = defaultemoji[target]
var emojis = '' const keymap = Object.keys(json)
Object.keys(json).forEach(function(key) { let emojis = ''
var emoji = json[key] for (let i = 0; i < json.length; i++) {
const key = keymap[i]
const emoji = json[key]
let def = `<a data-shortcode="${emoji['shortcode']}" class="pointer defEmoji">`
if (announcement) { if (announcement) {
var def = `<a onclick="emojiReactionDef('${emoji['shortcode']}')" class="pointer">` def = `<a data-shortcode="${emoji['shortcode']}" class="pointer defEmoji">`
} else {
var def = `<a onclick="defEmoji('${emoji['shortcode']}')" class="pointer">`
} }
emojis = emojis =
emojis + emojis +
@ -54,52 +54,39 @@ function defaultEmoji(target) {
width: 20px; height: 20px; display: inline-block; background-image: url('../../img/sheet.png'); background-size: 4900%; width: 20px; height: 20px; display: inline-block; background-image: url('../../img/sheet.png'); background-size: 4900%;
background-position:${emoji['css']};"></span> background-position:${emoji['css']};"></span>
</a>` </a>`
}) }
$('#emoji-list').html(emojis) document.querySelector('#emoji-list').innerHTML = emojis
$('#now-emoji').text(lang.lang_defaultemojis_text.replace('{{cat}}', defaultemojiname[target])) document.querySelector('#now-emoji').innerText = lang.lang_defaultemojis_text.replace('{{cat}}', defaultemojiname[target])
$('.emoji-control').addClass('hide') document.querySelector('.emoji-control').classList.add('hide')
const targets = document.querySelectorAll('.defEmoji')
for (let j = 0; j < targets.length; j++) {
const target = targets[j]
const sc = target.getAttribute('data-shortcode')
target.addEventListener('click', () => defEmoji(sc))
}
} }
function customEmoji() { function customEmoji() {
$('#emoji-suggest').val('') document.querySelector('#emoji-suggest').value = ''
$('.emoji-control').removeClass('hide') document.querySelector('.emoji-control').classList.remove('hide')
emojiList('home') emojiList('home')
} }
function defEmoji(target) { function defEmoji(target) {
var selin = $('#textarea').prop('selectionStart') const textarea = document.querySelector('#textarea')
let selin = textarea.selectionStart
if (!selin) { if (!selin) {
selin = 0 selin = 0
} }
var emojiraw = newpack.filter(function(item, index) { const hex = emojipack[target].unified.split('-')
if (item.short_name == target) return true let emoji = twemoji.convert.fromCodePoint(hex[0])
})
var hex = emojiraw[0].unified.split('-')
if (hex.length === 2) { if (hex.length === 2) {
emoji = twemoji.convert.fromCodePoint(hex[0]) + twemoji.convert.fromCodePoint(hex[1]) emoji = twemoji.convert.fromCodePoint(hex[0]) + twemoji.convert.fromCodePoint(hex[1])
} else {
emoji = twemoji.convert.fromCodePoint(hex[0])
} }
var now = $('#textarea').val() const now = textarea.value
var before = now.substr(0, selin) const before = now.substr(0, selin)
var after = now.substr(selin, now.length) const after = now.substr(selin, now.length)
newt = before + emoji + after const newt = before + emoji + after
$('#textarea').val(newt) textarea.value = newt
$('#textarea').focus() textarea.focus()
}
function faicon() {
var json = faicons
var emojis = ''
Object.keys(json).forEach(function(key) {
var emoji = json[key]
var eje = emoji.replace(/fa-/g, '')
emojis =
emojis +
'<a onclick="emojiInsert(\'[faicon]' +
eje +
'[/faicon]\')" class="pointer white-text" style="font-size:24px"><i class="fa ' +
emoji +
'"></i></a>'
})
$('#emoji-list').html(emojis)
$('#now-emoji').text('faicon')
$('.emoji-control').addClass('hide')
} }

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
//インスタンスリスト //インスタンスリスト
var idata = { const idata = {
"kirishima.cloud": "instance", "kirishima.cloud": "instance",
"kirishima.cloud_name": "アスタルテ", "kirishima.cloud_name": "アスタルテ",
"kirishima.cloud_letters": "6229", "kirishima.cloud_letters": "6229",
@ -84,5 +84,3 @@ var idata = {
"biwakodon.com_quote":"enabled", "biwakodon.com_quote":"enabled",
"comm.cx_quote":"enabled" "comm.cx_quote":"enabled"
}; };
localStorage.setItem("instance", JSON.stringify(idata));

View File

@ -1,617 +1,276 @@
/*ログイン処理・認証までのJS*/ /*ログイン処理・認証までのJS*/
//最初に読むやつ //最初に読むやつ
//アスタルテ判定初期化
localStorage.removeItem('kirishima') localStorage.removeItem('kirishima')
localStorage.removeItem('quoters') localStorage.removeItem('quoters')
localStorage.removeItem('imas') localStorage.removeItem('imas')
localStorage.removeItem('image') //stable, 固定タグのことらしい。ふざけるな。
localStorage.removeItem('stable') localStorage.removeItem('stable')
localStorage.setItem('mode_misskey.xyz', 'misskey') const acctList = JSON.parse(localStorage.getItem('multi'))
function ck() {
var main = localStorage.getItem('main') async function ck() {
const main = localStorage.getItem('main')
if (!main) { if (!main) {
localStorage.setItem('main', 0) localStorage.setItem('main', '0')
} }
//コード受信 //コード受信
if (location.search) { if (location.search) {
var m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=(.+)/) const m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=(.+)/)
var mode = m[1] const mode = m[1]
var codex = m[2] const codex = m[2]
if (mode == 'manager' || mode == 'login') { if (mode == 'manager' || mode == 'login') {
code(codex, mode) code(codex, mode)
} else { } else {
} }
} }
var multi = localStorage.getItem('multi') const multi = localStorage.getItem('multi')
if (!multi || multi == '[]') { if (!multi || multi == '[]') {
var date = new Date() const date = new Date()
localStorage.setItem('showSupportMe', date.getMonth() + 2) localStorage.setItem('showSupportMe', date.getMonth() + 2)
location.href = 'acct.html?mode=first&code=true' location.href = 'acct.html?mode=first&code=true'
} else { } else {
var obj = JSON.parse(multi) const obj = JSON.parse(multi)
var jp = false const keymap = Object.keys(obj)
Object.keys(obj).forEach(function(key) { let req = false
var acct = obj[key] for (let i = 0; i < keymap.length; i++) {
const key = keymap[i]
const acct = obj[key]
if (acct.domain) { if (acct.domain) {
refresh(key, true) let refreshed = await refresh(key, true)
if (refreshed) req = true
} }
if (acct.domain == 'mstdn.jp') {
jp = true
} }
if (req) {
Swal.fire({
title: 'Reload required',
text: lang.lang_login_changedData,
type: 'info',
showCancelButton: true,
confirmButtonText: lang.lang_no,
cancelButtonText: lang.lang_yesno
}).then(result => {
if (result) location.reload()
}) })
if (obj[0].domain) {
$('#tl').show()
ticker()
multiSelector(false)
verck(ver, jp)
$('.stw').show()
if (localStorage.getItem('tips')) {
tips(localStorage.getItem('tips'))
} }
$('#something-wrong img').attr('src', '../../img/thinking.svg') if (obj[0].domain) {
showElm('#tl')
ticker()
parseColumn()
verck(ver)
showElm('.stw')
const tipsType = localStorage.getItem('tips')
if (tipsType) {
tips(tipsType)
}
document.querySelector('#something-wrong img').setAttribute('src', '../../img/thinking.svg')
} }
} }
} }
ck() ck()
//ログインポップアップ
function login(url) {
if ($('#linux:checked').val() == 'on') {
var red = 'urn:ietf:wg:oauth:2.0:oob'
} else {
var red = 'thedesk://login'
}
localStorage.setItem('redirect', red)
var start = 'https://' + url + '/api/v1/apps'
var httpreq = new XMLHttpRequest()
httpreq.open('POST', start, true)
httpreq.setRequestHeader('Content-Type', 'application/json')
httpreq.responseType = 'json'
httpreq.send(
JSON.stringify({
scopes: 'read write follow',
client_name: 'TheDesk(PC)',
redirect_uris: red,
website: 'https://thedesk.top'
})
)
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response
if (this.status !== 200) {
setLog(start, this.status, json)
}
var auth =
'https://' +
url +
'/oauth/authorize?client_id=' +
json['client_id'] +
'&client_secret=' +
json['client_secret'] +
'&response_type=code&redirect_uri=' +
red +
'&scope=read+write+follow'
localStorage.setItem('domain_' + acct_id, url)
localStorage.setItem('client_id', json['client_id'])
localStorage.setItem('client_secret', json['client_secret'])
$('#auth').show()
$('#masara').hide()
postMessage(['openUrl', auth], '*')
if ($('#linux:checked').val() == 'on') {
} else {
postMessage(['sendSinmpleIpc', 'quit'], '*')
}
}
}
}
//テキストボックスにURL入れた
function instance() {
var url = $('#url').val()
login(url)
}
//コードを入れた後認証
function code(code, mode) {
var red = localStorage.getItem('redirect')
localStorage.removeItem('redirect')
if (!code) {
var code = $('#code').val()
}
if (localStorage.getItem('domain_tmp')) {
var url = localStorage.getItem('domain_tmp')
} else {
var url = localStorage.getItem('domain_' + acct_id)
}
var start = 'https://' + url + '/oauth/token'
var id = localStorage.getItem('client_id')
var secret = localStorage.getItem('client_secret')
fetch(start, {
method: 'POST',
headers: {
'content-type': 'application/json'
},
body: JSON.stringify({
grant_type: 'authorization_code',
redirect_uri: red,
client_id: id,
client_secret: secret,
code: code
})
})
.then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text)
})
}
return response.json()
})
.catch(function(error) {
todo(error)
setLog(start, 'JSON', error)
console.error(error)
})
.then(function(json) {
todo(json)
if (json['access_token']) {
localStorage.setItem(url + '_at', json['access_token'])
if (mode == 'manager') {
getdataAdv(url, json['access_token'])
} else {
getdata()
}
}
})
}
//ユーザーデータ取得(最初)
function getdata() {
var acct_id = 0
var domain = localStorage.getItem('domain_' + acct_id)
var at = localStorage.getItem('acct_' + acct_id + '_at')
var start = 'https://' + domain + '/api/v1/accounts/verify_credentials'
fetch(start, {
method: 'GET',
headers: {
'content-type': 'application/json',
Authorization: 'Bearer ' + at
}
})
.then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text)
})
}
return response.json()
})
.catch(function(error) {
todo(error)
setLog(start, 'JSON', error)
console.error(error)
})
.then(function(json) {
if (json.error) {
console.error('Error:' + json.error)
M.toast({ html: lang.lang_fatalerroroccured + 'Error:' + json.error, displayLength: 5000 })
return
}
var avatar = json['avatar']
//missingがmissingなやつ
if (avatar == '/avatars/original/missing.png') {
avatar = './img/missing.svg'
}
var obj = [
{
at: at,
name: json['display_name'],
domain: domain,
user: json['acct'],
prof: avatar,
id: json['id'],
vis: json['source']['privacy']
}
]
var json = JSON.stringify(obj)
localStorage.setItem('multi', json)
localStorage.setItem('name_' + acct_id, json['display_name'])
localStorage.setItem('user_' + acct_id, json['acct'])
localStorage.setItem('user-id_' + acct_id, json['id'])
localStorage.setItem('prof_' + acct_id, avatar)
$('#masara').hide()
$('#auth').hide()
$('#tl').show()
parseColumn()
ckdb()
})
}
//ユーザーデータ取得(追加)
function getdataAdv(domain, at) {
var start = 'https://' + domain + '/api/v1/accounts/verify_credentials'
fetch(start, {
method: 'GET',
headers: {
'content-type': 'application/json',
Authorization: 'Bearer ' + at
}
})
.then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text)
})
}
return response.json()
})
.catch(function(error) {
todo(error)
setLog(start, 'JSON', error)
console.error(error)
})
.then(function(json) {
if (json.error) {
console.error('Error:' + json.error)
M.toast({ html: lang.lang_fatalerroroccured + 'Error:' + json.error, displayLength: 5000 })
return
}
var avatar = json['avatar']
//missingがmissingなやつ
if (avatar == '/avatars/original/missing.png') {
avatar = '../../img/missing.svg'
}
if (json['source']['privacy']) {
var priv = json['source']['privacy']
} else {
var priv = 'public'
}
var add = {
at: at,
name: json['display_name'],
domain: domain,
user: json['acct'],
prof: avatar,
id: json['id'],
vis: priv
}
var multi = localStorage.getItem('multi')
var obj = JSON.parse(multi)
var target = obj.lengtth
obj.push(add)
localStorage.setItem('name_' + target, json['display_name'])
localStorage.setItem('user_' + target, json['acct'])
localStorage.setItem('user-id_' + target, json['id'])
localStorage.setItem('prof_' + target, avatar)
var json = JSON.stringify(obj)
localStorage.setItem('multi', json)
location.href = 'index.html'
})
}
//ユーザーデータ更新 //ユーザーデータ更新
function refresh(target, loadskip) { async function refresh(target, loadskip) {
var multi = localStorage.getItem('multi') let obj = acctList
var obj = JSON.parse(multi) let requireReload = false
if (obj[target].mode == 'misskey') { const { mode, domain, at, background, text, name, prof, vis } = obj[target]
if (mode == 'misskey') {
return return
} }
var start = 'https://' + obj[target].domain + '/api/v1/accounts/verify_credentials' const start = `https://${domain}/api/v1/accounts/verify_credentials`
fetch(start, { let json
method: 'GET', try {
headers: { json = await getApi(start, at)
'content-type': 'application/json', } catch {
Authorization: 'Bearer ' + obj[target].at return false
} }
})
.then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text)
})
}
return response.json()
})
.catch(function(error) {
todo(error)
setLog(start, 'JSON', error)
console.error(error)
})
.then(function(json) {
if (json.error) { if (json.error) {
console.error('Error:' + json.error) console.error('Error:' + json.error)
M.toast({ html: lang.lang_fatalerroroccured + 'Error:' + json.error, displayLength: 5000 }) M.toast({ html: lang.lang_fatalerroroccured + 'Error:' + json.error, displayLength: 5000 })
return return
} }
var avatar = json['avatar'] if (!json) return false
let avatar = json['avatar']
//missingがmissingなやつ //missingがmissingなやつ
if (avatar == '/avatars/original/missing.png' || !avatar) { if (avatar == '/avatars/original/missing.png' || !avatar) {
avatar = './img/missing.svg' avatar = './img/missing.svg'
} }
var ref = { const newName = json.display_name
at: obj[target].at, const newProf = avatar
name: json['display_name'], const newVis = json.source.privacy
domain: obj[target].domain, if (newName != name || newProf != prof || newVis != vis) {
let ref = {
at: at,
name: newName,
domain: domain,
user: json['acct'], user: json['acct'],
prof: avatar, prof: avatar,
id: json['id'], id: json['id'],
vis: json['source']['privacy'] vis: newVis
} }
if (obj[target].background) { if (background) {
ref.background = obj[target].background ref.background = background
} }
if (obj[target].text) { if (text) {
ref.text = obj[target].text ref.text = text
} }
localStorage.setItem('name_' + target, json['display_name'])
localStorage.setItem('user_' + target, json['acct'])
localStorage.setItem('user-id_' + target, json['id'])
localStorage.setItem('prof_' + target, avatar)
localStorage.setItem('follow_' + target, json['following_count'])
if (json['source']['sensitive']) { if (json['source']['sensitive']) {
localStorage.setItem('nsfw_' + target, 'true') localStorage.setItem('nsfw_' + target, true)
} else { } else {
localStorage.removeItem('nsfw_' + target) localStorage.removeItem('nsfw_' + target)
} }
obj[target] = ref obj[target] = ref
var json = JSON.stringify(obj) const save = JSON.stringify(obj)
localStorage.setItem('multi', json) localStorage.setItem('multi', save)
requireReload = true
}
if (!loadskip) { if (!loadskip) {
load() load()
} else {
return requireReload
} }
})
} }
//MarkdownやBBCodeの対応、文字数制限をチェック //MarkdownやBBCodeの対応、文字数制限をチェック
//絶対ストリーミングを閉じさせないマン //絶対ストリーミングを閉じさせないマン
function ckdb(acct_id) { async function ckdb(acct_id) {
var domain = localStorage.getItem('domain_' + acct_id) const domain = localStorage.getItem(`domain_${acct_id}`)
localStorage.removeItem('home_' + acct_id)
localStorage.removeItem('bb_' + acct_id)
localStorage.removeItem('md_' + acct_id)
localStorage.removeItem('local_' + acct_id)
localStorage.removeItem('public_' + acct_id)
localStorage.removeItem('notification_' + acct_id)
localStorage.removeItem('post_' + acct_id)
localStorage.removeItem('fav_' + acct_id)
localStorage.removeItem('bt_' + acct_id)
localStorage.removeItem('followlocale_' + acct_id)
if (domain == 'kirishima.cloud') { if (domain == 'kirishima.cloud') {
localStorage.setItem('kirishima', 'true') localStorage.setItem('kirishima', true)
} else if (domain == 'imastodon.net') { } else if (domain == 'imastodon.net') {
localStorage.setItem('imas', 'true') localStorage.setItem('imas', true)
$('.imasonly').show() showElm('.imasonly')
}
var at = localStorage.getItem('acct_' + acct_id + '_at')
var bbcode = domain + '_bbcode'
var letters = domain + '_letters'
var quoteMarker = domain + '_quote'
if (localStorage.getItem('instance')) {
var json = JSON.parse(localStorage.getItem('instance'))
if (json[quoteMarker] == 'enabled') {
localStorage.setItem('quoters', 'true')
localStorage.setItem('quote_' + acct_id, 'true')
}
if (json[bbcode]) {
if (json[bbcode] == 'enabled') {
localStorage.setItem('bb_' + acct_id, 'true')
} else {
localStorage.removeItem('bb_' + acct_id)
$("[data-activates='bbcode']").addClass('disabled')
$("[data-activates='bbcode']").prop('disabled', true)
}
} else {
localStorage.removeItem('bb_' + acct_id)
$("[data-activates='bbcode']").addClass('disabled')
$("[data-activates='bbcode']").addClass('disabled', true)
} }
const at = localStorage.getItem(`acct_${acct_id}_at`)
const letters = `${domain}_letters`
const quoteMarker = `${domain}_quote`
if (json[domain + '_markdown'] == 'enabled') { if (idata) {
localStorage.setItem('md_' + acct_id, 'true') //check and replace json to idata
$('.markdown').show() const json = idata
} else { if (json[quoteMarker] == 'enabled') {
$('.anti-markdown').hide() localStorage.setItem('quoters', true)
$('.markdown').hide() localStorage.setItem(quoteMarker, true)
localStorage.removeItem('bb_' + acct_id)
}
if (json[domain + '_home']) {
localStorage.setItem('home_' + acct_id, json[domain + '_home'])
}
if (json[domain + '_local']) {
localStorage.setItem('local_' + acct_id, json[domain + '_local'])
}
if (json[domain + '_public']) {
localStorage.setItem('public_' + acct_id, json[domain + '_public'])
}
if (json[domain + '_notification']) {
localStorage.setItem('notification_' + acct_id, json[domain + '_notification'])
}
if (json[domain + '_post']) {
localStorage.setItem('post_' + acct_id, json[domain + '_post'])
}
if (json[domain + '_fav']) {
localStorage.setItem('fav_' + acct_id, json[domain + '_fav'])
}
if (json[domain + '_bt']) {
localStorage.setItem('bt_' + acct_id, json[domain + '_bt'])
}
if (json[domain + '_follow']) {
localStorage.setItem('followlocale_' + acct_id, json[domain + '_follow'])
} }
} }
if (localStorage.getItem('mode_' + domain) != 'misskey') { if (!isMisskey(domain)) {
var start = 'https://' + domain + '/api/v1/instance' const start = `https://${domain}/api/v1/instance`
fetch(start, { let json
method: 'GET', try {
headers: { json = await getApi(start, null)
'content-type': 'application/json' } catch {
return null
} }
}) if (!json || json.error) {
.then(function(response) {
return response.json()
})
.catch(function(error) {
console.error(error)
})
.then(function(json) {
if (json.error) {
console.error(json.error)
return return
} }
if (json) { const mtc = json['max_toot_chars']
if (json['max_toot_chars']) { if (mtc) {
localStorage.setItem('letters_' + acct_id, json['max_toot_chars']) localStorage.setItem(letters, mtc)
} }
if (json['urls']['streaming_api']) { if (json['feature_quote']) {
localStorage.setItem('streaming_' + acct_id, json['urls']['streaming_api']) localStorage.setItem(quoteMarker, true)
} else {
localStorage.removeItem('streaming_' + acct_id)
} }
const str = json['urls']['streaming_api']
if (str) {
localStorage.setItem(`streaming_${domain}`, str)
} }
})
} else {
} }
} }
//アカウントを選択…を実装 //アカウントを選択…を実装
function multiSelector(parseC) { function multiSelector() {
var multi = localStorage.getItem('multi') let obj = acctList
if (!multi) { //if (!obj) obj = JSON.parse(localStorage.getItem('multi'))
var obj = [] let template = ''
var json = JSON.stringify(obj) //StringなのはlocalStorageがStringしか返さないから
localStorage.setItem('multi', json) let lastUsed = '0'
} else {
var obj = JSON.parse(multi)
}
var templete
if (localStorage.getItem('mainuse') == 'main') { if (localStorage.getItem('mainuse') == 'main') {
var last = localStorage.getItem('main') lastUsed = localStorage.getItem('main')
} else if (localStorage.getItem('last-use')) { } else if (localStorage.getItem('last-use')) {
var last = localStorage.getItem('last-use') lastUsed = localStorage.getItem('last-use')
if (last == 'webview' || last == 'noauth') { if (lastUsed == 'webview' || lastUsed == 'noauth') {
last = '0' lastUsed = '0'
} }
} else { } else {
var last = '0' lastUsed = '0'
} }
last = last + '' let sel
var sel
if (obj.length < 1) { if (obj.length < 1) {
$('#src-acct-sel').html('<option value="tootsearch">Tootsearch</option>') document.querySelector('#src-acct-sel').innerHTML = '<option value="tootsearch">Tootsearch</option>'
$('#add-acct-sel').html('<option value="noauth">' + lang.lang_login_noauth + '</option>') document.querySelector('#add-acct-sel').innerHTML = `<option value="noauth">${lang.lang_login_noauth}</option>`
} else { } else {
Object.keys(obj).forEach(function(key) { for (let i = 0; i < obj.length; i++) {
var acct = obj[key] const acct = obj[i]
var list = key * 1 + 1 const strKey = i.toString()
if (key + '' === last) { if (strKey == lastUsed) {
sel = 'selected' sel = 'selected'
var domain = acct.domain const domain = acct.domain
localStorage.setItem('domain_' + key, domain) const letters = idata[`${domain}_letters`]
if (idata[domain + '_letters']) { const textarea = document.querySelector('#textarea')
$('#textarea').attr('data-length', idata[domain + '_letters']) if (letters) {
textarea.setAttribute('data-length', letters)
} else { } else {
var maxletters = localStorage.getItem('letters_' + key) //手動でアカマネで変えれちゃうから
if (maxletters > 0) { const maxLetters = localStorage.getItem(`${domain}_letters`)
$('#textarea').attr('data-length', maxletters) if (maxLetters > 0) {
textarea.setAttribute('data-length', maxLetters)
} else { } else {
$('#textarea').attr('data-length', 500) textarea.setAttribute('data-length', 500)
} }
} }
if (idata[domain + '_glitch']) { if (idata[`${domain}_glitch`]) {
$('#local-button').removeClass('hide') document.querySelector('#local-button').classList.remove('hide')
} }
var profimg = acct.prof let profimg = acct.prof
//localStorage.setItem("prof_" + key, profimg);
if (!profimg) { if (!profimg) {
profimg = '../../img/missing.svg' profimg = '../../img/missing.svg'
} }
$('#acct-sel-prof').attr('src', profimg) document.querySelector('#acct-sel-prof').setAttribute('src', profimg)
let cc = ''
if (domain) { if (domain) {
var cc = '(' + domain + ')' cc = `(${domain})`
} else {
var cc = ''
} }
$('#toot-post-btn').text(lang.lang_toot + cc) const tpb = document.querySelector('#toot-post-btn')
tpb.innerText = lang.lang_toot + cc
if (acct.background && acct.background != 'def' && acct.text && acct.text != 'def') { if (acct.background && acct.background != 'def' && acct.text && acct.text != 'def') {
$('#toot-post-btn').removeClass('indigo') tpb.classList.remove('indigo')
$('#toot-post-btn').css('background-color', '#' + acct.background) tpb.style.backgroundColor = `#${acct.background}`
$('#toot-post-btn').css('color', acct.text) tpb.style.color = `#${acct.text}`
} else {
}
if (domain == 'kirishima.cloud') {
$('#faicon-btn').show()
} else {
$('#faicon-btn').hide()
} }
if (domain == 'imastodon.net') { if (domain == 'imastodon.net') {
trendTag() trendTag()
} else { } else {
$('#trendtag').html('') if (document.querySelector('#trendtag')) document.querySelector('#trendtag').innerHTML = ''
} }
} else { } else {
sel = '' sel = ''
} }
templete = template = template + `
'<option value="' + <option value="${strKey}" data-icon="${acct.prof}" class="left circle" ${sel}>@${acct.user}@${acct.domain}
key + </option>
'" data-icon="' + `
acct.prof +
'" class="left circle" ' +
sel +
'>' +
acct.user +
'@' +
acct.domain +
'</option>'
$('.acct-sel').append(templete)
})
$('#src-acct-sel').append('<option value="tootsearch">Tootsearch</option>')
$('#add-acct-sel').append(
'<option value="noauth">' +
lang.lang_login_noauth +
'</option><option value="webview">Twitter</option>'
)
$('#dir-acct-sel').append('<option value="noauth">' + lang.lang_login_noauth + '</option>')
} }
$('select').formSelect() const forSrc = template + '<option value="tootsearch">Tootsearch</option>'
if (!parseC) { const forAdd = template + `
parseColumn(null, true) <option value="noauth">${lang.lang_login_noauth}</option>
<option value="webview">Twitter</option>
`
const forDir = template + `<option value="noauth">${lang.lang_login_noauth}</option>`
document.querySelector('#post-acct-sel').innerHTML = template
document.querySelector('#list-acct-sel').innerHTML = template
document.querySelector('#filter-acct-sel').innerHTML = template
document.querySelector('#src-acct-sel').innerHTML = forSrc
document.querySelector('#add-acct-sel').innerHTML = forAdd
document.querySelector('#dir-acct-sel').innerHTML = forDir
} }
} const elems = document.querySelectorAll('select')
M.FormSelect.init(elems, null)
//バージョンエンコ
function enc(ver) {
var ver = ver.replace(/\s/g, '')
var ver = ver.replace(/\(/g, '-')
var ver = ver.replace(/\)/g, '')
var ver = ver.replace(/\[/g, '_')
var ver = ver.replace(/\]/g, '')
return ver
} }
//インスタンスティッカー //インスタンスティッカー
function ticker() { async function ticker() {
var start = 'https://toot.app/toot/index.php' const start = 'https://toot-app.thedesk.top/toot/index.php'
fetch(start, { const json = await getApi(start, null)
method: 'GET', if (json) localStorage.setItem('ticker', JSON.stringify(json))
cors: true, }
headers: { function isMisskey(domain) {
'content-type': 'application/json' return localStorage.getItem(`mode_${domain}`) == 'misskey'
}
})
.then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text)
})
}
return response.json()
})
.catch(function(error) {
console.error(error)
})
.then(function(json) {
if (json) {
localStorage.setItem('ticker', JSON.stringify(json))
}
})
} }

View File

@ -1,7 +1,7 @@
//ログアウトします //ログアウトします
function logout() { function logout() {
localStorage.removeItem("acct_" + acct_id + "_at"); localStorage.removeItem(`acct_${acct_id}_at`)
localStorage.removeItem("domain_" + acct_id); localStorage.removeItem(`domain_${acct_id}`)
location.href = "index.html"; location.href = 'index.html'
todc(); todc()
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,11 @@
$.strip_tags = function(str, allowed) { $.strip_tags = function (str, allowed) {
if (!str) { if (!str) {
return '' return ''
} }
allowed = (((allowed || '') + '').toLowerCase().match(/<[a-z][a-z0-9]*>/g) || []).join('') allowed = (((allowed || '') + '').toLowerCase().match(/<[a-z][a-z0-9]*>/g) || []).join('')
var tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>?/gi, var tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>?/gi,
commentsAndPhpTags = /<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>/gi commentsAndPhpTags = /<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>/gi
return str.replace(commentsAndPhpTags, '').replace(tags, function($0, $1) { return str.replace(commentsAndPhpTags, '').replace(tags, function ($0, $1) {
return allowed.indexOf('<' + $1.toLowerCase() + '>') > -1 ? $0 : '' return allowed.indexOf('<' + $1.toLowerCase() + '>') > -1 ? $0 : ''
}) })
} }
@ -13,12 +13,7 @@ function escapeHTML(str) {
if (!str) { if (!str) {
return '' return ''
} }
return str return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#039;')
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#039;')
} }
//PHPのnl2brと同様 //PHPのnl2brと同様
function nl2br(str) { function nl2br(str) {
@ -88,17 +83,18 @@ function formattimeutc(date) {
} }
postMessage(['sendSinmpleIpc', 'custom-css-request'], '*') postMessage(['sendSinmpleIpc', 'custom-css-request'], '*')
function makeCID() { function makeCID() {
return ( let chars = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.split('')
randomStr(8) + for (let i = 0, len = chars.length; i < len; i++) {
'-' + switch (chars[i]) {
randomStr(4) + case 'x':
'-' + chars[i] = Math.floor(Math.random() * 16).toString(16)
randomStr(4) + break
'-' + case 'y':
randomStr(4) + chars[i] = (Math.floor(Math.random() * 4) + 8).toString(16)
'-' + break
randomStr(12) }
) }
return chars.join('')
} }
function randomStr(l) { function randomStr(l) {
// 生成する文字列に含める文字セット // 生成する文字列に含める文字セット
@ -129,7 +125,7 @@ function rgbToHex(color) {
// RGBからHEXへ変換 // RGBからHEXへ変換
parseInt(regex[1]).toString(16), parseInt(regex[1]).toString(16),
parseInt(regex[2]).toString(16), parseInt(regex[2]).toString(16),
parseInt(regex[3]).toString(16) parseInt(regex[3]).toString(16),
] ]
for (var i = 0; i < rgb.length; ++i) { for (var i = 0; i < rgb.length; ++i) {
@ -147,15 +143,15 @@ function rgbToHex(color) {
console.error(color + ':第1引数はRGB形式で入力') console.error(color + ':第1引数はRGB形式で入力')
} }
/*マルチバイト用切り出し*/ /*マルチバイト用切り出し*/
$.isSurrogatePear = function(upper, lower) { $.isSurrogatePear = function (upper, lower) {
return 0xd800 <= upper && upper <= 0xdbff && 0xdc00 <= lower && lower <= 0xdfff return 0xd800 <= upper && upper <= 0xdbff && 0xdc00 <= lower && lower <= 0xdfff
} }
$.mb_strlen = function(str) { $.mb_strlen = function (str) {
var splitter = new GraphemeSplitter() var splitter = new GraphemeSplitter()
var arr = splitter.splitGraphemes(str) var arr = splitter.splitGraphemes(str)
return arr.length return arr.length
} }
$.mb_substr = function(str, begin, end) { $.mb_substr = function (str, begin, end) {
//配列にする //配列にする
var splitter = new GraphemeSplitter() var splitter = new GraphemeSplitter()
var arr = splitter.splitGraphemes(str) var arr = splitter.splitGraphemes(str)
@ -175,7 +171,7 @@ function object_array_sort(data, key, order, fn) {
num_a = 1 num_a = 1
num_b = -1 num_b = -1
} }
data = data.sort(function(a, b) { data = data.sort(function (a, b) {
var x = a[key] var x = a[key]
var y = b[key] var y = b[key]
if (x > y) return num_a if (x > y) return num_a
@ -252,7 +248,7 @@ function statusModel(now) {
reblog: null, reblog: null,
application: { application: {
name: null, name: null,
website: null website: null,
}, },
account: { account: {
id: '', id: '',
@ -273,12 +269,53 @@ function statusModel(now) {
statuses_count: 0, statuses_count: 0,
last_status_at: now, last_status_at: now,
emojis: [], emojis: [],
fields: [] fields: [],
}, },
media_attachments: [], media_attachments: [],
mentions: [], mentions: [],
tags: [], tags: [],
card: null, card: null,
poll: null poll: null,
} }
} }
function isFocused(query) {
const allTarget = document.querySelectorAll(query)
const active = document.activeElement
let is = false
for (let i = 0; i < allTarget.length; i++) {
if (allTarget[i] == active) {
is = true
break
}
}
return is
}
function getHeight(query) {
const elm = document.querySelector(query)
return parseFloat(getComputedStyle(elm, null).height.replace('px', ''))
}
function showElm(query) {
const allTarget = document.querySelectorAll(query)
for (let i = 0; i < allTarget.length; i++) {
const target = allTarget[i]
target.style.display = 'inherit'
}
}
function setAllClasses(query, className, action) {
const allTarget = document.querySelectorAll(query)
for (let i = 0; i < allTarget.length; i++) {
const target = allTarget[i]
if (action == 'add') target.classList.add(className)
if (action == 'remove') target.classList.remove(className)
}
}
function appendPrepend(query, elm, action) {
const allTarget = document.querySelectorAll(query)
for (let i = 0; i < allTarget.length; i++) {
const target = allTarget[i]
if (action == 'prepend') target.insertBefore(elm, target.firstChild)
if (action == 'append') target.appendChild(document.createTextNode(elm))
}
}
const sleep = (msec) => new Promise((resolve) => setTimeout(resolve, msec))

View File

@ -2,11 +2,12 @@
//アカウント変えた時にBBとかMDとか //アカウント変えた時にBBとかMDとか
function mdCheck() { function mdCheck() {
var acct_id = $('#post-acct-sel').val() var acct_id = $('#post-acct-sel').val()
var profimg = localStorage.getItem('prof_' + acct_id) /*var profimg = localStorage.getItem('prof_' + acct_id)
if (!profimg) { if (!profimg) {
profimg = '../../img/missing.svg' profimg = '../../img/missing.svg'
} }
$('#acct-sel-prof').attr('src', profimg) $('#acct-sel-prof').attr('src', profimg)
*/
if (localStorage.getItem('post_' + acct_id)) { if (localStorage.getItem('post_' + acct_id)) {
$('#toot-post-btn').text( $('#toot-post-btn').text(
localStorage.getItem('post_' + acct_id) + localStorage.getItem('post_' + acct_id) +
@ -50,7 +51,7 @@ function mdCheck() {
if (idata[domain + '_letters']) { if (idata[domain + '_letters']) {
$('#textarea').attr('data-length', idata[domain + '_letters']) $('#textarea').attr('data-length', idata[domain + '_letters'])
} else { } else {
var maxletters = localStorage.getItem('letters_' + acct_id) var maxletters = localStorage.getItem(domain + 'letters_')
if (maxletters > 0) { if (maxletters > 0) {
$('#textarea').attr('data-length', maxletters) $('#textarea').attr('data-length', maxletters)
} else { } else {

View File

@ -108,7 +108,6 @@ async function media(b64, type, no, stamped) {
} }
$('.toot-btn-group').prop('disabled', true) $('.toot-btn-group').prop('disabled', true)
$('#post-acct-sel').prop('disabled', true) $('#post-acct-sel').prop('disabled', true)
localStorage.setItem('image', 'busy')
todo('Image Upload...') todo('Image Upload...')
var media = toBlob(b64, type) var media = toBlob(b64, type)
var fd = new FormData() var fd = new FormData()
@ -159,7 +158,6 @@ async function media(b64, type, no, stamped) {
M.toast({ html: '<span>' + lang.lang_postimg_sync + '</span><button class="btn-flat toast-action" onclick="syncDetail()">Click</button>', displayLength: 3000 }) M.toast({ html: '<span>' + lang.lang_postimg_sync + '</span><button class="btn-flat toast-action" onclick="syncDetail()">Click</button>', displayLength: 3000 })
$('#imgup').text('') $('#imgup').text('')
$('#imgsel').show() $('#imgsel').show()
localStorage.removeItem('image')
} }
} catch { } catch {
var start = 'https://' + domain + '/api/v1/media' var start = 'https://' + domain + '/api/v1/media'

View File

@ -342,7 +342,6 @@ function clear() {
$('.mastodon-choice').map(function() { $('.mastodon-choice').map(function() {
$(this).val('') $(this).val('')
}) })
localStorage.removeItem('image')
if (localStorage.getItem('mainuse') == 'main') { if (localStorage.getItem('mainuse') == 'main') {
$('#post-acct-sel').val(localStorage.getItem('main')) $('#post-acct-sel').val(localStorage.getItem('main'))
} }

View File

@ -42,7 +42,6 @@ function parseColumn(target, dontclose) {
var multi = localStorage.getItem('multi') var multi = localStorage.getItem('multi')
if (multi) { if (multi) {
var obj = JSON.parse(multi) var obj = JSON.parse(multi)
var templete var templete
Object.keys(obj).forEach(function (key) { Object.keys(obj).forEach(function (key) {
var acct = obj[key] var acct = obj[key]
@ -102,6 +101,7 @@ function parseColumn(target, dontclose) {
$('.box, .boxIn').resizable('destroy') $('.box, .boxIn').resizable('destroy')
} }
} }
console.log(obj)
var basekey = 0 var basekey = 0
for (var key = 0; key < obj.length; key++) { for (var key = 0; key < obj.length; key++) {
var next = key + 1 var next = key + 1
@ -444,7 +444,7 @@ function parseColumn(target, dontclose) {
<br> <br>
<div id="picker_${key}" class="color-picker"></div> <div id="picker_${key}" class="color-picker"></div>
</div>${if_tag} </div>${if_tag}
<div class="tl-box" tlid="${key}"> <div class="tl-box" tlid="${key}" id="tlBox${key}">
<div id="timeline_${key}" class="tl ${acct.type}-timeline " tlid="${key}" <div id="timeline_${key}" class="tl ${acct.type}-timeline " tlid="${key}"
data-type="${acct.type}" data-acct="${acct.domain}" data-const="${acct.type}_${acct.domain}"> data-type="${acct.type}" data-acct="${acct.domain}" data-const="${acct.type}_${acct.domain}">
<div id="landing_${key}" style="text-align:center"> <div id="landing_${key}" style="text-align:center">
@ -508,6 +508,8 @@ function parseColumn(target, dontclose) {
} }
} }
} }
console.log('multiSelector')
multiSelector()
$('.box, .boxIn').resizable({ $('.box, .boxIn').resizable({
minHeight: 50, minHeight: 50,
minWidth: 50, minWidth: 50,
@ -804,7 +806,7 @@ function webviewParse(url, key, insert, icnsert, css) {
<br> <br>
<div id="picker_${key}" class="color-picker"></div> <div id="picker_${key}" class="color-picker"></div>
</div> </div>
<div class="tl-box" tlid="${key}" style="width:100%;height:100%;"> <div class="tl-box" tlid="${key}" style="width:100%;height:100%;" id="tlBox${key}">
<div id="timeline_${key}" class="tl" tlid="${key}" data-type="webview" style="width:100%;height:100%;"> <div id="timeline_${key}" class="tl" tlid="${key}" data-type="webview" style="width:100%;height:100%;">
<webview src="${url}" style="width:100%;height:100%;" id="webview" preload="./js/platform/twitter.js"></webview> <webview src="${url}" style="width:100%;height:100%;" id="webview" preload="./js/platform/twitter.js"></webview>
</div> </div>
@ -866,7 +868,7 @@ function unstreamingTL(type, key, basekey, insert, icnsert, left_fold, css, anim
${lang.lang_layout_headercolor}<br> ${lang.lang_layout_headercolor}<br>
<div id="picker_${key}" class="color-picker"></div> <div id="picker_${key}" class="color-picker"></div>
</div> </div>
<div class="tl-box" tlid="${key}"> <div class="tl-box" tlid="${key}" id="tlBox${key}">
<div id="timeline_${key}" class="tl ${type}-timeline" tlid="${key}" data-type="${type}" data-acct="${data}"> <div id="timeline_${key}" class="tl ${type}-timeline" tlid="${key}" data-type="${type}" data-acct="${data}">
<div id="landing_${key}" style="text-align:center"> <div id="landing_${key}" style="text-align:center">
${lang.lang_layout_nodata} ${lang.lang_layout_nodata}

View File

@ -32,7 +32,6 @@ function mini() {
function show() { function show() {
$('#post-box').addClass('appear') $('#post-box').addClass('appear')
$('#textarea').focus() $('#textarea').focus()
console.log('show' + localStorage.getItem('postbox-left'))
var left = localStorage.getItem('postbox-left') var left = localStorage.getItem('postbox-left')
if (left > $('body').width() - $('#post-box').width()) { if (left > $('body').width() - $('#post-box').width()) {
left = $('body').width() - $('#post-box').width() left = $('body').width() - $('#post-box').width()
@ -55,10 +54,12 @@ function show() {
} }
$('#post-box').fadeIn() $('#post-box').fadeIn()
$('#textarea').characterCounter() $('#textarea').characterCounter()
mdCheck() mdCheck()
} }
$(function () { $(function () {
$('#post-box').draggable({ $('#post-box').draggable({
handle: '#post-bar', handle: '#post-bar',
stop: function () { stop: function () {

View File

@ -157,7 +157,7 @@ function spotifytips() {
setLog(start, 'JSON', error) setLog(start, 'JSON', error)
console.error(error) console.error(error)
}) })
.then(function(json) { .then(async function(json) {
var ms = json.progress_ms var ms = json.progress_ms
if(!ms) { if(!ms) {
tips('ver') tips('ver')
@ -175,7 +175,7 @@ function spotifytips() {
} }
} }
artisttxt = escapeHTML(artisttxt) artisttxt = escapeHTML(artisttxt)
sleep(last) await sleep(last)
var tms = item.duration_ms var tms = item.duration_ms
var per = (ms / item.duration_ms) * 100 var per = (ms / item.duration_ms) * 100
ms = ms / 1000 ms = ms / 1000
@ -251,10 +251,10 @@ function trendTagonTipInterval() {
} }
//時計 //時計
var clockint var clockint
function clock() { async function clock() {
var now = new Date() var now = new Date()
var last = 1000 - (now.getTime() % 1000) var last = 1000 - (now.getTime() % 1000)
sleep(last) await sleep(last)
clockint = setInterval(clockStart, 1000) clockint = setInterval(clockStart, 1000)
} }
function clockStart() { function clockStart() {
@ -286,10 +286,6 @@ function clockStart() {
'</span>' '</span>'
$('#tips-text').html(msg) $('#tips-text').html(msg)
} }
function sleep(waitMsec) {
var startMsec = new Date()
while (new Date() - startMsec < waitMsec);
}
function tipsToggle() { function tipsToggle() {
$('#tips').toggleClass('hide') $('#tips').toggleClass('hide')
$('#tips-menu').toggleClass('hide') $('#tips-menu').toggleClass('hide')

View File

@ -1,65 +1,68 @@
//プロフ編集 //プロフ編集
//文字系 //文字系
function profedit() { function profedit() {
var acct_id = $('#his-data').attr("use-acct"); var acct_id = $('#his-data').attr('use-acct')
todo("Updating..."); todo('Updating...')
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem('domain_' + acct_id)
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem('acct_' + acct_id + '_at')
var start = "https://" + domain + "/api/v1/accounts/update_credentials"; var start = 'https://' + domain + '/api/v1/accounts/update_credentials'
var name = $("#his-name-val").val(); var name = $('#his-name-val').val()
var des = $("#his-des-val").val(); var des = $('#his-des-val').val()
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest()
httpreq.open('PATCH', start, true); httpreq.open('PATCH', start, true)
httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader('Content-Type', 'application/json')
httpreq.setRequestHeader('Authorization', 'Bearer ' + at); httpreq.setRequestHeader('Authorization', 'Bearer ' + at)
httpreq.responseType = "json"; httpreq.responseType = 'json'
httpreq.send(JSON.stringify({ httpreq.send(
JSON.stringify({
display_name: name, display_name: name,
note: des, note: des,
})); })
)
httpreq.onreadystatechange = function () { httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
$('#his-data').modal('close'); $('#his-data').modal('close')
todc(); todc()
} }
} }
} }
//画像系 //画像系
function imgChange(imgfile, target) { function imgChange(imgfile, target) {
var acct_id = $('#his-data').attr("use-acct"); var acct_id = $('#his-data').attr('use-acct')
todo("アップロードしています") todo('アップロードしています')
if (!imgfile.files.length) { if (!imgfile.files.length) {
console.warn("No Image to upload"); console.warn('No Image to upload')
return; return
} }
var file = imgfile.files[0]; var file = imgfile.files[0]
var fr = new FileReader(); var fr = new FileReader()
fr.onload = function (evt) { fr.onload = function (evt) {
var b64 = this.result; var b64 = this.result
var blob = toBlob(b64, 'image/png'); var blob = toBlob(b64, 'image/png')
var fd = new FormData(); var fd = new FormData()
fd.append(target, blob); fd.append(target, blob)
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem('domain_' + acct_id)
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem('acct_' + acct_id + '_at')
var start = "https://" + domain + "/api/v1/accounts/update_credentials"; var start = 'https://' + domain + '/api/v1/accounts/update_credentials'
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest()
httpreq.open('PATCH', start, true); httpreq.open('PATCH', start, true)
httpreq.upload.addEventListener("progress", progshow, false); httpreq.upload.addEventListener('progress', progshow, false)
httpreq.setRequestHeader('Authorization', 'Bearer ' + at); httpreq.setRequestHeader('Authorization', 'Bearer ' + at)
httpreq.responseType = "json"; httpreq.responseType = 'json'
httpreq.send(fd); httpreq.send(fd)
httpreq.onreadystatechange = function () { httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
var json = httpreq.response; var json = httpreq.response
if(this.status!==200){ setLog(start, this.status, this.response); } if (this.status !== 200) {
$('#his-data').modal('close'); setLog(start, this.status, this.response)
todc(); }
localStorage.removeItem("image"); $('#his-data').modal('close')
todc()
} }
} }
} }
$("#prof-change").html($("#prof-change").html()); $('#prof-change').html($('#prof-change').html())
$("#header-change").html($("#header-change").html()); $('#header-change').html($('#header-change').html())
fr.readAsDataURL(file); fr.readAsDataURL(file)
} }

View File

@ -33,20 +33,20 @@ function udgEx(user, acct_id) {
Authorization: "Bearer " + at Authorization: "Bearer " + at
} }
}) })
.then(function(response) { .then(function (response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function (text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}) })
.catch(function(error) { .catch(function (error) {
todo(error); todo(error);
setLog(start, "JSON", error); setLog(start, "JSON", error);
console.error(error); console.error(error);
}) })
.then(function(json) { .then(function (json) {
if (json.accounts[0]) { if (json.accounts[0]) {
var id = json.accounts[0].id; var id = json.accounts[0].id;
udg(id, acct_id); udg(id, acct_id);
@ -76,20 +76,20 @@ function udg(user, acct_id) {
Authorization: "Bearer " + at Authorization: "Bearer " + at
} }
}) })
.then(function(response) { .then(function (response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function (text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}) })
.catch(function(error) { .catch(function (error) {
todo(error); todo(error);
setLog(start, "JSON", error); setLog(start, "JSON", error);
console.error(error); console.error(error);
}) })
.then(function(json) { .then(function (json) {
//一つ前のユーザーデータ //一つ前のユーザーデータ
if (!localStorage.getItem("history")) { if (!localStorage.getItem("history")) {
$("#his-history-btn").prop("disabled", true); $("#his-history-btn").prop("disabled", true);
@ -129,7 +129,7 @@ function udg(user, acct_id) {
} }
//絵文字があれば //絵文字があれば
if (actemojick) { if (actemojick) {
Object.keys(json.emojis).forEach(function(key5) { Object.keys(json.emojis).forEach(function (key5) {
var emoji = json.emojis[key5]; var emoji = json.emojis[key5];
var shortcode = emoji.shortcode; var shortcode = emoji.shortcode;
var emoji_url = '<img src="' + emoji.url + '" class="emoji-img" data-emoji="' + shortcode + '" draggable="false">'; var emoji_url = '<img src="' + emoji.url + '" class="emoji-img" data-emoji="' + shortcode + '" draggable="false">';
@ -239,7 +239,7 @@ function udg(user, acct_id) {
$(".only-his-data").show(); $(".only-his-data").show();
} }
todc(); todc();
if(json.locked) { if (json.locked) {
$('#his-data').addClass('locked') $('#his-data').addClass('locked')
} else { } else {
$('#his-data').removeClass('locked') $('#his-data').removeClass('locked')
@ -271,20 +271,20 @@ function misskeyUdg(user, acct_id) {
userId: user userId: user
}) })
}) })
.then(function(response) { .then(function (response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function (text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}) })
.catch(function(error) { .catch(function (error) {
todo(error); todo(error);
setLog(start, "JSON", error); setLog(start, "JSON", error);
console.error(error); console.error(error);
}) })
.then(function(json) { .then(function (json) {
//一つ前のユーザーデータ //一つ前のユーザーデータ
if (!localStorage.getItem("history")) { if (!localStorage.getItem("history")) {
$("#his-history-btn").prop("disabled", true); $("#his-history-btn").prop("disabled", true);
@ -402,22 +402,22 @@ function relations(user, acct_id) {
Authorization: "Bearer " + at Authorization: "Bearer " + at
} }
}) })
.then(function(response) { .then(function (response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function (text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}) })
.catch(function(error) { .catch(function (error) {
todo(error); todo(error);
setLog(start, "JSON", error); setLog(start, "JSON", error);
console.error(error); console.error(error);
}) })
.then(function(json) { .then(function (json) {
var json = json[0]; var json = json[0];
if(json.requested) { if (json.requested) {
//フォロリク中 //フォロリク中
$('#his-data').addClass('following') $('#his-data').addClass('following')
$("#his-follow-btn-text").text(lang.lang_status_requesting) $("#his-follow-btn-text").text(lang.lang_status_requesting)
@ -482,7 +482,7 @@ function profbrws() {
function setMain() { function setMain() {
var acct_id = $("#his-data").attr("use-acct"); var acct_id = $("#his-data").attr("use-acct");
localStorage.setItem("main", acct_id); localStorage.setItem("main", acct_id);
multiSelector(true); multiSelector();
M.toast({ html: lang.lang_manager_mainAcct, displayLength: 3000 }); M.toast({ html: lang.lang_manager_mainAcct, displayLength: 3000 });
} }
//オールリセット //オールリセット
@ -551,7 +551,7 @@ function reset() {
$('#his-data').removeClass('locked') $('#his-data').removeClass('locked')
$('#his-data').removeClass('requesting') $('#his-data').removeClass('requesting')
} }
$("#my-data-nav .anc-link").on("click", function() { $("#my-data-nav .anc-link").on("click", function () {
var target = $(this).attr("go"); var target = $(this).attr("go");
if (target) { if (target) {
$("#my-data-nav .anc-link").removeClass("active-back"); $("#my-data-nav .anc-link").removeClass("active-back");

View File

@ -69,7 +69,7 @@
<div class="pwa"> <div class="pwa">
@@codesetupwarn@@<br /> @@codesetupwarn@@<br />
<label> <label>
<input type="checkbox" class="filled-in" id="linux" /> <input type="checkbox" class="filled-in checked" id="linux" checked />
<span>@@codesetup@@</span> <span>@@codesetup@@</span>
</label> </label>
<br /> <br />
@ -128,17 +128,17 @@
<div id="instance-data"> <div id="instance-data">
Some instance data by Some instance data by
<a href="https://instances.social" target="_blank">instances.social API</a><br /> <a href="https://instances.social" target="_blank">instances.social API</a><br />
<h5 id="ins-title"></h5> <h5 id="ins-title" class="ins-loading"></h5>
Administered by:<a id="ins-admin"></a><br /> Administered by:<a id="ins-admin" class="ins-loading"></a><br />
<span id="ins-desc"></span><br /> <span id="ins-desc" class="ins-loading"></span><br />
<img src="../../img/loading.svg" id="ins-prof" width="200" /><br /> <img src="../../img/loading.svg" id="ins-prof" width="200" /><br />
<br /> <br />
@@domain@@:<span id="ins-name"></span><br /> @@domain@@:<span id="ins-name" class="ins-loading"></span><br />
@@connect@@:<span id="ins-connect"></span>@@ko@@<br /> @@connect@@:<span id="ins-connect" class="ins-loading"></span>@@ko@@<br />
@@toots@@:<span id="ins-toot"></span>@@ko@@<br /> @@toots@@:<span id="ins-toot" class="ins-loading"></span>@@ko@@<br />
@@users@@:<span id="ins-user"></span>@@users@@<br /> @@users@@:<span id="ins-user" class="ins-loading"></span>@@users@@<br />
@@safety@@:<span id="ins-per"></span>%<br /> @@safety@@:<span id="ins-per" class="ins-loading"></span>%<br />
@@ver@@:<span id="ins-ver"></span>@<span id="ins-upd"></span><br /> @@ver@@:<span id="ins-ver" class="ins-loading"></span>@<span id="ins-upd" class="ins-loading"></span><br />
</div> </div>
</div> </div>
<script type="text/javascript" src="../../js/ui/theme.js"></script> <script type="text/javascript" src="../../js/ui/theme.js"></script>

View File

@ -1538,7 +1538,7 @@
</div> </div>
</div> </div>
</div> </div>
<a onclick="about()" class="nex waves-effect pwa"> <a id="onClickAbout" class="nex waves-effect pwa">
<i class="material-icons" style="font-size: 1rem;">info</i>@@about@@ </a <i class="material-icons" style="font-size: 1rem;">info</i>@@about@@ </a
>&nbsp;|&nbsp; >&nbsp;|&nbsp;
<a onclick="bottomReverse()" class="nex waves-effect"> <a onclick="bottomReverse()" class="nex waves-effect">
@ -1723,6 +1723,7 @@
<!--JS--> <!--JS-->
<script type="text/javascript" src="../../@@node_base@@/jquery/dist/jquery.js"></script> <script type="text/javascript" src="../../@@node_base@@/jquery/dist/jquery.js"></script>
<script type="text/javascript" src="../../js/platform/first.js"></script> <script type="text/javascript" src="../../js/platform/first.js"></script>
<script type="text/javascript" src="../../js/common/api.js"></script>
<script type="text/javascript" src="../../@@node_base@@/grapheme-splitter/index.js"></script> <script type="text/javascript" src="../../@@node_base@@/grapheme-splitter/index.js"></script>
<script <script
type="text/javascript" type="text/javascript"

View File

@ -3,8 +3,8 @@
"lang_toot": "トゥート", "lang_toot": "トゥート",
"lang_there": "あり", "lang_there": "あり",
"lang_nothing": "なし", "lang_nothing": "なし",
"lang_yesno": "はい", "lang_yesno": "せやな",
"lang_no": "いいえ", "lang_no": "ちゃうわ",
"lang_progress": "処理中", "lang_progress": "処理中",
"lang_edit": "編集", "lang_edit": "編集",
"lang_del": "削除", "lang_del": "削除",
@ -38,6 +38,7 @@
"lang_version_platform_linux": "このソフトウェアSnapcraftからダウンロードしたんか普通はホームページからインストールするし「いいえ」でええんやけど。「はい」にしたらSnapcraftはんがアップデートするからTheDeskはアップデートせえへんとか言わへんようになる。", "lang_version_platform_linux": "このソフトウェアSnapcraftからダウンロードしたんか普通はホームページからインストールするし「いいえ」でええんやけど。「はい」にしたらSnapcraftはんがアップデートするからTheDeskはアップデートせえへんとか言わへんようになる。",
"lang_version_platform_mac": "このソフトウェアHomebrew caskからダウンロードしたんか普通はホームページからインストールするし「いいえ」でええんやけど。「はい」にしたらHomebrew caskはんがアップデートするからTheDeskはアップデートせえへんとか言わへんようになる。", "lang_version_platform_mac": "このソフトウェアHomebrew caskからダウンロードしたんか普通はホームページからインストールするし「いいえ」でええんやけど。「はい」にしたらHomebrew caskはんがアップデートするからTheDeskはアップデートせえへんとか言わへんようになる。",
"lang_login_noauth": "認証せんと見る", "lang_login_noauth": "認証せんと見る",
"lang_login_changedData": "プロフの情報が変わってしもたけど、もっかい読み込んだ方がええんちゃうか?",
"lang_manager_info": "インスタンス情報", "lang_manager_info": "インスタンス情報",
"lang_manager_refresh": "情報更新", "lang_manager_refresh": "情報更新",
"lang_manager_delete": "削除", "lang_manager_delete": "削除",

View File

@ -38,6 +38,7 @@
"lang_version_platform_linux": "このソフトウェアはSnapcraft(snapd)からインストールしましたか通常はホームページからインストールするため「いいえ」を選んでください。「はい」を選ぶとSnapcraftからアップデートが提供され、アップデートの通知を出しません。", "lang_version_platform_linux": "このソフトウェアはSnapcraft(snapd)からインストールしましたか通常はホームページからインストールするため「いいえ」を選んでください。「はい」を選ぶとSnapcraftからアップデートが提供され、アップデートの通知を出しません。",
"lang_version_platform_mac": "このソフトウェアはHomebrew Caskからインストールしましたか通常はホームページからインストールするため「いいえ」を選んでください。「はい」を選ぶとアップデートの通知を出しません。", "lang_version_platform_mac": "このソフトウェアはHomebrew Caskからインストールしましたか通常はホームページからインストールするため「いいえ」を選んでください。「はい」を選ぶとアップデートの通知を出しません。",
"lang_login_noauth": "認証せずに見る", "lang_login_noauth": "認証せずに見る",
"lang_login_changedData": "プロフィール情報が変更されました。再読み込みしますか?",
"lang_manager_info": "インスタンス情報", "lang_manager_info": "インスタンス情報",
"lang_manager_refresh": "情報更新", "lang_manager_refresh": "情報更新",
"lang_manager_delete": "削除", "lang_manager_delete": "削除",

View File

@ -515,7 +515,7 @@
<button class="btn waves-effect red" style="width:100%; max-width:40rem;" <button class="btn waves-effect red" style="width:100%; max-width:40rem;"
onclick="if(confirm('@@resetconfirm@@')){ localStorage.clear(); location.href='index.html'; }"><i onclick="if(confirm('@@resetconfirm@@')){ localStorage.clear(); location.href='index.html'; }"><i
class="material-icons left">delete</i>@@reset@@</button><br><br> class="material-icons left">delete</i>@@reset@@</button><br><br>
<button class="btn waves-effect indigo pwa" onclick="about()" style="width:100%; max-width:40rem;"><i <button class="btn waves-effect indigo pwa" id="onClickAbout" style="width:100%; max-width:40rem;"><i
class="material-icons left">info</i>@@about@@</button> class="material-icons left">info</i>@@about@@</button>
<a href="https://thedesk.top" class="btn waves-effect deep-purple lighten-2" style="width:100%; max-width:40rem;"><i <a href="https://thedesk.top" class="btn waves-effect deep-purple lighten-2" style="width:100%; max-width:40rem;"><i
class="material-icons left">web</i>@@hp@@</a> class="material-icons left">web</i>@@hp@@</a>

View File

@ -83,7 +83,7 @@
<script type="text/javascript" src="../../@@node_base@@/jquery/dist/jquery.js"></script> <script type="text/javascript" src="../../@@node_base@@/jquery/dist/jquery.js"></script>
<script type="text/javascript" src="../../js/platform/first.js"></script> <script type="text/javascript" src="../../js/platform/first.js"></script>
<script type="text/javascript" src="../../@@node_base@@/materialize-css/dist/js/materialize.js"></script> <script type="text/javascript" src="../../@@node_base@@/materialize-css/dist/js/materialize.js"></script>
<i class="material-icons pointer waves-effect" onclick="about();">info</i> <i class="material-icons pointer waves-effect" id="onClickAbout">info</i>
<i class="material-icons pointer waves-effect" onclick="skipper();">clear</i> <i class="material-icons pointer waves-effect" onclick="skipper();">clear</i>
<!--a href="update.html">Reload</a--> <!--a href="update.html">Reload</a-->
<div id="start"> <div id="start">