Coding style

This commit is contained in:
cutls 2019-11-08 22:52:54 +09:00
parent 615b89be3a
commit f35232cc52
30 changed files with 8287 additions and 7037 deletions

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -1,214 +1,225 @@
document.title="TheDesk" document.title = 'TheDesk'
$.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) || []) allowed = (((allowed || '') + '').toLowerCase().match(/<[a-z][a-z0-9]*>/g) || []).join('')
.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 : ''
}); })
}; }
function escapeHTML(str) { function escapeHTML(str) {
if (!str) { if (!str) {
return ""; return ''
} }
return str.replace(/&/g, '&amp;') return str
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;') .replace(/</g, '&lt;')
.replace(/>/g, '&gt;') .replace(/>/g, '&gt;')
.replace(/"/g, '&quot;') .replace(/"/g, '&quot;')
.replace(/'/g, '&#039;'); .replace(/'/g, '&#039;')
} }
//PHPのnl2brと同様 //PHPのnl2brと同様
function nl2br(str) { function nl2br(str) {
if (!str) { if (!str) {
return ""; return ''
} }
str = str.replace(/\r\n/g, "<br />"); str = str.replace(/\r\n/g, '<br />')
str = str.replace(/(\n|\r)/g, "<br />"); str = str.replace(/(\n|\r)/g, '<br />')
return str; return str
} }
function br2nl(str) { function br2nl(str) {
if (!str) { if (!str) {
return ""; return ''
} }
str = str.replace(/<br \/>/g, "\r\n"); str = str.replace(/<br \/>/g, '\r\n')
return str; return str
} }
function formattime(date) { function formattime(date) {
var str = date.getFullYear() + "-"; var str = date.getFullYear() + '-'
if (date.getMonth() + 1 < 10) { if (date.getMonth() + 1 < 10) {
str = str + "0" + (date.getMonth() + 1) + "-"; str = str + '0' + (date.getMonth() + 1) + '-'
} else { } else {
str = str + (date.getMonth() + 1) + "-"; str = str + (date.getMonth() + 1) + '-'
} }
if (date.getDate() < 10) { if (date.getDate() < 10) {
str = str + "0" + date.getDate() str = str + '0' + date.getDate()
} else { } else {
str = str + date.getDate() str = str + date.getDate()
} }
str = str + "T"; str = str + 'T'
if (date.getHours() < 10) { if (date.getHours() < 10) {
str = str + "0" + date.getHours() + ":" str = str + '0' + date.getHours() + ':'
} else { } else {
str = str + date.getHours() + ":" str = str + date.getHours() + ':'
} }
if (date.getMinutes() < 10) { if (date.getMinutes() < 10) {
str = str + "0" + date.getMinutes() str = str + '0' + date.getMinutes()
} else { } else {
str = str + date.getMinutes() str = str + date.getMinutes()
} }
return escapeHTML(str); return escapeHTML(str)
} }
function formattimeutc(date) { function formattimeutc(date) {
var str = date.getUTCFullYear() + "-"; var str = date.getUTCFullYear() + '-'
if (date.getUTCMonth() + 1 < 10) { if (date.getUTCMonth() + 1 < 10) {
str = str + "0" + (date.getUTCMonth() + 1) + "-"; str = str + '0' + (date.getUTCMonth() + 1) + '-'
} else { } else {
str = str + (date.getUTCMonth() + 1) + "-"; str = str + (date.getUTCMonth() + 1) + '-'
} }
if (date.getUTCDate() < 10) { if (date.getUTCDate() < 10) {
str = str + "0" + date.getUTCDate() str = str + '0' + date.getUTCDate()
} else { } else {
str = str + date.getUTCDate() str = str + date.getUTCDate()
} }
str = str + "T"; str = str + 'T'
if (date.getUTCHours() < 10) { if (date.getUTCHours() < 10) {
str = str + "0" + date.getUTCHours() + ":" str = str + '0' + date.getUTCHours() + ':'
} else { } else {
str = str + date.getUTCHours() + ":" str = str + date.getUTCHours() + ':'
} }
if (date.getUTCMinutes() < 10) { if (date.getUTCMinutes() < 10) {
str = str + "0" + date.getUTCMinutes() str = str + '0' + date.getUTCMinutes()
} else { } else {
str = str + date.getUTCMinutes() str = str + date.getUTCMinutes()
} }
return escapeHTML(str); return escapeHTML(str)
} }
postMessage(["sendSinmpleIpc", "custom-css-request"], "*") postMessage(['sendSinmpleIpc', 'custom-css-request'], '*')
function makeCID() { function makeCID() {
return randomStr(8) + "-" + randomStr(4) + "-" + randomStr(4) + "-" + randomStr(4) + "-" + randomStr(12); return (
randomStr(8) +
'-' +
randomStr(4) +
'-' +
randomStr(4) +
'-' +
randomStr(4) +
'-' +
randomStr(12)
)
} }
function randomStr(l) { function randomStr(l) {
// 生成する文字列に含める文字セット // 生成する文字列に含める文字セット
var c = "abcdefghijklmnopqrstuvwxyz0123456789"; var c = 'abcdefghijklmnopqrstuvwxyz0123456789'
var cl = c.length; var cl = c.length
var r = ""; var 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)]
} }
return r; return r
} }
function rgbToHex(color) { function rgbToHex(color) {
// HEXに変換したものを代入する変数 // HEXに変換したものを代入する変数
var hex = ''; var hex = ''
// 第1引数がHEXのとき変換処理は必要ないのでそのままreturn // 第1引数がHEXのとき変換処理は必要ないのでそのままreturn
// IE8の場合はjQueryのcss()関数でHEXを返すので除外 // IE8の場合はjQueryのcss()関数でHEXを返すので除外
if (color.match(/^#[a-f\d]{3}$|^#[a-f\d]{6}$/i)) { if (color.match(/^#[a-f\d]{3}$|^#[a-f\d]{6}$/i)) {
return color; return color
} }
// 正規表現 // 正規表現
var regex = color.match(/^rgb\(([0-9.]+),\s*([0-9.]+),\s*([0-9.]+)\)$/); var regex = color.match(/^rgb\(([0-9.]+),\s*([0-9.]+),\s*([0-9.]+)\)$/)
// 正規表現でマッチしたとき // 正規表現でマッチしたとき
if (regex) { if (regex) {
var rgb = var rgb = [
[
// 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) {
// rgb(1,1,1)のようなときHEXに変換すると1桁になる // rgb(1,1,1)のようなときHEXに変換すると1桁になる
// 1桁のときは前に0を足す // 1桁のときは前に0を足す
if (rgb[i].length == 1) { if (rgb[i].length == 1) {
rgb[i] = '0' + rgb[i]; rgb[i] = '0' + rgb[i]
} }
hex += rgb[i]; hex += rgb[i]
} }
return hex; return hex
} }
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 ret = 0; var ret = 0
for (var i = 0; i < str.length; i++, ret++) { for (var i = 0; i < str.length; i++, ret++) {
var upper = str.charCodeAt(i); var upper = str.charCodeAt(i)
var lower = str.length > (i + 1) ? str.charCodeAt(i + 1) : 0; var lower = str.length > i + 1 ? str.charCodeAt(i + 1) : 0
if ($.isSurrogatePear(upper, lower)) { if ($.isSurrogatePear(upper, lower)) {
i++; i++
} }
} }
return ret; return ret
}; }
$.mb_substr = function(str, begin, end) { $.mb_substr = function(str, begin, end) {
var ret = ''; var ret = ''
for (var i = 0, len = 0; i < str.length; i++, len++) { for (var i = 0, len = 0; i < str.length; i++, len++) {
var upper = str.charCodeAt(i); var upper = str.charCodeAt(i)
var lower = str.length > (i + 1) ? str.charCodeAt(i + 1) : 0; var lower = str.length > i + 1 ? str.charCodeAt(i + 1) : 0
var s = ''; var s = ''
if ($.isSurrogatePear(upper, lower)) { if ($.isSurrogatePear(upper, lower)) {
i++; i++
s = String.fromCharCode(upper, lower); s = String.fromCharCode(upper, lower)
} else { } else {
s = String.fromCharCode(upper); s = String.fromCharCode(upper)
} }
if (begin <= len && len < end) { if (begin <= len && len < end) {
ret += s; ret += s
} }
} }
return ret; return ret
}; }
//ソートするやつ //ソートするやつ
function object_array_sort(data, key, order, fn) { function object_array_sort(data, key, order, fn) {
var num_a = -1; var num_a = -1
var num_b = 1; var num_b = 1
if (order === 'asc') { if (order === 'asc') {
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
if (x < y) return num_b; if (x < y) return num_b
return 0; return 0
}); })
var arrObj = {}; var arrObj = {}
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
arrObj[data[i]['family']] = data[i]; arrObj[data[i]['family']] = data[i]
} }
data = []; data = []
for (var key in arrObj) { for (var key in arrObj) {
data.push(arrObj[key]); data.push(arrObj[key])
} }
fn(data); fn(data)
} }
function setLog(txt1, txt2, txt3) { function setLog(txt1, txt2, txt3) {
//url,statuscode,responsetext //url,statuscode,responsetext
var text = new Date().toUTCString() var text = new Date().toUTCString()
text=text+","+txt1+","+txt2+","+escapeCsv(txt3) text = text + ',' + txt1 + ',' + txt2 + ',' + escapeCsv(txt3)
console.error(text) console.error(text)
postMessage(["log", text], "*") postMessage(['log', text], '*')
} }
function escapeCsv(str) { function escapeCsv(str) {
if(!str){return str;} if (!str) {
var result; return str
result = str.replace(/\"/g, "\"\"");
if (result.indexOf(",") >= 0) {
result = "\"" + result + "\""
} }
return result; var result
result = str.replace(/\"/g, '""')
if (result.indexOf(',') >= 0) {
result = '"' + result + '"'
}
return result
} }

View File

@ -1,126 +1,125 @@
//TL取得 //TL取得
var websocket; var websocket
function tl(data) { function tl(data) {
var tlid = 0; var tlid = 0
if (websocket) { if (websocket) {
websocket.close() websocket.close()
} }
var acct_id = $("#post-acct-sel").val(); var acct_id = $('#post-acct-sel').val()
var type = $("#type-sel").val(); var type = $('#type-sel').val()
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem('domain_' + acct_id)
//タグの場合はカラム追加して描画 //タグの場合はカラム追加して描画
if (!type) { if (!type) {
//デフォルト //デフォルト
var type = "local"; var type = 'local'
} }
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem('acct_' + acct_id + '_at')
$("#notice_nano").text(cap(type, data) + " TL(" + localStorage.getItem( $('#notice_nano').text(
"user_" + acct_id) + "@" + domain + ")"); cap(type, data) + ' TL(' + localStorage.getItem('user_' + acct_id) + '@' + domain + ')'
var start = "https://" + domain + "/api/v1/timelines/" + com(type, data); )
var start = 'https://' + domain + '/api/v1/timelines/' + com(type, data)
fetch(start, { fetch(start, {
method: 'GET', method: 'GET',
headers: { headers: {
'content-type': 'application/json', 'content-type': 'application/json',
'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) { })
console.error(error); .catch(function(error) {
}).then(function (json) { console.error(error)
var templete = parse([json[0]], '', acct_id, tlid); })
$("#timeline_nano").html(templete); .then(function(json) {
jQuery("time.timeago").timeago(); var templete = parse([json[0]], '', acct_id, tlid)
$("#menu").addClass("hide"); $('#timeline_nano').html(templete)
}); jQuery('time.timeago').timeago()
$('#menu').addClass('hide')
})
//Streaming接続 //Streaming接続
var tlid = 0; var tlid = 0
if (type == "home") { if (type == 'home') {
var start = "wss://" + domain + var start = 'wss://' + domain + '/api/v1/streaming/?stream=user&access_token=' + at
"/api/v1/streaming/?stream=user&access_token=" + at; } else if (type == 'pub') {
} else if (type == "pub") { var start = 'wss://' + domain + '/api/v1/streaming/?stream=public&access_token=' + at
var start = "wss://" + domain + } else if (type == 'local') {
"/api/v1/streaming/?stream=public&access_token=" + at; var start = 'wss://' + domain + '/api/v1/streaming/?stream=public:local&access_token=' + at
} else if (type == "local") { } else if (type == 'tag') {
var start = "wss://" + domain + var start =
"/api/v1/streaming/?stream=public:local&access_token=" + at; 'wss://' + domain + '/api/v1/streaming/?stream=hashtag&tag=' + data + '&access_token=' + at
} else if (type == "tag") {
var start = "wss://" + domain +
"/api/v1/streaming/?stream=hashtag&tag=" + data + "&access_token=" + at;
} }
websocket = new WebSocket(start); websocket = new WebSocket(start)
websocket.onopen = function(mess) { websocket.onopen = function(mess) {
$("#notice_icon_" + tlid).removeClass("red-text"); $('#notice_icon_' + tlid).removeClass('red-text')
} }
websocket.onmessage = function(mess) { websocket.onmessage = function(mess) {
var typeA = JSON.parse(mess.data).event; var typeA = JSON.parse(mess.data).event
if (typeA == "update") { if (typeA == 'update') {
var obj = JSON.parse(JSON.parse(mess.data).payload); var obj = JSON.parse(JSON.parse(mess.data).payload)
var templete = parse([obj], '', acct_id, tlid); var templete = parse([obj], '', acct_id, tlid)
jQuery("time.timeago").timeago(); jQuery('time.timeago').timeago()
$("#timeline_nano").html(templete); $('#timeline_nano').html(templete)
} }
} }
websocket.onerror = function(error) { websocket.onerror = function(error) {
console.error('WebSocket Error ' + error); console.error('WebSocket Error ' + error)
}; }
websocket.onclose = function(mess) { websocket.onclose = function(mess) {
console.error("Close Streaming API:" + type); console.error('Close Streaming API:' + type)
} }
} }
//TLのタイトル //TLのタイトル
function cap(type, data) { function cap(type, data) {
if (type == "home") { if (type == 'home') {
return "Home" return 'Home'
} else if (type == "local") { } else if (type == 'local') {
return "Local" return 'Local'
} else if (type == "pub") { } else if (type == 'pub') {
return "Public" return 'Public'
} else if (type == "tag") { } else if (type == 'tag') {
return "#" + data return '#' + data
} else if (type == "list") { } else if (type == 'list') {
return "List(id:" + data + ")" return 'List(id:' + data + ')'
} else if (type == "notf") { } else if (type == 'notf') {
return "Notification" return 'Notification'
} }
} }
//TLのURL //TLのURL
function com(type, data) { function com(type, data) {
if (type == "home") { if (type == 'home') {
return "home?" return 'home?'
} else if (type == "local") { } else if (type == 'local') {
return "public?local=true&" return 'public?local=true&'
} else if (type == "pub") { } else if (type == 'pub') {
return "public?" return 'public?'
} else if (type == "tag") { } else if (type == 'tag') {
return "tag/" + data + "?" return 'tag/' + data + '?'
} }
if (type == "list") { if (type == 'list') {
return "list/" + data + "?" return 'list/' + data + '?'
} }
} }
//TLのアイコン //TLのアイコン
function icon(type) { function icon(type) {
if (type == "home") { if (type == 'home') {
return "home" return 'home'
} else if (type == "local") { } else if (type == 'local') {
return "people_outline" return 'people_outline'
} else if (type == "pub") { } else if (type == 'pub') {
return "language" return 'language'
} else if (type == "tag") { } else if (type == 'tag') {
return "search" return 'search'
} }
if (type == "list") { if (type == 'list') {
return "subject" return 'subject'
} }
} }
function todo() {} function todo() {}
@ -129,134 +128,136 @@ function hide() { }
$(function($) { $(function($) {
//キーボードショートカット //キーボードショートカット
$(window).keydown(function(e) { $(window).keydown(function(e) {
var hasFocus = $('input').is(':focus'); var hasFocus = $('input').is(':focus')
var hasFocus2 = $('textarea').is(':focus'); var hasFocus2 = $('textarea').is(':focus')
//Ctrl+Enter:投稿 //Ctrl+Enter:投稿
if (event.ctrlKey) { if (event.ctrlKey) {
if (e.keyCode === 13) { if (e.keyCode === 13) {
post(); post()
return false; return false
} }
} }
}); })
}); })
function set() { function set() {
$("#menu").toggleClass("hide"); $('#menu').toggleClass('hide')
if($("#menu").hasClass("hide")){ if ($('#menu').hasClass('hide')) {
$("#setting").text("Setting") $('#setting').text('Setting')
} else { } else {
$("#setting").text("Close") $('#setting').text('Close')
} }
} }
var multi = localStorage.getItem("multi"); var multi = localStorage.getItem('multi')
if (!multi) { if (!multi) {
var obj = [ var obj = [
{ {
at: localStorage.getItem(localStorage.getItem("domain_" + acct_id) + "_at"), at: localStorage.getItem(localStorage.getItem('domain_' + acct_id) + '_at'),
name: localStorage.getItem("name_" + acct_id), name: localStorage.getItem('name_' + acct_id),
domain: localStorage.getItem("domain_" + acct_id), domain: localStorage.getItem('domain_' + acct_id),
user: localStorage.getItem("user_" + acct_id), user: localStorage.getItem('user_' + acct_id),
prof: localStorage.getItem("prof_" + acct_id) prof: localStorage.getItem('prof_' + acct_id)
} }
]; ]
var json = JSON.stringify(obj); var json = JSON.stringify(obj)
localStorage.setItem("multi", json); localStorage.setItem('multi', json)
} else { } else {
var obj = JSON.parse(multi); var obj = JSON.parse(multi)
} }
var templete; var templete
var last = localStorage.getItem("last-use"); var last = localStorage.getItem('last-use')
var sel; var sel
Object.keys(obj).forEach(function(key) { Object.keys(obj).forEach(function(key) {
var acct = obj[key]; var acct = obj[key]
var list = key * 1 + 1; var list = key * 1 + 1
if (key == last) { if (key == last) {
sel = "selected"; sel = 'selected'
} else { } else {
sel = ""; sel = ''
} }
templete = '<option value="' + key + '" ' + sel + ">" + acct.user + "@" + acct.domain + "</option>"; templete = `<option value="${key}" ${sel}>${acct.user}@${acct.domain}</option>`
$("#post-acct-sel").append(templete); $('#post-acct-sel').append(templete)
}); })
function mov() { function mov() {
return false; return false
} }
function resetmv() { function resetmv() {
return false; return false
} }
function post() { function post() {
var acct_id = $("#post-acct-sel").val(); var acct_id = $('#post-acct-sel').val()
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/statuses"; var start = 'https://' + domain + '/api/v1/statuses'
var str = $("#textarea").val(); var str = $('#textarea').val()
var toot = { var toot = {
status: str status: str
}; }
var vis = loadVis(acct_id); var vis = loadVis(acct_id)
toot.visibility = vis; toot.visibility = vis
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest()
httpreq.open("POST", start, true); httpreq.open('POST', 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(toot)); httpreq.send(JSON.stringify(toot))
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
if(this.status!==200){ setLog(start, this.status, this.response); } if (this.status !== 200) {
$("#textarea").val(""); setLog(start, this.status, this.response)
}
$('#textarea').val('')
}
} }
};
} }
function loadVis(acct_id) { function loadVis(acct_id) {
var vist = localStorage.getItem("vis"); var vist = localStorage.getItem('vis')
if (!vist) { if (!vist) {
return "public"; return 'public'
} else { } else {
if (vist == "memory") { if (vist == 'memory') {
var memory = localStorage.getItem("vis-memory-" + acct_id); var memory = localStorage.getItem('vis-memory-' + acct_id)
if (!memory) { if (!memory) {
memory = "public"; memory = 'public'
} }
return memory; return memory
} else if (vist == "server" || vist == "useapi") { } else if (vist == 'server' || vist == 'useapi') {
var multi = localStorage.getItem("multi"); var multi = localStorage.getItem('multi')
var obj = JSON.parse(multi); var obj = JSON.parse(multi)
var memory = obj[acct_id]["vis"]; var memory = obj[acct_id]['vis']
if (!memory) { if (!memory) {
memory = "public"; memory = 'public'
} }
return memory; return memory
} else { } else {
return vist; return vist
} }
} }
} }
function loader() { function loader() {
var acct_id = $("#post-acct-sel").val() var acct_id = $('#post-acct-sel').val()
console.log(loadVis(acct_id)) console.log(loadVis(acct_id))
$("#vis-sel").val(loadVis(acct_id)); $('#vis-sel').val(loadVis(acct_id))
} }
loader() loader()
$("textarea").height(15); //init $('textarea').height(15) //init
$("textarea").css("lineHeight", "1rem"); //init $('textarea').css('lineHeight', '1rem') //init
$("textarea").on("input", function(evt) { $('textarea').on('input', function(evt) {
if (evt.target.scrollHeight > evt.target.offsetHeight) { if (evt.target.scrollHeight > evt.target.offsetHeight) {
$(evt.target).height(evt.target.scrollHeight); $(evt.target).height(evt.target.scrollHeight)
} else { } else {
var lineHeight = Number( var lineHeight = Number(
$(evt.target) $(evt.target)
.css("lineHeight") .css('lineHeight')
.split("px")[0] .split('px')[0]
); )
while (true) { while (true) {
$(evt.target).height($(evt.target).height() - lineHeight); $(evt.target).height($(evt.target).height() - lineHeight)
if (evt.target.scrollHeight > evt.target.offsetHeight) { if (evt.target.scrollHeight > evt.target.offsetHeight) {
$(evt.target).height(evt.target.scrollHeight); $(evt.target).height(evt.target.scrollHeight)
break; break
} }
} }
} }
}); })

View File

@ -1,194 +1,194 @@
var electron = require("electron"); var electron = require('electron')
const shell = electron.shell; const shell = electron.shell
var ipc = electron.ipcRenderer; var ipc = electron.ipcRenderer
onmessage = function(e) { onmessage = function(e) {
if (e.data[0] == "openUrl") { if (e.data[0] == 'openUrl') {
urls = e.data[1].match(/https?:\/\/(.+)/); urls = e.data[1].match(/https?:\/\/(.+)/)
if (urls) { if (urls) {
shell.openExternal(e.data[1]); shell.openExternal(e.data[1])
}
} else if (e.data[0] == 'sendSinmpleIpc') {
ipc.send(e.data[1], '')
} else if (e.data[0] == 'dialogStore') {
ipc.send('dialogStore', e.data[1])
} else if (e.data[0] == 'bmpImage') {
ipc.send('bmp-image', e.data[1])
} else if (e.data[0] == 'dialogCW') {
ipc.send('dialogCW', e.data[1])
} else if (e.data[0] == 'nativeNotf') {
console.log(e.data[1])
ipc.send('native-notf', e.data[1])
} else if (e.data[0] == 'dialogClient') {
ipc.send('dialogClient', e.data[1])
} else if (e.data[0] == 'generalDL') {
ipc.send('general-dl', e.data[1])
} else if (e.data[0] == 'openFinder') {
ipc.send('open-finder', e.data[1])
} else if (e.data[0] == 'columnDel') {
ipc.send('column-del', e.data[1])
} else if (e.data[0] == 'lang') {
ipc.send('lang', e.data[1])
} else if (e.data[0] == 'exportSettings') {
ipc.send('exportSettings', e.data[1])
} else if (e.data[0] == 'exportSettingsCoreComplete') {
ipc.send('export', e.data[1])
} else if (e.data[0] == 'importSettings') {
ipc.send('importSettings', e.data[1])
} else if (e.data[0] == 'customSound') {
ipc.send('customSound', e.data[1])
} else if (e.data[0] == 'themeJsonDelete') {
ipc.send('theme-json-delete', e.data[1])
} else if (e.data[0] == 'themeJsonCreate') {
ipc.send('theme-json-create', e.data[1])
} else if (e.data[0] == 'themeJsonRequest') {
ipc.send('theme-json-request', e.data[1])
} else if (e.data[0] == 'ha') {
ipc.send('ha', e.data[1])
} else if (e.data[0] == 'ua') {
ipc.send('ua', e.data[1])
} else if (e.data[0] == 'aboutData') {
ipc.send('aboutData', '')
} else if (e.data[0] == 'itunes') {
console.log('NowPlaying')
ipc.send('itunes', e.data[1])
} else if (e.data[0] == 'themeCSSRequest') {
ipc.send('theme-css-request', e.data[1])
} else if (e.data[0] == 'customCSSRequest') {
ipc.send('custom-css-request', e.data[1])
} else if (e.data[0] == 'downloadButton') {
ipc.send('download-btn', e.data[1])
} else if (e.data[0] == 'nano') {
ipc.send('nano', null)
} else if (e.data[0] == 'asReadComp') {
ipc.send('sendMarkersComplete', null)
} else if (e.data[0] == 'copy') {
ipc.send('copy', e.data[1])
} else if (e.data[0] == 'log') {
ipc.send('log', e.data[1])
} }
} else if (e.data[0] == "sendSinmpleIpc") {
ipc.send(e.data[1], "");
} else if (e.data[0] == "dialogStore") {
ipc.send("dialogStore", e.data[1]);
} else if (e.data[0] == "bmpImage") {
ipc.send("bmp-image", e.data[1]);
} else if (e.data[0] == "dialogCW") {
ipc.send("dialogCW", e.data[1]);
} else if (e.data[0] == "nativeNotf") {
console.log(e.data[1]);
ipc.send("native-notf", e.data[1]);
} else if (e.data[0] == "dialogClient") {
ipc.send("dialogClient", e.data[1]);
} else if (e.data[0] == "generalDL") {
ipc.send("general-dl", e.data[1]);
} else if (e.data[0] == "openFinder") {
ipc.send("open-finder", e.data[1]);
} else if (e.data[0] == "columnDel") {
ipc.send("column-del", e.data[1]);
} else if (e.data[0] == "lang") {
ipc.send("lang", e.data[1]);
} else if (e.data[0] == "exportSettings") {
ipc.send("exportSettings", e.data[1]);
} else if (e.data[0] == "exportSettingsCoreComplete") {
ipc.send("export", e.data[1]);
} else if (e.data[0] == "importSettings") {
ipc.send("importSettings", e.data[1]);
} else if (e.data[0] == "customSound") {
ipc.send("customSound", e.data[1]);
} else if (e.data[0] == "themeJsonDelete") {
ipc.send("theme-json-delete", e.data[1]);
} else if (e.data[0] == "themeJsonCreate") {
ipc.send("theme-json-create", e.data[1]);
} else if (e.data[0] == "themeJsonRequest") {
ipc.send("theme-json-request", e.data[1]);
} else if (e.data[0] == "ha") {
ipc.send("ha", e.data[1]);
} else if (e.data[0] == "ua") {
ipc.send("ua", e.data[1]);
} else if (e.data[0] == "aboutData") {
ipc.send("aboutData", "");
} else if (e.data[0] == "itunes") {
console.log("NowPlaying");
ipc.send("itunes", e.data[1]);
} else if (e.data[0] == "themeCSSRequest") {
ipc.send("theme-css-request", e.data[1]);
} else if (e.data[0] == "customCSSRequest") {
ipc.send("custom-css-request", e.data[1]);
} else if (e.data[0] == "downloadButton") {
ipc.send("download-btn", e.data[1]);
} else if (e.data[0] == "nano") {
ipc.send("nano", null);
} else if (e.data[0] == "asReadComp") {
ipc.send("sendMarkersComplete", null);
} else if (e.data[0] == "copy") {
ipc.send("copy", e.data[1]);
} else if (e.data[0] == "log") {
ipc.send("log", e.data[1]);
} }
};
//version.js //version.js
ipc.send("getPlatform", ""); ipc.send('getPlatform', '')
ipc.on("platform", function(event, args) { ipc.on('platform', function(event, args) {
localStorage.setItem("platform", args[0]); localStorage.setItem('platform', args[0])
localStorage.setItem("bit", args[1]); localStorage.setItem('bit', args[1])
localStorage.setItem("about", JSON.stringify([args[2], args[3], args[4], args[5]])); localStorage.setItem('about', JSON.stringify([args[2], args[3], args[4], args[5]]))
}); })
ipc.on("reload", function(event, arg) { ipc.on('reload', function(event, arg) {
location.reload(); location.reload()
}); })
//Native Notf //Native Notf
ipc.on("shownotf", function(event, args) { ipc.on('shownotf', function(event, args) {
if (args["type"] == "toot") { if (args['type'] == 'toot') {
postMessage(["details", [id, acct_id]], "*"); postMessage(['details', [id, acct_id]], '*')
} else if (args["type"] == "userdata") { } else if (args['type'] == 'userdata') {
postMessage(["udg", [user, acct_id]], "*"); postMessage(['udg', [user, acct_id]], '*')
} }
}); })
//first.js //first.js
ipc.on("custom-css-response", function(event, arg) { ipc.on('custom-css-response', function(event, arg) {
if (arg == "") { if (arg == '') {
return false; return false
} }
var styleNode = document.createElement("style"); var styleNode = document.createElement('style')
styleNode.setAttribute("type", "text/css"); styleNode.setAttribute('type', 'text/css')
var content = document.createTextNode(arg); var content = document.createTextNode(arg)
styleNode.append(content); styleNode.append(content)
document.getElementsByTagName("head")[0].append(styleNode); document.getElementsByTagName('head')[0].append(styleNode)
}); })
ipc.on("theme-css-response", function(event, arg) { ipc.on('theme-css-response', function(event, arg) {
if (arg == "") { if (arg == '') {
return false; return false
} }
var styleNode = document.createElement("style"); var styleNode = document.createElement('style')
styleNode.setAttribute("type", "text/css"); styleNode.setAttribute('type', 'text/css')
var content = document.createTextNode(arg); var content = document.createTextNode(arg)
styleNode.append(content); styleNode.append(content)
document.getElementsByTagName("head")[0].append(styleNode); document.getElementsByTagName('head')[0].append(styleNode)
}); })
//img.js //img.js
ipc.on("bmp-img-comp", function(event, b64) { ipc.on('bmp-img-comp', function(event, b64) {
postMessage(["media", [b64[0], "image/png", b64[1]]], "*"); postMessage(['media', [b64[0], 'image/png', b64[1]]], '*')
}); })
//ui,img.js //ui,img.js
ipc.on("general-dl-prog", function(event, arg) { ipc.on('general-dl-prog', function(event, arg) {
console.log("Progress: " + arg); console.log('Progress: ' + arg)
}); })
ipc.on("general-dl-message", function(event, arg) { ipc.on('general-dl-message', function(event, arg) {
var argC = arg.replace(/\\/g, "\\\\") + "\\\\."; var argC = arg.replace(/\\/g, '\\\\') + '\\\\.'
console.log("saved"); console.log('saved')
postMessage(["toastSaved", [arg, argC]], "*"); postMessage(['toastSaved', [arg, argC]], '*')
}); })
//setting.js //setting.js
ipc.on("langres", function(event, arg) { ipc.on('langres', function(event, arg) {
location.href = "../" + arg + "/setting.html"; location.href = '../' + arg + '/setting.html'
}); })
ipc.on("exportSettingsFile", function(event, arg) { ipc.on('exportSettingsFile', function(event, arg) {
postMessage(["exportSettingsCore", arg], "*"); postMessage(['exportSettingsCore', arg], '*')
}); })
ipc.on("exportAllComplete", function(event, arg) { ipc.on('exportAllComplete', function(event, arg) {
postMessage(["alert", "Complete"], "*"); postMessage(['alert', 'Complete'], '*')
}); })
ipc.on("config", function(event, arg) { ipc.on('config', function(event, arg) {
postMessage(["importSettingsCore", arg], "*"); postMessage(['importSettingsCore', arg], '*')
}); })
ipc.on("savefolder", function(event, arg) { ipc.on('savefolder', function(event, arg) {
localStorage.setItem("savefolder", arg); localStorage.setItem('savefolder', arg)
}); })
ipc.on("font-list", function(event, arg) { ipc.on('font-list', function(event, arg) {
postMessage(["fontList", arg], "*"); postMessage(['fontList', arg], '*')
}); })
ipc.on("customSoundRender", function(event, args) { ipc.on('customSoundRender', function(event, args) {
postMessage(["customSoundSave", [args[0], args[1]]], "*"); postMessage(['customSoundSave', [args[0], args[1]]], '*')
}); })
ipc.on("theme-json-list-response", function(event, args) { ipc.on('theme-json-list-response', function(event, args) {
postMessage(["ctLoadCore", args], "*"); postMessage(['ctLoadCore', args], '*')
}); })
ipc.on("theme-json-delete-complete", function(event, args) { ipc.on('theme-json-delete-complete', function(event, args) {
postMessage(["ctLoad", ""], "*"); postMessage(['ctLoad', ''], '*')
}); })
ipc.on("theme-json-response", function(event, args) { ipc.on('theme-json-response', function(event, args) {
postMessage(["customConnect", args], "*"); postMessage(['customConnect', args], '*')
}); })
ipc.on("theme-json-create-complete", function(event, args) { ipc.on('theme-json-create-complete', function(event, args) {
postMessage(["clearCustomImport", ""], "*"); postMessage(['clearCustomImport', ''], '*')
postMessage(["ctLoad", ""], "*"); postMessage(['ctLoad', ''], '*')
}); })
//spotify.js //spotify.js
ipc.on("itunes-np", function(event, arg) { ipc.on('itunes-np', function(event, arg) {
postMessage(["npCore", arg], "*"); postMessage(['npCore', arg], '*')
}); })
//tips.js //tips.js
ipc.on("memory", function(event, arg) { ipc.on('memory', function(event, arg) {
var use = arg[0]; var use = arg[0]
var cpu = arg[1]; var cpu = arg[1]
var total = arg[2]; var total = arg[2]
postMessage(["renderMem", [use, cpu, total]], "*"); postMessage(['renderMem', [use, cpu, total]], '*')
}); })
//log //log
ipc.on("logData", function(event, args) { ipc.on('logData', function(event, args) {
postMessage(["logData", args], "*"); postMessage(['logData', args], '*')
}); })
//update.html //update.html
ipc.on("prog", function(event, arg) { ipc.on('prog', function(event, arg) {
postMessage(["updateProg", arg], "*"); postMessage(['updateProg', arg], '*')
}); })
ipc.on("mess", function(event, arg) { ipc.on('mess', function(event, arg) {
postMessage(["updateMess", arg], "*"); postMessage(['updateMess', arg], '*')
}); })
ipc.on("asRead", function(event, arg) { ipc.on('asRead', function(event, arg) {
postMessage(["asRead", ""], "*"); postMessage(['asRead', ''], '*')
}); })
ipc.on("asReadEnd", function(event, arg) { ipc.on('asReadEnd', function(event, arg) {
postMessage(["asReadEnd", ""], "*"); postMessage(['asReadEnd', ''], '*')
}); })
var webviewDom = document.getElementById("webview"); var webviewDom = document.getElementById('webview')
if (webviewDom) { if (webviewDom) {
webviewDom.addEventListener("new-window", function(e) { webviewDom.addEventListener('new-window', function(e) {
shell.openExternal(e.url); shell.openExternal(e.url)
}); })
} }

View File

@ -1,18 +1,15 @@
/*! https://mths.be/punycode v1.4.1 by @mathias */ /*! https://mths.be/punycode v1.4.1 by @mathias */
;(function(root) { ;(function(root) {
/** Detect free variables */ /** Detect free variables */
var freeExports = typeof exports == 'object' && exports && var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports
!exports.nodeType && exports; var freeModule = typeof module == 'object' && module && !module.nodeType && module
var freeModule = typeof module == 'object' && module && var freeGlobal = typeof global == 'object' && global
!module.nodeType && module;
var freeGlobal = typeof global == 'object' && global;
if ( if (
freeGlobal.global === freeGlobal || freeGlobal.global === freeGlobal ||
freeGlobal.window === freeGlobal || freeGlobal.window === freeGlobal ||
freeGlobal.self === freeGlobal freeGlobal.self === freeGlobal
) { ) {
root = freeGlobal; root = freeGlobal
} }
/** /**
@ -21,10 +18,8 @@
* @type Object * @type Object
*/ */
var punycode, var punycode,
/** Highest positive signed 32-bit float value */ /** Highest positive signed 32-bit float value */
maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1 maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1
/** Bootstring parameters */ /** Bootstring parameters */
base = 36, base = 36,
tMin = 1, tMin = 1,
@ -34,26 +29,22 @@
initialBias = 72, initialBias = 72,
initialN = 128, // 0x80 initialN = 128, // 0x80
delimiter = '-', // '\x2D' delimiter = '-', // '\x2D'
/** Regular expressions */ /** Regular expressions */
regexPunycode = /^xn--/, regexPunycode = /^xn--/,
regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars
regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators
/** Error messages */ /** Error messages */
errors = { errors = {
'overflow': 'Overflow: input needs wider integers to process', overflow: 'Overflow: input needs wider integers to process',
'not-basic': 'Illegal input >= 0x80 (not a basic code point)', 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
'invalid-input': 'Invalid input' 'invalid-input': 'Invalid input'
}, },
/** Convenience shortcuts */ /** Convenience shortcuts */
baseMinusTMin = base - tMin, baseMinusTMin = base - tMin,
floor = Math.floor, floor = Math.floor,
stringFromCharCode = String.fromCharCode, stringFromCharCode = String.fromCharCode,
/** Temporary variable */ /** Temporary variable */
key; key
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
@ -64,7 +55,7 @@
* @returns {Error} Throws a `RangeError` with the applicable error message. * @returns {Error} Throws a `RangeError` with the applicable error message.
*/ */
function error(type) { function error(type) {
throw new RangeError(errors[type]); throw new RangeError(errors[type])
} }
/** /**
@ -76,12 +67,12 @@
* @returns {Array} A new array of values returned by the callback function. * @returns {Array} A new array of values returned by the callback function.
*/ */
function map(array, fn) { function map(array, fn) {
var length = array.length; var length = array.length
var result = []; var result = []
while (length--) { while (length--) {
result[length] = fn(array[length]); result[length] = fn(array[length])
} }
return result; return result
} }
/** /**
@ -95,19 +86,19 @@
* function. * function.
*/ */
function mapDomain(string, fn) { function mapDomain(string, fn) {
var parts = string.split('@'); var parts = string.split('@')
var result = ''; var result = ''
if (parts.length > 1) { if (parts.length > 1) {
// In email addresses, only the domain name should be punycoded. Leave // In email addresses, only the domain name should be punycoded. Leave
// the local part (i.e. everything up to `@`) intact. // the local part (i.e. everything up to `@`) intact.
result = parts[0] + '@'; result = parts[0] + '@'
string = parts[1]; string = parts[1]
} }
// Avoid `split(regex)` for IE8 compatibility. See #17. // Avoid `split(regex)` for IE8 compatibility. See #17.
string = string.replace(regexSeparators, '\x2E'); string = string.replace(regexSeparators, '\x2E')
var labels = string.split('.'); var labels = string.split('.')
var encoded = map(labels, fn).join('.'); var encoded = map(labels, fn).join('.')
return result + encoded; return result + encoded
} }
/** /**
@ -128,25 +119,26 @@
counter = 0, counter = 0,
length = string.length, length = string.length,
value, value,
extra; extra
while (counter < length) { while (counter < length) {
value = string.charCodeAt(counter++); value = string.charCodeAt(counter++)
if (value >= 0xD800 && value <= 0xDBFF && counter < length) { if (value >= 0xd800 && value <= 0xdbff && counter < length) {
// high surrogate, and there is a next character // high surrogate, and there is a next character
extra = string.charCodeAt(counter++); extra = string.charCodeAt(counter++)
if ((extra & 0xFC00) == 0xDC00) { // low surrogate if ((extra & 0xfc00) == 0xdc00) {
output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); // low surrogate
output.push(((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000)
} else { } else {
// unmatched surrogate; only append this code unit, in case the next // unmatched surrogate; only append this code unit, in case the next
// code unit is the high surrogate of a surrogate pair // code unit is the high surrogate of a surrogate pair
output.push(value); output.push(value)
counter--; counter--
} }
} else { } else {
output.push(value); output.push(value)
} }
} }
return output; return output
} }
/** /**
@ -159,15 +151,15 @@
*/ */
function ucs2encode(array) { function ucs2encode(array) {
return map(array, function(value) { return map(array, function(value) {
var output = ''; var output = ''
if (value > 0xFFFF) { if (value > 0xffff) {
value -= 0x10000; value -= 0x10000
output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800); output += stringFromCharCode(((value >>> 10) & 0x3ff) | 0xd800)
value = 0xDC00 | value & 0x3FF; value = 0xdc00 | (value & 0x3ff)
} }
output += stringFromCharCode(value); output += stringFromCharCode(value)
return output; return output
}).join(''); }).join('')
} }
/** /**
@ -181,15 +173,15 @@
*/ */
function basicToDigit(codePoint) { function basicToDigit(codePoint) {
if (codePoint - 48 < 10) { if (codePoint - 48 < 10) {
return codePoint - 22; return codePoint - 22
} }
if (codePoint - 65 < 26) { if (codePoint - 65 < 26) {
return codePoint - 65; return codePoint - 65
} }
if (codePoint - 97 < 26) { if (codePoint - 97 < 26) {
return codePoint - 97; return codePoint - 97
} }
return base; return base
} }
/** /**
@ -206,7 +198,7 @@
function digitToBasic(digit, flag) { function digitToBasic(digit, flag) {
// 0..25 map to ASCII a..z or A..Z // 0..25 map to ASCII a..z or A..Z
// 26..35 map to ASCII 0..9 // 26..35 map to ASCII 0..9
return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5); return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5)
} }
/** /**
@ -215,13 +207,13 @@
* @private * @private
*/ */
function adapt(delta, numPoints, firstTime) { function adapt(delta, numPoints, firstTime) {
var k = 0; var k = 0
delta = firstTime ? floor(delta / damp) : delta >> 1; delta = firstTime ? floor(delta / damp) : delta >> 1
delta += floor(delta / numPoints); delta += floor(delta / numPoints)
for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) { for (; /* no initialization */ delta > (baseMinusTMin * tMax) >> 1; k += base) {
delta = floor(delta / baseMinusTMin); delta = floor(delta / baseMinusTMin)
} }
return floor(k + (baseMinusTMin + 1) * delta / (delta + skew)); return floor(k + ((baseMinusTMin + 1) * delta) / (delta + skew))
} }
/** /**
@ -248,81 +240,77 @@
digit, digit,
t, t,
/** Cached calculation results */ /** Cached calculation results */
baseMinusT; baseMinusT
// Handle the basic code points: let `basic` be the number of input code // Handle the basic code points: let `basic` be the number of input code
// points before the last delimiter, or `0` if there is none, then copy // points before the last delimiter, or `0` if there is none, then copy
// the first basic code points to the output. // the first basic code points to the output.
basic = input.lastIndexOf(delimiter); basic = input.lastIndexOf(delimiter)
if (basic < 0) { if (basic < 0) {
basic = 0; basic = 0
} }
for (j = 0; j < basic; ++j) { for (j = 0; j < basic; ++j) {
// if it's not a basic code point // if it's not a basic code point
if (input.charCodeAt(j) >= 0x80) { if (input.charCodeAt(j) >= 0x80) {
error('not-basic'); error('not-basic')
} }
output.push(input.charCodeAt(j)); output.push(input.charCodeAt(j))
} }
// Main decoding loop: start just after the last delimiter if any basic code // Main decoding loop: start just after the last delimiter if any basic code
// points were copied; start at the beginning otherwise. // points were copied; start at the beginning otherwise.
for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) { for (index = basic > 0 ? basic + 1 : 0; index < inputLength /* no final expression */; ) {
// `index` is the index of the next character to be consumed. // `index` is the index of the next character to be consumed.
// Decode a generalized variable-length integer into `delta`, // Decode a generalized variable-length integer into `delta`,
// which gets added to `i`. The overflow checking is easier // which gets added to `i`. The overflow checking is easier
// if we increase `i` as we go, then subtract off its starting // if we increase `i` as we go, then subtract off its starting
// value at the end to obtain `delta`. // value at the end to obtain `delta`.
for (oldi = i, w = 1, k = base; /* no condition */; k += base) { for (oldi = i, w = 1, k = base /* no condition */; ; k += base) {
if (index >= inputLength) { if (index >= inputLength) {
error('invalid-input'); error('invalid-input')
} }
digit = basicToDigit(input.charCodeAt(index++)); digit = basicToDigit(input.charCodeAt(index++))
if (digit >= base || digit > floor((maxInt - i) / w)) { if (digit >= base || digit > floor((maxInt - i) / w)) {
error('overflow'); error('overflow')
} }
i += digit * w; i += digit * w
t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias
if (digit < t) { if (digit < t) {
break; break
} }
baseMinusT = base - t; baseMinusT = base - t
if (w > floor(maxInt / baseMinusT)) { if (w > floor(maxInt / baseMinusT)) {
error('overflow'); error('overflow')
} }
w *= baseMinusT; w *= baseMinusT
} }
out = output.length + 1; out = output.length + 1
bias = adapt(i - oldi, out, oldi == 0); bias = adapt(i - oldi, out, oldi == 0)
// `i` was supposed to wrap around from `out` to `0`, // `i` was supposed to wrap around from `out` to `0`,
// incrementing `n` each time, so we'll fix that now: // incrementing `n` each time, so we'll fix that now:
if (floor(i / out) > maxInt - n) { if (floor(i / out) > maxInt - n) {
error('overflow'); error('overflow')
} }
n += floor(i / out); n += floor(i / out)
i %= out; i %= out
// Insert `n` at position `i` of the output // Insert `n` at position `i` of the output
output.splice(i++, 0, n); output.splice(i++, 0, n)
} }
return ucs2encode(output); return ucs2encode(output)
} }
/** /**
@ -350,93 +338,89 @@
/** Cached calculation results */ /** Cached calculation results */
handledCPCountPlusOne, handledCPCountPlusOne,
baseMinusT, baseMinusT,
qMinusT; qMinusT
// Convert the input in UCS-2 to Unicode // Convert the input in UCS-2 to Unicode
input = ucs2decode(input); input = ucs2decode(input)
// Cache the length // Cache the length
inputLength = input.length; inputLength = input.length
// Initialize the state // Initialize the state
n = initialN; n = initialN
delta = 0; delta = 0
bias = initialBias; bias = initialBias
// Handle the basic code points // Handle the basic code points
for (j = 0; j < inputLength; ++j) { for (j = 0; j < inputLength; ++j) {
currentValue = input[j]; currentValue = input[j]
if (currentValue < 0x80) { if (currentValue < 0x80) {
output.push(stringFromCharCode(currentValue)); output.push(stringFromCharCode(currentValue))
} }
} }
handledCPCount = basicLength = output.length; handledCPCount = basicLength = output.length
// `handledCPCount` is the number of code points that have been handled; // `handledCPCount` is the number of code points that have been handled;
// `basicLength` is the number of basic code points. // `basicLength` is the number of basic code points.
// Finish the basic string - if it is not empty - with a delimiter // Finish the basic string - if it is not empty - with a delimiter
if (basicLength) { if (basicLength) {
output.push(delimiter); output.push(delimiter)
} }
// Main encoding loop: // Main encoding loop:
while (handledCPCount < inputLength) { while (handledCPCount < inputLength) {
// All non-basic code points < n have been handled already. Find the next // All non-basic code points < n have been handled already. Find the next
// larger one: // larger one:
for (m = maxInt, j = 0; j < inputLength; ++j) { for (m = maxInt, j = 0; j < inputLength; ++j) {
currentValue = input[j]; currentValue = input[j]
if (currentValue >= n && currentValue < m) { if (currentValue >= n && currentValue < m) {
m = currentValue; m = currentValue
} }
} }
// Increase `delta` enough to advance the decoder's <n,i> state to <m,0>, // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
// but guard against overflow // but guard against overflow
handledCPCountPlusOne = handledCPCount + 1; handledCPCountPlusOne = handledCPCount + 1
if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) { if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
error('overflow'); error('overflow')
} }
delta += (m - n) * handledCPCountPlusOne; delta += (m - n) * handledCPCountPlusOne
n = m; n = m
for (j = 0; j < inputLength; ++j) { for (j = 0; j < inputLength; ++j) {
currentValue = input[j]; currentValue = input[j]
if (currentValue < n && ++delta > maxInt) { if (currentValue < n && ++delta > maxInt) {
error('overflow'); error('overflow')
} }
if (currentValue == n) { if (currentValue == n) {
// Represent delta as a generalized variable-length integer // Represent delta as a generalized variable-length integer
for (q = delta, k = base; /* no condition */; k += base) { for (q = delta, k = base /* no condition */; ; k += base) {
t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias
if (q < t) { if (q < t) {
break; break
} }
qMinusT = q - t; qMinusT = q - t
baseMinusT = base - t; baseMinusT = base - t
output.push( output.push(stringFromCharCode(digitToBasic(t + (qMinusT % baseMinusT), 0)))
stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)) q = floor(qMinusT / baseMinusT)
);
q = floor(qMinusT / baseMinusT);
} }
output.push(stringFromCharCode(digitToBasic(q, 0))); output.push(stringFromCharCode(digitToBasic(q, 0)))
bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength); bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength)
delta = 0; delta = 0
++handledCPCount; ++handledCPCount
} }
} }
++delta; ++delta
++n; ++n
} }
return output.join(''); return output.join('')
} }
/** /**
@ -452,10 +436,8 @@
*/ */
function toUnicode(input) { function toUnicode(input) {
return mapDomain(input, function(string) { return mapDomain(input, function(string) {
return regexPunycode.test(string) return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string
? decode(string.slice(4).toLowerCase()) })
: string;
});
} }
/** /**
@ -471,10 +453,8 @@
*/ */
function toASCII(input) { function toASCII(input) {
return mapDomain(input, function(string) { return mapDomain(input, function(string) {
return regexNonASCII.test(string) return regexNonASCII.test(string) ? 'xn--' + encode(string) : string
? 'xn--' + encode(string) })
: string;
});
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
@ -486,7 +466,7 @@
* @memberOf punycode * @memberOf punycode
* @type String * @type String
*/ */
'version': '1.4.1', version: '1.4.1',
/** /**
* An object of methods to convert from JavaScript's internal character * An object of methods to convert from JavaScript's internal character
* representation (UCS-2) to Unicode code points, and back. * representation (UCS-2) to Unicode code points, and back.
@ -494,40 +474,35 @@
* @memberOf punycode * @memberOf punycode
* @type Object * @type Object
*/ */
'ucs2': { ucs2: {
'decode': ucs2decode, decode: ucs2decode,
'encode': ucs2encode encode: ucs2encode
}, },
'decode': decode, decode: decode,
'encode': encode, encode: encode,
'toASCII': toASCII, toASCII: toASCII,
'toUnicode': toUnicode toUnicode: toUnicode
}; }
/** Expose `punycode` */ /** Expose `punycode` */
// Some AMD build optimizers, like r.js, check for specific condition patterns // Some AMD build optimizers, like r.js, check for specific condition patterns
// like the following: // like the following:
if ( if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
typeof define == 'function' &&
typeof define.amd == 'object' &&
define.amd
) {
define('punycode', function() { define('punycode', function() {
return punycode; return punycode
}); })
} else if (freeExports && freeModule) { } else if (freeExports && freeModule) {
if (module.exports == freeExports) { if (module.exports == freeExports) {
// in Node.js, io.js, or RingoJS v0.8.0+ // in Node.js, io.js, or RingoJS v0.8.0+
freeModule.exports = punycode; freeModule.exports = punycode
} else { } else {
// in Narwhal or RingoJS v0.7.0- // in Narwhal or RingoJS v0.7.0-
for (key in punycode) { for (key in punycode) {
punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]); punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key])
} }
} }
} else { } else {
// in Rhino or a web browser // in Rhino or a web browser
root.punycode = punycode; root.punycode = punycode
} }
})(this)
}(this));

File diff suppressed because one or more lines are too long

View File

@ -1,110 +1,118 @@
//BBCodeとMarkdownの入力・パーサー //BBCodeとMarkdownの入力・パーサー
//アカウント変えた時に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(localStorage.getItem("post_" + acct_id) + "(" + localStorage.getItem("domain_" + acct_id) + ")"); $('#toot-post-btn').text(
localStorage.getItem('post_' + acct_id) +
'(' +
localStorage.getItem('domain_' + acct_id) +
')'
)
} else { } else {
$("#toot-post-btn").text(lang.lang_toot + "(" + localStorage.getItem("domain_" + acct_id) + ")"); $('#toot-post-btn').text(lang.lang_toot + '(' + localStorage.getItem('domain_' + acct_id) + ')')
} }
if (!localStorage.getItem("bb_" + acct_id) && !localStorage.getItem("md_" + acct_id)) { if (!localStorage.getItem('bb_' + acct_id) && !localStorage.getItem('md_' + acct_id)) {
$(".markdown").addClass("hide"); $('.markdown').addClass('hide')
$(".anti-markdown").addClass("hide"); $('.anti-markdown').addClass('hide')
} else { } else {
$(".anti-markdown").removeClass("hide"); $('.anti-markdown').removeClass('hide')
} }
if ($(".markdown").hasClass("hide")) { if ($('.markdown').hasClass('hide')) {
localStorage.setItem("md", "hide"); localStorage.setItem('md', 'hide')
} else { } else {
localStorage.removeItem("md"); localStorage.removeItem('md')
} }
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem('domain_' + acct_id)
if (domain == "itabashi.0j0.jp") { if (domain == 'itabashi.0j0.jp') {
$("#limited-button").removeClass("hide"); $('#limited-button').removeClass('hide')
} else { } else {
$("#limited-button").addClass("hide"); $('#limited-button').addClass('hide')
} }
if (domain == "kirishima.cloud") { if (domain == 'kirishima.cloud') {
$("#faicon-btn").show(); $('#faicon-btn').show()
} else { } else {
$("#faicon-btn").hide(); $('#faicon-btn').hide()
} }
if (domain == "imastodon.net") { if (domain == 'imastodon.net') {
trendTag(); trendTag()
} else { } else {
$("#trendtag").html(""); $('#trendtag').html('')
} }
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem('mode_' + domain) == 'misskey') {
M.toast({ html: lang.lang_bbmd_misskey, displayLength: 5000 }) M.toast({ html: lang.lang_bbmd_misskey, displayLength: 5000 })
} }
if (idata[domain + "_letters"]) { if (idata[domain + '_letters']) {
$("#textarea").attr("data-length", idata[domain + "_letters"]) $('#textarea').attr('data-length', idata[domain + '_letters'])
} else { } else {
$("#textarea").attr("data-length", 500) $('#textarea').attr('data-length', 500)
} }
if (idata[domain + "_glitch"] === "true") { if (idata[domain + '_glitch'] === 'true') {
$("#local-button").removeClass("hide"); $('#local-button').removeClass('hide')
} else { } else {
$("#local-button").addClass("hide"); $('#local-button').addClass('hide')
} }
var multi = localStorage.getItem("multi"); var multi = localStorage.getItem('multi')
if (multi) { if (multi) {
var obj = JSON.parse(multi); var obj = JSON.parse(multi)
if (obj[acct_id].background && obj[acct_id].background != "def" && obj[acct_id].text && obj[acct_id].text != "def") { if (
$("#toot-post-btn").removeClass("indigo"); obj[acct_id].background &&
$("#toot-post-btn").css("background-color", "#" + obj[acct_id].background); obj[acct_id].background != 'def' &&
$("#toot-post-btn").css("color", obj[acct_id].text); obj[acct_id].text &&
obj[acct_id].text != 'def'
) {
$('#toot-post-btn').removeClass('indigo')
$('#toot-post-btn').css('background-color', '#' + obj[acct_id].background)
$('#toot-post-btn').css('color', obj[acct_id].text)
} else { } else {
$("#toot-post-btn").css("background-color", ""); $('#toot-post-btn').css('background-color', '')
$("#toot-post-btn").css("color", ""); $('#toot-post-btn').css('color', '')
$("#toot-post-btn").addClass("indigo"); $('#toot-post-btn').addClass('indigo')
} }
} }
loadVis(); loadVis()
} }
//BOXのトグルボタン //BOXのトグルボタン
function mdToggle() { function mdToggle() {
$(".markdown").toggleClass("hide"); $('.markdown').toggleClass('hide')
$(".anti-markdown").toggleClass("hide"); $('.anti-markdown').toggleClass('hide')
if ($(".markdown").hasClass("hide")) { if ($('.markdown').hasClass('hide')) {
localStorage.setItem("md", "hide"); localStorage.setItem('md', 'hide')
} else { } else {
localStorage.removeItem("md"); localStorage.removeItem('md')
} }
} }
//最初に読み込みます(MD対応インスタンスかチェック) //最初に読み込みます(MD対応インスタンスかチェック)
if (localStorage.getItem("md") == "hide") { if (localStorage.getItem('md') == 'hide') {
$(".markdown").addClass("hide"); $('.markdown').addClass('hide')
$(".anti-markdown").removeClass("hide"); $('.anti-markdown').removeClass('hide')
} }
//タグを選んだ時に(BB版) //タグを選んだ時に(BB版)
function tagsel(tag) { function tagsel(tag) {
var acct_id = $("#post-acct-sel").val(); var acct_id = $('#post-acct-sel').val()
if (!localStorage.getItem("bb_" + acct_id)) { if (!localStorage.getItem('bb_' + acct_id)) {
return false; return false
} }
if (tag == "large" || tag == "size" || tag == "color" || tag == "colorhex") { if (tag == 'large' || tag == 'size' || tag == 'color' || tag == 'colorhex') {
var sub = $("#" + tag).val(); var sub = $('#' + tag).val()
var sub = sub.replace(/#/g, ""); var sub = sub.replace(/#/g, '')
surroundHTML(tag + "=" + sub, tag); surroundHTML(tag + '=' + sub, tag)
} else if (tag == "flip=vertical" || tag == "flip=horizontal") { } else if (tag == 'flip=vertical' || tag == 'flip=horizontal') {
surroundHTML(tag, "flip"); surroundHTML(tag, 'flip')
} else { } else {
surroundHTML(tag, tag); surroundHTML(tag, tag)
} }
$("#textarea").focus(); $('#textarea').focus()
} }
//HTMLをエスケープしてXSSを防ぐ //HTMLをエスケープしてXSSを防ぐ
function escape_html(string) { function escape_html(string) {
if (typeof string !== 'string') { if (typeof string !== 'string') {
return string; return string
} }
return string.replace(/[&'`"<>]/g, function(match) { return string.replace(/[&'`"<>]/g, function(match) {
return { return {
@ -113,204 +121,221 @@ function escape_html(string) {
'`': '&#x60;', '`': '&#x60;',
'"': '&quot;', '"': '&quot;',
'<': '&lt;', '<': '&lt;',
'>': '&gt;', '>': '&gt;'
}[match] }[match]
}); })
} }
//テキストボックスで選択したやつをタグで囲む(BB版) //テキストボックスで選択したやつをタグで囲む(BB版)
function surroundHTML(tagS, tagE) { function surroundHTML(tagS, tagE) {
var acct_id = $("#post-acct-sel").val(); var acct_id = $('#post-acct-sel').val()
if (!localStorage.getItem("bb_" + acct_id)) { if (!localStorage.getItem('bb_' + acct_id)) {
return false; return false
} }
var target = document.getElementById("textarea"); var target = document.getElementById('textarea')
var pos = getAreaRange(target); var pos = getAreaRange(target)
var val = target.value; var val = target.value
var range = val.slice(pos.start, pos.end); var range = val.slice(pos.start, pos.end)
var beforeNode = val.slice(0, pos.start); var beforeNode = val.slice(0, pos.start)
var afterNode = val.slice(pos.end); var afterNode = val.slice(pos.end)
var insertNode; var insertNode
if (range || pos.start != pos.end) { if (range || pos.start != pos.end) {
insertNode = '[' + tagS + ']' + range + '[/' + tagE + ']'; insertNode = '[' + tagS + ']' + range + '[/' + tagE + ']'
target.value = beforeNode + insertNode + afterNode; target.value = beforeNode + insertNode + afterNode
} } else if (pos.start == pos.end) {
insertNode = '[' + tagS + ']' + '[/' + tagE + ']'
else if (pos.start == pos.end) { target.value = beforeNode + insertNode + afterNode
insertNode = '[' + tagS + ']' + '[/' + tagE + ']';
target.value = beforeNode + insertNode + afterNode;
} }
} }
function markdown(tag, ck, br, space) { function markdown(tag, ck, br, space) {
if (space == "before") { if (space == 'before') {
tagE = tag; tagE = tag
tag = " " + tag; tag = ' ' + tag
} else { } else {
tagE = tag; tagE = tag
} }
surroundMD(tag, tagE, ck, br); surroundMD(tag, tagE, ck, br)
$("#textarea").focus(); $('#textarea').focus()
} }
function surroundMD(tagS, tagE, ck, br) { function surroundMD(tagS, tagE, ck, br) {
var acct_id = $("#post-acct-sel").val(); var acct_id = $('#post-acct-sel').val()
if (!localStorage.getItem("md_" + acct_id)) { if (!localStorage.getItem('md_' + acct_id)) {
return false; return false
} }
var target = document.getElementById("textarea"); var target = document.getElementById('textarea')
var pos = getAreaRange(target); var pos = getAreaRange(target)
var val = target.value; var val = target.value
var range = val.slice(pos.start, pos.end); var range = val.slice(pos.start, pos.end)
var beforeNode = val.slice(0, pos.start); var beforeNode = val.slice(0, pos.start)
var afterNode = val.slice(pos.end); var afterNode = val.slice(pos.end)
var insertNode; var insertNode
if (br == "yes") { if (br == 'yes') {
var br = "\n"; var br = '\n'
} else { } else {
var br = ""; var br = ''
} }
if ((range || pos.start != pos.end) && ck == "yes") { if ((range || pos.start != pos.end) && ck == 'yes') {
insertNode = tagS + range + tagE; insertNode = tagS + range + tagE
target.value = beforeNode + insertNode + br + afterNode; target.value = beforeNode + insertNode + br + afterNode
} } else if (pos.start == pos.end || ck == 'no') {
insertNode = tagS + range
else if (pos.start == pos.end || ck == "no") { target.value = beforeNode + insertNode + br + afterNode
insertNode = tagS + range;
target.value = beforeNode + insertNode + br + afterNode;
} }
} }
//テキストボックスの前後チェック //テキストボックスの前後チェック
function getAreaRange(obj) { function getAreaRange(obj) {
var pos = new Object(); var pos = new Object()
if (window.getSelection()) { if (window.getSelection()) {
pos.start = obj.selectionStart; pos.start = obj.selectionStart
pos.end = obj.selectionEnd; pos.end = obj.selectionEnd
} }
return pos; return pos
} }
//Markdownのリンク挿入 //Markdownのリンク挿入
function markdownLink() { function markdownLink() {
var acct_id = $("#post-acct-sel").val(); var acct_id = $('#post-acct-sel').val()
if (!localStorage.getItem("md_" + acct_id)) { if (!localStorage.getItem('md_' + acct_id)) {
return false; return false
} }
var linkIns = "[" + $("#linkt").val() + "]" + "(" + $("#link2").val() + ")"; var linkIns = '[' + $('#linkt').val() + ']' + '(' + $('#link2').val() + ')'
if (linkIns != "[]()") { if (linkIns != '[]()') {
$("#textarea").val($("#textarea").val() + linkIns); $('#textarea').val($('#textarea').val() + linkIns)
$("#linkt").val(""); $('#linkt').val('')
$("#link2").val(""); $('#link2').val('')
$("#textarea").focus(); $('#textarea').focus()
} }
} }
//Markdownのimg挿入 //Markdownのimg挿入
function markdownImage() { function markdownImage() {
var acct_id = $("#post-acct-sel").val(); var acct_id = $('#post-acct-sel').val()
if (!localStorage.getItem("md_" + acct_id)) { if (!localStorage.getItem('md_' + acct_id)) {
return false; return false
} }
var imgIns = "![" + $("#image").val() + "]" + "(" + $("#image2").val() + ")"; var imgIns = '![' + $('#image').val() + ']' + '(' + $('#image2').val() + ')'
if (imgIns != "![]()") { if (imgIns != '![]()') {
$("#textarea").val($("#textarea").val() + imgIns); $('#textarea').val($('#textarea').val() + imgIns)
$("#image").val(""); $('#image').val('')
$("#image2").val(""); $('#image2').val('')
$("#textarea").focus(); $('#textarea').focus()
} }
} }
//文字数をチェック(hタグ用) //文字数をチェック(hタグ用)
function str_count(all, part) { function str_count(all, part) {
return (all.match(new RegExp(part, "g")) || []).length; return (all.match(new RegExp(part, 'g')) || []).length
} }
//プレビュー //プレビュー
function preview() { function preview() {
$("#preview-field").show(); $('#preview-field').show()
$("#toot-field").hide(); $('#toot-field').hide()
$("#preview-btn").hide(); $('#preview-btn').hide()
var bb = escape_html($("#textarea").val()); var bb = escape_html($('#textarea').val())
//quote //quote
var bb = bb.replace(/>(.+)$/g, '<blockquote>$1<\/blockquote>'); var bb = bb.replace(/>(.+)$/g, '<blockquote>$1</blockquote>')
//spin //spin
var bb = bb.replace(/\[spin\](.+)\[\/spin\]/g, '<span class="fa fa-spin">$1<\/span>'); var bb = bb.replace(/\[spin\](.+)\[\/spin\]/g, '<span class="fa fa-spin">$1</span>')
//pulse //pulse
var bb = bb.replace(/\[pulse\](.+)\[\/pulse\]/g, '<span class="bbcode-pulse-loading">$1<\/span>'); var bb = bb.replace(/\[pulse\](.+)\[\/pulse\]/g, '<span class="bbcode-pulse-loading">$1</span>')
//large //large
var bb = bb.replace(/\[large=([0-9]{1,2})x\](.+)\[\/large\]/g, '<span class="fa fa-$1x">$2<\/span>'); var bb = bb.replace(
/\[large=([0-9]{1,2})x\](.+)\[\/large\]/g,
'<span class="fa fa-$1x">$2</span>'
)
//vertical //vertical
var bb = bb.replace(/\[flip=vertical\](.+)\[\/flip\]/g, '<span class="fa fa-flip-vertical">$1<\/span>'); var bb = bb.replace(
/\[flip=vertical\](.+)\[\/flip\]/g,
'<span class="fa fa-flip-vertical">$1</span>'
)
//horizontal //horizontal
var bb = bb.replace(/\[flip=horizontal\](.+)\[\/flip\]/g, '<span class="fa fa-flip-horizontal">$1<\/span>'); var bb = bb.replace(
/\[flip=horizontal\](.+)\[\/flip\]/g,
'<span class="fa fa-flip-horizontal">$1</span>'
)
//b //b
var bb = bb.replace(/\[b\](.+)\[\/b\]/g, '<b>$1<\/b>'); var bb = bb.replace(/\[b\](.+)\[\/b\]/g, '<b>$1</b>')
//i //i
var bb = bb.replace(/\[i\](.+)\[\/i\]/g, '<i>$1<\/i>'); var bb = bb.replace(/\[i\](.+)\[\/i\]/g, '<i>$1</i>')
//u //u
var bb = bb.replace(/\[u\](.+)\[\/u\]/g, '<u>$1<\/u>'); var bb = bb.replace(/\[u\](.+)\[\/u\]/g, '<u>$1</u>')
//s //s
var bb = bb.replace(/\[s\](.+)\[\/s\]/g, '<s>$1<\/s>'); var bb = bb.replace(/\[s\](.+)\[\/s\]/g, '<s>$1</s>')
//size //size
var bb = bb.replace(/\[size=([0-9]{1,2})\](.+)\[\/size\]/g, '<span style="font-size:$1px">$2<\/span>'); var bb = bb.replace(
/\[size=([0-9]{1,2})\](.+)\[\/size\]/g,
'<span style="font-size:$1px">$2</span>'
)
//colorhex //colorhex
var bb = bb.replace(/\[colorhex=([A-Fa-f0-9]+)\](.+)\[\/colorhex\]/g, '<span style="color:#$1">$2<\/span>'); var bb = bb.replace(
/\[colorhex=([A-Fa-f0-9]+)\](.+)\[\/colorhex\]/g,
'<span style="color:#$1">$2</span>'
)
//code //code
var bb = bb.replace(/`(.+)`/g, '<code>$1<\/code>'); var bb = bb.replace(/`(.+)`/g, '<code>$1</code>')
//head //head
var m; var m
m = bb.match(/^#{1,6}(.+)$/gm); m = bb.match(/^#{1,6}(.+)$/gm)
if (m) { if (m) {
for (let i = 0; i < m.length; i++) { for (let i = 0; i < m.length; i++) {
var t = m[i].match(/^#{1,6}(.+)$/); var t = m[i].match(/^#{1,6}(.+)$/)
var indexct = '<h' + str_count(m[i], "#") + '>' + t[1] + '</h' + str_count(m[i], "#") + '>'; var indexct = '<h' + str_count(m[i], '#') + '>' + t[1] + '</h' + str_count(m[i], '#') + '>'
var bb = bb.replace(new RegExp(m[i], ""), indexct); var bb = bb.replace(new RegExp(m[i], ''), indexct)
} }
} }
//list(ul) //list(ul)
var li; var li
li = bb.match(/^\- (.+)$/gm); li = bb.match(/^\- (.+)$/gm)
if (li) { if (li) {
for (let l = 0; l < li.length; l++) { for (let l = 0; l < li.length; l++) {
var u = li[l].match(/^\- (.+)$/); var u = li[l].match(/^\- (.+)$/)
var listUl = '<li>' + u[1] + '</li>'; var listUl = '<li>' + u[1] + '</li>'
if (l == 0) { if (l == 0) {
listUl = '<ul>' + listUl; listUl = '<ul>' + listUl
} }
if (l == li.length - 1) { if (l == li.length - 1) {
listUl = listUl + '</ul>'; listUl = listUl + '</ul>'
} }
var bb = bb.replace(new RegExp(li[l], ""), listUl); var bb = bb.replace(new RegExp(li[l], ''), listUl)
} }
} }
//list(ol) //list(ol)
var li; var li
li = bb.match(/^1\. (.+)$/gm); li = bb.match(/^1\. (.+)$/gm)
if (li) { if (li) {
for (let l = 0; l < li.length; l++) { for (let l = 0; l < li.length; l++) {
var u = li[l].match(/^1\. (.+)$/); var u = li[l].match(/^1\. (.+)$/)
var listUl = '<li>' + u[1] + '</li>'; var listUl = '<li>' + u[1] + '</li>'
if (l === 0) { if (l === 0) {
listUl = '<ol>' + listUl; listUl = '<ol>' + listUl
} }
if (l === li.length - 1) { if (l === li.length - 1) {
listUl = listUl + '</ol>'; listUl = listUl + '</ol>'
} }
var bb = bb.replace(new RegExp(li[l], ""), listUl); var bb = bb.replace(new RegExp(li[l], ''), listUl)
} }
} }
//img //img
var bb = bb.replace(/!\[(.+)\]\((https:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)\)/g, '<img src="$2" text="$1" style="width:100%">'); var bb = bb.replace(
/!\[(.+)\]\((https:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)\)/g,
'<img src="$2" text="$1" style="width:100%">'
)
//link //link
var bb = bb.replace(/\[(.+)\]\((https?:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)\)/g, '<a href="$2" target="_blank">$1<\/a>'); var bb = bb.replace(
bb = nl2br(bb); /\[(.+)\]\((https?:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)\)/g,
bb = bb.replace(new RegExp("</li><br />", "g"), ""); '<a href="$2" target="_blank">$1</a>'
$("#md-preview").html(bb); )
bb = nl2br(bb)
bb = bb.replace(new RegExp('</li><br />', 'g'), '')
$('#md-preview').html(bb)
} }
//Editで戻る //Editで戻る
function previewEdit() { function previewEdit() {
$("#preview-field").hide(); $('#preview-field').hide()
$("#toot-field").show(); $('#toot-field').show()
$("#preview-btn").show(); $('#preview-btn').show()
$("#md-preview").html(""); $('#md-preview').html('')
} }

View File

@ -1,319 +1,323 @@
//絵文字ピッカー //絵文字ピッカー
//最初に読み込む //最初に読み込む
$("#emoji-before").addClass("disabled"); $('#emoji-before').addClass('disabled')
$("#emoji-next").addClass("disabled"); $('#emoji-next').addClass('disabled')
//絵文字ボタンのトグル //絵文字ボタンのトグル
function emojiToggle(reaction) { function emojiToggle(reaction) {
var acct_id = $("#post-acct-sel").val(); var acct_id = $('#post-acct-sel').val()
var selin = $("#textarea").prop("selectionStart"); var selin = $('#textarea').prop('selectionStart')
if (!selin) { if (!selin) {
selin = 0; selin = 0
} }
if ($("#emoji").hasClass("hide")) { if ($('#emoji').hasClass('hide')) {
$("#emoji").removeClass("hide"); $('#emoji').removeClass('hide')
$("#right-side").show(); $('#right-side').show()
$("#right-side").css("width", "300px"); $('#right-side').css('width', '300px')
$("#left-side").css("width", "calc(100% - 300px)"); $('#left-side').css('width', 'calc(100% - 300px)')
var width = localStorage.getItem("postbox-width"); var width = localStorage.getItem('postbox-width')
if (width) { if (width) {
width = width.replace("px", "") * 1 + 300; width = width.replace('px', '') * 1 + 300
} else { } else {
width = 600; width = 600
} }
$("#post-box").css("width", width + "px"); $('#post-box').css('width', width + 'px')
$("#suggest").html(""); $('#suggest').html('')
if (!localStorage.getItem("emojis_" + acct_id)) { if (!localStorage.getItem('emojis_' + acct_id)) {
var html = '<button class="btn waves-effect green" style="width:100%; padding:0; margin-top:0;" onclick="emojiGet(\'true\');">' + lang.lang_emoji_get + "</button>"; var html = `<button class="btn waves-effect green" style="width:100%; padding:0; margin-top:0;" onclick="emojiGet('true');">${lang.lang_emoji_get}</button>`
$("#emoji-list").html(html); $('#emoji-list').html(html)
} else { } else {
emojiList("home", reaction); emojiList('home', reaction)
} }
} else { } else {
$("#poll").addClass("hide"); $('#poll').addClass('hide')
$("#right-side").hide(); $('#right-side').hide()
$("#right-side").css("width", "300px"); $('#right-side').css('width', '300px')
$("#emoji").addClass("hide"); $('#emoji').addClass('hide')
$("#suggest").html(""); $('#suggest').html('')
$("#left-side").css("width", "100%"); $('#left-side').css('width', '100%')
var width = localStorage.getItem("postbox-width"); var width = localStorage.getItem('postbox-width')
if (width) { if (width) {
width = width.replace("px", "") * 1; width = width.replace('px', '') * 1
} else { } else {
width = 300; width = 300
} }
$("#post-box").css("width", width + "px"); $('#post-box').css('width', width + 'px')
} }
} }
//絵文字リスト挿入 //絵文字リスト挿入
function emojiGet(parse, started) { function emojiGet(parse, started) {
$("#emoji-list").text("Loading..."); $('#emoji-list').text('Loading...')
var acct_id = $("#post-acct-sel").val(); var acct_id = $('#post-acct-sel').val()
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem('domain_' + acct_id)
if (localStorage.getItem("mode_" + domain) != "misskey") { if (localStorage.getItem('mode_' + domain) != 'misskey') {
var start = "https://" + domain + "/api/v1/custom_emojis"; var start = 'https://' + domain + '/api/v1/custom_emojis'
fetch(start, { fetch(start, {
method: "GET", method: 'GET',
headers: { headers: {
"content-type": "application/json" 'content-type': 'application/json'
} }
}) })
.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 (parse == "true") { if (parse == 'true') {
$("#emoji-list").text("Parsing..."); $('#emoji-list').text('Parsing...')
var md = { var md = {
categorized: {}, categorized: {},
uncategorized: [] uncategorized: []
}; }
var if_categorized = false; var if_categorized = false
Object.keys(json).forEach(function(key) { Object.keys(json).forEach(function(key) {
var emoji = json[key]; var emoji = json[key]
if (emoji.visible_in_picker) { if (emoji.visible_in_picker) {
var listed = true; var listed = true
} else { } else {
var listed = false; var listed = false
} }
if (emoji.category) { if (emoji.category) {
var cat = emoji.category; var cat = emoji.category
if (!md["categorized"][cat]) { if (!md['categorized'][cat]) {
md["categorized"][cat] = []; md['categorized'][cat] = []
} }
md["categorized"][cat].push({ md['categorized'][cat].push({
shortcode: emoji.shortcode, shortcode: emoji.shortcode,
url: emoji.url, url: emoji.url,
listed: listed listed: listed
}); })
if_categorized = true; if_categorized = true
} else { } else {
md["uncategorized"].push({ md['uncategorized'].push({
shortcode: emoji.shortcode, shortcode: emoji.shortcode,
url: emoji.url, url: emoji.url,
listed: listed listed: listed
}); })
} }
}); })
console.log(md); console.log(md)
//絵文字をマストドン公式と同順にソート //絵文字をマストドン公式と同順にソート
md["uncategorized"].sort(function(a, b) { md['uncategorized'].sort(function(a, b) {
if (a.shortcode < b.shortcode) return -1; if (a.shortcode < b.shortcode) return -1
if (a.shortcode > b.shortcode) return 1; if (a.shortcode > b.shortcode) return 1
return 0; return 0
}); })
Object.keys(md["categorized"]).forEach(function(key) { Object.keys(md['categorized']).forEach(function(key) {
md["categorized"][key].sort(function(a, b) { md['categorized'][key].sort(function(a, b) {
if (a.shortcode < b.shortcode) return -1; if (a.shortcode < b.shortcode) return -1
if (a.shortcode > b.shortcode) return 1; if (a.shortcode > b.shortcode) return 1
return 0; return 0
}); })
}); })
md["if_categorized"] = if_categorized; md['if_categorized'] = if_categorized
localStorage.setItem("emojis_" + acct_id, JSON.stringify(md)); localStorage.setItem('emojis_' + acct_id, JSON.stringify(md))
} else { } else {
localStorage.setItem("emojis_" + acct_id, JSON.stringify(md)); localStorage.setItem('emojis_' + acct_id, JSON.stringify(md))
} }
localStorage.setItem("emojiseek", 0); localStorage.setItem('emojiseek', 0)
if (!started) { if (!started) {
emojiList("home"); emojiList('home')
} }
}); })
} else { } else {
var start = "https://" + domain + "/api/meta"; var start = 'https://' + domain + '/api/meta'
fetch(start, { fetch(start, {
method: "POST", method: 'POST',
headers: { headers: {
"content-type": "application/json" 'content-type': 'application/json'
} }
}) })
.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.enableEmojiReaction) { if (json.enableEmojiReaction) {
localStorage.setItem("emojiReaction_" + acct_id, "true"); localStorage.setItem('emojiReaction_' + acct_id, 'true')
} else { } else {
localStorage.setItem("emojiReaction_" + acct_id, "disabled"); localStorage.setItem('emojiReaction_' + acct_id, 'disabled')
} }
var emojis = json.emojis; var emojis = json.emojis
var md = { uncategorized: [] }; var md = { uncategorized: [] }
Object.keys(emojis).forEach(function(key) { Object.keys(emojis).forEach(function(key) {
var emoji = emojis[key]; var emoji = emojis[key]
md["uncategorized"].push({ md['uncategorized'].push({
shortcode: emoji.name, shortcode: emoji.name,
url: emoji.url, url: emoji.url,
listed: true listed: true
}); })
}); })
md["if_categorized"] = false; md['if_categorized'] = false
if (parse == "true") { if (parse == 'true') {
$("#emoji-list").text("Parsing..."); $('#emoji-list').text('Parsing...')
//絵文字をマストドン公式と同順にソート //絵文字をマストドン公式と同順にソート
md["uncategorized"].sort(function(a, b) { md['uncategorized'].sort(function(a, b) {
if (a.shortcode < b.shortcode) return -1; if (a.shortcode < b.shortcode) return -1
if (a.shortcode > b.shortcode) return 1; if (a.shortcode > b.shortcode) return 1
return 0; return 0
}); })
localStorage.setItem("emojis_" + acct_id, JSON.stringify(md)); localStorage.setItem('emojis_' + acct_id, JSON.stringify(md))
} else { } else {
localStorage.setItem("emojis_" + acct_id, JSON.stringify(md)); localStorage.setItem('emojis_' + acct_id, JSON.stringify(md))
} }
localStorage.setItem("emojiseek", 0); localStorage.setItem('emojiseek', 0)
if (!started) { if (!started) {
emojiList("home"); emojiList('home')
} }
}); })
} }
} }
//リストの描画 //リストの描画
function emojiList(target, reaction) { function emojiList(target, reaction) {
$("#now-emoji").text(lang.lang_emoji_custom); $('#now-emoji').text(lang.lang_emoji_custom)
var acct_id = $("#post-acct-sel").val(); var acct_id = $('#post-acct-sel').val()
if (reaction && localStorage.getItem("emojiReaction_" + acct_id) != "true") { if (reaction && localStorage.getItem('emojiReaction_' + acct_id) != 'true') {
console.error("Disabled"); console.error('Disabled')
clear(); clear()
hide(); hide()
return false; return false
} }
var start = localStorage.getItem("emojiseek"); var start = localStorage.getItem('emojiseek')
if (target == "next") { if (target == 'next') {
var start = start * 1 + 127; var start = start * 1 + 127
localStorage.setItem("emojiseek", start); localStorage.setItem('emojiseek', start)
} else if (target == "before") { } else if (target == 'before') {
var start = start - 127; var start = start - 127
localStorage.setItem("emojiseek", start); localStorage.setItem('emojiseek', start)
} else { } else {
var start = 0; var start = 0
localStorage.getItem("emojiseek", 0); localStorage.getItem('emojiseek', 0)
} }
var html = ""; var html = ''
var raw = JSON.parse(localStorage.getItem("emojis_" + acct_id)); var raw = JSON.parse(localStorage.getItem('emojis_' + acct_id))
console.log(raw); console.log(raw)
if (raw.if_categorized) { if (raw.if_categorized) {
var obj = [ var obj = [
{ {
divider: true, divider: true,
cat: lang.lang_emoji_uncat cat: lang.lang_emoji_uncat
} }
]; ]
var cats = raw["uncategorized"]; var cats = raw['uncategorized']
obj = obj.concat(cats); obj = obj.concat(cats)
Object.keys(raw["categorized"]).forEach(function(key) { Object.keys(raw['categorized']).forEach(function(key) {
var cats = raw["categorized"][key]; var cats = raw['categorized'][key]
obj = obj.concat([ obj = obj.concat([
{ {
divider: true, divider: true,
cat: key cat: key
} }
]); ])
obj = obj.concat(cats); obj = obj.concat(cats)
}); })
} else { } else {
var obj = raw["uncategorized"]; var obj = raw['uncategorized']
} }
console.log(obj); console.log(obj)
var num = obj.length; var num = obj.length
if (num < start) { if (num < start) {
var start = 0; var start = 0
localStorage.setItem("emojiseek", start); localStorage.setItem('emojiseek', start)
} }
var page = Math.ceil(num / 126); var page = Math.ceil(num / 126)
$("#emoji-sum").text(page); $('#emoji-sum').text(page)
var ct = Math.ceil(start / 126); var ct = Math.ceil(start / 126)
if (ct === 0) { if (ct === 0) {
if (num > 0) { if (num > 0) {
var ct = 1; var ct = 1
} }
$("#emoji-before").addClass("disabled"); $('#emoji-before').addClass('disabled')
} else { } else {
$("#emoji-before").removeClass("disabled"); $('#emoji-before').removeClass('disabled')
} }
if (page != 1) { if (page != 1) {
$("#emoji-next").removeClass("disabled"); $('#emoji-next').removeClass('disabled')
} else { } else {
$("#emoji-next").addClass("disabled"); $('#emoji-next').addClass('disabled')
} }
$("#emoji-count").text(ct); $('#emoji-count').text(ct)
for (i = start; i < start + 126; i++) { for (i = start; i < start + 126; i++) {
var emoji = obj[i]; var emoji = obj[i]
if (emoji) { if (emoji) {
if (reaction) { if (reaction) {
html = html + "<a onclick=\"emojiReaction(':" + emoji.shortcode + ':\')" class="pointer"><img src="' + emoji.url + '" width="20" title="' + emoji.shortcode + '"></a>'; html =
html +
`<a onclick="emojiReaction(':${emoji.shortcode}:')" class="pointer"><img src="${emoji.url}" width="20" title="${emoji.shortcode}"></a>`
} else { } else {
if (emoji.divider) { if (emoji.divider) {
html = html + '<p style="margin-bottom:0">' + emoji.cat + "</p>"; html = html + '<p style="margin-bottom:0">' + emoji.cat + '</p>'
} else { } else {
if (emoji.listed) { if (emoji.listed) {
html = html + "<a onclick=\"emojiInsert(':" + emoji.shortcode + ':\')" class="pointer"><img src="' + emoji.url + '" width="20" title="' + emoji.shortcode + '"></a>'; html =
html +
`<a onclick="emojiInsert(':${emoji.shortcode}:')" class="pointer"><img src="${emoji.url}" width="20" title="${emoji.shortcode}"></a>`
} }
} }
} }
} }
} }
$("#emoji-list").html(html); $('#emoji-list').html(html)
} }
//絵文字など様々なものをテキストボックスに挿入 //絵文字など様々なものをテキストボックスに挿入
function emojiInsert(code, del) { function emojiInsert(code, del) {
var now = $("#textarea").val(); var now = $('#textarea').val()
var selin = $("#textarea").prop("selectionStart"); var selin = $('#textarea').prop('selectionStart')
if (localStorage.getItem("emoji-zero-width") == "yes") { if (localStorage.getItem('emoji-zero-width') == 'yes') {
var blank = ""; var blank = ''
} else { } else {
var blank = " "; var blank = ' '
} }
var before = now.substr(0, selin); var before = now.substr(0, selin)
if (before.slice(-1) != " ") { if (before.slice(-1) != ' ') {
before = before + blank; before = before + blank
} }
var after = now.substr(selin, now.length); var after = now.substr(selin, now.length)
if (after.slice(-1) != " ") { if (after.slice(-1) != ' ') {
after = blank + after; after = blank + after
} }
newt = before + code + after; newt = before + code + after
if (!del) { if (!del) {
$("#textarea").val(newt); $('#textarea').val(newt)
//emoji(); //emoji();
} else { } else {
var regExp = new RegExp(del.replace(/[.*+?^=!:${}()|[\]\/\\]/g, "\\$&"), "g"); var regExp = new RegExp(del.replace(/[.*+?^=!:${}()|[\]\/\\]/g, '\\$&'), 'g')
var now = now.replace(regExp, ""); var now = now.replace(regExp, '')
$("#textarea").val(now + blank + code); $('#textarea').val(now + blank + code)
} }
$("#textarea").focus(); $('#textarea').focus()
} }
//改行挿入 //改行挿入
function brInsert(code) { function brInsert(code) {
if (!$("#post-box").hasClass("appear")) { if (!$('#post-box').hasClass('appear')) {
localStorage.setItem("nohide", true); localStorage.setItem('nohide', true)
show(); show()
} }
var now = $("#textarea").val(); var now = $('#textarea').val()
$("#textarea").val(now + code); $('#textarea').val(now + code)
$("#textarea").focus(); $('#textarea').focus()
} }

View File

@ -1,269 +1,273 @@
//ドラッグ・アンド・ドロップからアップロードまで。uiのimg.jsとは異なります。 //ドラッグ・アンド・ドロップからアップロードまで。uiのimg.jsとは異なります。
var obj = $("body"); var obj = $('body')
var system; var system
//ドラッグスタート //ドラッグスタート
obj.on("dragstart", function(e) { obj.on('dragstart', function(e) {
system = "locked"; system = 'locked'
}); })
//何もなくファイルが通過 //何もなくファイルが通過
obj.on("dragend", function(e) { obj.on('dragend', function(e) {
system = ""; system = ''
}); })
//ドラッグファイルが画面上に //ドラッグファイルが画面上に
obj.on("dragenter", function(e) { obj.on('dragenter', function(e) {
if (system != "locked") { if (system != 'locked') {
$("#drag").css("display", "flex"); $('#drag').css('display', 'flex')
} }
}); })
$("body").on("dragover", function(e) { $('body').on('dragover', function(e) {
e.stopPropagation(); e.stopPropagation()
e.preventDefault(); e.preventDefault()
}); })
//ドロップした //ドロップした
$("body").on("drop", function(e) { $('body').on('drop', function(e) {
if (system != "locked") { if (system != 'locked') {
$("#drag").css("display", "none"); $('#drag').css('display', 'none')
e.preventDefault(); e.preventDefault()
var files = e.originalEvent.dataTransfer.files; var files = e.originalEvent.dataTransfer.files
pimg(files); pimg(files)
} }
}); })
//何もなくファイルが通過 //何もなくファイルが通過
$("#drag").on("dragleave", function(e) { $('#drag').on('dragleave', function(e) {
$("#drag").css("display", "none"); $('#drag').css('display', 'none')
}); })
//複数アップ //複数アップ
function pimg(files) { function pimg(files) {
console.table(files); console.table(files)
for (i = 0; i < files.length; i++) { for (i = 0; i < files.length; i++) {
var dot = files[i].path.match(/\.(.+)$/)[1]; var dot = files[i].path.match(/\.(.+)$/)[1]
if (dot == "bmp" || dot == "BMP") { if (dot == 'bmp' || dot == 'BMP') {
postMessage(["bmpImage", [files[i].path, i]], "*"); postMessage(['bmpImage', [files[i].path, i]], '*')
todo(lang.lang_progress); todo(lang.lang_progress)
} else { } else {
handleFileUpload(files[i], obj, i); handleFileUpload(files[i], obj, i)
} }
} }
} }
//ドラッグ・アンド・ドロップを終了 //ドラッグ・アンド・ドロップを終了
function closedrop() { function closedrop() {
$("#drag").css("display", "none"); $('#drag').css('display', 'none')
} }
//ファイル選択 //ファイル選択
function fileselect() { function fileselect() {
postMessage(["sendSinmpleIpc", "file-select"], "*"); postMessage(['sendSinmpleIpc', 'file-select'], '*')
} }
//ファイル読み込み //ファイル読み込み
function handleFileUpload(files, obj, no) { function handleFileUpload(files, obj, no) {
var fr = new FileReader(); var fr = new FileReader()
fr.onload = function(evt) { fr.onload = function(evt) {
var b64 = evt.target.result; var b64 = evt.target.result
$("#b64-box").val(b64); $('#b64-box').val(b64)
var ret = media(b64, files["type"], no); var ret = media(b64, files['type'], no)
}; }
fr.readAsDataURL(files); fr.readAsDataURL(files)
$("#mec").append(files["name"] + "/"); $('#mec').append(files['name'] + '/')
} }
//ファイルアップロード //ファイルアップロード
function media(b64, type, no) { function media(b64, type, no) {
var l = 4; var l = 4
var c = "abcdefghijklmnopqrstuvwxyz0123456789"; var c = 'abcdefghijklmnopqrstuvwxyz0123456789'
var cl = c.length; var cl = c.length
var r = ""; var 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)]
} }
if ($("#media").val()) { if ($('#media').val()) {
$("#media").val($("#media").val() + "," + "tmp_" + r); $('#media').val($('#media').val() + ',' + 'tmp_' + r)
} else { } else {
$("#media").val("tmp_" + r); $('#media').val('tmp_' + r)
} }
$(".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"); 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()
fd.append("file", media); fd.append('file', media)
var acct_id = $("#post-acct-sel").val(); var acct_id = $('#post-acct-sel').val()
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 httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest()
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem('mode_' + domain) == 'misskey') {
var start = "https://" + domain + "/api/drive/files/create"; var start = 'https://' + domain + '/api/drive/files/create'
httpreq.open("POST", start, true); httpreq.open('POST', start, true)
httpreq.upload.addEventListener("progress", progshow, false); httpreq.upload.addEventListener('progress', progshow, false)
httpreq.responseType = "json"; httpreq.responseType = 'json'
if ($("#nsfw").hasClass("nsfw-avail")) { if ($('#nsfw').hasClass('nsfw-avail')) {
var nsfw = true; var nsfw = true
} else { } else {
var nsfw = false; var nsfw = false
} }
var previewer = "url"; var previewer = 'url'
fd.append("i", at); fd.append('i', at)
//fd.append('isSensitive', nsfw); //fd.append('isSensitive', nsfw);
httpreq.send(fd); httpreq.send(fd)
} else { } else {
var previewer = "preview_url"; var previewer = 'preview_url'
var start = "https://" + domain + "/api/v1/media"; var start = 'https://' + domain + '/api/v1/media'
httpreq.open("POST", start, true); httpreq.open('POST', start, true)
httpreq.upload.addEventListener("progress", progshow, false); httpreq.upload.addEventListener('progress', progshow, false)
httpreq.responseType = "json"; httpreq.responseType = 'json'
httpreq.setRequestHeader("Authorization", "Bearer " + at); httpreq.setRequestHeader('Authorization', 'Bearer ' + at)
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) { if (this.status !== 200) {
setLog(start, this.status, json); setLog(start, this.status, json)
} }
if (!json.id) { if (!json.id) {
todc(); todc()
$("#imgup").text(""); $('#imgup').text('')
$(".toot-btn-group").prop("disabled", false); $('.toot-btn-group').prop('disabled', false)
$("#post-acct-sel").prop("disabled", false); $('#post-acct-sel').prop('disabled', false)
$("select").formSelect(); $('select').formSelect()
$("#imgsel").show(); $('#imgsel').show()
M.toast({ html: lang.lang_postimg_failupload, displayLength: 5000 }); M.toast({ html: lang.lang_postimg_failupload, displayLength: 5000 })
return false; return false
} }
var img = localStorage.getItem("img"); var img = localStorage.getItem('img')
if (json.type.indexOf("image") != -1) { if (json.type.indexOf('image') != -1) {
var html = '<img src="' + json[previewer] + '" class="preview-img pointer" data-media="' + json["id"] + '" oncontextmenu="deleteImage(\'' + json["id"] + "')\" onclick=\"altImage('" + acct_id + "','" + json["id"] + '\')" title="' + lang.lang_postimg_delete + '">'; var html = `<img src="${json[previewer]}" class="preview-img pointer" data-media="${
$("#preview").append(html); json['id']
}" oncontextmenu="deleteImage('${json['id']}')" onclick="altImage('${acct_id}','${
json['id']
}')" title="${lang.lang_postimg_delete}">`
$('#preview').append(html)
} else { } else {
$("#preview").append(lang.lang_postimg_previewdis); $('#preview').append(lang.lang_postimg_previewdis)
} }
if (!img) { if (!img) {
var img = "no-act"; var img = 'no-act'
} }
if (img != "inline") { if (img != 'inline') {
var mediav = $("#media").val(); var mediav = $('#media').val()
var regExp = new RegExp("tmp_" + r, "g"); var regExp = new RegExp('tmp_' + r, 'g')
mediav = mediav.replace(regExp, json["id"]); mediav = mediav.replace(regExp, json['id'])
$("#media").val(mediav); $('#media').val(mediav)
} }
if (img == "url") { if (img == 'url') {
$("#textarea").val($("#textarea").val() + " " + json["text_url"]); $('#textarea').val($('#textarea').val() + ' ' + json['text_url'])
} }
todc(); todc()
if (localStorage.getItem("nsfw_" + acct_id)) { if (localStorage.getItem('nsfw_' + acct_id)) {
$("#nsfw").addClass("yellow-text"); $('#nsfw').addClass('yellow-text')
$("#nsfw").html("visibility"); $('#nsfw').html('visibility')
$("#nsfw").addClass("nsfw-avail"); $('#nsfw').addClass('nsfw-avail')
}
$('.toot-btn-group').prop('disabled', false)
$('select').formSelect()
$('#mec').text(lang.lang_there)
M.toast({ html: lang.lang_postimg_aftupload, displayLength: 1000 })
$('#imgup').text('')
$('#imgsel').show()
localStorage.removeItem('image')
} }
$(".toot-btn-group").prop("disabled", false);
$("select").formSelect();
$("#mec").text(lang.lang_there);
M.toast({ html: lang.lang_postimg_aftupload, displayLength: 1000 });
$("#imgup").text("");
$("#imgsel").show();
localStorage.removeItem("image");
} }
};
} }
//Base64からBlobへ //Base64からBlobへ
function toBlob(base64, type) { function toBlob(base64, type) {
var bin = atob(base64.replace(/^.*,/, "")); var bin = atob(base64.replace(/^.*,/, ''))
var buffer = new Uint8Array(bin.length); var buffer = new Uint8Array(bin.length)
for (var i = 0; i < bin.length; i++) { for (var i = 0; i < bin.length; i++) {
buffer[i] = bin.charCodeAt(i); buffer[i] = bin.charCodeAt(i)
} }
// Blobを作成 // Blobを作成
try { try {
var blob = new Blob([new Uint8Array(buffer)], { var blob = new Blob([new Uint8Array(buffer)], {
type: type type: type
}); })
} catch (e) { } catch (e) {
return false; return false
} }
return blob; return blob
} }
//画像を貼り付けたら… //画像を貼り付けたら…
var element = document.querySelector("#textarea"); var element = document.querySelector('#textarea')
element.addEventListener("paste", function(e) { element.addEventListener('paste', function(e) {
if (!e.clipboardData || !e.clipboardData.items) { if (!e.clipboardData || !e.clipboardData.items) {
return true; return true
} }
// DataTransferItemList に画像が含まれいない場合は終了する // DataTransferItemList に画像が含まれいない場合は終了する
var imageItems = [...e.clipboardData.items].filter(i => i.type.startsWith("image")); var imageItems = [...e.clipboardData.items].filter(i => i.type.startsWith('image'))
if (imageItems.length == 0) { if (imageItems.length == 0) {
console.warn("it is not image"); console.warn('it is not image')
return true; return true
} }
// ファイルとして得る // ファイルとして得る
// DataTransferItem の kind は file なので getAsString ではなく getAsFile を呼ぶ // DataTransferItem の kind は file なので getAsString ではなく getAsFile を呼ぶ
var imageFile = imageItems[0].getAsFile(); var imageFile = imageItems[0].getAsFile()
var imageType = imageItems[0].type; var imageType = imageItems[0].type
// FileReaderで読み込む // FileReaderで読み込む
var fr = new FileReader(); var fr = new FileReader()
fr.onload = function(e) { fr.onload = function(e) {
// onload内ではe.target.resultにbase64が入っているのであとは煮るなり焼くなり // onload内ではe.target.resultにbase64が入っているのであとは煮るなり焼くなり
var base64 = e.target.result; var base64 = e.target.result
var mediav = $("#media").val(); var mediav = $('#media').val()
if (mediav) { if (mediav) {
var i = mediav.split(",").length; var i = mediav.split(',').length
} }
// DataTransferItem の type に mime tipes があるのでそれを使う // DataTransferItem の type に mime tipes があるのでそれを使う
media(base64, imageType, i); media(base64, imageType, i)
}; }
fr.readAsDataURL(imageFile); fr.readAsDataURL(imageFile)
// 画像以外がペーストされたときのために、元に戻しておく // 画像以外がペーストされたときのために、元に戻しておく
}); })
function deleteImage(key) { function deleteImage(key) {
Swal.fire({ Swal.fire({
title: lang.lang_postimg_delete, title: lang.lang_postimg_delete,
type: "warning", type: 'warning',
showCancelButton: true, showCancelButton: true,
confirmButtonColor: "#3085d6", confirmButtonColor: '#3085d6',
cancelButtonColor: "#d33", cancelButtonColor: '#d33',
confirmButtonText: lang.lang_yesno, confirmButtonText: lang.lang_yesno,
cancelButtonText: lang.lang_no cancelButtonText: lang.lang_no
}).then(result => { }).then(result => {
if (result.value) { if (result.value) {
var media = $("#media").val(); var media = $('#media').val()
var arr = media.split(","); var arr = media.split(',')
for (var i = 0; i < media.length; i++) { for (var i = 0; i < media.length; i++) {
if (arr[i] == key) { if (arr[i] == key) {
arr.splice(i, 1); arr.splice(i, 1)
break; break
} }
} }
$("#media").val(arr.join(",")); $('#media').val(arr.join(','))
$("#preview [data-media=" + key + "]").remove(); $('#preview [data-media=' + key + ']').remove()
} }
}); })
} }
function altImage(acct_id, id) { function altImage(acct_id, id) {
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/media/" + id; var start = 'https://' + domain + '/api/v1/media/' + id
Swal.fire({ Swal.fire({
title: lang.lang_postimg_desc, title: lang.lang_postimg_desc,
text: lang.lang_postimg_leadContext, text: lang.lang_postimg_leadContext,
input: "text", input: 'text',
inputAttributes: { inputAttributes: {
autocapitalize: "off" autocapitalize: 'off'
}, },
showCancelButton: true, showCancelButton: true,
confirmButtonText: "Post", confirmButtonText: 'Post',
showLoaderOnConfirm: true, showLoaderOnConfirm: true,
preConfirm: data => { preConfirm: data => {
return fetch(start, { return fetch(start, {
method: "PUT", method: 'PUT',
headers: { headers: {
"content-type": "application/json", 'content-type': 'application/json',
Authorization: "Bearer " + at Authorization: 'Bearer ' + at
}, },
body: JSON.stringify({ body: JSON.stringify({
description: data description: data
@ -272,27 +276,27 @@ function altImage(acct_id, id) {
.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) {
console.log(json); console.log(json)
$("[data-media=" + id + "]").attr("title", data); $('[data-media=' + id + ']').attr('title', data)
}); })
}, },
allowOutsideClick: () => !Swal.isLoading() allowOutsideClick: () => !Swal.isLoading()
}).then(result => { }).then(result => {
if (result.value) { if (result.value) {
Swal.fire({ Swal.fire({
title: "Complete" title: 'Complete'
}); })
} }
}); })
} }

View File

@ -1,261 +1,273 @@
//Renpost //Renpost
function renote(id, acct_id, remote) { function renote(id, acct_id, remote) {
if ($("#pub_" + id).hasClass("rted")) { if ($('#pub_' + id).hasClass('rted')) {
return false; return false
} }
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/notes/create"; var start = 'https://' + domain + '/api/notes/create'
if (localStorage.getItem("mode_" + domain) != "misskey") { if (localStorage.getItem('mode_' + domain) != 'misskey') {
return false; return false
} }
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest()
httpreq.open("POST", start, true); httpreq.open('POST', start, true)
httpreq.setRequestHeader("Content-Type", "application/json"); httpreq.setRequestHeader('Content-Type', 'application/json')
httpreq.responseType = "json"; httpreq.responseType = 'json'
httpreq.send(JSON.stringify({ i: at, renoteId: id })); httpreq.send(JSON.stringify({ i: at, renoteId: id }))
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) { if (this.status !== 200) {
setLog(start, this.status, json); setLog(start, this.status, json)
}
console.log(['Success: renote', json])
$('[toot-id=' + id + ']').addClass('rted')
$('.rt_' + id).toggleClass('teal-text')
} }
console.log(["Success: renote", json]);
$("[toot-id=" + id + "]").addClass("rted");
$(".rt_" + id).toggleClass("teal-text");
} }
};
} }
//Renote //Renote
function renoteqt(id, acct_id) { function renoteqt(id, acct_id) {
localStorage.setItem("nohide", true); localStorage.setItem('nohide', true)
show(); show()
$("#reply").val("renote_" + id); $('#reply').val('renote_' + id)
$("#rec").text("Renote"); $('#rec').text('Renote')
$("#post-acct-sel").val(acct_id); $('#post-acct-sel').val(acct_id)
$("#post-acct-sel").prop("disabled", true); $('#post-acct-sel').prop('disabled', true)
$("select").formSelect(); $('select').formSelect()
$("#textarea").attr("placeholder", lang.lang_misskeyparse_qt); $('#textarea').attr('placeholder', lang.lang_misskeyparse_qt)
$("#textarea").focus(); $('#textarea').focus()
} }
//Reply //Reply
function misskeyreply(id, acct_id) { function misskeyreply(id, acct_id) {
localStorage.setItem("nohide", true); localStorage.setItem('nohide', true)
show(); show()
$("#reply").val(id); $('#reply').val(id)
$("#rec").text("Renote"); $('#rec').text('Renote')
$("#post-acct-sel").val(acct_id); $('#post-acct-sel').val(acct_id)
$("#post-acct-sel").prop("disabled", true); $('#post-acct-sel').prop('disabled', true)
$("select").formSelect(); $('select').formSelect()
$("#textarea").attr("placeholder", lang.lang_misskeyparse_qt); $('#textarea').attr('placeholder', lang.lang_misskeyparse_qt)
$("#textarea").focus(); $('#textarea').focus()
} }
//Reaction //Reaction
function reactiontoggle(id, acct_id, tlid) { function reactiontoggle(id, acct_id, tlid) {
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/notes/show"; var start = 'https://' + domain + '/api/notes/show'
if (localStorage.getItem("mode_" + domain) != "misskey") { if (localStorage.getItem('mode_' + domain) != 'misskey') {
return false; return false
} }
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest()
httpreq.open("POST", start, true); httpreq.open('POST', start, true)
httpreq.setRequestHeader("Content-Type", "application/json"); httpreq.setRequestHeader('Content-Type', 'application/json')
httpreq.responseType = "json"; httpreq.responseType = 'json'
httpreq.send(JSON.stringify({ i: at, noteId: id })); httpreq.send(JSON.stringify({ i: at, noteId: id }))
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) { if (this.status !== 200) {
setLog(start, this.status, json); setLog(start, this.status, json)
} }
console.log(["Success: reaction", json]); console.log(['Success: reaction', json])
if (json.reactions) { if (json.reactions) {
var reactions = ["like", "love", "laugh", "hmm", "surprise", "congrats", "angry", "confused", "pudding", "rip"]; var reactions = [
'like',
'love',
'laugh',
'hmm',
'surprise',
'congrats',
'angry',
'confused',
'pudding',
'rip'
]
for (var i = 0; i < reactions.length; i++) { for (var i = 0; i < reactions.length; i++) {
if (json.reactions[reactions[i]]) { if (json.reactions[reactions[i]]) {
$("#pub_" + id + " .re-" + reactions[i] + "ct").text(json.reactions[reactions[i]]); $('#pub_' + id + ' .re-' + reactions[i] + 'ct').text(json.reactions[reactions[i]])
$("#pub_" + id + " .re-" + reactions[i]).removeClass("hide"); $('#pub_' + id + ' .re-' + reactions[i]).removeClass('hide')
} else { } else {
$("#pub_" + id + " .re-" + reactions[i] + "ct").text(0); $('#pub_' + id + ' .re-' + reactions[i] + 'ct').text(0)
if ($("#pub_" + id + " .reactions").hasClass("fullreact")) { if ($('#pub_' + id + ' .reactions').hasClass('fullreact')) {
$("#pub_" + id + " .re-" + reactions[i]).addClass("hide"); $('#pub_' + id + ' .re-' + reactions[i]).addClass('hide')
} else { } else {
$("#pub_" + id + " .re-" + reactions[i]).removeClass("hide"); $('#pub_' + id + ' .re-' + reactions[i]).removeClass('hide')
} }
$("#pub_" + id + " .re-" + reactions[i] + "ct").text(json.reactions[reactions[i]]); $('#pub_' + id + ' .re-' + reactions[i] + 'ct').text(json.reactions[reactions[i]])
} }
} }
$("#pub_" + id + " .reactions").removeClass("hide"); $('#pub_' + id + ' .reactions').removeClass('hide')
$("#pub_" + id + " .reactions").toggleClass("fullreact"); $('#pub_' + id + ' .reactions').toggleClass('fullreact')
} else { } else {
if ($("#pub_" + id + " .reactions").hasClass("fullreact")) { if ($('#pub_' + id + ' .reactions').hasClass('fullreact')) {
$("#pub_" + id + " .reactions").addClass("hide"); $('#pub_' + id + ' .reactions').addClass('hide')
$("#pub_" + id + " .reactions").removeClass("fullreact"); $('#pub_' + id + ' .reactions').removeClass('fullreact')
} else { } else {
$("#pub_" + id + " .reactions").removeClass("hide"); $('#pub_' + id + ' .reactions').removeClass('hide')
$("#pub_" + id + " .reaction").removeClass("hide"); $('#pub_' + id + ' .reaction').removeClass('hide')
$("#pub_" + id + " .reactions").addClass("fullreact"); $('#pub_' + id + ' .reactions').addClass('fullreact')
} }
} }
} }
}; }
$("#pub_" + id + " .freeReact").toggleClass("hide"); $('#pub_' + id + ' .freeReact').toggleClass('hide')
} }
//reactioncustom //reactioncustom
function reactioncustom(acct_id, id) { function reactioncustom(acct_id, id) {
$("#reply").val(id); $('#reply').val(id)
$("#unreact").hide(); $('#unreact').hide()
$("#addreact").removeClass("hide"); $('#addreact').removeClass('hide')
$("#post-acct-sel").val(acct_id); $('#post-acct-sel').val(acct_id)
$("select").formSelect(); $('select').formSelect()
localStorage.setItem("nohide", true); localStorage.setItem('nohide', true)
show(); show()
emojiToggle(true); emojiToggle(true)
$("#left-side").hide(); $('#left-side').hide()
$("#default-emoji").hide(); $('#default-emoji').hide()
} }
function reactRefresh(acct_id, id) { function reactRefresh(acct_id, id) {
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/notes/show"; var start = 'https://' + domain + '/api/notes/show'
var req = {}; var req = {}
req.i = at; req.i = at
req.noteId = id; req.noteId = id
var i = { var i = {
method: "POST", method: 'POST',
body: JSON.stringify(req) body: JSON.stringify(req)
}; }
fetch(start, i) fetch(start, i)
.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) { if (!json) {
return false; return false
} }
var poll = ""; var poll = ''
if (json.error) { if (json.error) {
$("[toot-id=" + id + "]").hide(); $('[toot-id=' + id + ']').hide()
$("[toot-id=" + id + "]").remove(); $('[toot-id=' + id + ']').remove()
} else { } else {
reactRefreshCore(json); reactRefreshCore(json)
} }
}); })
} }
function reactRefreshCore(json) { function reactRefreshCore(json) {
var id = json.id; var id = json.id
if (json.reactions) { if (json.reactions) {
$("#pub_" + id + " .reactions").removeClass("hide"); $('#pub_' + id + ' .reactions').removeClass('hide')
var regExp = new RegExp(":", "g"); var regExp = new RegExp(':', 'g')
Object.keys(json.reactions).forEach(function(keye) { Object.keys(json.reactions).forEach(function(keye) {
keyeClass = keye.replace(regExp, ""); keyeClass = keye.replace(regExp, '')
if (json.reactions[keye]) { if (json.reactions[keye]) {
$("#pub_" + id + " .re-" + keyeClass + "ct").text(json.reactions[keye]); $('#pub_' + id + ' .re-' + keyeClass + 'ct').text(json.reactions[keye])
$("#pub_" + id + " .re-" + keyeClass).removeClass("hide"); $('#pub_' + id + ' .re-' + keyeClass).removeClass('hide')
} else { } else {
$("#pub_" + id + " .re-" + keyeClass + "ct").text(0); $('#pub_' + id + ' .re-' + keyeClass + 'ct').text(0)
if ($("#pub_" + id + " .reactions").hasClass("fullreact")) { if ($('#pub_' + id + ' .reactions').hasClass('fullreact')) {
$("#pub_" + id + " .re-" + keyeClass).addClass("hide"); $('#pub_' + id + ' .re-' + keyeClass).addClass('hide')
} }
$("#pub_" + id + " .re-" + keyeClass + "ct").text(json.reactions[keye]); $('#pub_' + id + ' .re-' + keyeClass + 'ct').text(json.reactions[keye])
} }
}); })
} }
} }
function emojiReaction(emoji) { function emojiReaction(emoji) {
var acct_id = $("#post-acct-sel").val(); var acct_id = $('#post-acct-sel').val()
var id = $("#reply").val(); var id = $('#reply').val()
reaction(emoji, id, acct_id, null); reaction(emoji, id, acct_id, null)
clear(); clear()
hide(); hide()
} }
function reaction(mode, id, acct_id, tlid) { function reaction(mode, id, acct_id, tlid) {
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')
if ($(".fav_" + id).hasClass("yellow-text")) { if ($('.fav_' + id).hasClass('yellow-text')) {
var flag = "delete"; var flag = 'delete'
} else { } else {
var flag = "create"; var flag = 'create'
} }
var start = "https://" + domain + "/api/notes/reactions/" + flag; var start = 'https://' + domain + '/api/notes/reactions/' + flag
if (localStorage.getItem("mode_" + domain) != "misskey") { if (localStorage.getItem('mode_' + domain) != 'misskey') {
return false; return false
} }
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest()
httpreq.open("POST", start, true); httpreq.open('POST', start, true)
httpreq.setRequestHeader("Content-Type", "application/json"); httpreq.setRequestHeader('Content-Type', 'application/json')
httpreq.responseType = "json"; httpreq.responseType = 'json'
httpreq.send(JSON.stringify({ i: at, noteId: id, reaction: mode })); httpreq.send(JSON.stringify({ i: at, noteId: id, reaction: mode }))
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
if (this.status !== 200) { if (this.status !== 200) {
setLog(start, this.status, this.response); setLog(start, this.status, this.response)
}
$('.fav_' + id).toggleClass('yellow-text')
} }
$(".fav_" + id).toggleClass("yellow-text");
} }
};
} }
//Vote //Vote
function vote(acct_id, id, to) { function vote(acct_id, id, to) {
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/notes/polls/vote"; var start = 'https://' + domain + '/api/notes/polls/vote'
if (localStorage.getItem("mode_" + domain) != "misskey") { if (localStorage.getItem('mode_' + domain) != 'misskey') {
return false; return false
} }
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest()
httpreq.open("POST", start, true); httpreq.open('POST', start, true)
httpreq.setRequestHeader("Content-Type", "application/json"); httpreq.setRequestHeader('Content-Type', 'application/json')
httpreq.responseType = "json"; httpreq.responseType = 'json'
httpreq.send(JSON.stringify({ i: at, noteId: id, choice: to })); httpreq.send(JSON.stringify({ i: at, noteId: id, choice: to }))
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
voterefresh(acct_id, id); voterefresh(acct_id, id)
}; }
} }
function voterefresh(acct_id, id) { function voterefresh(acct_id, id) {
var httpreqd = new XMLHttpRequest(); var httpreqd = new XMLHttpRequest()
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/notes/show"; var start = 'https://' + domain + '/api/notes/show'
httpreqd.open("POST", start, true); httpreqd.open('POST', start, true)
httpreqd.setRequestHeader("Content-Type", "application/json"); httpreqd.setRequestHeader('Content-Type', 'application/json')
httpreqd.responseType = "json"; httpreqd.responseType = 'json'
httpreqd.send(JSON.stringify({ i: at, noteId: id })); httpreqd.send(JSON.stringify({ i: at, noteId: id }))
httpreqd.onreadystatechange = function() { httpreqd.onreadystatechange = function() {
if (httpreqd.readyState == 4) { if (httpreqd.readyState == 4) {
var json = httpreqd.response; var json = httpreqd.response
if (this.status !== 200) { if (this.status !== 200) {
setLog(start, this.status, json); setLog(start, this.status, json)
} }
if (!json) { if (!json) {
return false; return false
} }
var poll = ""; var poll = ''
if (json.poll) { if (json.poll) {
var choices = json.poll.choices; var choices = json.poll.choices
Object.keys(choices).forEach(function(keyc) { Object.keys(choices).forEach(function(keyc) {
var choice = choices[keyc]; var choice = choices[keyc]
if (choice.isVoted) { if (choice.isVoted) {
var myvote = twemoji.parse("✅"); var myvote = twemoji.parse('✅')
} else { } else {
var myvote = ""; var myvote = ''
}
//WIP here
poll = poll + `<div class="pointer vote" onclick="vote('${acct_id}','${json.id}',"${choice.id}')">${escapeHTML(choice.text)}(${choice.votes})${myvote})</div>`
})
$('.vote_' + json.id).html(poll)
} }
poll = poll + '<div class="pointer vote" onclick="vote(\'' + acct_id + "','" + json.id + "'," + choice.id + ')">' + escapeHTML(choice.text) + "(" + choice.votes + "" + myvote + ")</div>";
});
$(".vote_" + json.id).html(poll);
} }
} }
};
} }

View File

@ -1,35 +1,39 @@
/*投稿系*/ /*投稿系*/
//投稿 //投稿
function sec() { function sec() {
var mode = localStorage.getItem("sec"); var mode = localStorage.getItem('sec')
var acct_id = $("#post-acct-sel").val(); var acct_id = $('#post-acct-sel').val()
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem('domain_' + acct_id)
if (~domain.indexOf("kirishima.cloud") >= 0 && mode == "local") { if (~domain.indexOf('kirishima.cloud') >= 0 && mode == 'local') {
mode = "unlisted"; mode = 'unlisted'
} }
post(null, mode); post(null, mode)
} }
function post(mode, postvis) { function post(mode, postvis) {
if ($("#toot-post-btn").prop("disabled")) { if ($('#toot-post-btn').prop('disabled')) {
return false; return false
} }
var str = $("#textarea").val(); var str = $('#textarea').val()
var acct_id = $("#post-acct-sel").val(); var acct_id = $('#post-acct-sel').val()
localStorage.setItem("last-use", acct_id); localStorage.setItem('last-use', acct_id)
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem('domain_' + acct_id)
if (!localStorage.getItem("cw_sentence")) { if (!localStorage.getItem('cw_sentence')) {
var cw_sent = 500; var cw_sent = 500
} else { } else {
var cw_sent = localStorage.getItem("cw_sentence"); var cw_sent = localStorage.getItem('cw_sentence')
} }
if (!localStorage.getItem("cw_letters")) { if (!localStorage.getItem('cw_letters')) {
var cw_ltres = 7000; var cw_ltres = 7000
} else { } else {
var cw_ltres = localStorage.getItem("cw_letters"); var cw_ltres = localStorage.getItem('cw_letters')
} }
if (domain != "kirishima.cloud") { if (domain != 'kirishima.cloud') {
if (mode != "pass" && !$("#cw").hasClass("cw-avail") && (str.length > cw_sent || (str.split("\n").length - 1) > cw_ltres)) { if (
var plus = str.replace(/\n/g, "").slice(0, 10) + "..."; mode != 'pass' &&
!$('#cw').hasClass('cw-avail') &&
(str.length > cw_sent || str.split('\n').length - 1 > cw_ltres)
) {
var plus = str.replace(/\n/g, '').slice(0, 10) + '...'
Swal.fire({ Swal.fire({
title: lang.lang_post_cwtitle, title: lang.lang_post_cwtitle,
text: lang.lang_post_cwtxt + plus, text: lang.lang_post_cwtxt + plus,
@ -40,34 +44,34 @@ function post(mode, postvis) {
confirmButtonText: lang.lang_post_btn2, confirmButtonText: lang.lang_post_btn2,
cancelButtonText: lang.lang_post_btn3, cancelButtonText: lang.lang_post_btn3,
showCloseButton: true, showCloseButton: true,
focusConfirm: false, focusConfirm: false
}).then((result) => { }).then(result => {
if (result.dismiss == "cancel") { if (result.dismiss == 'cancel') {
//btn3:sonomama //btn3:sonomama
post("pass") post('pass')
} else if (result.value) { } else if (result.value) {
//btn2:auto-CW //btn2:auto-CW
$("#cw-text").show(); $('#cw-text').show()
$("#cw").addClass("yellow-text"); $('#cw').addClass('yellow-text')
$("#cw").addClass("cw-avail"); $('#cw').addClass('cw-avail')
$("#cw-text").val(plus); $('#cw-text').val(plus)
post("pass") post('pass')
} }
}) })
return false; return false
} }
} }
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem('mode_' + domain) == 'misskey') {
misskeyPost(); misskeyPost()
return; return
} }
$(".toot-btn-group").prop("disabled", true); $('.toot-btn-group').prop('disabled', true)
todo("Posting"); todo('Posting')
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem('acct_' + acct_id + '_at')
var start = "https://" + domain + "/api/v1/statuses"; var start = 'https://' + domain + '/api/v1/statuses'
var reply = $("#reply").val(); var reply = $('#reply').val()
if (str.indexOf(localStorage.getItem("stable")) == -1) { if (str.indexOf(localStorage.getItem('stable')) == -1) {
str + " #" + localStorage.getItem("stable"); str + ' #' + localStorage.getItem('stable')
} }
var toot = { var toot = {
status: str status: str
@ -75,66 +79,66 @@ function post(mode, postvis) {
if (reply) { if (reply) {
toot.in_reply_to_id = reply toot.in_reply_to_id = reply
} }
var media = $("#media").val(); var media = $('#media').val()
if (media) { if (media) {
toot.media_ids = media.split(","); toot.media_ids = media.split(',')
} }
var quote = $("#quote").val(); var quote = $('#quote').val()
if (quote) { if (quote) {
toot.quote_id = quote; toot.quote_id = quote
} }
if ($("#nsfw").hasClass("nsfw-avail")) { if ($('#nsfw').hasClass('nsfw-avail')) {
var nsfw = "true"; var nsfw = 'true'
toot.sensitive = nsfw; toot.sensitive = nsfw
} else { } else {
var nsfw = "false"; var nsfw = 'false'
} }
if (postvis) { if (postvis) {
var vis = postvis; var vis = postvis
} else { } else {
var vis = $("#vis").text(); var vis = $('#vis').text()
} }
if (vis != "inherit" && vis != "local") { if (vis != 'inherit' && vis != 'local') {
toot.visibility = vis; toot.visibility = vis
} else if (vis == "local") { } else if (vis == 'local') {
toot.status = str + "👁️"; toot.status = str + '👁️'
} }
if ($("#cw").hasClass("cw-avail")) { if ($('#cw').hasClass('cw-avail')) {
var spo = $("#cw-text").val(); var spo = $('#cw-text').val()
cw(); cw()
toot.spoiler_text = spo; toot.spoiler_text = spo
} else { } else {
var spo = ""; var spo = ''
} }
if ($("#sch-box").hasClass("sch-avail")) { if ($('#sch-box').hasClass('sch-avail')) {
var scheduled = formattimeutc(new Date(Date.parse($("#sch-date").val()))) var scheduled = formattimeutc(new Date(Date.parse($('#sch-date').val())))
console.log("This toot will be posted at:" + scheduled) console.log('This toot will be posted at:' + scheduled)
schedule(); schedule()
toot.scheduled_at = scheduled; toot.scheduled_at = scheduled
} else { } else {
var scheduled = ""; var scheduled = ''
} }
if (!$("#poll").hasClass("hide")) { if (!$('#poll').hasClass('hide')) {
var options = []; var options = []
$(".mastodon-choice").map(function () { $('.mastodon-choice').map(function() {
var choice = $(this).val(); var choice = $(this).val()
if (choice != "") { if (choice != '') {
options.push(choice); options.push(choice)
} }
}); })
if ($("#poll-multiple:checked").val() == "1") { if ($('#poll-multiple:checked').val() == '1') {
var mul = true; var mul = true
} else { } else {
var mul = false; var mul = false
} }
if ($("#poll-until:checked").val() == "1") { if ($('#poll-until:checked').val() == '1') {
var htt = true; var htt = true
} else { } else {
var htt = false; var htt = false
} }
var exin = pollCalc(); var exin = pollCalc()
if (!exin) { if (!exin) {
todc("Error: Poll expires_in param") todc('Error: Poll expires_in param')
} }
toot.poll = { toot.poll = {
options: options, options: options,
@ -143,167 +147,174 @@ function post(mode, postvis) {
hide_totals: htt hide_totals: htt
} }
} }
console.table(toot); console.table(toot)
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest()
httpreq.open('POST', start, true); httpreq.open('POST', 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(toot)); httpreq.send(JSON.stringify(toot))
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, json); } if (this.status !== 200) {
var box = localStorage.getItem("box"); setLog(start, this.status, json)
if (box == "yes" || !box) {
$("#textarea").blur();
hide();
} }
$(".toot-btn-group").prop("disabled", false); var box = localStorage.getItem('box')
todc(); if (box == 'yes' || !box) {
clear(); $('#textarea').blur()
hide()
}
$('.toot-btn-group').prop('disabled', false)
todc()
clear()
} }
} }
} }
function misskeyPost() { function misskeyPost() {
var str = $("#textarea").val(); var str = $('#textarea').val()
var acct_id = $("#post-acct-sel").val(); var acct_id = $('#post-acct-sel').val()
localStorage.setItem("last-use", acct_id); localStorage.setItem('last-use', acct_id)
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem('domain_' + acct_id)
$(".toot-btn-group").prop("disabled", true); $('.toot-btn-group').prop('disabled', true)
todo("Posting"); todo('Posting')
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem('acct_' + acct_id + '_at')
var start = "https://" + domain + "/api/notes/create"; var start = 'https://' + domain + '/api/notes/create'
var reply = $("#reply").val(); var reply = $('#reply').val()
var toot = { var toot = {
text: str text: str
} }
if (reply) { if (reply) {
if (reply.indexOf("renote") !== -1) { if (reply.indexOf('renote') !== -1) {
toot.renoteId = reply.replace("renote_", "") toot.renoteId = reply.replace('renote_', '')
} else { } else {
toot.replyId = reply toot.replyId = reply
} }
} }
var media = $("#media").val(); var media = $('#media').val()
if (media) { if (media) {
toot.mediaIds = media.split(","); toot.mediaIds = media.split(',')
} }
if ($("#nsfw").hasClass("nsfw-avail")) { if ($('#nsfw').hasClass('nsfw-avail')) {
var nsfw = "true"; var nsfw = 'true'
toot.sensitive = nsfw; toot.sensitive = nsfw
} else { } else {
var nsfw = "false"; var nsfw = 'false'
} }
var vis = $("#vis").text(); var vis = $('#vis').text()
if (vis == "unlisted") { if (vis == 'unlisted') {
vis = "home" vis = 'home'
} else if (vis == "direct") { } else if (vis == 'direct') {
vis = "specified"; vis = 'specified'
toot.visibleUserIds = str.match(/@([a-zA-Z0-9_@.-]+)(\s|$)/g).join('').split("@"); toot.visibleUserIds = str
.match(/@([a-zA-Z0-9_@.-]+)(\s|$)/g)
.join('')
.split('@')
} }
if (vis != "inherit") { if (vis != 'inherit') {
toot.visibility = vis; toot.visibility = vis
} }
if ($("#cw").hasClass("cw-avail")) { if ($('#cw').hasClass('cw-avail')) {
var spo = $("#cw-text").val(); var spo = $('#cw-text').val()
cw(); cw()
toot.cw = spo; toot.cw = spo
} else { } else {
var spo = ""; var spo = ''
} }
toot.i = at; toot.i = at
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest()
httpreq.open('POST', start, true); httpreq.open('POST', start, true)
httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader('Content-Type', 'application/json')
httpreq.responseType = "json"; httpreq.responseType = 'json'
httpreq.send(JSON.stringify(toot)); httpreq.send(JSON.stringify(toot))
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
if (str.indexOf(localStorage.getItem("stable")) == -1) { if (str.indexOf(localStorage.getItem('stable')) == -1) {
localStorage.removeItem("stable") localStorage.removeItem('stable')
} }
var json = httpreq.response; var json = httpreq.response
if(this.status!==200){ setLog(start, this.status, json); } if (this.status !== 200) {
console.log(["Success: toot", json]); setLog(start, this.status, json)
var box = localStorage.getItem("box");
if (box == "yes") {
hide();
} else if (box == "hide") {
$("body").addClass("mini-post");
$(".mini-btn").text("expand_less");
} }
$(".toot-btn-group").prop("disabled", false); console.log(['Success: toot', json])
todc(); var box = localStorage.getItem('box')
clear(); if (box == 'yes') {
hide()
} else if (box == 'hide') {
$('body').addClass('mini-post')
$('.mini-btn').text('expand_less')
}
$('.toot-btn-group').prop('disabled', false)
todc()
clear()
} }
} }
} }
//クリア(Shift+C) //クリア(Shift+C)
function clear() { function clear() {
$("#textarea").val(""); $('#textarea').val('')
if (localStorage.getItem("stable")) { if (localStorage.getItem('stable')) {
$("#textarea").val("#" + localStorage.getItem("stable") + " ") $('#textarea').val('#' + localStorage.getItem('stable') + ' ')
} }
$("#textarea").attr("placeholder", lang.lang_toot); $('#textarea').attr('placeholder', lang.lang_toot)
$("#reply").val(""); $('#reply').val('')
$("#quote").val(""); $('#quote').val('')
$("#media").val(""); $('#media').val('')
var cwt = localStorage.getItem("cw-text"); var cwt = localStorage.getItem('cw-text')
if (cwt) { if (cwt) {
$("#cw-text").val(cwt); $('#cw-text').val(cwt)
} else { } else {
$("#cw-text").val(""); $('#cw-text').val('')
} }
var acw = localStorage.getItem("always-cw"); var acw = localStorage.getItem('always-cw')
if (acw != "yes") { if (acw != 'yes') {
$("#cw").removeClass("yellow-text"); $('#cw').removeClass('yellow-text')
$("#cw").removeClass("cw-avail"); $('#cw').removeClass('cw-avail')
$("#cw-text").hide(); $('#cw-text').hide()
} else { } else {
$("#cw").addClass("yellow-text"); $('#cw').addClass('yellow-text')
$("#cw").addClass("cw-avail"); $('#cw').addClass('cw-avail')
$("#cw-text").show(); $('#cw-text').show()
} }
$("#rec").text(lang.lang_no); $('#rec').text(lang.lang_no)
$("#mec").text(lang.lang_nothing); $('#mec').text(lang.lang_nothing)
loadVis(); loadVis()
$("#nsfw").removeClass("yellow-text"); $('#nsfw').removeClass('yellow-text')
$("#nsfw").html("visibility_off"); $('#nsfw').html('visibility_off')
$("#nsfw").removeClass("nsfw-avail"); $('#nsfw').removeClass('nsfw-avail')
$("#nsc").text(lang.lang_nothing); $('#nsc').text(lang.lang_nothing)
$("#drag").css("background-color", "#e0e0e0"); $('#drag').css('background-color', '#e0e0e0')
$("#preview").html(""); $('#preview').html('')
$(".toot-btn-group").prop("disabled", false); $('.toot-btn-group').prop('disabled', false)
$("#post-acct-sel").prop("disabled", false); $('#post-acct-sel').prop('disabled', false)
$("#days_poll").val(0); $('#days_poll').val(0)
$("#hours_poll").val(0); $('#hours_poll').val(0)
$("#mins_poll").val(6); $('#mins_poll').val(6)
$("#poll").addClass("hide") $('#poll').addClass('hide')
$("#pollsta").text(lang.lang_no) $('#pollsta').text(lang.lang_no)
$(".mastodon-choice").map(function () { $('.mastodon-choice').map(function() {
$(this).val(""); $(this).val('')
}); })
localStorage.removeItem("image"); 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'))
} }
$("#emoji").addClass("hide") $('#emoji').addClass('hide')
$('select').formSelect(); $('select').formSelect()
$("#default-emoji").show(); $('#default-emoji').show()
$("#unreact").show(); $('#unreact').show()
$("#addreact").addClass("hide"); $('#addreact').addClass('hide')
$("#right-side").hide() $('#right-side').hide()
$("#right-side").css("width", "300px") $('#right-side').css('width', '300px')
$("#left-side").css("width", "100%") $('#left-side').css('width', '100%')
var width = localStorage.getItem("postbox-width"); var width = localStorage.getItem('postbox-width')
if (width) { if (width) {
width = width.replace("px", "") * 1 width = width.replace('px', '') * 1
} else { } else {
width = 300 width = 300
} }
$("#post-box").css("width", width) $('#post-box').css('width', width)
mdCheck() mdCheck()
} }

View File

@ -1,130 +1,128 @@
/*保護系*/ /*保護系*/
//画像保護 //画像保護
function nsfw() { function nsfw() {
if ($("#nsfw").hasClass("nsfw-avail")) { if ($('#nsfw').hasClass('nsfw-avail')) {
$("#nsfw").removeClass("yellow-text"); $('#nsfw').removeClass('yellow-text')
$("#nsfw").html("visibility_off"); $('#nsfw').html('visibility_off')
$("#nsfw").removeClass("nsfw-avail"); $('#nsfw').removeClass('nsfw-avail')
} else { } else {
$("#nsfw").addClass("yellow-text"); $('#nsfw').addClass('yellow-text')
$("#nsfw").html("visibility"); $('#nsfw').html('visibility')
$("#nsfw").addClass("nsfw-avail"); $('#nsfw').addClass('nsfw-avail')
} }
} }
//投稿公開範囲 //投稿公開範囲
function vis(set) { function vis(set) {
$("#vis").text(set); $('#vis').text(set)
$("#vis-icon").removeClass("red-text"); $('#vis-icon').removeClass('red-text')
$("#vis-icon").removeClass("orange-text"); $('#vis-icon').removeClass('orange-text')
$("#vis-icon").removeClass("blue-text"); $('#vis-icon').removeClass('blue-text')
$("#vis-icon").removeClass("purple-text"); $('#vis-icon').removeClass('purple-text')
$("#vis-icon").removeClass("light-blue-text"); $('#vis-icon').removeClass('light-blue-text')
$("#vis-icon").removeClass("teal-text"); $('#vis-icon').removeClass('teal-text')
if (set == "public") { if (set == 'public') {
$("#vis-icon").text("public"); $('#vis-icon').text('public')
$("#vis-icon").addClass("purple-text"); $('#vis-icon').addClass('purple-text')
} else if (set == "unlisted") { } else if (set == 'unlisted') {
$("#vis-icon").text("lock_open"); $('#vis-icon').text('lock_open')
$("#vis-icon").addClass("blue-text"); $('#vis-icon').addClass('blue-text')
} else if (set == "private") { } else if (set == 'private') {
$("#vis-icon").text("lock"); $('#vis-icon').text('lock')
$("#vis-icon").addClass("orange-text"); $('#vis-icon').addClass('orange-text')
} else if (set == "direct") { } else if (set == 'direct') {
$("#vis-icon").text("mail"); $('#vis-icon').text('mail')
$("#vis-icon").addClass("red-text"); $('#vis-icon').addClass('red-text')
} else if (set == "limited") { } else if (set == 'limited') {
$("#vis-icon").text("group"); $('#vis-icon').text('group')
$("#vis-icon").addClass("teal-text"); $('#vis-icon').addClass('teal-text')
} else if (set == "local") { } else if (set == 'local') {
$("#vis-icon").text("visibility"); $('#vis-icon').text('visibility')
$("#vis-icon").addClass("light-blue-text"); $('#vis-icon').addClass('light-blue-text')
} }
var vis = localStorage.getItem("vis"); var vis = localStorage.getItem('vis')
if (vis == "memory") { if (vis == 'memory') {
var acct_id = $("#post-acct-sel").val(); var acct_id = $('#post-acct-sel').val()
localStorage.setItem("vis-memory-" + acct_id, set); localStorage.setItem('vis-memory-' + acct_id, set)
} }
var ins = M.Dropdown.getInstance($('#dropdown1')) var ins = M.Dropdown.getInstance($('#dropdown1'))
if (ins) { if (ins) {
ins.close(); ins.close()
} }
} }
function loadVis() { function loadVis() {
var vist = localStorage.getItem("vis"); var vist = localStorage.getItem('vis')
if (!vist) { if (!vist) {
vis("public"); vis('public')
} else { } else {
if (vist == "memory") { if (vist == 'memory') {
var acct_id = $("#post-acct-sel").val(); var acct_id = $('#post-acct-sel').val()
var memory = localStorage.getItem("vis-memory-" + acct_id); var memory = localStorage.getItem('vis-memory-' + acct_id)
if (!memory) { if (!memory) {
memory = "public"; memory = 'public'
} }
vis(memory); vis(memory)
} else if (vist == "useapi") { } else if (vist == 'useapi') {
var acct_id = $("#post-acct-sel").val(); var acct_id = $('#post-acct-sel').val()
var multi = localStorage.getItem("multi"); var multi = localStorage.getItem('multi')
var obj = JSON.parse(multi); var obj = JSON.parse(multi)
var memory = obj[acct_id]["vis"]; var memory = obj[acct_id]['vis']
if (!memory) { if (!memory) {
memory = "public"; memory = 'public'
} }
vis(memory); vis(memory)
} else { } else {
vis(vist); vis(vist)
} }
} }
} }
loadVis(); loadVis()
//コンテントワーニング //コンテントワーニング
function cw() { function cw() {
if ($("#cw").hasClass("cw-avail")) { if ($('#cw').hasClass('cw-avail')) {
$("#cw-text").val(); $('#cw-text').val()
$("#cw-text").hide(); $('#cw-text').hide()
$("#cw").removeClass("yellow-text"); $('#cw').removeClass('yellow-text')
$("#cw").removeClass("cw-avail"); $('#cw').removeClass('cw-avail')
} else { } else {
$("#cw-text").show(); $('#cw-text').show()
$("#cw").addClass("yellow-text"); $('#cw').addClass('yellow-text')
$("#cw").addClass("cw-avail"); $('#cw').addClass('cw-avail')
var cwt = localStorage.getItem("cw-text"); var cwt = localStorage.getItem('cw-text')
if (cwt) { if (cwt) {
$("#cw-text").val(cwt); $('#cw-text').val(cwt)
} }
} }
} }
//TLでコンテントワーニングを表示トグル //TLでコンテントワーニングを表示トグル
function cw_show(id) { function cw_show(id) {
$(".cw_hide_" + id).toggleClass("cw"); $('.cw_hide_' + id).toggleClass('cw')
$(".cw-long-" + id).toggleClass("hide"); $('.cw-long-' + id).toggleClass('hide')
} }
$(function() { $(function() {
$('#cw-text').on('change', function(event) { $('#cw-text').on('change', function(event) {
var acct_id = $("#post-acct-sel").val(); var acct_id = $('#post-acct-sel').val()
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem('domain_' + acct_id)
var cwlen = $('#cw-text').val().length; var cwlen = $('#cw-text').val().length
if (idata[domain + "_letters"]) { if (idata[domain + '_letters']) {
$("#textarea").attr("data-length", idata[domain + "_letters"] - cwlen) $('#textarea').attr('data-length', idata[domain + '_letters'] - cwlen)
} else { } else {
$("#textarea").attr("data-length", 500 - cwlen) $('#textarea').attr('data-length', 500 - cwlen)
} }
})
})
});
});
//スケジュール //スケジュール
function schedule() { function schedule() {
if ($("#sch-box").hasClass("sch-avail")) { if ($('#sch-box').hasClass('sch-avail')) {
$("#sch-box").hide(); $('#sch-box').hide()
$("#sch-box").removeClass("sch-avail"); $('#sch-box').removeClass('sch-avail')
} else { } else {
var date = new Date(); var date = new Date()
$("#sch-box").show(); $('#sch-box').show()
$("#sch-date").val(formattime(date)); $('#sch-date').val(formattime(date))
$("#sch-box").addClass("sch-avail"); $('#sch-box').addClass('sch-avail')
} }
} }

View File

@ -1,596 +1,596 @@
//お気に入り登録やブースト等、フォローやブロック等 //お気に入り登録やブースト等、フォローやブロック等
//お気に入り登録 //お気に入り登録
function fav(id, acct_id, remote) { function fav(id, acct_id, remote) {
if ($("#pub_" + id).hasClass("faved")) { if ($('#pub_' + id).hasClass('faved')) {
var flag = "unfavourite"; var flag = 'unfavourite'
} else { } else {
var flag = "favourite"; var flag = 'favourite'
} }
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/statuses/" + id + "/" + flag; var start = 'https://' + domain + '/api/v1/statuses/' + id + '/' + flag
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest()
httpreq.open("POST", start, true); httpreq.open('POST', 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(); httpreq.send()
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) { if (this.status !== 200) {
setLog(start, this.status, json); setLog(start, this.status, json)
} }
if (json.reblog) { if (json.reblog) {
json = json.reblog; json = json.reblog
} }
if (remote != "remote") { if (remote != 'remote') {
//APIのふぁぼカウントがおかしい //APIのふぁぼカウントがおかしい
if ($("[unique-id=" + id + "] .fav_ct").text() == json.favourites_count) { if ($('[unique-id=' + id + '] .fav_ct').text() == json.favourites_count) {
if (flag == "unfavourite") { if (flag == 'unfavourite') {
var fav = json.favourites_count - 1; var fav = json.favourites_count - 1
if (fav * 1 < 0) { if (fav * 1 < 0) {
fav = 0; fav = 0
} }
} else { } else {
var fav = json.favourites_count; var fav = json.favourites_count
//var fav = json.favourites_count; //var fav = json.favourites_count;
} }
} else { } else {
var fav = json.favourites_count; var fav = json.favourites_count
} }
$("[unique-id=" + id + "] .fav_ct").text(fav); $('[unique-id=' + id + '] .fav_ct').text(fav)
$("[unique-id=" + id + "] .rt_ct").text(json.reblogs_count); $('[unique-id=' + id + '] .rt_ct').text(json.reblogs_count)
if ($("[unique-id=" + id + "]").hasClass("faved")) { if ($('[unique-id=' + id + ']').hasClass('faved')) {
$("[unique-id=" + id + "]").removeClass("faved"); $('[unique-id=' + id + ']').removeClass('faved')
$(".fav_" + id).removeClass("yellow-text"); $('.fav_' + id).removeClass('yellow-text')
} else { } else {
$("[unique-id=" + id + "]").addClass("faved"); $('[unique-id=' + id + ']').addClass('faved')
$(".fav_" + id).addClass("yellow-text"); $('.fav_' + id).addClass('yellow-text')
} }
} else { } else {
M.toast({ html: lang.lang_status_favWarn, displayLength: 1000 }); M.toast({ html: lang.lang_status_favWarn, displayLength: 1000 })
}
} }
} }
};
} }
//ブースト //ブースト
function rt(id, acct_id, remote, vis) { function rt(id, acct_id, remote, vis) {
if ($("#pub_" + id).hasClass("rted")) { if ($('#pub_' + id).hasClass('rted')) {
var flag = "unreblog"; var flag = 'unreblog'
} else { } else {
var flag = "reblog"; var flag = 'reblog'
} }
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/statuses/" + id + "/" + flag; var start = 'https://' + domain + '/api/v1/statuses/' + id + '/' + flag
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest()
httpreq.open("POST", start, true); httpreq.open('POST', 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'
if (vis) { if (vis) {
httpreq.send(JSON.stringify({ visibility: vis })); httpreq.send(JSON.stringify({ visibility: vis }))
} else { } else {
httpreq.send(); httpreq.send()
} }
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) { if (this.status !== 200) {
setLog(start, this.status, json); setLog(start, this.status, json)
} }
if (json.reblog) { if (json.reblog) {
json = json.reblog; json = json.reblog
} }
console.log(["Success: boost", json]); console.log(['Success: boost', json])
$("[unique-id=" + id + "] .fav_ct").text(json.favourites_count); $('[unique-id=' + id + '] .fav_ct').text(json.favourites_count)
if (!json.reblog) { if (!json.reblog) {
if (flag == "unreblog") { if (flag == 'unreblog') {
var rt = json.reblogs_count - 1; var rt = json.reblogs_count - 1
if (rt * 1 < 0) { if (rt * 1 < 0) {
rt = 0; rt = 0
} }
} else { } else {
var rt = json.reblogs_count; var rt = json.reblogs_count
} }
$("[unique-id=" + id + "] .rt_ct").text(rt); $('[unique-id=' + id + '] .rt_ct').text(rt)
} else { } else {
$("[unique-id=" + id + "] .rt_ct").text(json.reblogs_count); $('[unique-id=' + id + '] .rt_ct').text(json.reblogs_count)
} }
if ($("[unique-id=" + id + "]").hasClass("rted")) { if ($('[unique-id=' + id + ']').hasClass('rted')) {
$("[unique-id=" + id + "]").removeClass("rted"); $('[unique-id=' + id + ']').removeClass('rted')
$(".rt_" + id).removeClass("light-blue-text"); $('.rt_' + id).removeClass('light-blue-text')
} else { } else {
$("[unique-id=" + id + "]").addClass("rted"); $('[unique-id=' + id + ']').addClass('rted')
$(".rt_" + id).addClass("light-blue-text"); $('.rt_' + id).addClass('light-blue-text')
}
} }
} }
};
} }
function boostWith(vis) { function boostWith(vis) {
var id = $("#tootmodal").attr("data-id"); var id = $('#tootmodal').attr('data-id')
var acct_id = $("#tootmodal").attr("data-acct"); var acct_id = $('#tootmodal').attr('data-acct')
rt(id, acct_id, false, vis); rt(id, acct_id, false, vis)
} }
//フォロー //フォロー
async function follow(acct_id, resolve) { async function follow(acct_id, resolve) {
if (!acct_id && acct_id != "selector") { if (!acct_id && acct_id != 'selector') {
var acct_id = $("#his-data").attr("use-acct"); var acct_id = $('#his-data').attr('use-acct')
} else if (acct_id == "selector") { } else if (acct_id == 'selector') {
var acct_id = $("#user-acct-sel").val(); var acct_id = $('#user-acct-sel').val()
} }
if (!resolve && $("#his-data").hasClass("following")) { if (!resolve && $('#his-data').hasClass('following')) {
var flag = "unfollow"; var flag = 'unfollow'
var flagm = "delete"; var flagm = 'delete'
} else { } else {
var flag = "follow"; var flag = 'follow'
var flagm = "create"; var flagm = 'create'
} }
var id = $("#his-data").attr("user-id"); var id = $('#his-data').attr('user-id')
if (resolve == "selector") { if (resolve == 'selector') {
var fullacct = $("#his-acct").attr("fullname"); var fullacct = $('#his-acct').attr('fullname')
var id = await acctResolve(acct_id, fullacct); var id = await acctResolve(acct_id, fullacct)
console.log(id); console.log(id)
} }
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/" + id + "/" + flag; var start = 'https://' + domain + '/api/v1/accounts/' + id + '/' + flag
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem('mode_' + domain) == 'misskey') {
var start = "https://" + domain + "/api/following/" + flagm; var start = 'https://' + domain + '/api/following/' + flagm
var ent = { i: at, userId: id }; var ent = { i: at, userId: id }
} else if (flag == "follow") { } else if (flag == 'follow') {
var ent = {}; var ent = {}
} }
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest()
httpreq.open("POST", start, true); httpreq.open('POST', 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(ent)); httpreq.send(JSON.stringify(ent))
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) { if (this.status !== 200) {
setLog(start, this.status, json); setLog(start, this.status, json)
} }
console.log(["Success: folllow", json]); console.log(['Success: folllow', json])
if ($("#his-data").hasClass("following")) { if ($('#his-data').hasClass('following')) {
$("#his-data").removeClass("following"); $('#his-data').removeClass('following')
$("#his-follow-btn-text").text(lang.lang_status_follow); $('#his-follow-btn-text').text(lang.lang_status_follow)
} else { } else {
$("#his-data").addClass("following"); $('#his-data').addClass('following')
$("#his-follow-btn-text").text(lang.lang_status_unfollow); $('#his-follow-btn-text').text(lang.lang_status_unfollow)
}
} }
} }
};
} }
async function acctResolve(acct_id, user) { async function acctResolve(acct_id, user) {
console.log("Get user data of " + user); console.log('Get user data of ' + user)
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem('domain_' + acct_id)
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem('mode_' + domain) == 'misskey') {
return false; return false
} }
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem('acct_' + acct_id + '_at')
var start = "https://" + domain + "/api/v2/search?resolve=true&q=" + user; var start = 'https://' + domain + '/api/v2/search?resolve=true&q=' + user
let promise = await fetch(start, { let promise = await fetch(start, {
method: "GET", method: 'GET',
headers: { headers: {
"content-type": "application/json", 'content-type': 'application/json',
Authorization: "Bearer " + at Authorization: 'Bearer ' + at
} }
}); })
var idJson = await promise.json(); var idJson = await promise.json()
if (idJson.accounts[0]) { if (idJson.accounts[0]) {
var id = idJson.accounts[0].id; var id = idJson.accounts[0].id
} else { } else {
M.toast({ html: lang.lang_fatalerroroccured, displayLength: 2000 }); M.toast({ html: lang.lang_fatalerroroccured, displayLength: 2000 })
} }
return id; return id
} }
//ブロック //ブロック
function block(acct_id) { function block(acct_id) {
if ($("#his-data").hasClass("blocking")) { if ($('#his-data').hasClass('blocking')) {
var flag = "unblock"; var flag = 'unblock'
var txt = lang.lang_status_unmute; var txt = lang.lang_status_unmute
} else { } else {
var flag = "block"; var flag = 'block'
var txt = lang.lang_status_block; var txt = lang.lang_status_block
} }
Swal.fire({ Swal.fire({
title: txt, title: txt,
text: "", text: '',
type: "warning", type: 'warning',
showCancelButton: true, showCancelButton: true,
confirmButtonColor: "#3085d6", confirmButtonColor: '#3085d6',
cancelButtonColor: "#d33", cancelButtonColor: '#d33',
confirmButtonText: lang.lang_yesno, confirmButtonText: lang.lang_yesno,
cancelButtonText: lang.lang_no cancelButtonText: lang.lang_no
}).then(result => { }).then(result => {
if (result.value) { if (result.value) {
if (!acct_id) { if (!acct_id) {
var acct_id = $("#his-data").attr("use-acct"); var acct_id = $('#his-data').attr('use-acct')
} }
var id = $("#his-data").attr("user-id"); var id = $('#his-data').attr('user-id')
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/" + id + "/" + flag; var start = 'https://' + domain + '/api/v1/accounts/' + id + '/' + flag
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest()
httpreq.open("POST", start, true); httpreq.open('POST', 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(); httpreq.send()
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
if (this.status !== 200) { if (this.status !== 200) {
setLog(start, this.status, this.response); setLog(start, this.status, this.response)
} }
if ($("#his-data").hasClass("blocking")) { if ($('#his-data').hasClass('blocking')) {
$("#his-data").removeClass("blocking"); $('#his-data').removeClass('blocking')
$("#his-block-btn-text").text(lang.lang_status_block); $('#his-block-btn-text').text(lang.lang_status_block)
} else { } else {
$("#his-data").addClass("blocking"); $('#his-data').addClass('blocking')
$("#his-block-btn-text").text(lang.lang_status_unblock); $('#his-block-btn-text').text(lang.lang_status_unblock)
} }
} }
};
} }
}); }
})
} }
//ミュート //ミュート
function muteDo(acct_id) { function muteDo(acct_id) {
if ($("#his-data").hasClass("muting")) { if ($('#his-data').hasClass('muting')) {
var flag = "unmute"; var flag = 'unmute'
var flagm = "delete"; var flagm = 'delete'
var txt = lang.lang_status_unmute; var txt = lang.lang_status_unmute
} else { } else {
var flag = "mute"; var flag = 'mute'
var flagm = "create"; var flagm = 'create'
var txt = lang.lang_status_mute; var txt = lang.lang_status_mute
} }
Swal.fire({ Swal.fire({
title: txt, title: txt,
text: "", text: '',
type: "warning", type: 'warning',
showCancelButton: true, showCancelButton: true,
confirmButtonColor: "#3085d6", confirmButtonColor: '#3085d6',
cancelButtonColor: "#d33", cancelButtonColor: '#d33',
confirmButtonText: lang.lang_yesno, confirmButtonText: lang.lang_yesno,
cancelButtonText: lang.lang_no cancelButtonText: lang.lang_no
}).then(result => { }).then(result => {
if (result.value) { if (result.value) {
if (!acct_id) { if (!acct_id) {
var acct_id = $("#his-data").attr("use-acct"); var acct_id = $('#his-data').attr('use-acct')
} }
var id = $("#his-data").attr("user-id"); var id = $('#his-data').attr('user-id')
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')
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem('mode_' + domain) == 'misskey') {
var start = "https://" + domain + "/api/mute/" + flagm; var start = 'https://' + domain + '/api/mute/' + flagm
var ent = { i: at, userId: id }; var ent = { i: at, userId: id }
var rq = JSON.stringify(ent); var rq = JSON.stringify(ent)
} else { } else {
var start = "https://" + domain + "/api/v1/accounts/" + id + "/" + flag; var start = 'https://' + domain + '/api/v1/accounts/' + id + '/' + flag
var rq = ""; var rq = ''
} }
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest()
httpreq.open("POST", start, true); httpreq.open('POST', 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(rq); httpreq.send(rq)
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
if (this.status !== 200) { if (this.status !== 200) {
setLog(start, this.status, this.response); setLog(start, this.status, this.response)
} }
if ($("#his-data").hasClass("muting")) { if ($('#his-data').hasClass('muting')) {
$("#his-data").removeClass("muting"); $('#his-data').removeClass('muting')
$("#his-mute-btn-text").text(lang.lang_status_mute); $('#his-mute-btn-text').text(lang.lang_status_mute)
} else { } else {
$("#his-data").addClass("muting"); $('#his-data').addClass('muting')
$("#his-mute-btn-text").text(lang.lang_status_unmute); $('#his-mute-btn-text').text(lang.lang_status_unmute)
} }
} }
};
} }
}); }
})
} }
//投稿削除 //投稿削除
function del(id, acct_id) { function del(id, acct_id) {
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')
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem('mode_' + domain) == 'misskey') {
var start = "https://" + domain + "/api/notes/delete"; var start = 'https://' + domain + '/api/notes/delete'
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest()
httpreq.open("POST", start, true); httpreq.open('POST', start, true)
httpreq.setRequestHeader("Content-Type", "application/json"); httpreq.setRequestHeader('Content-Type', 'application/json')
httpreq.responseType = "json"; httpreq.responseType = 'json'
httpreq.send(JSON.stringify({ i: at, noteId: id })); httpreq.send(JSON.stringify({ i: at, noteId: id }))
$("[toot-id=" + id + "]").hide(); $('[toot-id=' + id + ']').hide()
$("[toot-id=" + id + "]").remove(); $('[toot-id=' + id + ']').remove()
} else { } else {
var start = "https://" + domain + "/api/v1/statuses/" + id; var start = 'https://' + domain + '/api/v1/statuses/' + id
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest()
httpreq.open("DELETE", start, true); httpreq.open('DELETE', 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(); httpreq.send()
} }
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
if (this.status !== 200) { if (this.status !== 200) {
setLog(start, this.status, this.response); setLog(start, this.status, this.response)
}
} }
} }
};
} }
//redraft //redraft
function redraft(id, acct_id) { function redraft(id, acct_id) {
Swal.fire({ Swal.fire({
title: lang.lang_status_redraftTitle, title: lang.lang_status_redraftTitle,
text: lang.lang_status_redraft, text: lang.lang_status_redraft,
type: "warning", type: 'warning',
showCancelButton: true, showCancelButton: true,
confirmButtonColor: "#3085d6", confirmButtonColor: '#3085d6',
cancelButtonColor: "#d33", cancelButtonColor: '#d33',
confirmButtonText: lang.lang_yesno, confirmButtonText: lang.lang_yesno,
cancelButtonText: lang.lang_no cancelButtonText: lang.lang_no
}).then(result => { }).then(result => {
if (result.value) { if (result.value) {
show(); show()
del(id, acct_id); del(id, acct_id)
$("#post-acct-sel").prop("disabled", true); $('#post-acct-sel').prop('disabled', true)
$("#post-acct-sel").val(acct_id); $('#post-acct-sel').val(acct_id)
$("select").formSelect(); $('select').formSelect()
mdCheck(); mdCheck()
var medias = $("[toot-id=" + id + "]").attr("data-medias"); var medias = $('[toot-id=' + id + ']').attr('data-medias')
var vismode = $("[toot-id=" + id + "] .vis-data").attr("data-vis"); var vismode = $('[toot-id=' + id + '] .vis-data').attr('data-vis')
vis(vismode); vis(vismode)
$("#media").val(medias); $('#media').val(medias)
var ct = medias.split(",").length; var ct = medias.split(',').length
$("[toot-id=" + id + "] img.toot-img").each(function(i, elem) { $('[toot-id=' + id + '] img.toot-img').each(function(i, elem) {
if (i < ct) { if (i < ct) {
var url = $(elem).attr("src"); var url = $(elem).attr('src')
console.log("Play back image data:" + url); console.log('Play back image data:' + url)
$("#preview").append('<img src="' + url + '" style="width:50px; max-height:100px;">'); $('#preview').append('<img src="' + url + '" style="width:50px; max-height:100px;">')
} }
}); })
var html = $("[toot-id=" + id + "] .toot").html(); var html = $('[toot-id=' + id + '] .toot').html()
html = html.replace(/^<p>(.+)<\/p>$/, "$1"); html = html.replace(/^<p>(.+)<\/p>$/, '$1')
html = html.replace(/<br\s?\/?>/, "\n"); html = html.replace(/<br\s?\/?>/, '\n')
html = html.replace(/<p>/, "\n"); html = html.replace(/<p>/, '\n')
html = html.replace(/<\/p>/, "\n"); html = html.replace(/<\/p>/, '\n')
html = html.replace(/<img[\s\S]*alt="(.+?)"[\s\S]*?>/g, "$1"); html = html.replace(/<img[\s\S]*alt="(.+?)"[\s\S]*?>/g, '$1')
html = $.strip_tags(html); html = $.strip_tags(html)
localStorage.setItem("nohide", true); localStorage.setItem('nohide', true)
show(); show()
$("#textarea").val(html); $('#textarea').val(html)
var cwtxt = $("[toot-id=" + id + "] .cw_text").html(); var cwtxt = $('[toot-id=' + id + '] .cw_text').html()
if (cwtxt != "") { if (cwtxt != '') {
cwtxt = $.strip_tags(cwtxt); cwtxt = $.strip_tags(cwtxt)
cw(); cw()
$("#cw-text").val(cwtxt); $('#cw-text').val(cwtxt)
} }
} }
}); })
} }
//ピン留め //ピン留め
function pin(id, acct_id) { function pin(id, acct_id) {
if ($("#pub_" + id).hasClass("pined")) { if ($('#pub_' + id).hasClass('pined')) {
var flag = "unpin"; var flag = 'unpin'
} else { } else {
var flag = "pin"; var flag = 'pin'
} }
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/statuses/" + id + "/" + flag; var start = 'https://' + domain + '/api/v1/statuses/' + id + '/' + flag
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest()
httpreq.open("POST", start, true); httpreq.open('POST', 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(); httpreq.send()
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) { if (this.status !== 200) {
setLog(start, this.status, this.response); setLog(start, this.status, this.response)
} }
console.log(["Success: pinned", json]); console.log(['Success: pinned', json])
if ($("[toot-id=" + id + "]").hasClass("pined")) { if ($('[toot-id=' + id + ']').hasClass('pined')) {
$("[toot-id=" + id + "]").removeClass("pined"); $('[toot-id=' + id + ']').removeClass('pined')
$(".pin_" + id).removeClass("blue-text"); $('.pin_' + id).removeClass('blue-text')
} else { } else {
$("[toot-id=" + id + "]").addClass("pined"); $('[toot-id=' + id + ']').addClass('pined')
$(".pin_" + id).addClass("blue-text"); $('.pin_' + id).addClass('blue-text')
}
} }
} }
};
} }
//フォロリク //フォロリク
function request(id, flag, acct_id) { function request(id, flag, acct_id) {
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/follow_requests/" + id + "/" + flag; var start = 'https://' + domain + '/api/v1/follow_requests/' + id + '/' + flag
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest()
httpreq.open("POST", start, true); httpreq.open('POST', 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(); httpreq.send()
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) { if (this.status !== 200) {
setLog(start, this.status, this.response); setLog(start, this.status, this.response)
}
console.log(['Success: request', 'type:' + flag, json])
showReq()
} }
console.log(["Success: request", "type:" + flag, json]);
showReq();
} }
};
} }
//ドメインブロック(未実装) //ドメインブロック(未実装)
function domainblock(add, flag, acct_id) { function domainblock(add, flag, acct_id) {
if (!acct_id) { if (!acct_id) {
var acct_id = $("#his-data").attr("use-acct"); var acct_id = $('#his-data').attr('use-acct')
} }
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/domain_blocks"; var start = 'https://' + domain + '/api/v1/domain_blocks'
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest()
httpreq.open("POST", start, true); httpreq.open('POST', 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(); httpreq.send()
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) { if (this.status !== 200) {
setLog(start, this.status, this.response); setLog(start, this.status, this.response)
}
console.log(['Success: domain block', json])
showDom()
} }
console.log(["Success: domain block", json]);
showDom();
} }
};
} }
function addDomainblock() { function addDomainblock() {
var domain = $("#domainblock").val(); var domain = $('#domainblock').val()
domainblock(domain, "POST"); domainblock(domain, 'POST')
} }
//ユーザー強調 //ユーザー強調
function empUser() { function empUser() {
var usr = localStorage.getItem("user_emp"); var usr = localStorage.getItem('user_emp')
var obj = JSON.parse(usr); var obj = JSON.parse(usr)
var id = $("#his-acct").attr("fullname"); var id = $('#his-acct').attr('fullname')
if (!obj) { if (!obj) {
var obj = []; var obj = []
obj.push(id); obj.push(id)
M.toast({ html: id + lang.lang_status_emphas, displayLength: 4000 }); M.toast({ html: id + lang.lang_status_emphas, displayLength: 4000 })
} else { } else {
var can; var can
Object.keys(obj).forEach(function(key) { Object.keys(obj).forEach(function(key) {
var usT = obj[key]; var usT = obj[key]
if (usT != id && !can) { if (usT != id && !can) {
can = false; can = false
} else { } else {
can = true; can = true
obj.splice(key, 1); obj.splice(key, 1)
M.toast({ html: id + lang.lang_status_unemphas, displayLength: 4000 }); M.toast({ html: id + lang.lang_status_unemphas, displayLength: 4000 })
} }
}); })
} }
var json = JSON.stringify(obj); var json = JSON.stringify(obj)
localStorage.setItem("user_emp", json); localStorage.setItem('user_emp', json)
} }
//Endorse //Endorse
function pinUser() { function pinUser() {
var id = $("#his-data").attr("user-id"); var id = $('#his-data').attr('user-id')
var acct_id = $("#his-data").attr("use-acct"); var acct_id = $('#his-data').attr('use-acct')
if ($("#his-end-btn").hasClass("endorsed")) { if ($('#his-end-btn').hasClass('endorsed')) {
var flag = "unpin"; var flag = 'unpin'
} else { } else {
var flag = "pin"; var flag = 'pin'
} }
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/" + id + "/" + flag; var start = 'https://' + domain + '/api/v1/accounts/' + id + '/' + flag
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest()
httpreq.open("POST", start, true); httpreq.open('POST', 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(); httpreq.send()
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) { if (this.status !== 200) {
setLog(start, this.status, this.response); setLog(start, this.status, this.response)
} }
if ($("#his-end-btn").hasClass("endorsed")) { if ($('#his-end-btn').hasClass('endorsed')) {
$("#his-end-btn").removeClass("endorsed"); $('#his-end-btn').removeClass('endorsed')
$("#his-end-btn").text(lang.lang_status_endorse); $('#his-end-btn').text(lang.lang_status_endorse)
} else { } else {
$("#his-end-btn").addClass("endorsed"); $('#his-end-btn').addClass('endorsed')
$("#his-end-btn").text(lang.lang_status_unendorse); $('#his-end-btn').text(lang.lang_status_unendorse)
}
} }
} }
};
} }
//URLコピー //URLコピー
function tootUriCopy(url) { function tootUriCopy(url) {
execCopy(url); execCopy(url)
M.toast({ html: lang.lang_details_url, displayLength: 1500 }); M.toast({ html: lang.lang_details_url, displayLength: 1500 })
} }
//他のアカウントで… //他のアカウントで…
function staEx(mode) { function staEx(mode) {
var url = $("#tootmodal").attr("data-url"); var url = $('#tootmodal').attr('data-url')
var acct_id = $("#status-acct-sel").val(); var acct_id = $('#status-acct-sel').val()
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/v2/search?resolve=true&q=" + url; var start = 'https://' + domain + '/api/v2/search?resolve=true&q=' + url
fetch(start, { fetch(start, {
method: "GET", method: 'GET',
headers: { headers: {
"content-type": "application/json", 'content-type': 'application/json',
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 id = json.statuses[0].id; var id = json.statuses[0].id
if (mode == "rt") { if (mode == 'rt') {
rt(id, acct_id, "remote"); rt(id, acct_id, 'remote')
} else if (mode == "fav") { } else if (mode == 'fav') {
fav(id, acct_id, "remote"); fav(id, acct_id, 'remote')
} else if (mode == "reply") { } else if (mode == 'reply') {
reEx(id); reEx(id)
} }
}); })
return; return
} }
function toggleAction(id, tlid, acct_id) { function toggleAction(id, tlid, acct_id) {
if (tlid == "notf") { if (tlid == 'notf') {
var tlide = "[data-acct=" + acct_id + "] .notf-timeline"; var tlide = '[data-acct=' + acct_id + '] .notf-timeline'
} else if (tlid == "user") { } else if (tlid == 'user') {
var tlide = "#his-tl-contents"; var tlide = '#his-tl-contents'
} else { } else {
var tlide = "[tlid=" + tlid + "]"; var tlide = '[tlid=' + tlid + ']'
} }
if (!$(tlide + " [toot-id=" + id + "]").hasClass("ext-mode")) { if (!$(tlide + ' [toot-id=' + id + ']').hasClass('ext-mode')) {
$(tlide + " [toot-id=" + id + "] .type-a").hide(); $(tlide + ' [toot-id=' + id + '] .type-a').hide()
$(tlide + " [toot-id=" + id + "] .type-b").show(); $(tlide + ' [toot-id=' + id + '] .type-b').show()
$(tlide + " [toot-id=" + id + "]").addClass("ext-mode"); $(tlide + ' [toot-id=' + id + ']').addClass('ext-mode')
$(tlide + " [toot-id=" + id + "] .act-icon").text("expand_less"); $(tlide + ' [toot-id=' + id + '] .act-icon').text('expand_less')
} else { } else {
$(tlide + " [toot-id=" + id + "] .type-b").hide(); $(tlide + ' [toot-id=' + id + '] .type-b').hide()
$(tlide + " [toot-id=" + id + "] .type-a").show(); $(tlide + ' [toot-id=' + id + '] .type-a').show()
$(tlide + " [toot-id=" + id + "]").removeClass("ext-mode"); $(tlide + ' [toot-id=' + id + ']').removeClass('ext-mode')
$(tlide + " [toot-id=" + id + "] .act-icon").text("expand_more"); $(tlide + ' [toot-id=' + id + '] .act-icon').text('expand_more')
} }
} }

View File

@ -1,254 +1,262 @@
//入力時にハッシュタグと@をサジェスト //入力時にハッシュタグと@をサジェスト
var timer = null; var timer = null
var input = document.getElementById("textarea"); var input = document.getElementById('textarea')
var prev_val = input.value; var prev_val = input.value
var oldSuggest; var oldSuggest
var suggest; var suggest
input.addEventListener( input.addEventListener(
"focus", 'focus',
function() { function() {
localStorage.removeItem("cursor"); localStorage.removeItem('cursor')
var acct_id = $("#post-acct-sel").val(); var acct_id = $('#post-acct-sel').val()
$("#suggest").html(""); $('#suggest').html('')
window.clearInterval(timer); window.clearInterval(timer)
timer = window.setInterval(function() { timer = window.setInterval(function() {
var new_val = input.value; var new_val = input.value
if (new_val == "") { if (new_val == '') {
$("#suggest").html(""); $('#suggest').html('')
if ($("#poll").hasClass("hide") && $("#emoji").hasClass("hide")) { if ($('#poll').hasClass('hide') && $('#emoji').hasClass('hide')) {
$("#right-side").hide(); $('#right-side').hide()
$("#right-side").css("width", "300px"); $('#right-side').css('width', '300px')
$("#left-side").css("width", "100%"); $('#left-side').css('width', '100%')
var width = localStorage.getItem("postbox-width"); var width = localStorage.getItem('postbox-width')
if (width) { if (width) {
width = width.replace("px", "") * 1; width = width.replace('px', '') * 1
} else { } else {
width = 300; width = 300
} }
$("#post-box").css("width", width + "px"); $('#post-box').css('width', width + 'px')
} }
return; return
} }
if (prev_val != new_val) { if (prev_val != new_val) {
var tag = new_val.match(/#(\S{3,})/); var tag = new_val.match(/#(\S{3,})/)
var acct = new_val.match(/@(\S{3,})/); var acct = new_val.match(/@(\S{3,})/)
if (tag && tag[1]) { if (tag && tag[1]) {
var q = tag[1]; var q = tag[1]
} else if (acct && acct[1]) { } else if (acct && acct[1]) {
var q = acct[1]; var q = acct[1]
} else { } else {
$("#suggest").html(""); $('#suggest').html('')
if ($("#poll").hasClass("hide") && $("#emoji").hasClass("hide")) { if ($('#poll').hasClass('hide') && $('#emoji').hasClass('hide')) {
$("#right-side").hide(); $('#right-side').hide()
$("#right-side").css("width", "300px"); $('#right-side').css('width', '300px')
$("#left-side").css("width", "100%"); $('#left-side').css('width', '100%')
var width = localStorage.getItem("postbox-width"); var width = localStorage.getItem('postbox-width')
if (width) { if (width) {
width = width.replace("px", "") * 1; width = width.replace('px', '') * 1
} else { } else {
width = 300; width = 300
} }
$("#post-box").css("width", width + "px"); $('#post-box').css('width', width + 'px')
} }
return; return
} }
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')
suggest = "https://" + domain + "/api/v2/search?q=" + q; suggest = 'https://' + domain + '/api/v2/search?q=' + q
if (suggest != oldSuggest) { if (suggest != oldSuggest) {
console.log("Try to get suggest at " + suggest); console.log('Try to get suggest at ' + suggest)
fetch(suggest, { fetch(suggest, {
method: "GET", method: 'GET',
headers: { headers: {
"content-type": "application/json", 'content-type': 'application/json',
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) {
console.log(["Search", json]); console.log(['Search', json])
//ハッシュタグ //ハッシュタグ
if (json.hashtags[0] && tag) { if (json.hashtags[0] && tag) {
if (tag[1]) { if (tag[1]) {
var tags = []; var tags = []
Object.keys(json.hashtags).forEach(function(key4) { Object.keys(json.hashtags).forEach(function(key4) {
var tag = json.hashtags[key4]; var tag = json.hashtags[key4]
var his = tag.history; var his = tag.history
var uses = his[0].uses * 1 + his[1].uses * 1 + his[2].uses * 1 + his[3].uses * 1 + his[4].uses * 1 + his[5].uses * 1 + his[6].uses * 1; var uses =
tagHTML = "<br><a onclick=\"tagInsert('#" + escapeHTML(tag.name) + "','#" + q + '\')" class="pointer">#' + escapeHTML(tag.name) + "</a>&nbsp;" + uses + "toot(s)"; his[0].uses * 1 +
his[1].uses * 1 +
his[2].uses * 1 +
his[3].uses * 1 +
his[4].uses * 1 +
his[5].uses * 1 +
his[6].uses * 1
tagHTML = `<br><a onclick="tagInsert('#${escapeHTML(tag.name)}','#${escapeHTML(tag.name)}')" class="pointer">#${escapeHTML(tag.name)}</a>&nbsp;${uses}toot(s)`
var item = { var item = {
uses: uses, uses: uses,
html: tagHTML html: tagHTML
}; }
tags.push(item); tags.push(item)
}); })
var num_a = -1; var num_a = -1
var num_b = 1; var num_b = 1
tags = tags.sort(function(a, b) { tags = tags.sort(function(a, b) {
var x = a["uses"]; var x = a['uses']
var y = b["uses"]; var y = b['uses']
if (x > y) return num_a; if (x > y) return num_a
if (x < y) return num_b; if (x < y) return num_b
return 0; return 0
}); })
var ins = ""; var ins = ''
var nev = false; var nev = false
Object.keys(tags).forEach(function(key7) { Object.keys(tags).forEach(function(key7) {
ins = ins + tags[key7].html; ins = ins + tags[key7].html
if (key7 <= 0 && !nev) { if (key7 <= 0 && !nev) {
ins = ins + "<br>"; ins = ins + '<br>'
nev = true; nev = true
} }
}); })
$("#suggest").html(ins); $('#suggest').html(ins)
$("#right-side").show(); $('#right-side').show()
$("#right-side").css("width", "200px"); $('#right-side').css('width', '200px')
$("#left-side").css("width", "calc(100% - 200px)"); $('#left-side').css('width', 'calc(100% - 200px)')
var width = localStorage.getItem("postbox-width"); var width = localStorage.getItem('postbox-width')
if (width) { if (width) {
width = width.replace("px", "") * 1 + 200; width = width.replace('px', '') * 1 + 200
} else { } else {
width = 500; width = 500
} }
$("#post-box").css("width", width + "px"); $('#post-box').css('width', width + 'px')
$("#poll").addClass("hide"); $('#poll').addClass('hide')
$("#emoji").addClass("hide"); $('#emoji').addClass('hide')
} }
} else if (json.accounts[0] && acct[1]) { } else if (json.accounts[0] && acct[1]) {
var accts = ""; var accts = ''
Object.keys(json.accounts).forEach(function(key3) { Object.keys(json.accounts).forEach(function(key3) {
var acct = json.accounts[key3]; var acct = json.accounts[key3]
if (acct.acct != q) { if (acct.acct != q) {
//Instance Actorって… //Instance Actorって…
if (acct.username.indexOf(".") < 0) { if (acct.username.indexOf('.') < 0) {
accts = accts + "<a onclick=\"tagInsert('@" + acct.acct + "','@" + q + '\')" class="pointer">@' + acct.acct + "</a><br>"; accts = accts + `<a onclick="tagInsert('@${acct.acct}','@${q}')" class="pointer">@${acct.acct}</a><br>`
} }
} }
}); })
$("#right-side").show(); $('#right-side').show()
$("#right-side").css("width", "200px"); $('#right-side').css('width', '200px')
$("#left-side").css("width", "calc(100% - 200px)"); $('#left-side').css('width', 'calc(100% - 200px)')
var width = localStorage.getItem("postbox-width"); var width = localStorage.getItem('postbox-width')
if (width) { if (width) {
width = width.replace("px", "") * 1 + 200; width = width.replace('px', '') * 1 + 200
} else { } else {
width = 500; width = 500
} }
$("#post-box").css("width", width + "px"); $('#post-box').css('width', width + 'px')
$("#suggest").html(accts); $('#suggest').html(accts)
$("#poll").addClass("hide"); $('#poll').addClass('hide')
$("#emoji").addClass("hide"); $('#emoji').addClass('hide')
} else { } else {
if ($("#poll").hasClass("hide") && $("#emoji").hasClass("hide")) { if ($('#poll').hasClass('hide') && $('#emoji').hasClass('hide')) {
$("#right-side").hide(); $('#right-side').hide()
$("#right-side").css("width", "300px"); $('#right-side').css('width', '300px')
$("#left-side").css("width", "100%"); $('#left-side').css('width', '100%')
var width = localStorage.getItem("postbox-width"); var width = localStorage.getItem('postbox-width')
if (width) { if (width) {
width = width.replace("px", "") * 1; width = width.replace('px', '') * 1
} else { } else {
width = 300; width = 300
} }
$("#post-box").css("width", width + "px"); $('#post-box').css('width', width + 'px')
} }
} }
}); })
} }
} }
oldSuggest = suggest; oldSuggest = suggest
prev_value = new_val; prev_value = new_val
}, 1000); }, 1000)
}, },
false false
); )
input.addEventListener( input.addEventListener(
"blur", 'blur',
function() { function() {
window.clearInterval(timer); window.clearInterval(timer)
favTag(); favTag()
}, },
false false
); )
function tagInsert(code, del) { function tagInsert(code, del) {
var now = $("#textarea").val(); var now = $('#textarea').val()
var selin = $("#textarea").prop("selectionStart"); var selin = $('#textarea').prop('selectionStart')
if (!del) { if (!del) {
} else { } else {
var regExp = new RegExp(del.replace(/[.*+?^=!:${}()|[\]\/\\]/g, "\\$&"), "g"); var regExp = new RegExp(del.replace(/[.*+?^=!:${}()|[\]\/\\]/g, '\\$&'), 'g')
var now = now.replace(regExp, ""); var now = now.replace(regExp, '')
selin = selin - del.length; selin = selin - del.length
} }
if (selin > 0) { if (selin > 0) {
var before = now.substr(0, selin); var before = now.substr(0, selin)
var after = now.substr(selin, now.length); var after = now.substr(selin, now.length)
newt = before + " " + code + " " + after; newt = before + ' ' + code + ' ' + after
} else { } else {
newt = code + " " + now; newt = code + ' ' + now
} }
$("#textarea").val(newt); $('#textarea').val(newt)
$("#textarea").focus(); $('#textarea').focus()
if ($("#poll").hasClass("hide") && $("#emoji").hasClass("hide")) { if ($('#poll').hasClass('hide') && $('#emoji').hasClass('hide')) {
$("#right-side").hide(); $('#right-side').hide()
$("#right-side").css("width", "300px"); $('#right-side').css('width', '300px')
$("#left-side").css("width", "50%"); $('#left-side').css('width', '50%')
var width = localStorage.getItem("postbox-width").replace("px", "") * 1; var width = localStorage.getItem('postbox-width').replace('px', '') * 1
if (!width) { if (!width) {
width = 300; width = 300
} }
$("#post-box").css("width", width + "px"); $('#post-box').css('width', width + 'px')
} }
$("#suggest").html(""); $('#suggest').html('')
} }
function cgNPs(q) { function cgNPs(q) {
suggest = "https://cg.toot.app/api/v1/search/light?q=" + q; suggest = 'https://cg.toot.app/api/v1/search/light?q=' + q
if (suggest != oldSuggest) { if (suggest != oldSuggest) {
console.log("Try to get suggest at " + suggest); console.log('Try to get suggest at ' + suggest)
fetch(suggest, { fetch(suggest, {
method: "GET", method: 'GET',
headers: { headers: {
"content-type": "application/json" 'content-type': 'application/json'
} }
}) })
.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[0]) { if (json[0]) {
var tags = ""; var tags = ''
Object.keys(json).forEach(function(key4) { Object.keys(json).forEach(function(key4) {
var tag = json[key4]; var tag = json[key4]
tags = tags + "<a onclick=\"cgNP('" + json[key4] + '\')" class="pointer">' + escapeHTML(json[key4]) + "</a> "; tags = tags + `<a onclick="cgNp('${json[key4]}')" class="pointer">${escapeHTML(json[key4])}</a>`
}); })
$("#suggest").html("Cinderella NowPlaying:" + tags); $('#suggest').html('Cinderella NowPlaying:' + tags)
} else { } else {
$("#suggest").html("Cinderella NowPlaying:Not Found"); $('#suggest').html('Cinderella NowPlaying:Not Found')
} }
}); })
} }
} }

View File

@ -1,81 +1,81 @@
/*リプライ*/ /*リプライ*/
function re(id, ats_cm, acct_id, mode) { function re(id, ats_cm, acct_id, mode) {
clear(); clear()
var ats = ats_cm.split(','); var ats = ats_cm.split(',')
localStorage.setItem("nohide", true); localStorage.setItem('nohide', true)
show(); show()
$("#reply").val(id); $('#reply').val(id)
for (var i = 0; i < ats.length; i++) { for (var i = 0; i < ats.length; i++) {
var at = ats[i]; var at = ats[i]
var te = $("#textarea").val(); var te = $('#textarea').val()
if (at != localStorage.getItem("user_" + acct_id)) { if (at != localStorage.getItem('user_' + acct_id)) {
$("#textarea").val("@" + at + " " + te); $('#textarea').val('@' + at + ' ' + te)
} }
} }
$("#rec").text(lang.lang_yesno); $('#rec').text(lang.lang_yesno)
$("#post-acct-sel").val(acct_id); $('#post-acct-sel').val(acct_id)
$("#post-acct-sel").prop("disabled", true); $('#post-acct-sel').prop('disabled', true)
$('select').formSelect(); $('select').formSelect()
mdCheck() mdCheck()
$("#textarea").attr("placeholder", lang.lang_usetxtbox_reply); $('#textarea').attr('placeholder', lang.lang_usetxtbox_reply)
$("#textarea").focus(); $('#textarea').focus()
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)
vis(mode); vis(mode)
} }
function reEx(id) { function reEx(id) {
$('#tootmodal').modal('close'); $('#tootmodal').modal('close')
var at = $("#tootmodal").attr("data-user"); var at = $('#tootmodal').attr('data-user')
var acct_id = $("#status-acct-sel").val(); var acct_id = $('#status-acct-sel').val()
var mode = $("#tootmodal .vis-data").attr("data-vis"); var mode = $('#tootmodal .vis-data').attr('data-vis')
re(id, at, acct_id, mode); re(id, at, acct_id, mode)
} }
//引用 //引用
function qt(id, acct_id, at, url) { function qt(id, acct_id, at, url) {
localStorage.setItem("nohide", true); localStorage.setItem('nohide', true)
var qt = localStorage.getItem("quote"); var qt = localStorage.getItem('quote')
if (!qt) { if (!qt) {
var qt = "simple"; var qt = 'simple'
} }
if (qt == "nothing") { if (qt == 'nothing') {
return false; return false
} }
if (qt == "simple") { if (qt == 'simple') {
show(); show()
$("#textarea").val("\n" + url); $('#textarea').val('\n' + url)
} else if (qt == "mention") { } else if (qt == 'mention') {
show(); show()
$("#textarea").val("\n" + url + " From:@" + at); $('#textarea').val('\n' + url + ' From:@' + at)
} else if (qt == "full") { } else if (qt == 'full') {
show(); show()
var html = $("[toot-id=" + id + "] .toot").html(); var html = $('[toot-id=' + id + '] .toot').html()
html = html.match(/^<p>(.+)<\/p>$/)[1]; html = html.match(/^<p>(.+)<\/p>$/)[1]
html = html.replace(/<br\s?\/?>/, "\n"); html = html.replace(/<br\s?\/?>/, '\n')
html = html.replace(/<p>/, "\n"); html = html.replace(/<p>/, '\n')
html = html.replace(/<\/p>/, "\n"); html = html.replace(/<\/p>/, '\n')
html = $.strip_tags(html); html = $.strip_tags(html)
$("#textarea").val("\n" + "@" + at + " " + html + "\n" + url); $('#textarea').val('\n' + '@' + at + ' ' + html + '\n' + url)
} else if (qt == "apiQuote") { } else if (qt == 'apiQuote') {
clear(); clear()
localStorage.setItem("nohide", true); localStorage.setItem('nohide', true)
show(); show()
$("#quote").val(id); $('#quote').val(id)
$("#post-acct-sel").val(acct_id); $('#post-acct-sel').val(acct_id)
$("#post-acct-sel").prop("disabled", true); $('#post-acct-sel').prop('disabled', true)
$('select').formSelect(); $('select').formSelect()
$("#textarea").attr("placeholder", lang.lang_usetxtbox_reply); $('#textarea').attr('placeholder', lang.lang_usetxtbox_reply)
$("#textarea").focus(); $('#textarea').focus()
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)
} }
$("#post-acct-sel").val(acct_id); $('#post-acct-sel').val(acct_id)
$('select').formSelect(); $('select').formSelect()
mdCheck() mdCheck()
$("#textarea").focus(); $('#textarea').focus()
} }

View File

@ -4,292 +4,349 @@ function additional(acct_id, tlid) {
//メンション系 //メンション系
//$(".mention").attr("href", ""); //$(".mention").attr("href", "");
$("#timeline-container .mention").addClass("parsed"); $('#timeline-container .mention').addClass('parsed')
$("#timeline-container .hashtag, #timeline-container [rel=tag]").each(function(i, elem) { $('#timeline-container .hashtag, #timeline-container [rel=tag]').each(function(i, elem) {
var tags = $(this) var tags = $(this)
.attr("href") .attr('href')
.match(/https?:\/\/([-a-zA-Z0-9@.]+)\/tags\/([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/); .match(/https?:\/\/([-a-zA-Z0-9@.]+)\/tags\/([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/)
if (tags) { if (tags) {
var tagThis = tags[2]; var tagThis = tags[2]
} else { } else {
var tagThis = $(this).attr("data-tag"); var tagThis = $(this).attr('data-tag')
} }
if (tagThis) { if (tagThis) {
$(this).attr("onclick", "tagShow('" + tagThis + "')"); $(this).attr('onclick', "tagShow('" + tagThis + "')")
$(this).attr("href", "#"); $(this).attr('href', '#')
} }
}); })
//トゥートサムネ //トゥートサムネ
$("#timeline_" + tlid + " .toot a:not(.parsed)").each(function(i, elem) { $('#timeline_' + tlid + ' .toot a:not(.parsed)').each(function(i, elem) {
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 card = localStorage.getItem("card_" + tlid); var card = localStorage.getItem('card_' + tlid)
var text = $(this).attr("href"); var text = $(this).attr('href')
if (text) { if (text) {
if (text.indexOf("twimg.com") === -1) { if (text.indexOf('twimg.com') === -1) {
var urls = text.match(/https?:\/\/([-a-zA-Z0-9@.]+)\/media\/([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/); var urls = text.match(
/https?:\/\/([-a-zA-Z0-9@.]+)\/media\/([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/
)
} }
} else { } else {
text = ""; text = ''
var urls = []; var urls = []
} }
//トゥートのURLぽかったら //トゥートのURLぽかったら
toot = text.match(/https:\/\/([a-zA-Z0-9.-]+)\/@([a-zA-Z0-9_]+)\/([0-9]+)/); toot = text.match(/https:\/\/([a-zA-Z0-9.-]+)\/@([a-zA-Z0-9_]+)\/([0-9]+)/)
if (toot) { if (toot) {
if (toot[1]) { if (toot[1]) {
$(this).attr("data-acct", acct_id); $(this).attr('data-acct', acct_id)
} }
} }
if (urls) { if (urls) {
$(this).remove(); $(this).remove()
} else if (!card) { } else if (!card) {
var id = $(this) var id = $(this)
.parents(".cvo") .parents('.cvo')
.attr("toot-id"); .attr('toot-id')
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem('mode_' + domain) == 'misskey') {
var start = "https://" + domain + "/url?url=" + text; var start = 'https://' + domain + '/url?url=' + text
fetch(start, { fetch(start, {
method: "GET", method: 'GET',
headers: { headers: {
"content-type": "application/json" 'content-type': 'application/json'
} }
//body: JSON.stringify({}) //body: JSON.stringify({})
}) })
.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.title) { if (json.title) {
$("[toot-id=" + id + "] .additional").html('<span class="gray">URL' + lang.lang_cards_check + ":<br>Title:" + escapeHTML(json.title) + "<br>" + escapeHTML(json.description) + "</span>"); $('[toot-id=' + id + '] .additional').html(
$("[toot-id=" + id + "] a:not(.parsed)").addClass("parsed"); '<span class="gray">URL' +
$("[toot-id=" + id + "]").addClass("parsed"); lang.lang_cards_check +
':<br>Title:' +
escapeHTML(json.title) +
'<br>' +
escapeHTML(json.description) +
'</span>'
)
$('[toot-id=' + id + '] a:not(.parsed)').addClass('parsed')
$('[toot-id=' + id + ']').addClass('parsed')
} }
}); })
} }
} else { } else {
$(this).attr("title", text); $(this).attr('title', text)
} }
}); })
$("i.unparsed").each(function(i, elem) { $('i.unparsed').each(function(i, elem) {
var dem = $(this).text(); var dem = $(this).text()
var dom = $(this); var dom = $(this)
var start = "./js/emoji/emoji-map.json"; var start = './js/emoji/emoji-map.json'
var xmlHttpRequest = new XMLHttpRequest(); var xmlHttpRequest = new XMLHttpRequest()
xmlHttpRequest.onreadystatechange = function() { xmlHttpRequest.onreadystatechange = function() {
if (this.readyState === 4 && this.status === 200) { if (this.readyState === 4 && this.status === 200) {
if (this.response) { if (this.response) {
var json = this.response; var json = this.response
if (this.status !== 200) { if (this.status !== 200) {
setLog(start, this.status, this.response); setLog(start, this.status, this.response)
} }
var emojis = json.emojis; var emojis = json.emojis
for (i = 0; i < emojis.length; i++) { for (i = 0; i < emojis.length; i++) {
var emojie = emojis[i]; var emojie = emojis[i]
var regExp = new RegExp(dem, "g"); var regExp = new RegExp(dem, 'g')
if (emojie.emoji.match(regExp)) { if (emojie.emoji.match(regExp)) {
var sc = emojie.name; var sc = emojie.name
var sc = "twa-" + sc.replace(/_/g, "-"); var sc = 'twa-' + sc.replace(/_/g, '-')
dom.addClass(sc); dom.addClass(sc)
dom.text(""); dom.text('')
dom.removeClass("unparsed"); dom.removeClass('unparsed')
break; break
} }
} }
} }
} }
}; }
xmlHttpRequest.open("GET", start, true); xmlHttpRequest.open('GET', start, true)
xmlHttpRequest.responseType = "json"; xmlHttpRequest.responseType = 'json'
xmlHttpRequest.send(null); xmlHttpRequest.send(null)
}); })
$("#timeline_" + tlid + " .toot:not(:has(a:not(.add-show,.parsed)))").each(function(i, elem) { $('#timeline_' + tlid + ' .toot:not(:has(a:not(.add-show,.parsed)))').each(function(i, elem) {
$(this) $(this)
.parent() .parent()
.find(".add-show") .find('.add-show')
.hide(); .hide()
}); })
//Markdownイメージビューワー //Markdownイメージビューワー
$("#timeline_" + tlid + " .toot a:not(.img-parsed):has(img)").each(function(i, elem) { $('#timeline_' + tlid + ' .toot a:not(.img-parsed):has(img)').each(function(i, elem) {
var ilink = $(this).attr("href"); var ilink = $(this).attr('href')
var id = $(this) var id = $(this)
.parents(".cvo") .parents('.cvo')
.attr("toot-id"); .attr('toot-id')
$(this).attr("href", "#"); $(this).attr('href', '#')
$(this).attr("onclick", "imgv('" + id + "','" + i + "')"); $(this).attr('onclick', "imgv('" + id + "','" + i + "')")
$(this).attr("data-type", "image"); $(this).attr('data-type', 'image')
$(this).attr("id", id + "-image-" + i); $(this).attr('id', id + '-image-' + i)
$(this).attr("data-url", ilink); $(this).attr('data-url', ilink)
$(this).addClass("img-parsed"); $(this).addClass('img-parsed')
}); })
} }
function additionalIndv(tlid, acct_id, id) { function additionalIndv(tlid, acct_id, id) {
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 text = $("[toot-id=" + id + "] .toot a").attr("href"); var text = $('[toot-id=' + id + '] .toot a').attr('href')
var urls = text.match(/https?:\/\/([-a-zA-Z0-9@.]+)\/media\/([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/); var urls = text.match(
/https?:\/\/([-a-zA-Z0-9@.]+)\/media\/([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/
)
if (urls) { if (urls) {
$("[toot-id=" + id + "] .toot a").remove(); $('[toot-id=' + id + '] .toot a').remove()
} else { } else {
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem('mode_' + domain) == 'misskey') {
var start = "https://" + domain + "/url?url=" + text; var start = 'https://' + domain + '/url?url=' + text
fetch(start, { fetch(start, {
method: "GET", method: 'GET',
headers: { headers: {
"content-type": "application/json" 'content-type': 'application/json'
} }
//body: JSON.stringify({}) //body: JSON.stringify({})
}) })
.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.title) { if (json.title) {
$("[toot-id=" + id + "] .additional").html('<span class="gray">URL' + lang.lang_cards_check + ":<br>Title:" + escapeHTML(json.title) + "<br>" + escapeHTML(json.description) + "</span>"); $('[toot-id=' + id + '] .additional').html(
$("[toot-id=" + id + "] a:not(.parsed)").addClass("parsed"); `<span class="gray">URL${lang.lang_cards_check}:<br>Title:${escapeHTML(
$("[toot-id=" + id + "]").addClass("parsed"); json.title
)}<br>${escapeHTML(json.description)}</span>`
)
$('[toot-id=' + id + '] a:not(.parsed)').addClass('parsed')
$('[toot-id=' + id + ']').addClass('parsed')
} }
}); })
} else { } else {
var id = $("[toot-id=" + id + "] .toot a") var id = $('[toot-id=' + id + '] .toot a')
.parents(".cvo") .parents('.cvo')
.attr("toot-id"); .attr('toot-id')
var start = "https://" + domain + "/api/v1/statuses/" + id; var start = 'https://' + domain + '/api/v1/statuses/' + id
fetch(start, { fetch(start, {
method: "GET", method: 'GET',
headers: { headers: {
"content-type": "application/json", 'content-type': 'application/json',
Authorization: "Bearer " + at Authorization: 'Bearer ' + at
} }
//body: JSON.stringify({}) //body: JSON.stringify({})
}) })
.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) {
json = json.card; json = json.card
//このリンク鳥やんけ、ってとき //このリンク鳥やんけ、ってとき
if (json.provider_name == "Twitter") { if (json.provider_name == 'Twitter') {
if (json.image) { if (json.image) {
var twiImg = '<br><img src="' + json.image + '" style="max-width:100%" onclick="imgv(\'twi_' + id + "', 0, 'twitter');\" id=\"twi_" + id + '-image-0" data-url="' + json.image + '" data-type="image">'; var twiImg = `
<br><img src="${json.image}" style="max-width:100%"
onclick="imgv('twi_${id}',0,'twitter')" id="twi_${id}-image-0"
data-url="${json.image}"
data-type="image">
`
} else { } else {
var twiImg = ""; var twiImg = ''
} }
$("[toot-id=" + id + "] .additional").html('<div class="twitter-tweet"><b>' + escapeHTML(json.author_name) + "</b><br>" + escapeHTML(json.description) + twiImg + "</div>"); $('[toot-id=' + id + '] .additional').html(`
} else if (json.provider_name == "pixiv") { <div class="twitter-tweet"><b>
${escapeHTML(json.author_name)}
</b><br>
${escapeHTML(json.description)}
${twiImg}
</div>
`)
} else if (json.provider_name == 'pixiv') {
if (json.image) { if (json.image) {
var pxvImg = '<br><img src="' + json.image + '" style="max-width:100%" onclick="imgv(\'pixiv_' + id + "', 0, 'pixiv');\" id=\"pixiv_" + id + '-image-0" data-url="' + json.embed_url + '" data-type="image">'; var pxvImg = `
<br><img src="${json.image}" style="max-width:100%"
onclick="imgv('pixiv_${id}',0,'pixiv')" id="pixiv_${id}-image-0"
data-url="${json.embed_url}"
data-type="image">
`
} else { } else {
var pxvImg = ""; var pxvImg = ''
} }
$("[toot-id=" + id + "] .additional").html('<div class="pixiv-post"><b><a href="' + json.author_url + '" target="_blank">' + escapeHTML(json.author_name) + "</a></b><br>" + escapeHTML(json.title) + pxvImg + "</div>"); $('[toot-id=' + id + '] .additional').html(
`<div class="pixiv-post"><b><a href="
${json.author_url}
" target="_blank">
${escapeHTML(json.author_name)}
</a></b><br>
${escapeHTML(json.title)}
${pxvImg}
</div>`
)
} else { } else {
if (json.title) { if (json.title) {
$("[toot-id=" + id + "] .additional").html('<span class="gray">URL' + lang.lang_cards_check + ":<br>Title:" + escapeHTML(json.title) + "<br>" + escapeHTML(json.description) + "</span>"); $('[toot-id=' + id + '] .additional').html(
`<span class="gray">URL
${lang.lang_cards_check}
:<br>Title:
${escapeHTML(json.title)}
<br>
${escapeHTML(json.description)}
</span>`
)
} }
if (json.html) { if (json.html) {
$("[toot-id=" + id + "] .additional").html(json.html + '<i class="material-icons sml pointer" onclick="pip(\'' + id + '\')" title="' + lang.lang_cards_pip + '">picture_in_picture_alt</i>'); $('[toot-id=' + id + '] .additional').html(
json.html +
`<i class="material-icons sml pointer" onclick="pip('
${id}
')" title="
${lang.lang_cards_pip}
">picture_in_picture_alt</i>`
)
} }
} }
if (json.title) { if (json.title) {
$("[toot-id=" + id + "] a:not(.parsed)").addClass("parsed"); $('[toot-id=' + id + '] a:not(.parsed)').addClass('parsed')
$("[toot-id=" + id + "]").addClass("parsed"); $('[toot-id=' + id + ']').addClass('parsed')
} }
}); })
} }
} }
} }
//各TL上方のLink[On/Off] //各TL上方のLink[On/Off]
function cardToggle(tlid) { function cardToggle(tlid) {
var card = localStorage.getItem("card_" + tlid); var card = localStorage.getItem('card_' + tlid)
if (!card) { if (!card) {
localStorage.setItem("card_" + tlid, "true"); localStorage.setItem('card_' + tlid, 'true')
$("#sta-card-" + tlid).text("Off"); $('#sta-card-' + tlid).text('Off')
$("#sta-card-" + tlid).css("color", "red"); $('#sta-card-' + tlid).css('color', 'red')
} else { } else {
localStorage.removeItem("card_" + tlid); localStorage.removeItem('card_' + tlid)
$("#sta-card-" + tlid).text("On"); $('#sta-card-' + tlid).text('On')
$("#sta-card-" + tlid).css("color", "#009688"); $('#sta-card-' + tlid).css('color', '#009688')
} }
} }
//各TL上方のLink[On/Off]をチェック //各TL上方のLink[On/Off]をチェック
function cardCheck(tlid) { function cardCheck(tlid) {
var card = localStorage.getItem("card_" + tlid); var card = localStorage.getItem('card_' + tlid)
if (!card) { if (!card) {
$("#sta-card-" + tlid).text("On"); $('#sta-card-' + tlid).text('On')
$("#sta-card-" + tlid).css("color", "#009688"); $('#sta-card-' + tlid).css('color', '#009688')
} else { } else {
$("#sta-card-" + tlid).text("Off"); $('#sta-card-' + tlid).text('Off')
$("#sta-card-" + tlid).css("color", "red"); $('#sta-card-' + tlid).css('color', 'red')
} }
} }
function mov(id, tlid, type) { function mov(id, tlid, type) {
var click = false; var click = false
if (tlid == "notf") { if (tlid == 'notf') {
var tlide = "[data-notf=" + acct_id + "]"; var tlide = '[data-notf=' + acct_id + ']'
} else if (tlid == "user") { } else if (tlid == 'user') {
var tlide = "#his-data"; var tlide = '#his-data'
} else { } else {
var tlide = "[tlid=" + tlid + "]"; var tlide = '[tlid=' + tlid + ']'
} }
var mouseover = localStorage.getItem("mouseover"); var mouseover = localStorage.getItem('mouseover')
if (!mouseover) { if (!mouseover) {
mouseover = ""; mouseover = ''
} }
if (mouseover == "yes") { if (mouseover == 'yes') {
mouseover = "hide"; mouseover = 'hide'
} else if (mouseover == "click") { } else if (mouseover == 'click') {
if (type == "mv") { if (type == 'mv') {
mouseover = ""; mouseover = ''
} else { } else {
mouseover = "hide"; mouseover = 'hide'
} }
click = true; click = true
} else if (mouseover == "no") { } else if (mouseover == 'no') {
mouseover = ""; mouseover = ''
} }
if (mouseover == "hide") { if (mouseover == 'hide') {
if (click) { if (click) {
$(tlide + " [toot-id=" + id + "]").toggleClass("hide-actions"); $(tlide + ' [toot-id=' + id + ']').toggleClass('hide-actions')
} else { } else {
$(tlide + " [toot-id=" + id + "]").removeClass("hide-actions"); $(tlide + ' [toot-id=' + id + ']').removeClass('hide-actions')
} }
//$(tlide + " [toot-id=" + id + "] .area-vis").toggleClass("hide") //$(tlide + " [toot-id=" + id + "] .area-vis").toggleClass("hide")
@ -299,18 +356,18 @@ function mov(id, tlid, type) {
} }
function resetmv(type) { function resetmv(type) {
var mouseover = localStorage.getItem("mouseover"); var mouseover = localStorage.getItem('mouseover')
if (!mouseover) { if (!mouseover) {
mouseover = ""; mouseover = ''
} else if (mouseover == "yes") { } else if (mouseover == 'yes') {
mouseover = "hide"; mouseover = 'hide'
} else if (mouseover == "no") { } else if (mouseover == 'no') {
mouseover = ""; mouseover = ''
} else if (mouseover == "click" && type != "mv") { } else if (mouseover == 'click' && type != 'mv') {
mouseover = "hide"; mouseover = 'hide'
} }
if (mouseover == "hide") { if (mouseover == 'hide') {
$(".cvo").addClass("hide-actions"); $('.cvo').addClass('hide-actions')
//$(".area-vis").addClass("hide"); //$(".area-vis").addClass("hide");
//$(".area-actions").addClass("hide"); //$(".area-actions").addClass("hide");
//$(".area-side").addClass("hide"); //$(".area-side").addClass("hide");

File diff suppressed because it is too large Load Diff

View File

@ -1,200 +1,212 @@
/*メディアフィルター機能*/ /*メディアフィルター機能*/
//各TL上方のMedia[On/Off] //各TL上方のMedia[On/Off]
function mediaToggle(tlid) { function mediaToggle(tlid) {
var media = localStorage.getItem("media_" + tlid); var media = localStorage.getItem('media_' + tlid)
if (media) { if (media) {
localStorage.removeItem("media_" + tlid); localStorage.removeItem('media_' + tlid)
$("#sta-media-" + tlid).text("Off"); $('#sta-media-' + tlid).text('Off')
$("#sta-media-" + tlid).css("color", "red"); $('#sta-media-' + tlid).css('color', 'red')
$("#timeline_" + tlid).removeClass("media-filter"); $('#timeline_' + tlid).removeClass('media-filter')
} else { } else {
localStorage.setItem("media_" + tlid, "true"); localStorage.setItem('media_' + tlid, 'true')
$("#sta-media-" + tlid).text("On"); $('#sta-media-' + tlid).text('On')
$("#sta-media-" + tlid).css("color", "#009688"); $('#sta-media-' + tlid).css('color', '#009688')
$("#timeline_" + tlid).addClass("media-filter"); $('#timeline_' + tlid).addClass('media-filter')
} }
} }
//各TL上方のBT[BTOnly/BTExc/Off] //各TL上方のBT[BTOnly/BTExc/Off]
function ebtToggle(tlid) { function ebtToggle(tlid) {
var ebt = localStorage.getItem("ebt_" + tlid); var ebt = localStorage.getItem('ebt_' + tlid)
if (ebt == "true") { if (ebt == 'true') {
localStorage.setItem("ebt_" + tlid, "but"); localStorage.setItem('ebt_' + tlid, 'but')
$("#sta-bt-" + tlid).text("BT Only"); $('#sta-bt-' + tlid).text('BT Only')
$("#sta-bt-" + tlid).css("color", "#ff9800"); $('#sta-bt-' + tlid).css('color', '#ff9800')
$("#timeline_" + tlid).addClass("except-bt-filter"); $('#timeline_' + tlid).addClass('except-bt-filter')
$("#timeline_" + tlid).removeClass("bt-filter"); $('#timeline_' + tlid).removeClass('bt-filter')
} else if (ebt == "but") { } else if (ebt == 'but') {
localStorage.removeItem("ebt_" + tlid); localStorage.removeItem('ebt_' + tlid)
$("#sta-bt-" + tlid).text("Off"); $('#sta-bt-' + tlid).text('Off')
$("#sta-bt-" + tlid).css("color", "red"); $('#sta-bt-' + tlid).css('color', 'red')
$("#timeline_" + tlid).removeClass("bt-filter"); $('#timeline_' + tlid).removeClass('bt-filter')
$("#timeline_" + tlid).removeClass("except-bt-filter"); $('#timeline_' + tlid).removeClass('except-bt-filter')
} else { } else {
localStorage.setItem("ebt_" + tlid, "true"); localStorage.setItem('ebt_' + tlid, 'true')
$("#sta-bt-" + tlid).text("BT Ex"); $('#sta-bt-' + tlid).text('BT Ex')
$("#sta-bt-" + tlid).css("color", "#009688"); $('#sta-bt-' + tlid).css('color', '#009688')
$("#timeline_" + tlid).addClass("bt-filter"); $('#timeline_' + tlid).addClass('bt-filter')
$("#timeline_" + tlid).removeClass("except-bt-filter"); $('#timeline_' + tlid).removeClass('except-bt-filter')
} }
} }
//各TL上方のMedia[On/Off]をチェック //各TL上方のMedia[On/Off]をチェック
function mediaCheck(tlid) { function mediaCheck(tlid) {
var media = localStorage.getItem("media_" + tlid); var media = localStorage.getItem('media_' + tlid)
if (media) { if (media) {
$("#sta-media-" + tlid).text("On"); $('#sta-media-' + tlid).text('On')
$("#sta-media-" + tlid).css("color", "#009688"); $('#sta-media-' + tlid).css('color', '#009688')
$("#timeline_" + tlid).addClass("media-filter"); $('#timeline_' + tlid).addClass('media-filter')
} else { } else {
$("#sta-media-" + tlid).text("Off"); $('#sta-media-' + tlid).text('Off')
$("#sta-media-" + tlid).css("color", "red"); $('#sta-media-' + tlid).css('color', 'red')
$("#timeline_" + tlid).removeClass("media-filter"); $('#timeline_' + tlid).removeClass('media-filter')
} }
} }
//各TL上方のBT[On/Off]をチェック //各TL上方のBT[On/Off]をチェック
function ebtCheck(tlid) { function ebtCheck(tlid) {
var ebt = localStorage.getItem("ebt_" + tlid); var ebt = localStorage.getItem('ebt_' + tlid)
if (ebt == "true") { if (ebt == 'true') {
$("#sta-bt-" + tlid).text("BT Ex"); $('#sta-bt-' + tlid).text('BT Ex')
$("#sta-bt-" + tlid).css("color", "#009688"); $('#sta-bt-' + tlid).css('color', '#009688')
$("#timeline_" + tlid).addClass("bt-filter"); $('#timeline_' + tlid).addClass('bt-filter')
$("#timeline_" + tlid).removeClass("except-bt-filter"); $('#timeline_' + tlid).removeClass('except-bt-filter')
} else if (ebt == "but") { } else if (ebt == 'but') {
$("#sta-bt-" + tlid).text("BT Only"); $('#sta-bt-' + tlid).text('BT Only')
$("#sta-bt-" + tlid).css("color", "#ff9800"); $('#sta-bt-' + tlid).css('color', '#ff9800')
$("#timeline_" + tlid).addClass("except-bt-filter"); $('#timeline_' + tlid).addClass('except-bt-filter')
$("#timeline_" + tlid).removeClass("bt-filter"); $('#timeline_' + tlid).removeClass('bt-filter')
} else { } else {
$("#sta-bt-" + tlid).text("Off"); $('#sta-bt-' + tlid).text('Off')
$("#sta-bt-" + tlid).css("color", "red"); $('#sta-bt-' + tlid).css('color', 'red')
$("#timeline_" + tlid).removeClass("bt-filter"); $('#timeline_' + tlid).removeClass('bt-filter')
$("#timeline_" + tlid).removeClass("except-bt-filter"); $('#timeline_' + tlid).removeClass('except-bt-filter')
} }
} }
/* 削除追跡*/ /* 削除追跡*/
function catchToggle(tlid) { function catchToggle(tlid) {
var catchck = localStorage.getItem("catch_" + tlid); var catchck = localStorage.getItem('catch_' + tlid)
if (catchck) { if (catchck) {
localStorage.removeItem("catch_" + tlid); localStorage.removeItem('catch_' + tlid)
$("#sta-del-" + tlid).text("Off"); $('#sta-del-' + tlid).text('Off')
$("#sta-del-" + tlid).css("color", "red"); $('#sta-del-' + tlid).css('color', 'red')
parseColumn(tlid); parseColumn(tlid)
} else { } else {
localStorage.setItem("catch_" + tlid, "true"); localStorage.setItem('catch_' + tlid, 'true')
$("#sta-del-" + tlid).text("On"); $('#sta-del-' + tlid).text('On')
$("#sta-del-" + tlid).css("color", "#009688"); $('#sta-del-' + tlid).css('color', '#009688')
parseColumn(tlid); parseColumn(tlid)
} }
} }
function catchCheck(tlid) { function catchCheck(tlid) {
var catchck = localStorage.getItem("catch_" + tlid); var catchck = localStorage.getItem('catch_' + tlid)
if (catchck) { if (catchck) {
$("#sta-del-" + tlid).text("On"); $('#sta-del-' + tlid).text('On')
$("#sta-del-" + tlid).css("color", "#009688"); $('#sta-del-' + tlid).css('color', '#009688')
} else { } else {
$("#sta-del-" + tlid).text("Off"); $('#sta-del-' + tlid).text('Off')
$("#sta-del-" + tlid).css("color", "red"); $('#sta-del-' + tlid).css('color', 'red')
} }
} }
function delreset(tlid) { function delreset(tlid) {
$("[tlid=" + tlid + "] .by_delcatch").hide(); $('[tlid=' + tlid + '] .by_delcatch').hide()
$("[tlid=" + tlid + "] .by_delcatch").remove(); $('[tlid=' + tlid + '] .by_delcatch').remove()
} }
/*ワードフィルター機能*/ /*ワードフィルター機能*/
function filterMenu() { function filterMenu() {
$("#left-menu div").removeClass("active"); $('#left-menu div').removeClass('active')
$("#filterMenu").addClass("active"); $('#filterMenu').addClass('active')
$(".menu-content").addClass("hide"); $('.menu-content').addClass('hide')
$("#filter-box").removeClass("hide"); $('#filter-box').removeClass('hide')
} }
function filter() { function filter() {
$("#filtered-words").html(""); $('#filtered-words').html('')
$("#filter-edit-id").val(""); $('#filter-edit-id').val('')
var acct_id = $("#filter-acct-sel").val(); var acct_id = $('#filter-acct-sel').val()
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/filters"; var start = 'https://' + domain + '/api/v1/filters'
fetch(start, { fetch(start, {
method: "GET", method: 'GET',
headers: { headers: {
"content-type": "application/json", 'content-type': 'application/json',
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) { if (json) {
var filters = ""; var filters = ''
Object.keys(json).forEach(function(key) { Object.keys(json).forEach(function(key) {
var filterword = json[key]; var filterword = json[key]
var context = filterword.context.join(","); var context = filterword.context.join(',')
filters = filters + escapeHTML(filterword.phrase) + '<span class="sml">(for ' + context + ")</span>:<a onclick=\"filterEdit('" + filterword.id + "','" + acct_id + '\')" class="pointer">' + lang.lang_edit + '</a>/<a onclick="filterDel(' + filterword.id + "," + acct_id + ')" class="pointer">' + lang.lang_del + "</a><br> "; filters =
}); filters +
if (filters == "") { escapeHTML(filterword.phrase) +
filters = lang.lang_filter_nodata + "<br>"; `<span class="sml">(for ${context})</span>:
<a onclick="filterEdit('${filterword.id}','${acct_id}')" class="pointer">
${lang.lang_edit}
</a>/
<a onclick="filterDel('${filterword.id}','${acct_id}')" class="pointer">' +
${lang.lang_del}'
</a><br> `
})
if (filters == '') {
filters = lang.lang_filter_nodata + '<br>'
} }
$("#filtered-words").html(filters); $('#filtered-words').html(filters)
} else { } else {
$("#filtered-words").html(lang_filter_nodata); $('#filtered-words').html(lang_filter_nodata)
} }
}); })
} }
function filterTime(day, hour, min) { function filterTime(day, hour, min) {
$("#days_filter").val(day); $('#days_filter').val(day)
$("#hours_filter").val(hour); $('#hours_filter').val(hour)
$("#mins_filter").val(min); $('#mins_filter').val(min)
} }
function makeNewFilter() { function makeNewFilter() {
var acct_id = $("#filter-acct-sel").val(); var acct_id = $('#filter-acct-sel').val()
var phr = $("#filter-add-word").val(); var phr = $('#filter-add-word').val()
var cont = []; var cont = []
if ($("#home_filter:checked").val()) { if ($('#home_filter:checked').val()) {
cont.push("home"); cont.push('home')
} }
if ($("#local_filter:checked").val()) { if ($('#local_filter:checked').val()) {
cont.push("public"); cont.push('public')
} }
if ($("#notf_filter:checked").val()) { if ($('#notf_filter:checked').val()) {
cont.push("notifications"); cont.push('notifications')
} }
if ($("#conv_filter:checked").val()) { if ($('#conv_filter:checked').val()) {
cont.push("thread"); cont.push('thread')
} }
if (!cont.length) { if (!cont.length) {
$("#filtered-words").html("Error:" + lang.lang_filter_errordegree); $('#filtered-words').html('Error:' + lang.lang_filter_errordegree)
} }
var exc = $("#except_filter:checked").val(); var exc = $('#except_filter:checked').val()
var who = $("#wholeword_filter:checked").val(); var who = $('#wholeword_filter:checked').val()
if (!who) { if (!who) {
who = false; who = false
} }
var time = $("#days_filter").val() * 24 * 60 * 60 + $("#hours_filter").val() * 60 * 60 + $("#mins_filter").val() * 60; var time =
var domain = localStorage.getItem("domain_" + acct_id); $('#days_filter').val() * 24 * 60 * 60 +
var at = localStorage.getItem("acct_" + acct_id + "_at"); $('#hours_filter').val() * 60 * 60 +
if ($("#filter-edit-id").val()) { $('#mins_filter').val() * 60
var start = "https://" + domain + "/api/v1/filters/" + $("#filter-edit-id").val(); var domain = localStorage.getItem('domain_' + acct_id)
var method = "PUT"; var at = localStorage.getItem('acct_' + acct_id + '_at')
if ($('#filter-edit-id').val()) {
var start = 'https://' + domain + '/api/v1/filters/' + $('#filter-edit-id').val()
var method = 'PUT'
} else { } else {
var start = "https://" + domain + "/api/v1/filters"; var start = 'https://' + domain + '/api/v1/filters'
var method = "POST"; var method = 'POST'
} }
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest()
httpreq.open(method, start, true); httpreq.open(method, 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( httpreq.send(
JSON.stringify({ JSON.stringify({
phrase: phr, phrase: phr,
@ -203,220 +215,220 @@ function makeNewFilter() {
whole_word: who, whole_word: who,
expires_in: time expires_in: time
}) })
); )
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) { if (this.status !== 200) {
setLog(start, this.status, this.response); setLog(start, this.status, this.response)
}
filter()
filterUpdate(acct_id)
$('#filter-add-word').val('')
$('#home_filter').prop('checked', false)
$('#local_filter').prop('checked', false)
$('#notf_filter').prop('checked', false)
$('#conv_filter').prop('checked', false)
$('#except_filter').prop('checked', false)
$('#wholeword_filter').prop('checked', false)
$('#days_filter').val('0')
$('#hours_filter').val('0')
$('#mins_filter').val('0')
$('#add-filter-btn').text(lang.lang_add)
$('#filter-edit-id').val('')
} }
filter();
filterUpdate(acct_id);
$("#filter-add-word").val("");
$("#home_filter").prop("checked", false);
$("#local_filter").prop("checked", false);
$("#notf_filter").prop("checked", false);
$("#conv_filter").prop("checked", false);
$("#except_filter").prop("checked", false);
$("#wholeword_filter").prop("checked", false);
$("#days_filter").val("0");
$("#hours_filter").val("0");
$("#mins_filter").val("0");
$("#add-filter-btn").text(lang.lang_add);
$("#filter-edit-id").val("");
} }
};
} }
function filterEdit(id, acct_id) { function filterEdit(id, acct_id) {
$("#filter-add-word").val(""); $('#filter-add-word').val('')
$("#home_filter").prop("checked", false); $('#home_filter').prop('checked', false)
$("#local_filter").prop("checked", false); $('#local_filter').prop('checked', false)
$("#notf_filter").prop("checked", false); $('#notf_filter').prop('checked', false)
$("#conv_filter").prop("checked", false); $('#conv_filter').prop('checked', false)
$("#except_filter").prop("checked", false); $('#except_filter').prop('checked', false)
$("#wholeword_filter").prop("checked", false); $('#wholeword_filter').prop('checked', false)
$("#days_filter").val("0"); $('#days_filter').val('0')
$("#hours_filter").val("0"); $('#hours_filter').val('0')
$("#mins_filter").val("0"); $('#mins_filter').val('0')
$("#add-filter-btn").text(lang.lang_edit); $('#add-filter-btn').text(lang.lang_edit)
$("#filter-edit-id").val(id); $('#filter-edit-id').val(id)
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/filters/" + id; var start = 'https://' + domain + '/api/v1/filters/' + id
fetch(start, { fetch(start, {
method: "GET", method: 'GET',
headers: { headers: {
"content-type": "application/json", 'content-type': 'application/json',
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) { if (json) {
var now = new Date(); var now = new Date()
now = now.getTime(); now = now.getTime()
var now = Math.floor(now / 1000); var now = Math.floor(now / 1000)
$("#filter-add-word").val(json.phrase); $('#filter-add-word').val(json.phrase)
Object.keys(json.context).forEach(function(key) { Object.keys(json.context).forEach(function(key) {
var context = json.context[key]; var context = json.context[key]
$("[value=" + context + "]").prop("checked", true); $('[value=' + context + ']').prop('checked', true)
}); })
if (json.irreversible) { if (json.irreversible) {
$("#except_filter").prop("checked", true); $('#except_filter').prop('checked', true)
} }
if (json.whole_word) { if (json.whole_word) {
$("#wholeword_filter").prop("checked", true); $('#wholeword_filter').prop('checked', true)
} }
var expires = date(json.expires_at, "unix") - now; var expires = date(json.expires_at, 'unix') - now
var mins = Math.floor(expires / 60) % 60; var mins = Math.floor(expires / 60) % 60
var hours = Math.floor(expires / 3600) % 24; var hours = Math.floor(expires / 3600) % 24
var days = Math.floor(expires / 3600 / 24); var days = Math.floor(expires / 3600 / 24)
$("#days_filter").val(days); $('#days_filter').val(days)
$("#hours_filter").val(hours); $('#hours_filter').val(hours)
$("#mins_filter").val(mins); $('#mins_filter').val(mins)
} }
}); })
} }
function filterDel(id, acct_id) { function filterDel(id, acct_id) {
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/filters/" + id; var start = 'https://' + domain + '/api/v1/filters/' + id
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest()
httpreq.open("DELETE", start, true); httpreq.open('DELETE', 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(); httpreq.send()
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) { if (this.status !== 200) {
setLog(start, this.status, this.response); setLog(start, this.status, this.response)
}
filter()
filterUpdate(acct_id)
} }
filter();
filterUpdate(acct_id);
} }
};
} }
function getFilter(acct_id) { function getFilter(acct_id) {
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')
if (localStorage.getItem("mode_" + domain) != "misskey") { if (localStorage.getItem('mode_' + domain) != 'misskey') {
var start = "https://" + domain + "/api/v1/filters"; var start = 'https://' + domain + '/api/v1/filters'
fetch(start, { fetch(start, {
method: "GET", method: 'GET',
headers: { headers: {
"content-type": "application/json", 'content-type': 'application/json',
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) {
localStorage.setItem("filter_" + acct_id, JSON.stringify(json)); localStorage.setItem('filter_' + acct_id, JSON.stringify(json))
}); })
} else { } else {
localStorage.setItem("filter_" + acct_id, JSON.stringify({})); localStorage.setItem('filter_' + acct_id, JSON.stringify({}))
} }
} }
function getFilterType(json, type) { function getFilterType(json, type) {
if (!json) { if (!json) {
return []; return []
} }
if (type == "local") { if (type == 'local') {
type = "public"; type = 'public'
} else if (type == "list") { } else if (type == 'list') {
type = "home"; type = 'home'
} else if (type == "notf") { } else if (type == 'notf') {
type = "notifi"; type = 'notifi'
} }
var mutedfilters = []; var mutedfilters = []
Object.keys(json).forEach(function(key) { Object.keys(json).forEach(function(key) {
var filterword = json[key]; var filterword = json[key]
var phrases = filterword.phrase; var phrases = filterword.phrase
if (filterword.context.join(",").indexOf(type) !== -1) { if (filterword.context.join(',').indexOf(type) !== -1) {
mutedfilters.push(phrases); mutedfilters.push(phrases)
} }
}); })
return mutedfilters; return mutedfilters
} }
function filterUpdate(acct_id) { function filterUpdate(acct_id) {
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/filters"; var start = 'https://' + domain + '/api/v1/filters'
fetch(start, { fetch(start, {
method: "GET", method: 'GET',
headers: { headers: {
"content-type": "application/json", 'content-type': 'application/json',
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) {
localStorage.setItem("filter_" + acct_id, JSON.stringify(json)); localStorage.setItem('filter_' + acct_id, JSON.stringify(json))
filterUpdateInternal(json, "home"); filterUpdateInternal(json, 'home')
filterUpdateInternal(json, "local"); filterUpdateInternal(json, 'local')
filterUpdateInternal(json, "notf"); filterUpdateInternal(json, 'notf')
filterUpdateInternal(json, "pub"); filterUpdateInternal(json, 'pub')
}); })
} }
function filterUpdateInternal(json, type) { function filterUpdateInternal(json, type) {
var home = getFilterType(json, type); var home = getFilterType(json, type)
var wordmute = localStorage.getItem("word_mute"); var wordmute = localStorage.getItem('word_mute')
if (wordmute) { if (wordmute) {
var wordmute = JSON.parse(wordmute); var wordmute = JSON.parse(wordmute)
home = home.concat(wordmute); home = home.concat(wordmute)
} }
if (home) { if (home) {
$("[data-acct=" + acct_id + "] [data-type=" + type + "] .cvo").each(function(i, elem) { $('[data-acct=' + acct_id + '] [data-type=' + type + '] .cvo').each(function(i, elem) {
var id = $(elem).attr("toot-id"); var id = $(elem).attr('toot-id')
$("[toot-id=" + id + "]").removeClass("hide"); $('[toot-id=' + id + ']').removeClass('hide')
var text = $(elem) var text = $(elem)
.find(".toot") .find('.toot')
.html(); .html()
Object.keys(home).forEach(function(key8) { Object.keys(home).forEach(function(key8) {
var word = home[key8]; var word = home[key8]
var regExp = new RegExp(word.replace(/[.*+?^=!:${}()|[\]\/\\]/g, "\\$&"), "g"); var regExp = new RegExp(word.replace(/[.*+?^=!:${}()|[\]\/\\]/g, '\\$&'), 'g')
if ($.strip_tags(text).match(regExp)) { if ($.strip_tags(text).match(regExp)) {
$("[toot-id=" + id + "]").addClass("hide"); $('[toot-id=' + id + ']').addClass('hide')
} }
}); })
}); })
} }
} }
/* /*
@ -427,73 +439,73 @@ function filterUpdateInternal(json, type) {
*/ */
//通知フィルター //通知フィルター
function exclude(key) { function exclude(key) {
localStorage.setItem("exclude-" + key, ""); localStorage.setItem('exclude-' + key, '')
var excludetxt = localStorage.getItem("exclude-" + key); var excludetxt = localStorage.getItem('exclude-' + key)
if ($("#exc-reply-" + key + ":checked").val()) { if ($('#exc-reply-' + key + ':checked').val()) {
excludetxt = "?exclude_types[]=mention"; excludetxt = '?exclude_types[]=mention'
} }
if ($("#exc-fav-" + key + ":checked").val()) { if ($('#exc-fav-' + key + ':checked').val()) {
if (excludetxt || excludetxt != "") { if (excludetxt || excludetxt != '') {
excludetxt = excludetxt + "&exclude_types[]=favourite"; excludetxt = excludetxt + '&exclude_types[]=favourite'
} else { } else {
excludetxt = "?exclude_types[]=favourite"; excludetxt = '?exclude_types[]=favourite'
} }
} }
if ($("#exc-bt-" + key + ":checked").val()) { if ($('#exc-bt-' + key + ':checked').val()) {
if (excludetxt || excludetxt != "") { if (excludetxt || excludetxt != '') {
excludetxt = excludetxt + "&exclude_types[]=reblog"; excludetxt = excludetxt + '&exclude_types[]=reblog'
} else { } else {
excludetxt = "?exclude_types[]=reblog"; excludetxt = '?exclude_types[]=reblog'
} }
} }
if ($("#exc-follow-" + key + ":checked").val()) { if ($('#exc-follow-' + key + ':checked').val()) {
if (excludetxt || excludetxt != "") { if (excludetxt || excludetxt != '') {
excludetxt = excludetxt + "&exclude_types[]=follow"; excludetxt = excludetxt + '&exclude_types[]=follow'
} else { } else {
excludetxt = "?exclude_types[]=follow"; excludetxt = '?exclude_types[]=follow'
} }
} }
if ($("#exc-poll-" + key + ":checked").val()) { if ($('#exc-poll-' + key + ':checked').val()) {
if (excludetxt || excludetxt != "") { if (excludetxt || excludetxt != '') {
excludetxt = excludetxt + "&exclude_types[]=poll"; excludetxt = excludetxt + '&exclude_types[]=poll'
} else { } else {
excludetxt = "?exclude_types[]=poll"; excludetxt = '?exclude_types[]=poll'
} }
} else { } else {
} }
localStorage.setItem("exclude-" + key, excludetxt); localStorage.setItem('exclude-' + key, excludetxt)
parseColumn(key); parseColumn(key)
} }
function excludeCk(key, target) { function excludeCk(key, target) {
var exc = localStorage.getItem("exclude-" + key); var exc = localStorage.getItem('exclude-' + key)
if (!exc) { if (!exc) {
return ""; return ''
} }
if (~exc.indexOf(target)) { if (~exc.indexOf(target)) {
return "checked"; return 'checked'
} else { } else {
return ""; return ''
} }
} }
function checkNotfFilter(tlid) { function checkNotfFilter(tlid) {
var excludetxt = localStorage.getItem("exclude-" + tlid); var excludetxt = localStorage.getItem('exclude-' + tlid)
if (!excludetxt || excludetxt != "") { if (!excludetxt || excludetxt != '') {
return true; return true
} else { } else {
return false; return false
} }
} }
function resetNotfFilter(tlid) { function resetNotfFilter(tlid) {
localStorage.setItem("exclude-" + tlid, ""); localStorage.setItem('exclude-' + tlid, '')
parseColumn(tlid); parseColumn(tlid)
} }
function notfFilter(id, tlid, acct_id) { function notfFilter(id, tlid, acct_id) {
var excludetxt = localStorage.getItem("exclude-" + tlid); var excludetxt = localStorage.getItem('exclude-' + tlid)
if (excludetxt || excludetxt != "") { if (excludetxt || excludetxt != '') {
excludetxt = excludetxt + "&account_id=" + id; excludetxt = excludetxt + '&account_id=' + id
} else { } else {
excludetxt = "?account_id=" + id; excludetxt = '?account_id=' + id
} }
localStorage.setItem("exclude-" + tlid, excludetxt); localStorage.setItem('exclude-' + tlid, excludetxt)
parseColumn(tlid); parseColumn(tlid)
} }

View File

@ -1,21 +1,21 @@
function listMenu() { function listMenu() {
$("#left-menu div").removeClass("active"); $('#left-menu div').removeClass('active')
$("#listMenu").addClass("active"); $('#listMenu').addClass('active')
$(".menu-content").addClass("hide"); $('.menu-content').addClass('hide')
$("#list-box").removeClass("hide"); $('#list-box').removeClass('hide')
$("ul.tabs").tabs("select_tab", "src-sta"); $('ul.tabs').tabs('select_tab', 'src-sta')
$("#src-contents").html(""); $('#src-contents').html('')
} }
function list() { function list() {
$("#lists-user").html(""); $('#lists-user').html('')
var acct_id = $("#list-acct-sel").val(); var acct_id = $('#list-acct-sel').val()
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')
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem('mode_' + domain) == 'misskey') {
var start = "https://" + domain + "/api/users/lists/list"; var start = 'https://' + domain + '/api/users/lists/list'
fetch(start, { fetch(start, {
method: "POST", method: 'POST',
body: JSON.stringify({ body: JSON.stringify({
i: at i: at
}) })
@ -23,231 +23,256 @@ function list() {
.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) { if (json) {
var lists = ""; var lists = ''
Object.keys(json).forEach(function(key) { Object.keys(json).forEach(function(key) {
var list = json[key]; var list = json[key]
lists = lists + escapeHTML(list.title) + ":<a onclick=\"listShow('" + list.id + "','" + escapeHTML(list.title) + "','" + acct_id + '\')" class="pointer">' + lang.lang_list_show + "</a><br>"; lists =
}); lists +
$("#lists").html(lists); escapeHTML(list.title) +
`:<a onclick="listShow('${list.id}','${escapeHTML(
list.title
)}','${acct_id}')" class="pointer">
${lang.lang_list_show}
</a><br>`
})
$('#lists').html(lists)
} else { } else {
$("#lists").html(lang.lang_list_nodata); $('#lists').html(lang.lang_list_nodata)
} }
}); })
} else { } else {
var start = "https://" + domain + "/api/v1/lists"; var start = 'https://' + domain + '/api/v1/lists'
fetch(start, { fetch(start, {
method: "GET", method: 'GET',
headers: { headers: {
"content-type": "application/json", 'content-type': 'application/json',
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) { if (json) {
var lists = ""; var lists = ''
Object.keys(json).forEach(function(key) { Object.keys(json).forEach(function(key) {
var list = json[key]; var list = json[key]
lists = lists + escapeHTML(list.title) + ":<a onclick=\"listShow('" + list.id + "','" + escapeHTML(list.title) + "','" + acct_id + '\')" class="pointer">' + lang.lang_list_show + "</a>/<a onclick=\"listUser('" + list.id + "'," + acct_id + ')" class="pointer">' + lang.lang_list_users + "</a><br>"; lists =
}); lists +
$("#lists").html(lists); escapeHTML(list.title) +
`:<a onclick="listShow('${list.id}','${escapeHTML(
list.title
)}','${acct_id}')" class="pointer">
${lang.lang_list_show}
</a>/
<a onclick="listUser('${list.id}','${acct_id}')" class="pointer">
${lang.lang_list_users}
'</a><br>`
})
$('#lists').html(lists)
} else { } else {
$("#lists").html(lang.lang_list_nodata); $('#lists').html(lang.lang_list_nodata)
} }
}); })
} }
} }
function makeNewList() { function makeNewList() {
var acct_id = $("#list-acct-sel").val(); var acct_id = $('#list-acct-sel').val()
var text = $("#list-add").val(); var text = $('#list-add').val()
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')
if (localStorage.getItem("mode_" + domain) != "misskey") { if (localStorage.getItem('mode_' + domain) != 'misskey') {
var start = "https://" + domain + "/api/v1/lists"; var start = 'https://' + domain + '/api/v1/lists'
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest()
httpreq.open("POST", start, true); httpreq.open('POST', 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( httpreq.send(
JSON.stringify({ JSON.stringify({
title: text title: text
}) })
); )
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) { if (this.status !== 200) {
setLog(start, this.status, this.response); setLog(start, this.status, this.response)
}
list()
$('#list-add').val('')
} }
list();
$("#list-add").val("");
} }
};
} else { } else {
var start = "https://" + domain + "/api/users/lists/create"; var start = 'https://' + domain + '/api/users/lists/create'
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest()
httpreq.open("POST", start, true); httpreq.open('POST', start, true)
httpreq.setRequestHeader("Content-Type", "application/json"); httpreq.setRequestHeader('Content-Type', 'application/json')
httpreq.responseType = "json"; httpreq.responseType = 'json'
httpreq.send( httpreq.send(
JSON.stringify({ JSON.stringify({
i: at, i: at,
title: text title: text
}) })
); )
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) { if (this.status !== 200) {
setLog(start, this.status, this.response); setLog(start, this.status, this.response)
}
list()
$('#list-add').val('')
} }
list();
$("#list-add").val("");
} }
};
} }
} }
function listShow(id, title, acct_id) { function listShow(id, title, acct_id) {
localStorage.setItem("list_" + id + "_" + acct_id, title); localStorage.setItem('list_' + id + '_' + acct_id, title)
tl("list", id, acct_id, "add"); tl('list', id, acct_id, 'add')
} }
function listUser(id, acct_id) { function listUser(id, acct_id) {
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/lists/" + id + "/accounts"; var start = 'https://' + domain + '/api/v1/lists/' + id + '/accounts'
fetch(start, { fetch(start, {
method: "GET", method: 'GET',
headers: { headers: {
"content-type": "application/json", 'content-type': 'application/json',
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) { if (json) {
var lists = ""; var lists = ''
var templete = userparse(json, "", acct_id); var templete = userparse(json, '', acct_id)
if (!json[0]) { if (!json[0]) {
templete = lang.lang_list_nouser; templete = lang.lang_list_nouser
} }
$("#lists-user").html(templete); $('#lists-user').html(templete)
jQuery("time.timeago").timeago(); jQuery('time.timeago').timeago()
} else { } else {
$("#lists-user").html(lang.lang_list_nouser); $('#lists-user').html(lang.lang_list_nouser)
} }
}); })
} }
function hisList(user, acct_id) { function hisList(user, acct_id) {
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')
if (localStorage.getItem("mode_" + domain) != "misskey") { if (localStorage.getItem('mode_' + domain) != 'misskey') {
var start = "https://" + domain + "/api/v1/lists"; var start = 'https://' + domain + '/api/v1/lists'
fetch(start, { fetch(start, {
method: "GET", method: 'GET',
headers: { headers: {
"content-type": "application/json", 'content-type': 'application/json',
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) { if (json) {
var lists = lang.lang_list_add + "<br>"; var lists = lang.lang_list_add + '<br>'
Object.keys(json).forEach(function(key) { Object.keys(json).forEach(function(key) {
var list = json[key]; var list = json[key]
lists = lists + "<a onclick=\"listAdd('" + list.id + "','" + user + "','" + acct_id + '\')" class="pointer">' + escapeHTML(list.title) + "</a><br> "; lists =
}); lists +
$("#his-lists-a").html(lists); `<a onclick="listAdd('${list.id}','${user}','${acct_id}')" class="pointer">
${escapeHTML(list.title)}
</a><br> `
})
$('#his-lists-a').html(lists)
} else { } else {
$("#his-lists-a").html(lang.lang_list_nodata); $('#his-lists-a').html(lang.lang_list_nodata)
} }
}); })
var start = "https://" + domain + "/api/v1/accounts/" + user + "/lists"; var start = 'https://' + domain + '/api/v1/accounts/' + user + '/lists'
fetch(start, { fetch(start, {
method: "GET", method: 'GET',
headers: { headers: {
"content-type": "application/json", 'content-type': 'application/json',
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) { if (json) {
var lists = lang.lang_list_remove + "<br>"; var lists = lang.lang_list_remove + '<br>'
Object.keys(json).forEach(function(key) { Object.keys(json).forEach(function(key) {
var list = json[key]; var list = json[key]
lists = lists + "<a onclick=\"listRemove('" + list.id + "','" + user + "','" + acct_id + '\')" class="pointer">' + escapeHTML(list.title) + "</a><br> "; lists =
}); lists +
$("#his-lists-b").html(lists); `<a onclick="listRemove('${list.id}','${user}','${acct_id}')" class="pointer">
${escapeHTML(list.title)}
</a><br> `
})
$('#his-lists-b').html(lists)
} else { } else {
$("#his-lists-b").html(lang.lang_list_nodata); $('#his-lists-b').html(lang.lang_list_nodata)
} }
}); })
} else { } else {
var start = "https://" + domain + "/api/users/lists/list"; var start = 'https://' + domain + '/api/users/lists/list'
fetch(start, { fetch(start, {
method: "POST", method: 'POST',
body: JSON.stringify({ body: JSON.stringify({
i: at i: at
}) })
@ -255,94 +280,105 @@ function hisList(user, acct_id) {
.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) { if (json) {
var lists = ""; var lists = ''
Object.keys(json).forEach(function(key) { Object.keys(json).forEach(function(key) {
var list = json[key]; var list = json[key]
lists = lists + list.title + ":<a onclick=\"listShow('" + list.id + "','" + escapeHTML(list.title) + "','" + acct_id + '\')" class="pointer">' + lang.lang_list_show + "</a>/<a onclick=\"listAdd('" + list.id + "','" + user + "','" + acct_id + '\')" class="pointer">' + lang.lang_list_add + lang.lang_list_add_misskey + "</a><br>"; lists =
}); lists +
$("#his-lists-a").html(lists); list.title +
`:<a onclick="listShow('${list.id}','${escapeHTML(
list.title
)}','${acct_id}')" class="pointer">
${lang.lang_list_show}
</a>/
<a onclick="listAdd('${list.id}','${user}','${acct_id}')" class="pointer">
${lang.lang_list_add}
${lang.lang_list_add_misskey}
'</a><br>`
})
$('#his-lists-a').html(lists)
} else { } else {
$("#his-lists-a").html(lang.lang_list_nodata); $('#his-lists-a').html(lang.lang_list_nodata)
} }
}); })
$("#his-lists-b").html(""); $('#his-lists-b').html('')
} }
} }
function listAdd(id, user, acct_id) { function listAdd(id, user, acct_id) {
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')
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem('mode_' + domain) == 'misskey') {
var start = "https://" + domain + "/api/users/lists/push"; var start = 'https://' + domain + '/api/users/lists/push'
var i = { var i = {
i: at, i: at,
listId: id, listId: id,
userId: user userId: user
}; }
} else { } else {
var start = "https://" + domain + "/api/v1/lists/" + id + "/accounts"; var start = 'https://' + domain + '/api/v1/lists/' + id + '/accounts'
var i = { var i = {
account_ids: [user] account_ids: [user]
};
} }
var httpreq = new XMLHttpRequest(); }
httpreq.open("POST", start, true); var httpreq = new XMLHttpRequest()
httpreq.setRequestHeader("Content-Type", "application/json"); httpreq.open('POST', start, true)
httpreq.setRequestHeader("Authorization", "Bearer " + at); httpreq.setRequestHeader('Content-Type', 'application/json')
httpreq.responseType = "json"; httpreq.setRequestHeader('Authorization', 'Bearer ' + at)
httpreq.send(JSON.stringify(i)); httpreq.responseType = 'json'
httpreq.send(JSON.stringify(i))
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) { if (this.status !== 200) {
setLog(start, this.status, this.response); setLog(start, this.status, this.response)
}
hisList(user, acct_id)
} }
hisList(user, acct_id);
} }
};
} }
function listRemove(id, user, acct_id) { function listRemove(id, user, acct_id) {
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')
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem('mode_' + domain) == 'misskey') {
var start = "https://" + domain + "/api/users/lists/push"; var start = 'https://' + domain + '/api/users/lists/push'
var method = "POST"; var method = 'POST'
var i = { var i = {
i: at, i: at,
listId: id, listId: id,
userId: user userId: user
}; }
} else { } else {
var start = "https://" + domain + "/api/v1/lists/" + id + "/accounts"; var start = 'https://' + domain + '/api/v1/lists/' + id + '/accounts'
var method = "DELETE"; var method = 'DELETE'
var i = { var i = {
account_ids: [user] account_ids: [user]
};
} }
var httpreq = new XMLHttpRequest(); }
httpreq.open(method, start, true); var httpreq = new XMLHttpRequest()
httpreq.setRequestHeader("Content-Type", "application/json"); httpreq.open(method, start, true)
httpreq.setRequestHeader("Authorization", "Bearer " + at); httpreq.setRequestHeader('Content-Type', 'application/json')
httpreq.responseType = "json"; httpreq.setRequestHeader('Authorization', 'Bearer ' + at)
httpreq.send(JSON.stringify(i)); httpreq.responseType = 'json'
httpreq.send(JSON.stringify(i))
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) { if (this.status !== 200) {
setLog(start, this.status, this.response); setLog(start, this.status, this.response)
}
hisList(user, acct_id)
} }
hisList(user, acct_id);
} }
};
} }

View File

@ -1,353 +1,375 @@
//Integrated TL //Integrated TL
function mixtl(acct_id, tlid, type, delc, voice) { function mixtl(acct_id, tlid, type, delc, voice) {
localStorage.removeItem("morelock"); localStorage.removeItem('morelock')
localStorage.setItem("now", type); localStorage.setItem('now', type)
todo("Integrated TL Loading...(Local)"); todo('Integrated TL Loading...(Local)')
//まずLocal //まずLocal
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/timelines/public?local=true"; var start = 'https://' + domain + '/api/v1/timelines/public?local=true'
fetch(start, { fetch(start, {
method: "GET", method: 'GET',
headers: { headers: {
"content-type": "application/json", 'content-type': 'application/json',
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(jsonL) { .then(function(jsonL) {
var start = "https://" + domain + "/api/v1/timelines/home"; var start = 'https://' + domain + '/api/v1/timelines/home'
fetch(start, { fetch(start, {
method: "GET", method: 'GET',
headers: { headers: {
"content-type": "application/json", 'content-type': 'application/json',
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(jsonH) { .then(function(jsonH) {
var homearr = []; var homearr = []
var timeline = jsonL.concat(jsonH); var timeline = jsonL.concat(jsonH)
timeline.sort(function(a, b) { timeline.sort(function(a, b) {
if (date(a.created_at, "unix") >= date(b.created_at, "unix")) return -1; if (date(a.created_at, 'unix') >= date(b.created_at, 'unix')) return -1
if (date(a.created_at, "unix") < date(b.created_at, "unix")) return 1; if (date(a.created_at, 'unix') < date(b.created_at, 'unix')) return 1
return 0; return 0
}); })
if (type == "integrated") { if (type == 'integrated') {
timeline.splice(20); timeline.splice(20)
} }
var templete = ""; var templete = ''
if (localStorage.getItem("filter_" + acct_id) != "undefined") { if (localStorage.getItem('filter_' + acct_id) != 'undefined') {
var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), "mix"); var mute = getFilterType(JSON.parse(localStorage.getItem('filter_' + acct_id)), 'mix')
} else { } else {
var mute = []; var mute = []
} }
Object.keys(timeline).forEach(function(key) { Object.keys(timeline).forEach(function(key) {
var pkey = key * 1 + 1; var pkey = key * 1 + 1
if (pkey < timeline.length) { if (pkey < timeline.length) {
if (date(timeline[key].created_at, "unix") != date(timeline[pkey].created_at, "unix")) { if (
if (type == "integrated") { date(timeline[key].created_at, 'unix') != date(timeline[pkey].created_at, 'unix')
templete = templete + parse([timeline[key]], "", acct_id, tlid, "", mute, "mix"); ) {
} else if (type == "plus") { if (type == 'integrated') {
templete = templete + parse([timeline[key]], '', acct_id, tlid, '', mute, 'mix')
} else if (type == 'plus') {
if (timeline[key].account.acct == timeline[key].account.username) { if (timeline[key].account.acct == timeline[key].account.username) {
templete = templete + parse([timeline[key]], "", acct_id, tlid, "", mute, "plus"); templete =
templete + parse([timeline[key]], '', acct_id, tlid, '', mute, 'plus')
} }
} }
} }
} }
}); })
$("#landing_" + tlid).hide(); $('#landing_' + tlid).hide()
$("#timeline_" + tlid).html(templete); $('#timeline_' + tlid).html(templete)
mixre(acct_id, tlid, type, mute, delc, voice); mixre(acct_id, tlid, type, mute, delc, voice)
additional(acct_id, tlid); additional(acct_id, tlid)
jQuery("time.timeago").timeago(); jQuery('time.timeago').timeago()
todc(); todc()
}); })
}); })
} }
//Streamingに接続 //Streamingに接続
function mixre(acct_id, tlid, TLtype, mute, delc, voice, mode) { function mixre(acct_id, tlid, TLtype, mute, delc, voice, mode) {
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')
if (localStorage.getItem("streaming_" + acct_id)) { if (localStorage.getItem('streaming_' + acct_id)) {
var wss = localStorage.getItem("streaming_" + acct_id); var wss = localStorage.getItem('streaming_' + acct_id)
} else { } else {
var wss = "wss://" + domain; var wss = 'wss://' + domain
} }
var startHome = wss + "/api/v1/streaming/?stream=user&access_token=" + at; var startHome = wss + '/api/v1/streaming/?stream=user&access_token=' + at
var startLocal = wss + "/api/v1/streaming/?stream=public:local&access_token=" + at; var startLocal = wss + '/api/v1/streaming/?stream=public:local&access_token=' + at
var wshid = websocketHome.length; var wshid = websocketHome.length
var wslid = websocketLocal.length; var wslid = websocketLocal.length
websocketHome[wshid] = new WebSocket(startHome); websocketHome[wshid] = new WebSocket(startHome)
websocketLocal[wslid] = new WebSocket(startLocal); websocketLocal[wslid] = new WebSocket(startLocal)
websocketHome[wshid].onopen = function(mess) { websocketHome[wshid].onopen = function(mess) {
localStorage.setItem("wssH_" + tlid, wshid); localStorage.setItem('wssH_' + tlid, wshid)
console.table({ tlid: tlid, type: "Connect Streaming API(Integrated:Home)", domain: domain, message: mess }); console.table({
$("#notice_icon_" + tlid).removeClass("red-text"); tlid: tlid,
}; type: 'Connect Streaming API(Integrated:Home)',
domain: domain,
message: mess
})
$('#notice_icon_' + tlid).removeClass('red-text')
}
websocketLocal[wslid].onopen = function(mess) { websocketLocal[wslid].onopen = function(mess) {
localStorage.setItem("wssL_" + tlid, wslid); localStorage.setItem('wssL_' + tlid, wslid)
console.table({ tlid: tlid, type: "Connect Streaming API(Integrated:Local)", domain: domain, message: mess }); console.table({
$("#notice_icon_" + tlid).removeClass("red-text"); tlid: tlid,
}; type: 'Connect Streaming API(Integrated:Local)',
domain: domain,
message: mess
})
$('#notice_icon_' + tlid).removeClass('red-text')
}
websocketLocal[wslid].onmessage = function(mess) { websocketLocal[wslid].onmessage = function(mess) {
console.log(["Receive Streaming API:(Integrated:Local)", obj]); console.log(['Receive Streaming API:(Integrated:Local)', obj])
var obj = JSON.parse(JSON.parse(mess.data).payload); var obj = JSON.parse(JSON.parse(mess.data).payload)
var type = JSON.parse(mess.data).event; var type = JSON.parse(mess.data).event
if (type == "delete") { if (type == 'delete') {
if (delc == "true") { if (delc == 'true') {
$("#timeline_" + tlid + " [toot-id=" + JSON.parse(mess.data).payload + "]").addClass("emphasized"); $('#timeline_' + tlid + ' [toot-id=' + JSON.parse(mess.data).payload + ']').addClass(
$("#timeline_" + tlid + " [toot-id=" + JSON.parse(mess.data).payload + "]").addClass("by_delcatch"); 'emphasized'
)
$('#timeline_' + tlid + ' [toot-id=' + JSON.parse(mess.data).payload + ']').addClass(
'by_delcatch'
)
} else { } else {
$("[toot-id=" + JSON.parse(mess.data).payload + "]").hide(); $('[toot-id=' + JSON.parse(mess.data).payload + ']').hide()
$("[toot-id=" + JSON.parse(mess.data).payload + "]").remove(); $('[toot-id=' + JSON.parse(mess.data).payload + ']').remove()
} }
} else if (type == "update") { } else if (type == 'update') {
var templete = parse([obj], "", acct_id, tlid, "", mute); var templete = parse([obj], '', acct_id, tlid, '', mute)
if ($("#timeline_" + tlid + " [toot-id=" + obj.id + "]").length < 1) { if ($('#timeline_' + tlid + ' [toot-id=' + obj.id + ']').length < 1) {
if (voice) { if (voice) {
say(obj.content); say(obj.content)
} }
var templete = parse([obj], type, acct_id, tlid, "", mute, "mix"); var templete = parse([obj], type, acct_id, tlid, '', mute, 'mix')
var pool = localStorage.getItem("pool_" + tlid); var pool = localStorage.getItem('pool_' + tlid)
if (pool) { if (pool) {
pool = templete + pool; pool = templete + pool
} else { } else {
pool = templete; pool = templete
} }
localStorage.setItem("pool_" + tlid, pool); localStorage.setItem('pool_' + tlid, pool)
scrollck(); scrollck()
additional(acct_id, tlid); additional(acct_id, tlid)
jQuery("time.timeago").timeago(); jQuery('time.timeago').timeago()
} else { } else {
todo("二重取得発生中"); todo('二重取得発生中')
}
} }
} }
};
websocketHome[wshid].onmessage = function(mess) { websocketHome[wshid].onmessage = function(mess) {
console.log(["Receive Streaming API:(Integrated:Home)", obj]); console.log(['Receive Streaming API:(Integrated:Home)', obj])
var obj = JSON.parse(JSON.parse(mess.data).payload); var obj = JSON.parse(JSON.parse(mess.data).payload)
var type = JSON.parse(mess.data).event; var type = JSON.parse(mess.data).event
if (type == "delete") { if (type == 'delete') {
if (del > 10) { if (del > 10) {
reconnector(tlid, type, acct_id, data); reconnector(tlid, type, acct_id, data)
} else { } else {
localStorage.setItem("delete", del * 1 + 1); localStorage.setItem('delete', del * 1 + 1)
} }
if (delc == "true") { if (delc == 'true') {
$("[toot-id=" + JSON.parse(mess.data).payload + "]").addClass("emphasized"); $('[toot-id=' + JSON.parse(mess.data).payload + ']').addClass('emphasized')
$("[toot-id=" + JSON.parse(mess.data).payload + "]").addClass("by_delcatch"); $('[toot-id=' + JSON.parse(mess.data).payload + ']').addClass('by_delcatch')
} else { } else {
$("[toot-id=" + JSON.parse(mess.data).payload + "]").hide(); $('[toot-id=' + JSON.parse(mess.data).payload + ']').hide()
$("[toot-id=" + JSON.parse(mess.data).payload + "]").remove(); $('[toot-id=' + JSON.parse(mess.data).payload + ']').remove()
} }
} else if (type == "update") { } else if (type == 'update') {
localStorage.removeItem("delete"); localStorage.removeItem('delete')
if (TLtype == "integrated") { if (TLtype == 'integrated') {
var templete = parse([obj], "", acct_id, tlid); var templete = parse([obj], '', acct_id, tlid)
} else if (TLtype == "plus") { } else if (TLtype == 'plus') {
if (obj.account.acct == obj.account.username) { if (obj.account.acct == obj.account.username) {
var templete = parse([obj], "", acct_id, tlid, "", mute, "mix"); var templete = parse([obj], '', acct_id, tlid, '', mute, 'mix')
} else { } else {
var templete = ""; var templete = ''
} }
} }
if ($("#timeline_" + tlid + " [toot-id=" + obj.id + "]").length < 1) { if ($('#timeline_' + tlid + ' [toot-id=' + obj.id + ']').length < 1) {
if (voice) { if (voice) {
say(obj.content); say(obj.content)
} }
var templete = parse([obj], type, acct_id, tlid, "", mute, "mix"); var templete = parse([obj], type, acct_id, tlid, '', mute, 'mix')
var pool = localStorage.getItem("pool_" + tlid); var pool = localStorage.getItem('pool_' + tlid)
if (pool) { if (pool) {
pool = templete + pool; pool = templete + pool
} else { } else {
pool = templete; pool = templete
} }
localStorage.setItem("pool_" + tlid, pool); localStorage.setItem('pool_' + tlid, pool)
scrollck(); scrollck()
additional(acct_id, tlid); additional(acct_id, tlid)
jQuery("time.timeago").timeago(); jQuery('time.timeago').timeago()
} else { } else {
todo("二重取得発生中"); todo('二重取得発生中')
}
} }
} }
};
websocketLocal[wslid].onerror = function(error) { websocketLocal[wslid].onerror = function(error) {
console.error("WebSocketLocal Error"); console.error('WebSocketLocal Error')
console.error(error); console.error(error)
if (mode == "error") { if (mode == 'error') {
$("#notice_icon_" + tlid).addClass("red-text"); $('#notice_icon_' + tlid).addClass('red-text')
todo("WebSocket Error " + error); todo('WebSocket Error ' + error)
} else { } else {
var errorct = localStorage.getItem("wserror_" + tlid) * 1 + 1; var errorct = localStorage.getItem('wserror_' + tlid) * 1 + 1
localStorage.setItem("wserror_" + tlid, errorct); localStorage.setItem('wserror_' + tlid, errorct)
if (errorct < 3) { if (errorct < 3) {
reconnector(tlid, TLtype, acct_id, "", "error"); reconnector(tlid, TLtype, acct_id, '', 'error')
}
} }
} }
};
websocketLocal[wslid].onclose = function() { websocketLocal[wslid].onclose = function() {
console.warn("WebSocketLocal Closing:" + tlid); console.warn('WebSocketLocal Closing:' + tlid)
if (mode == "error") { if (mode == 'error') {
$("#notice_icon_" + tlid).addClass("red-text"); $('#notice_icon_' + tlid).addClass('red-text')
todo("WebSocket Closed"); todo('WebSocket Closed')
} else { } else {
var errorct = localStorage.getItem("wserror_" + tlid) * 1 + 1; var errorct = localStorage.getItem('wserror_' + tlid) * 1 + 1
localStorage.setItem("wserror_" + tlid, errorct); localStorage.setItem('wserror_' + tlid, errorct)
if (errorct < 3) { if (errorct < 3) {
reconnector(tlid, TLtype, acct_id, "", "error"); reconnector(tlid, TLtype, acct_id, '', 'error')
}
} }
} }
};
websocketHome[wshid].onerror = function(error) { websocketHome[wshid].onerror = function(error) {
console.error(["WebSocketHome Error", error]); console.error(['WebSocketHome Error', error])
if (mode == "error") { if (mode == 'error') {
$("#notice_icon_" + tlid).addClass("red-text"); $('#notice_icon_' + tlid).addClass('red-text')
todo("WebSocket Error " + error); todo('WebSocket Error ' + error)
} else { } else {
var errorct = localStorage.getItem("wserror_" + tlid) * 1 + 1; var errorct = localStorage.getItem('wserror_' + tlid) * 1 + 1
localStorage.setItem("wserror_" + tlid, errorct); localStorage.setItem('wserror_' + tlid, errorct)
if (errorct < 3) { if (errorct < 3) {
reconnector(tlid, TLtype, acct_id, "", "error"); reconnector(tlid, TLtype, acct_id, '', 'error')
}
} }
} }
};
websocketHome[wshid].onclose = function() { websocketHome[wshid].onclose = function() {
console.warn("WebSocketHome Closing:" + tlid); console.warn('WebSocketHome Closing:' + tlid)
if (mode == "error") { if (mode == 'error') {
$("#notice_icon_" + tlid).addClass("red-text"); $('#notice_icon_' + tlid).addClass('red-text')
todo("WebSocket Closed"); todo('WebSocket Closed')
} else { } else {
var errorct = localStorage.getItem("wserror_" + tlid) * 1 + 1; var errorct = localStorage.getItem('wserror_' + tlid) * 1 + 1
localStorage.setItem("wserror_" + tlid, errorct); localStorage.setItem('wserror_' + tlid, errorct)
if (errorct < 3) { if (errorct < 3) {
reconnector(tlid, TLtype, acct_id, "", "error"); reconnector(tlid, TLtype, acct_id, '', 'error')
}
} }
} }
};
} }
//ある程度のスクロールで発火 //ある程度のスクロールで発火
function mixmore(tlid, type) { function mixmore(tlid, type) {
var multi = localStorage.getItem("column"); var multi = localStorage.getItem('column')
var obj = JSON.parse(multi); var obj = JSON.parse(multi)
var acct_id = obj[tlid].domain; var acct_id = obj[tlid].domain
moreloading = true; moreloading = true
todo("Integrated TL MoreLoading...(Local)"); todo('Integrated TL MoreLoading...(Local)')
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 sid = $("#timeline_" + tlid + " .cvo") var sid = $('#timeline_' + tlid + ' .cvo')
.last() .last()
.attr("unique-id"); .attr('unique-id')
var start = "https://" + domain + "/api/v1/timelines/public?local=true&max_id=" + sid; var start = 'https://' + domain + '/api/v1/timelines/public?local=true&max_id=' + sid
fetch(start, { fetch(start, {
method: "GET", method: 'GET',
headers: { headers: {
"content-type": "application/json", 'content-type': 'application/json',
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(jsonL) { .then(function(jsonL) {
var start = "https://" + domain + "/api/v1/timelines/home?max_id=" + sid; var start = 'https://' + domain + '/api/v1/timelines/home?max_id=' + sid
fetch(start, { fetch(start, {
method: "GET", method: 'GET',
headers: { headers: {
"content-type": "application/json", 'content-type': 'application/json',
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(jsonH) { .then(function(jsonH) {
var homearr = []; var homearr = []
var timeline = jsonL.concat(jsonH); var timeline = jsonL.concat(jsonH)
timeline.sort(function(a, b) { timeline.sort(function(a, b) {
if (date(a.created_at, "unix") > date(b.created_at, "unix")) return -1; if (date(a.created_at, 'unix') > date(b.created_at, 'unix')) return -1
if (date(a.created_at, "unix") < date(b.created_at, "unix")) return 1; if (date(a.created_at, 'unix') < date(b.created_at, 'unix')) return 1
return 0; return 0
}); })
timeline.splice(20); timeline.splice(20)
var templete = ""; var templete = ''
Object.keys(timeline).forEach(function(key) { Object.keys(timeline).forEach(function(key) {
var pkey = key * 1 + 1; var pkey = key * 1 + 1
if (pkey < 20) { if (pkey < 20) {
if (date(timeline[key].created_at, "unix") != date(timeline[pkey].created_at, "unix")) { if (
if (localStorage.getItem("filter_" + acct_id) != "undefined") { date(timeline[key].created_at, 'unix') != date(timeline[pkey].created_at, 'unix')
var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), "mix"); ) {
if (localStorage.getItem('filter_' + acct_id) != 'undefined') {
var mute = getFilterType(
JSON.parse(localStorage.getItem('filter_' + acct_id)),
'mix'
)
} else { } else {
var mute = []; var mute = []
} }
if (type == "integrated") { if (type == 'integrated') {
templete = templete + parse([timeline[key]], "", acct_id, tlid, "", mute, "mix"); templete = templete + parse([timeline[key]], '', acct_id, tlid, '', mute, 'mix')
} else if (type == "plus") { } else if (type == 'plus') {
if (timeline[key].account.acct == timeline[key].account.username) { if (timeline[key].account.acct == timeline[key].account.username) {
templete = templete + parse([timeline[key]], "", acct_id, tlid, "", mute, "mix"); templete = templete + parse([timeline[key]], '', acct_id, tlid, '', mute, 'mix')
} }
} }
} }
} }
}); })
$("#timeline_" + tlid).append(templete); $('#timeline_' + tlid).append(templete)
additional(acct_id, tlid); additional(acct_id, tlid)
jQuery("time.timeago").timeago(); jQuery('time.timeago').timeago()
moreloading = false; moreloading = false
todc(); todc()
}); })
}); })
} }

View File

@ -1,422 +1,430 @@
//通知 //通知
//取得+Streaming接続 //取得+Streaming接続
function notf(acct_id, tlid, sys) { function notf(acct_id, tlid, sys) {
if (sys == "direct") { if (sys == 'direct') {
notfColumn(acct_id, tlid, sys); notfColumn(acct_id, tlid, sys)
} else { } else {
notfCommon(acct_id, tlid, sys); notfCommon(acct_id, tlid, sys)
} }
} }
function notfColumn(acct_id, tlid, sys) { function notfColumn(acct_id, tlid, sys) {
todo("Notifications Loading..."); todo('Notifications Loading...')
var native = localStorage.getItem("nativenotf"); var native = localStorage.getItem('nativenotf')
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem('acct_' + acct_id + '_at')
if (!native) { if (!native) {
native = "yes"; native = 'yes'
} }
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem('domain_' + acct_id)
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest()
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem('mode_' + domain) == 'misskey') {
var misskey = true; var misskey = true
var start = "https://" + domain + "/api/i/notifications"; var start = 'https://' + domain + '/api/i/notifications'
httpreq.open("POST", start, true); httpreq.open('POST', start, true)
httpreq.setRequestHeader("Content-Type", "application/json"); httpreq.setRequestHeader('Content-Type', 'application/json')
var body = JSON.stringify({ var body = JSON.stringify({
i: at i: at
}); })
} else { } else {
var misskey = false; var misskey = false
if (localStorage.getItem("exclude-" + tlid)) { if (localStorage.getItem('exclude-' + tlid)) {
var exc = localStorage.getItem("exclude-" + tlid); var exc = localStorage.getItem('exclude-' + tlid)
} else { } else {
var exc = ""; var exc = ''
} }
var start = "https://" + domain + "/api/v1/notifications" + exc; var start = 'https://' + domain + '/api/v1/notifications' + exc
httpreq.open("GET", start, true); httpreq.open('GET', start, true)
httpreq.setRequestHeader("Content-Type", "application/json"); httpreq.setRequestHeader('Content-Type', 'application/json')
httpreq.setRequestHeader("Authorization", "Bearer " + at); httpreq.setRequestHeader('Authorization', 'Bearer ' + at)
var body = ""; var body = ''
} }
httpreq.responseType = "json"; httpreq.responseType = 'json'
httpreq.send(body); httpreq.send(body)
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) { if (this.status !== 200) {
setLog(start, this.status, this.response); setLog(start, this.status, this.response)
} }
var max_id = httpreq.getResponseHeader("link"); var max_id = httpreq.getResponseHeader('link')
if (max_id) { if (max_id) {
max_id = max_id.match(/[?&]{1}max_id=([0-9]+)/)[1]; max_id = max_id.match(/[?&]{1}max_id=([0-9]+)/)[1]
} }
if (json[0]) { if (json[0]) {
var templete = ""; var templete = ''
var lastnotf = localStorage.getItem("lastnotf_" + acct_id); var lastnotf = localStorage.getItem('lastnotf_' + acct_id)
localStorage.setItem("lastnotf_" + acct_id, json[0].id); localStorage.setItem('lastnotf_' + acct_id, json[0].id)
Object.keys(json).forEach(function(key) { Object.keys(json).forEach(function(key) {
var obj = json[key]; var obj = json[key]
if (lastnotf == obj.id && key > 0 && native == "yes") { if (lastnotf == obj.id && key > 0 && native == 'yes') {
var ct = key; var ct = key
if (key > 14) { if (key > 14) {
ct = "15+"; ct = '15+'
} }
var os = localStorage.getItem("platform"); var os = localStorage.getItem('platform')
var options = { var options = {
body: ct + lang.lang_notf_new, body: ct + lang.lang_notf_new,
icon: localStorage.getItem("prof_" + acct_id) icon: localStorage.getItem('prof_' + acct_id)
};
var n = new Notification("TheDesk:" + domain, options);
} }
if (localStorage.getItem("filter_" + acct_id) != "undefined") { var n = new Notification('TheDesk:' + domain, options)
var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), "notif"); }
if (localStorage.getItem('filter_' + acct_id) != 'undefined') {
var mute = getFilterType(JSON.parse(localStorage.getItem('filter_' + acct_id)), 'notif')
} else { } else {
var mute = []; var mute = []
} }
if (obj.type != "follow") { if (obj.type != 'follow') {
if (misskey) { if (misskey) {
templete = templete + misskeyParse([obj], "notf", acct_id, tlid, -1, mute); templete = templete + misskeyParse([obj], 'notf', acct_id, tlid, -1, mute)
} else { } else {
templete = templete + parse([obj], "notf", acct_id, tlid, -1, mute); templete = templete + parse([obj], 'notf', acct_id, tlid, -1, mute)
} }
} else { } else {
if (misskey) { if (misskey) {
templete = templete + misskeyUserparse([obj], "notf", acct_id, tlid, -1, mute); templete = templete + misskeyUserparse([obj], 'notf', acct_id, tlid, -1, mute)
} else { } else {
templete = templete + userparse([obj.account], "notf", acct_id, tlid, -1); templete = templete + userparse([obj.account], 'notf', acct_id, tlid, -1)
} }
} }
}); })
templete = templete + '<div class="hide notif-marker" data-maxid="' + max_id + '"></div>'; templete = templete + '<div class="hide notif-marker" data-maxid="' + max_id + '"></div>'
$("#timeline_" + tlid).html(templete); $('#timeline_' + tlid).html(templete)
$("#landing_" + tlid).hide(); $('#landing_' + tlid).hide()
jQuery("time.timeago").timeago(); jQuery('time.timeago').timeago()
} }
$("#notf-box").addClass("fetched"); $('#notf-box').addClass('fetched')
todc(); todc()
//Markers //Markers
var markers = localStorage.getItem("markers"); var markers = localStorage.getItem('markers')
if (markers == "yes") { if (markers == 'yes') {
markers = true; markers = true
} else { } else {
markers = false; markers = false
} }
if (markers) { if (markers) {
getMarker(tlid, "notf", acct_id); getMarker(tlid, 'notf', acct_id)
}
} }
} }
};
if (!misskey) { if (!misskey) {
if (localStorage.getItem("streaming_" + acct_id)) { if (localStorage.getItem('streaming_' + acct_id)) {
var wss = localStorage.getItem("streaming_" + acct_id); var wss = localStorage.getItem('streaming_' + acct_id)
} else { } else {
var wss = "wss://" + domain; var wss = 'wss://' + domain
} }
var start = wss + "/api/v1/streaming/?stream=user&access_token=" + at; var start = wss + '/api/v1/streaming/?stream=user&access_token=' + at
} else { } else {
var start = "wss://" + domain + "/?i=" + at; var start = 'wss://' + domain + '/?i=' + at
} }
} }
function notfCommon(acct_id, tlid, sys) { function notfCommon(acct_id, tlid, sys) {
todo("Notifications Loading..."); todo('Notifications Loading...')
var native = localStorage.getItem("nativenotf"); var native = localStorage.getItem('nativenotf')
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem('acct_' + acct_id + '_at')
if (!native) { if (!native) {
native = "yes"; native = 'yes'
} }
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem('domain_' + acct_id)
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem('mode_' + domain) == 'misskey') {
var misskey = true; var misskey = true
var start = "https://" + domain + "/api/i/notifications"; var start = 'https://' + domain + '/api/i/notifications'
var i = { var i = {
method: "POST", method: 'POST',
headers: { headers: {
"content-type": "application/json" 'content-type': 'application/json'
}, },
body: JSON.stringify({ body: JSON.stringify({
i: at i: at
}) })
};
} else {
var misskey = false;
var start = "https://" + domain + "/api/v1/notifications";
var i = {
method: "GET",
headers: {
"content-type": "application/json",
Authorization: "Bearer " + at
} }
}; } else {
var misskey = false
var start = 'https://' + domain + '/api/v1/notifications'
var i = {
method: 'GET',
headers: {
'content-type': 'application/json',
Authorization: 'Bearer ' + at
}
}
} }
fetch(start, i) fetch(start, i)
.then(function(response) { .then(function(response) {
console.log("header to get param:" + response.headers.get("link")); console.log('header to get param:' + response.headers.get('link'))
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[0]) { if (json[0]) {
var templete = ""; var templete = ''
var lastnotf = localStorage.getItem("lastnotf_" + acct_id); var lastnotf = localStorage.getItem('lastnotf_' + acct_id)
localStorage.setItem("lastnotf_" + acct_id, json[0].id); localStorage.setItem('lastnotf_' + acct_id, json[0].id)
Object.keys(json).forEach(function(key) { Object.keys(json).forEach(function(key) {
var obj = json[key]; var obj = json[key]
if (lastnotf == obj.id && key > 0 && native == "yes") { if (lastnotf == obj.id && key > 0 && native == 'yes') {
var ct = key; var ct = key
if (key > 14) { if (key > 14) {
ct = "15+"; ct = '15+'
} }
var os = localStorage.getItem("platform"); var os = localStorage.getItem('platform')
var options = { var options = {
body: ct + lang.lang_notf_new, body: ct + lang.lang_notf_new,
icon: localStorage.getItem("prof_" + acct_id) icon: localStorage.getItem('prof_' + acct_id)
};
var n = new Notification("TheDesk:" + domain, options);
} }
if (localStorage.getItem("filter_" + acct_id) != "undefined") { var n = new Notification('TheDesk:' + domain, options)
var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), "notif"); }
if (localStorage.getItem('filter_' + acct_id) != 'undefined') {
var mute = getFilterType(JSON.parse(localStorage.getItem('filter_' + acct_id)), 'notif')
} else { } else {
var mute = []; var mute = []
} }
if (obj.type != "follow") { if (obj.type != 'follow') {
if (misskey) { if (misskey) {
templete = templete + misskeyParse([obj], "notf", acct_id, "notf", -1, mute); templete = templete + misskeyParse([obj], 'notf', acct_id, 'notf', -1, mute)
} else { } else {
templete = templete + parse([obj], "notf", acct_id, "notf", -1, mute); templete = templete + parse([obj], 'notf', acct_id, 'notf', -1, mute)
} }
} else { } else {
if (misskey) { if (misskey) {
templete = templete + misskeyUserparse([obj], "notf", acct_id, "notf", -1, mute); templete = templete + misskeyUserparse([obj], 'notf', acct_id, 'notf', -1, mute)
} else { } else {
templete = templete + userparse([obj.account], "notf", acct_id, "notf", -1); templete = templete + userparse([obj.account], 'notf', acct_id, 'notf', -1)
} }
} }
}); })
$("div[data-notf=" + acct_id + "]").html(templete); $('div[data-notf=' + acct_id + ']').html(templete)
$("#landing_" + tlid).hide(); $('#landing_' + tlid).hide()
jQuery("time.timeago").timeago(); jQuery('time.timeago').timeago()
} }
$("#notf-box").addClass("fetched"); $('#notf-box').addClass('fetched')
todc(); todc()
notfWS(misskey, acct_id, tlid, domain, at); notfWS(misskey, acct_id, tlid, domain, at)
}); })
} }
function notfWS(misskey, acct_id, tlid, domain, at) { function notfWS(misskey, acct_id, tlid, domain, at) {
if (!misskey) { if (!misskey) {
if (localStorage.getItem("streaming_" + acct_id)) { if (localStorage.getItem('streaming_' + acct_id)) {
var wss = localStorage.getItem("streaming_" + acct_id); var wss = localStorage.getItem('streaming_' + acct_id)
} else { } else {
var wss = "wss://" + domain; var wss = 'wss://' + domain
} }
var start = wss + "/api/v1/streaming/?stream=user&access_token=" + at; var start = wss + '/api/v1/streaming/?stream=user&access_token=' + at
var wsid = websocketNotf.length; var wsid = websocketNotf.length
websocketNotf[acct_id] = new WebSocket(start); websocketNotf[acct_id] = new WebSocket(start)
websocketNotf[acct_id].onopen = function(mess) { websocketNotf[acct_id].onopen = function(mess) {
console.table({ acct_id: acct_id, type: "Connect Streaming API(Notf)", domain: domain, message: [mess] }); console.table({
$("i[data-notf=" + acct_id + "]").removeClass("red-text"); acct_id: acct_id,
}; type: 'Connect Streaming API(Notf)',
domain: domain,
message: [mess]
})
$('i[data-notf=' + acct_id + ']').removeClass('red-text')
}
websocketNotf[acct_id].onmessage = function(mess) { websocketNotf[acct_id].onmessage = function(mess) {
//console.log(["Receive Streaming API(Notf):" + acct_id + "(" + domain + ")", JSON.parse(JSON.parse(mess.data).payload)]); //console.log(["Receive Streaming API(Notf):" + acct_id + "(" + domain + ")", JSON.parse(JSON.parse(mess.data).payload)]);
var popup = localStorage.getItem("popup"); var popup = localStorage.getItem('popup')
if (!popup) { if (!popup) {
popup = 0; popup = 0
} }
var obj = JSON.parse(JSON.parse(mess.data).payload); var obj = JSON.parse(JSON.parse(mess.data).payload)
var type = JSON.parse(mess.data).event; var type = JSON.parse(mess.data).event
if (type == "notification") { if (type == 'notification') {
var templete = ""; var templete = ''
localStorage.setItem("lastnotf_" + acct_id, obj.id); localStorage.setItem('lastnotf_' + acct_id, obj.id)
if (!$("#unread_" + tlid + " .material-icons").hasClass("teal-text")) { if (!$('#unread_' + tlid + ' .material-icons').hasClass('teal-text')) {
//markers show中はダメ //markers show中はダメ
if (obj.type != "follow") { if (obj.type != 'follow') {
templete = parse([obj], "notf", acct_id, "notf", popup); templete = parse([obj], 'notf', acct_id, 'notf', popup)
} else { } else {
templete = userparse([obj], "notf", acct_id, "notf", popup); templete = userparse([obj], 'notf', acct_id, 'notf', popup)
} }
if (!$("div[data-notfIndv=" + acct_id + "_" + obj.id + "]").length) { if (!$('div[data-notfIndv=' + acct_id + '_' + obj.id + ']').length) {
$("div[data-notf=" + acct_id + "]").prepend(templete); $('div[data-notf=' + acct_id + ']').prepend(templete)
$("div[data-const=notf_" + acct_id + "]").prepend(templete); $('div[data-const=notf_' + acct_id + ']').prepend(templete)
} }
jQuery("time.timeago").timeago(); jQuery('time.timeago').timeago()
}
} else if (type == 'delete') {
$('[toot-id=' + obj + ']').hide()
$('[toot-id=' + obj + ']').remove()
} }
} else if (type == "delete") {
$("[toot-id=" + obj + "]").hide();
$("[toot-id=" + obj + "]").remove();
} }
};
websocketNotf[acct_id].onerror = function(error) { websocketNotf[acct_id].onerror = function(error) {
console.error("WebSocket Error " + error); console.error('WebSocket Error ' + error)
errorct++; errorct++
console.log(errorct); console.log(errorct)
if (errorct < 3) { if (errorct < 3) {
notfWS(misskey, acct_id, tlid, domain, at); notfWS(misskey, acct_id, tlid, domain, at)
}
} }
};
websocketNotf[acct_id].onclose = function(error) { websocketNotf[acct_id].onclose = function(error) {
console.error("WebSocket Close " + error); console.error('WebSocket Close ' + error)
errorct++; errorct++
console.log(errorct); console.log(errorct)
if (errorct < 3) { if (errorct < 3) {
notfWS(misskey, acct_id, tlid, domain, at); notfWS(misskey, acct_id, tlid, domain, at)
}
} }
};
} }
} }
//一定のスクロールで発火 //一定のスクロールで発火
function notfmore(tlid) { function notfmore(tlid) {
console.log({ status: "kicked", status: moreloading }); console.log({ status: 'kicked', status: moreloading })
var multi = localStorage.getItem("column"); var multi = localStorage.getItem('column')
var obj = JSON.parse(multi); var obj = JSON.parse(multi)
var acct_id = obj[tlid].domain; var acct_id = obj[tlid].domain
if (!type) { if (!type) {
var type = obj[tlid].type; var type = obj[tlid].type
} else { } else {
var data; var data
} }
var sid = $("#timeline_" + tlid + " .notif-marker") var sid = $('#timeline_' + tlid + ' .notif-marker')
.last() .last()
.attr("data-maxid"); .attr('data-maxid')
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem('acct_' + acct_id + '_at')
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem('domain_' + acct_id)
if (sid && !moreloading) { if (sid && !moreloading) {
moreloading = true; moreloading = true
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest()
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem('mode_' + domain) == 'misskey') {
var misskey = true; var misskey = true
var start = "https://" + domain + "/api/i/notifications"; var start = 'https://' + domain + '/api/i/notifications'
httpreq.open(POST, start, true); httpreq.open(POST, start, true)
httpreq.setRequestHeader("Content-Type", "application/json"); httpreq.setRequestHeader('Content-Type', 'application/json')
var body = JSON.stringify({ var body = JSON.stringify({
i: at, i: at,
untilID: sid untilID: sid
}); })
} else { } else {
var misskey = false; var misskey = false
if (localStorage.getItem("exclude-" + tlid)) { if (localStorage.getItem('exclude-' + tlid)) {
var exc = localStorage.getItem("exclude-" + tlid) + "&max_id=" + sid; var exc = localStorage.getItem('exclude-' + tlid) + '&max_id=' + sid
} else { } else {
var exc = "?max_id=" + sid; var exc = '?max_id=' + sid
} }
var start = "https://" + domain + "/api/v1/notifications" + exc; var start = 'https://' + domain + '/api/v1/notifications' + exc
httpreq.open("GET", start, true); httpreq.open('GET', start, true)
httpreq.setRequestHeader("Content-Type", "application/json"); httpreq.setRequestHeader('Content-Type', 'application/json')
httpreq.setRequestHeader("Authorization", "Bearer " + at); httpreq.setRequestHeader('Authorization', 'Bearer ' + at)
var body = ""; var body = ''
} }
httpreq.responseType = "json"; httpreq.responseType = 'json'
httpreq.send(body); httpreq.send(body)
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) { if (this.status !== 200) {
setLog(start, this.status, this.response); setLog(start, this.status, this.response)
} }
console.log(["More notifications on " + tlid, json]); console.log(['More notifications on ' + tlid, json])
var max_id = httpreq.getResponseHeader("link").match(/[?&]{1}max_id=([0-9]+)/)[1]; var max_id = httpreq.getResponseHeader('link').match(/[?&]{1}max_id=([0-9]+)/)[1]
if (json[0]) { if (json[0]) {
var templete = ""; var templete = ''
var lastnotf = localStorage.getItem("lastnotf_" + acct_id); var lastnotf = localStorage.getItem('lastnotf_' + acct_id)
localStorage.setItem("lastnotf_" + acct_id, json[0].id); localStorage.setItem('lastnotf_' + acct_id, json[0].id)
Object.keys(json).forEach(function(key) { Object.keys(json).forEach(function(key) {
var obj = json[key]; var obj = json[key]
if (localStorage.getItem("filter_" + acct_id) != "undefined") { if (localStorage.getItem('filter_' + acct_id) != 'undefined') {
var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), "notif"); var mute = getFilterType(
JSON.parse(localStorage.getItem('filter_' + acct_id)),
'notif'
)
} else { } else {
var mute = []; var mute = []
} }
if (obj.type != "follow") { if (obj.type != 'follow') {
if (misskey) { if (misskey) {
templete = templete + misskeyParse([obj], "notf", acct_id, "notf", -1, mute); templete = templete + misskeyParse([obj], 'notf', acct_id, 'notf', -1, mute)
} else { } else {
templete = templete + parse([obj], "notf", acct_id, "notf", -1, mute); templete = templete + parse([obj], 'notf', acct_id, 'notf', -1, mute)
} }
} else { } else {
if (misskey) { if (misskey) {
templete = templete + misskeyUserparse([obj], "notf", acct_id, "notf", -1, mute); templete = templete + misskeyUserparse([obj], 'notf', acct_id, 'notf', -1, mute)
} else { } else {
templete = templete + userparse([obj.account], "notf", acct_id, "notf", -1); templete = templete + userparse([obj.account], 'notf', acct_id, 'notf', -1)
} }
} }
}); })
moreloading = false; moreloading = false
templete = templete + '<div class="hide notif-marker" data-maxid="' + max_id + '"></div>'; templete = templete + '<div class="hide notif-marker" data-maxid="' + max_id + '"></div>'
$("#timeline_" + tlid).append(templete); $('#timeline_' + tlid).append(templete)
$("#landing_" + tlid).hide(); $('#landing_' + tlid).hide()
jQuery("time.timeago").timeago(); jQuery('time.timeago').timeago()
}
$('#notf-box').addClass('fetched')
todc()
} }
$("#notf-box").addClass("fetched");
todc();
} }
};
} }
} }
//通知トグルボタン //通知トグルボタン
function notfToggle(acct, tlid) { function notfToggle(acct, tlid) {
if ($("#notf-box_" + tlid).hasClass("column-hide")) { if ($('#notf-box_' + tlid).hasClass('column-hide')) {
$("#notf-box_" + tlid).css("display", "block"); $('#notf-box_' + tlid).css('display', 'block')
$("#notf-box_" + tlid).animate( $('#notf-box_' + tlid).animate(
{ {
height: "400px" height: '400px'
}, },
{ {
duration: 300, duration: 300,
complete: function() { complete: function() {
$("#notf-box_" + tlid).css("overflow-y", "scroll"); $('#notf-box_' + tlid).css('overflow-y', 'scroll')
$("#notf-box_" + tlid).removeClass("column-hide"); $('#notf-box_' + tlid).removeClass('column-hide')
} }
} }
); )
} else { } else {
$("#notf-box_" + tlid).css("overflow-y", "hidden"); $('#notf-box_' + tlid).css('overflow-y', 'hidden')
$("#notf-box_" + tlid).animate( $('#notf-box_' + tlid).animate(
{ {
height: "0" height: '0'
}, },
{ {
duration: 300, duration: 300,
complete: function() { complete: function() {
$("#notf-box_" + tlid).addClass("column-hide"); $('#notf-box_' + tlid).addClass('column-hide')
$("#notf-box_" + tlid).css("display", "none"); $('#notf-box_' + tlid).css('display', 'none')
} }
} }
); )
} }
notfCanceler(acct); notfCanceler(acct)
} }
function notfCanceler(acct) { function notfCanceler(acct) {
$(".notf-reply_" + acct).text(0); $('.notf-reply_' + acct).text(0)
localStorage.removeItem("notf-reply_" + acct); localStorage.removeItem('notf-reply_' + acct)
$(".notf-reply_" + acct).addClass("hide"); $('.notf-reply_' + acct).addClass('hide')
$(".notf-fav_" + acct).text(0); $('.notf-fav_' + acct).text(0)
localStorage.removeItem("notf-fav_" + acct); localStorage.removeItem('notf-fav_' + acct)
$(".notf-fav_" + acct).addClass("hide"); $('.notf-fav_' + acct).addClass('hide')
$(".notf-bt_" + acct).text(0); $('.notf-bt_' + acct).text(0)
localStorage.removeItem("notf-bt_" + acct); localStorage.removeItem('notf-bt_' + acct)
$(".notf-bt_" + acct).addClass("hide"); $('.notf-bt_' + acct).addClass('hide')
$(".notf-follow_" + acct).text(0); $('.notf-follow_' + acct).text(0)
localStorage.removeItem("notf-follow_" + acct); localStorage.removeItem('notf-follow_' + acct)
$(".notf-follow_" + acct).addClass("hide"); $('.notf-follow_' + acct).addClass('hide')
$(".notf-icon_" + acct).removeClass("red-text"); $('.notf-icon_' + acct).removeClass('red-text')
} }
function allNotfRead() { function allNotfRead() {
var multi = localStorage.getItem("multi"); var multi = localStorage.getItem('multi')
if (multi) { if (multi) {
var obj = JSON.parse(multi); var obj = JSON.parse(multi)
Object.keys(obj).forEach(function(key) { Object.keys(obj).forEach(function(key) {
notfCanceler(key); notfCanceler(key)
}); })
} }
} }
allNotfRead(); allNotfRead()

File diff suppressed because one or more lines are too long

View File

@ -1,37 +1,37 @@
//アンケートのトグル //アンケートのトグル
function pollToggle() { function pollToggle() {
if ($("#poll").hasClass("hide")) { if ($('#poll').hasClass('hide')) {
$("#right-side").show() $('#right-side').show()
$("#right-side").css("width", "300px") $('#right-side').css('width', '300px')
$("#left-side").css("width", "calc(100% - 300px)") $('#left-side').css('width', 'calc(100% - 300px)')
var width = localStorage.getItem("postbox-width"); var width = localStorage.getItem('postbox-width')
if (width) { if (width) {
width = width.replace("px", "") * 1 + 300 width = width.replace('px', '') * 1 + 300
} else { } else {
width = 600 width = 600
} }
$("#post-box").css("width", width + "px") $('#post-box').css('width', width + 'px')
$("#poll").removeClass("hide") $('#poll').removeClass('hide')
$("#pollsta").text(lang.lang_yesno) $('#pollsta').text(lang.lang_yesno)
} else { } else {
$("#right-side").hide() $('#right-side').hide()
$("#left-side").css("width", "100%") $('#left-side').css('width', '100%')
$("#right-side").css("width", "300px") $('#right-side').css('width', '300px')
var width = localStorage.getItem("postbox-width"); var width = localStorage.getItem('postbox-width')
if (width) { if (width) {
width = width.replace("px", "") * 1 width = width.replace('px', '') * 1
} else { } else {
width = 300 width = 300
} }
$("#post-box").css("width", width + "px") $('#post-box').css('width', width + 'px')
$("#emoji").addClass("hide") $('#emoji').addClass('hide')
$("#poll").addClass("hide") $('#poll').addClass('hide')
$("#pollsta").text(lang.lang_no) $('#pollsta').text(lang.lang_no)
} }
} }
function pollProviderCk() { function pollProviderCk() {
$(".poll-provider").addClass("hide"); $('.poll-provider').addClass('hide')
$("#" + $("#poll-sel").val()).removeClass("hide"); $('#' + $('#poll-sel').val()).removeClass('hide')
} }
/* /*
function pollAddtime(num){ function pollAddtime(num){
@ -42,83 +42,83 @@ function pollAddtime(num){
} }
*/ */
function pollCalc() { function pollCalc() {
var days = $("#days_poll").val(); var days = $('#days_poll').val()
var hrs = $("#hours_poll").val(); var hrs = $('#hours_poll').val()
var mins = $("#mins_poll").val(); var mins = $('#mins_poll').val()
console.log("Poll calc:" + days * 86400 + hrs * 3600 + mins * 60) console.log('Poll calc:' + days * 86400 + hrs * 3600 + mins * 60)
return days * 86400 + hrs * 3600 + mins * 60; return days * 86400 + hrs * 3600 + mins * 60
} }
//Vote //Vote
function voteSelMastodon(acct_id, id, to, mul) { function voteSelMastodon(acct_id, id, to, mul) {
if ($('.vote_' + acct_id + '_' + id + '_' + to).hasClass("sel")) { if ($('.vote_' + acct_id + '_' + id + '_' + to).hasClass('sel')) {
$('.vote_' + acct_id + '_' + id + '_' + to).css("background-color", "transparent") $('.vote_' + acct_id + '_' + id + '_' + to).css('background-color', 'transparent')
$('.vote_' + acct_id + '_' + id + '_' + to).removeClass("sel"); $('.vote_' + acct_id + '_' + id + '_' + to).removeClass('sel')
} else { } else {
if (!mul) { if (!mul) {
$('.vote_' + acct_id + '_' + id + ' div').each(function(i, elem) { $('.vote_' + acct_id + '_' + id + ' div').each(function(i, elem) {
if (i == to) { if (i == to) {
$(this).css("background-color", "var(--emphasized)"); $(this).css('background-color', 'var(--emphasized)')
$(this).addClass("sel"); $(this).addClass('sel')
} else { } else {
$(this).css("background-color", "transparent") $(this).css('background-color', 'transparent')
$(this).removeClass("sel"); $(this).removeClass('sel')
} }
}); })
} else { } else {
$('.vote_' + acct_id + '_' + id + '_' + to).css("background-color", "var(--emphasized)") $('.vote_' + acct_id + '_' + id + '_' + to).css('background-color', 'var(--emphasized)')
$('.vote_' + acct_id + '_' + id + '_' + to).addClass("sel"); $('.vote_' + acct_id + '_' + id + '_' + to).addClass('sel')
} }
} }
} }
function voteMastodon(acct_id, id) { function voteMastodon(acct_id, id) {
var choice = []; var choice = []
$('.vote_' + acct_id + '_' + id + ' div').each(function(i, elem) { $('.vote_' + acct_id + '_' + id + ' div').each(function(i, elem) {
if ($(this).hasClass("sel")) { if ($(this).hasClass('sel')) {
choice.push(i + ""); choice.push(i + '')
} }
}); })
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/polls/" + id + "/votes"; var start = 'https://' + domain + '/api/v1/polls/' + id + '/votes'
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem('mode_' + domain) == 'misskey') {
return false; return false
} }
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest()
httpreq.open('POST', start, true); httpreq.open('POST', 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({ choices: choice })); httpreq.send(JSON.stringify({ choices: choice }))
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
voteMastodonrefresh(acct_id, id) voteMastodonrefresh(acct_id, id)
} }
} }
function showResult(acct_id, id) { function showResult(acct_id, id) {
$('.vote_' + acct_id + '_' + id + '_result').toggleClass("hide") $('.vote_' + acct_id + '_' + id + '_result').toggleClass('hide')
} }
function voteMastodonrefresh(acct_id, id) { function voteMastodonrefresh(acct_id, id) {
var datetype = localStorage.getItem("datetype"); var datetype = localStorage.getItem('datetype')
if (!datetype) { if (!datetype) {
datetype = "absolute"; datetype = 'absolute'
} }
var httpreqd = new XMLHttpRequest(); var httpreqd = new XMLHttpRequest()
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/polls/" + id; var start = 'https://' + domain + '/api/v1/polls/' + id
httpreqd.open('GET', start, true); httpreqd.open('GET', start, true)
httpreqd.setRequestHeader('Content-Type', 'application/json'); httpreqd.setRequestHeader('Content-Type', 'application/json')
httpreqd.setRequestHeader('Authorization', 'Bearer ' + at); httpreqd.setRequestHeader('Authorization', 'Bearer ' + at)
httpreqd.responseType = 'json'; httpreqd.responseType = 'json'
httpreqd.send(); httpreqd.send()
httpreqd.onreadystatechange = function() { httpreqd.onreadystatechange = function() {
if (httpreqd.readyState == 4) { if (httpreqd.readyState == 4) {
if(this.status!==200){ setLog(start, this.status, this.response); } if (this.status !== 200) {
var json = httpreqd.response; setLog(start, this.status, this.response)
console.log(["Refresh vote", json]); }
var json = httpreqd.response
console.log(['Refresh vote', json])
if (!json) { if (!json) {
return false; return false
} }
var poll = pollParse(json, acct_id) var poll = pollParse(json, acct_id)
$('.vote_' + acct_id + '_' + json.id).html(poll) $('.vote_' + acct_id + '_' + json.id).html(poll)

View File

@ -1,170 +1,183 @@
$voise = null; $voise = null
isBouyomi = localStorage.getItem("voice_bouyomi"); isBouyomi = localStorage.getItem('voice_bouyomi')
$voiseName = lang.lang_speech; $voiseName = lang.lang_speech
$voices = speechSynthesis.getVoices(); $voices = speechSynthesis.getVoices()
$synthes = new SpeechSynthesisUtterance(); $synthes = new SpeechSynthesisUtterance()
$voise = $.grep($voices, function (n, i) { return n.name == $voiseName })[0]; $voise = $.grep($voices, function(n, i) {
$synthes.voice = $voise; // 音声の設定 return n.name == $voiseName
localStorage.removeItem("voicebank"); })[0]
$synthes.voice = $voise // 音声の設定
localStorage.removeItem('voicebank')
speechSynthesis.cancel() speechSynthesis.cancel()
if (!localStorage.getItem("voice_vol")) { if (!localStorage.getItem('voice_vol')) {
localStorage.setItem("voice_vol", 1) localStorage.setItem('voice_vol', 1)
} }
voiceRate = localStorage.getItem("voice_speed"); voiceRate = localStorage.getItem('voice_speed')
$synthes.rate = voiceRate $synthes.rate = voiceRate
voicePitch = localStorage.getItem("voice_pitch"); voicePitch = localStorage.getItem('voice_pitch')
$synthes.pitch = voicePitch $synthes.pitch = voicePitch
voiceVol = localStorage.getItem("voice_vol"); voiceVol = localStorage.getItem('voice_vol')
$synthes.volume = voiceVol $synthes.volume = voiceVol
function say(msgr) { function say(msgr) {
msg = voiceParse(msgr); msg = voiceParse(msgr)
var voice = localStorage.getItem("voicebank"); var voice = localStorage.getItem('voicebank')
var obj = JSON.parse(voice); var obj = JSON.parse(voice)
if (!obj) { if (!obj) {
var json = JSON.stringify([msg]); var json = JSON.stringify([msg])
localStorage.setItem("voicebank", json); localStorage.setItem('voicebank', json)
} else { } else {
obj.push([msg]); obj.push([msg])
var json = JSON.stringify(obj); var json = JSON.stringify(obj)
localStorage.setItem("voicebank", json); localStorage.setItem('voicebank', json)
} }
} }
$repeat = setInterval(function() { $repeat = setInterval(function() {
if (!speechSynthesis.speaking) { if (!speechSynthesis.speaking) {
var voice = localStorage.getItem("voicebank"); var voice = localStorage.getItem('voicebank')
if (voice) { if (voice) {
var obj = JSON.parse(voice); var obj = JSON.parse(voice)
if (obj[0]) { if (obj[0]) {
if (localStorage.getItem("voice_bouyomi")) { if (localStorage.getItem('voice_bouyomi')) {
var delim = "<bouyomi>"; var delim = '<bouyomi>'
var thisVoiceRate = voiceRate * 10 + 70 var thisVoiceRate = voiceRate * 10 + 70
var thisVoicePitch = voicePitch * 50 + 70 var thisVoicePitch = voicePitch * 50 + 70
var thisVoiceVol = voiceVol * 100 var thisVoiceVol = voiceVol * 100
console.log(thisVoiceRate, thisVoicePitch, thisVoiceVol) console.log(thisVoiceRate, thisVoicePitch, thisVoiceVol)
var command = 0x0001; var command = 0x0001
var type = 0; var type = 0
var sends = "" + command + delim + thisVoiceRate + delim + thisVoicePitch + delim + thisVoiceVol + delim + type + delim + obj[0]; var sends =
'' +
command +
delim +
thisVoiceRate +
delim +
thisVoicePitch +
delim +
thisVoiceVol +
delim +
type +
delim +
obj[0]
bouyomiConnect(sends) bouyomiConnect(sends)
} else { } else {
$synthes.text = obj[0]; $synthes.text = obj[0]
speechSynthesis.speak($synthes); speechSynthesis.speak($synthes)
} }
obj.splice(0, 1); obj.splice(0, 1)
var json = JSON.stringify(obj); var json = JSON.stringify(obj)
localStorage.setItem("voicebank", json); localStorage.setItem('voicebank', json)
} }
} }
} }
}, 300); }, 300)
function voiceParse(msg) { function voiceParse(msg) {
msg = $.strip_tags(msg); msg = $.strip_tags(msg)
msg = msg.replace(/#/g, ""); msg = msg.replace(/#/g, '')
msg = msg.replace(/'/g, ""); msg = msg.replace(/'/g, '')
msg = msg.replace(/"/g, ""); msg = msg.replace(/"/g, '')
msg = msg.replace(/https?:\/\/[a-zA-Z0-9./-@_=?%&-]+/g, ""); msg = msg.replace(/https?:\/\/[a-zA-Z0-9./-@_=?%&-]+/g, '')
return msg; return msg
} }
function voiceToggle(tlid) { function voiceToggle(tlid) {
var voiceck = localStorage.getItem("voice_" + tlid); var voiceck = localStorage.getItem('voice_' + tlid)
if (voiceck) { if (voiceck) {
localStorage.removeItem("voice_" + tlid); localStorage.removeItem('voice_' + tlid)
speechSynthesis.cancel() speechSynthesis.cancel()
if (localStorage.getItem("voice_bouyomi")) { if (localStorage.getItem('voice_bouyomi')) {
var command = 0x0010; var command = 0x0010
var sends = "" + command; var sends = '' + command
bouyomiConnect(sends) bouyomiConnect(sends)
} }
$("#sta-voice-" + tlid).text("Off"); $('#sta-voice-' + tlid).text('Off')
$("#sta-voice-" + tlid).css("color", 'red'); $('#sta-voice-' + tlid).css('color', 'red')
parseColumn(tlid); parseColumn(tlid)
} else { } else {
localStorage.setItem("voice_" + tlid, "true"); localStorage.setItem('voice_' + tlid, 'true')
$("#sta-voice-" + tlid).text("On"); $('#sta-voice-' + tlid).text('On')
$("#sta-voice-" + tlid).css("color", '#009688'); $('#sta-voice-' + tlid).css('color', '#009688')
parseColumn(tlid); parseColumn(tlid)
} }
} }
function voiceCheck(tlid) { function voiceCheck(tlid) {
var voiceck = localStorage.getItem("voice_" + tlid); var voiceck = localStorage.getItem('voice_' + tlid)
if (voiceck) { if (voiceck) {
$("#sta-voice-" + tlid).text("On"); $('#sta-voice-' + tlid).text('On')
$("#sta-voice-" + tlid).css("color", '#009688'); $('#sta-voice-' + tlid).css('color', '#009688')
} else { } else {
$("#sta-voice-" + tlid).text("Off"); $('#sta-voice-' + tlid).text('Off')
$("#sta-voice-" + tlid).css("color", 'red'); $('#sta-voice-' + tlid).css('color', 'red')
} }
} }
function voicePlay() { function voicePlay() {
if (speechSynthesis.speaking) { if (speechSynthesis.speaking) {
speechSynthesis.cancel() speechSynthesis.cancel()
} else { } else {
var text = $("#voicetxt").val(); var text = $('#voicetxt').val()
var rate = $("#voicespeed").val(); var rate = $('#voicespeed').val()
var pitch = $("#voicepitch").val() var pitch = $('#voicepitch').val()
var vol = $("#voicevol").val() var vol = $('#voicevol').val()
if (localStorage.getItem("voice_bouyomi")) { if (localStorage.getItem('voice_bouyomi')) {
var delim = "<bouyomi>"; var delim = '<bouyomi>'
rate = rate * 1 + 70 rate = rate * 1 + 70
pitch = pitch * 1 + 70 pitch = pitch * 1 + 70
var command = 0x0001; // コマンドです。0x0001.読み上げ/0x0010.ポーズ/0x0020.再開/0x0030.スキップ var command = 0x0001 // コマンドです。0x0001.読み上げ/0x0010.ポーズ/0x0020.再開/0x0030.スキップ
/*var speed = 100; // 速度50-200-1を指定すると本体設定 /*var speed = 100; // 速度50-200-1を指定すると本体設定
var pitch = 100; // ピッチ50-200。-1を指定すると本体設定 var pitch = 100; // ピッチ50-200。-1を指定すると本体設定
var volume = 100; // ボリューム0-100。-1を指定すると本体設定*/ var volume = 100; // ボリューム0-100。-1を指定すると本体設定*/
var type = 0; // 声質(0.本体設定/1.女性1/2.女性2/3.男性1/4.男性2/5.中性/6.ロボット/7.機械1/8.機械2) var type = 0 // 声質(0.本体設定/1.女性1/2.女性2/3.男性1/4.男性2/5.中性/6.ロボット/7.機械1/8.機械2)
var sends = "" + command + delim + rate + delim + pitch + delim + vol + delim + type + delim + text; var sends =
'' + command + delim + rate + delim + pitch + delim + vol + delim + type + delim + text
bouyomiConnect(sends) bouyomiConnect(sends)
} else { } else {
$synthes.text = text $synthes.text = text
$synthes.rate = rate / 10 $synthes.rate = rate / 10
$synthes.pitch = pitch / 50 $synthes.pitch = pitch / 50
$synthes.volume = vol / 100; $synthes.volume = vol / 100
speechSynthesis.speak($synthes); speechSynthesis.speak($synthes)
} }
} }
} }
function voiceSettings() { function voiceSettings() {
var awk = $("[name=bym]:checked").val(); var awk = $('[name=bym]:checked').val()
if (awk == "yes") { if (awk == 'yes') {
localStorage.setItem("voice_bouyomi", "yes"); localStorage.setItem('voice_bouyomi', 'yes')
M.toast({ html: "Bouyomi Chan connection requires WebSocket Plugin", displayLength: 3000 }) M.toast({ html: 'Bouyomi Chan connection requires WebSocket Plugin', displayLength: 3000 })
} else { } else {
localStorage.removeItem("voice_bouyomi"); localStorage.removeItem('voice_bouyomi')
} }
localStorage.setItem("voice_speed", $("#voicespeed").val() / 10); localStorage.setItem('voice_speed', $('#voicespeed').val() / 10)
localStorage.setItem("voice_pitch", $("#voicepitch").val() / 50); localStorage.setItem('voice_pitch', $('#voicepitch').val() / 50)
localStorage.setItem("voice_vol", $("#voicevol").val() / 100); localStorage.setItem('voice_vol', $('#voicevol').val() / 100)
M.toast({ html: lang.lang_speech_refresh, displayLength: 3000 }) M.toast({ html: lang.lang_speech_refresh, displayLength: 3000 })
} }
function voiceSettingLoad() { function voiceSettingLoad() {
var flag = localStorage.getItem("voice_bouyomi"); var flag = localStorage.getItem('voice_bouyomi')
if (flag) { if (flag) {
$("#bym_yes").prop("checked", true); $('#bym_yes').prop('checked', true)
} else { } else {
$("#bym_no").prop("checked", true); $('#bym_no').prop('checked', true)
} }
var speed = localStorage.getItem("voice_speed"); var speed = localStorage.getItem('voice_speed')
var pitch = localStorage.getItem("voice_pitch"); var pitch = localStorage.getItem('voice_pitch')
var vol = localStorage.getItem("voice_vol"); var vol = localStorage.getItem('voice_vol')
if (speed) { if (speed) {
$("#voicespeed").val(speed * 10); $('#voicespeed').val(speed * 10)
$("#voicespeedVal").text(speed * 10); $('#voicespeedVal').text(speed * 10)
} }
if (pitch) { if (pitch) {
$("#voicepitch").val(pitch * 50); $('#voicepitch').val(pitch * 50)
$("#voicepitchVal").text(pitch * 50); $('#voicepitchVal').text(pitch * 50)
} }
if (vol) { if (vol) {
$("#voicevol").val(vol * 100); $('#voicevol').val(vol * 100)
$("#voicevolVal").text(vol * 100); $('#voicevolVal').text(vol * 100)
} }
} }
function bouyomiConnect(sends) { function bouyomiConnect(sends) {
var socket = new WebSocket('ws://localhost:50002/'); var socket = new WebSocket('ws://localhost:50002/')
socket.onopen = function() { socket.onopen = function() {
socket.send(sends); socket.send(sends)
} }
} }

View File

@ -1,226 +1,267 @@
//検索 //検索
//検索ボックストグル //検索ボックストグル
function searchMenu() { function searchMenu() {
$("#src-contents").html(""); $('#src-contents').html('')
trend(); trend()
$("#left-menu div").removeClass("active"); $('#left-menu div').removeClass('active')
$("#searchMenu").addClass("active"); $('#searchMenu').addClass('active')
$(".menu-content").addClass("hide"); $('.menu-content').addClass('hide')
$("#src-box").removeClass("hide"); $('#src-box').removeClass('hide')
//$('ul.tabs').tabs('select_tab', 'src-sta'); //$('ul.tabs').tabs('select_tab', 'src-sta');
} }
//検索取得 //検索取得
function src(mode, offset) { function src(mode, offset) {
if (!offset) { if (!offset) {
$("#src-contents").html(""); $('#src-contents').html('')
var add = ""; var add = ''
} else { } else {
var add = "&type=accounts&offset=" + $("#src-accts .cvo").length; var add = '&type=accounts&offset=' + $('#src-accts .cvo').length
} }
var q = $("#src").val(); var q = $('#src').val()
var acct_id = $("#src-acct-sel").val(); var acct_id = $('#src-acct-sel').val()
if (acct_id == "tootsearch") { if (acct_id == 'tootsearch') {
tsAdd(q); tsAdd(q)
return false; return false
} }
localStorage.setItem("last-use", acct_id); localStorage.setItem('last-use', acct_id)
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 m = q.match(/^#(.+)$/); var m = q.match(/^#(.+)$/)
if (m) { if (m) {
q = m[1]; q = m[1]
} }
if (user == "--now") { if (user == '--now') {
var user = $("#his-data").attr("user-id"); var user = $('#his-data').attr('user-id')
} }
if (!mode) { if (!mode) {
var start = "https://" + domain + "/api/v2/search?q=" + q + add; var start = 'https://' + domain + '/api/v2/search?q=' + q + add
} else { } else {
var start = "https://" + domain + "/api/v1/search?q=" + q; var start = 'https://' + domain + '/api/v1/search?q=' + q
} }
console.log("Try to search at " + start); console.log('Try to search at ' + start)
fetch(start, { fetch(start, {
method: "GET", method: 'GET',
headers: { headers: {
"content-type": "application/json", 'content-type': 'application/json',
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) {
src("v1"); src('v1')
return false; return false
}) })
.then(function(json) { .then(function(json) {
console.log(["Search", json]); console.log(['Search', json])
//ハッシュタグ //ハッシュタグ
if (json.hashtags[0]) { if (json.hashtags[0]) {
var tags = ""; var tags = ''
Object.keys(json.hashtags).forEach(function(key4) { Object.keys(json.hashtags).forEach(function(key4) {
var tag = json.hashtags[key4]; var tag = json.hashtags[key4]
if (mode) { if (mode) {
tags = tags + "<a onclick=\"tl('tag','" + tag + "','" + acct_id + "','add')\" class=\"pointer\">#" + escapeHTML(tag) + "</a><br> "; tags =
tags +
`<a onclick="tl('tag','${tag}','${acct_id}','add')" class="pointer">
#${escapeHTML(tag)}
</a>
<br> `
} else { } else {
tags = tags + graphDraw(tag, acct_id); tags = tags + graphDraw(tag, acct_id)
} }
}); })
$("#src-contents").append("Tags<br>" + tags); $('#src-contents').append('Tags<br>' + tags)
} }
//トゥート //トゥート
if (json.statuses[0]) { if (json.statuses[0]) {
var templete = parse(json.statuses, "", acct_id); var templete = parse(json.statuses, '', acct_id)
$("#src-contents").append("<br>Mentions<br>" + templete); $('#src-contents').append('<br>Mentions<br>' + templete)
} }
//アカウント //アカウント
if (json.accounts[0]) { if (json.accounts[0]) {
var templete = userparse(json.accounts, "", acct_id); var templete = userparse(json.accounts, '', acct_id)
if (!offset) { if (!offset) {
$("#src-contents").append('<br>Accounts<div id="src-accts">' + templete + '</div><a onclick="src(false,\'more\')" class="pointer">more...</a>'); $('#src-contents').append(
`<br>Accounts<div id="src-accts">
${templete}
</div><a onclick="src(false,'more')" class="pointer">more...</a>`
)
} else { } else {
$("#src-accts").append(templete); $('#src-accts').append(templete)
} }
} }
jQuery("time.timeago").timeago(); jQuery('time.timeago').timeago()
}); })
} }
function tsAdd(q) { function tsAdd(q) {
var add = { var add = {
domain: acct_id, domain: acct_id,
type: "tootsearch", type: 'tootsearch',
data: q data: q
}; }
var multi = localStorage.getItem("column"); var multi = localStorage.getItem('column')
var obj = JSON.parse(multi); var obj = JSON.parse(multi)
localStorage.setItem("card_" + obj.length, "true"); localStorage.setItem('card_' + obj.length, 'true')
obj.push(add); obj.push(add)
var json = JSON.stringify(obj); var json = JSON.stringify(obj)
localStorage.setItem("column", json); localStorage.setItem('column', json)
parseColumn("add"); parseColumn('add')
} }
function tootsearch(tlid, q) { function tootsearch(tlid, q) {
var start = "https://tootsearch.chotto.moe/api/v1/search?from=0&sort=created_at%3Adesc&q=" + q; var start = 'https://tootsearch.chotto.moe/api/v1/search?from=0&sort=created_at%3Adesc&q=' + q
console.log("Toot srrach at " + start); console.log('Toot srrach at ' + start)
$("#notice_" + tlid).text("tootsearch(" + q + ")"); $('#notice_' + tlid).text('tootsearch(' + q + ')')
$("#notice_icon_" + tlid).text("search"); $('#notice_icon_' + tlid).text('search')
fetch(start, { fetch(start, {
method: "GET", method: 'GET',
headers: { headers: {
"content-type": "application/json" 'content-type': 'application/json'
} }
}) })
.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(raw) { .then(function(raw) {
var templete = ""; var templete = ''
var json = raw.hits.hits; var json = raw.hits.hits
var max_id = raw["hits"].length; var max_id = raw['hits'].length
for (var i = 0; i < json.length; i++) { for (var i = 0; i < json.length; i++) {
var toot = json[i]["_source"]; var toot = json[i]['_source']
if (lastid != toot.uri) { if (lastid != toot.uri) {
if (toot && toot.account) { if (toot && toot.account) {
templete = templete + parse([toot], "noauth", null, tlid, 0, [], "tootsearch"); templete = templete + parse([toot], 'noauth', null, tlid, 0, [], 'tootsearch')
} }
} }
var lastid = toot.uri; var lastid = toot.uri
} }
if (!templete) { if (!templete) {
templete = lang.lang_details_nodata; templete = lang.lang_details_nodata
} else { } else {
templete = templete + '<div class="hide ts-marker" data-maxid="' + max_id + '"></div>'; templete = templete + `<div class="hide ts-marker" data-maxid="${max_id}"></div>`
} }
$("#timeline_" + tlid).html(templete); $('#timeline_' + tlid).html(templete)
jQuery("time.timeago").timeago(); jQuery('time.timeago').timeago()
}); })
} }
function moreTs(tlid, q) { function moreTs(tlid, q) {
var sid = $("#timeline_" + tlid + " .ts-marker") var sid = $('#timeline_' + tlid + ' .ts-marker')
.last() .last()
.attr("data-maxid"); .attr('data-maxid')
moreloading = true; moreloading = true
var start = "https://tootsearch.chotto.moe/api/v1/search?from=" + sid + "&sort=created_at%3Adesc&q=" + q; var start =
$("#notice_" + tlid).text("tootsearch(" + q + ")"); 'https://tootsearch.chotto.moe/api/v1/search?from=' + sid + '&sort=created_at%3Adesc&q=' + q
$("#notice_icon_" + tlid).text("search"); $('#notice_' + tlid).text('tootsearch(' + q + ')')
$('#notice_icon_' + tlid).text('search')
fetch(start, { fetch(start, {
method: "GET", method: 'GET',
headers: { headers: {
"content-type": "application/json" 'content-type': 'application/json'
} }
}) })
.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(raw) { .then(function(raw) {
var templete = ""; var templete = ''
var json = raw.hits.hits; var json = raw.hits.hits
var max_id = raw["hits"].length; var max_id = raw['hits'].length
for (var i = 0; i < json.length; i++) { for (var i = 0; i < json.length; i++) {
var toot = json[i]["_source"]; var toot = json[i]['_source']
if (lastid != toot.uri) { if (lastid != toot.uri) {
if (toot && toot.account) { if (toot && toot.account) {
templete = templete + parse([toot], "noauth", null, tlid, 0, [], "tootsearch"); templete = templete + parse([toot], 'noauth', null, tlid, 0, [], 'tootsearch')
} }
} }
var lastid = toot.uri; var lastid = toot.uri
} }
if (!templete) { if (!templete) {
templete = lang.lang_details_nodata; templete = lang.lang_details_nodata
} else { } else {
templete = templete + '<div class="hide ts-marker" data-maxid="' + max_id + '"></div>'; templete = templete + `<div class="hide ts-marker" data-maxid="${max_id}"></div>`
} }
$("#timeline_" + tlid).append(templete); $('#timeline_' + tlid).append(templete)
jQuery("time.timeago").timeago(); jQuery('time.timeago').timeago()
}); })
} }
function graphDraw(tag, acct_id) { function graphDraw(tag, acct_id) {
var tags = ""; var tags = ''
var his = tag.history; var his = tag.history
var max = Math.max.apply(null, [his[0].uses, his[1].uses, his[2].uses, his[3].uses, his[4].uses, his[5].uses, his[6].uses]); var max = Math.max.apply(null, [
var six = 50 - (his[6].uses / max) * 50; his[0].uses,
var five = 50 - (his[5].uses / max) * 50; his[1].uses,
var four = 50 - (his[4].uses / max) * 50; his[2].uses,
var three = 50 - (his[3].uses / max) * 50; his[3].uses,
var two = 50 - (his[2].uses / max) * 50; his[4].uses,
var one = 50 - (his[1].uses / max) * 50; his[5].uses,
var zero = 50 - (his[0].uses / max) * 50; his[6].uses
])
var six = 50 - (his[6].uses / max) * 50
var five = 50 - (his[5].uses / max) * 50
var four = 50 - (his[4].uses / max) * 50
var three = 50 - (his[3].uses / max) * 50
var two = 50 - (his[2].uses / max) * 50
var one = 50 - (his[1].uses / max) * 50
var zero = 50 - (his[0].uses / max) * 50
if (max === 0) { if (max === 0) {
tags = '<br><br><svg version="1.1" viewbox="0 0 60 50" width="60" height="50">' + '</svg><span style="font-size:200%">' + his[0].uses + "</span>toot(s)&nbsp;<a onclick=\"tl('tag','" + escapeHTML(tag.name) + "','" + acct_id + "','add')\" class=\"pointer\">#" + escapeHTML(tag.name) + "</a>&nbsp;" + his[0].accounts + lang.lang_src_people; tags =
`<br><br><svg version="1.1" viewbox="0 0 60 50" width="60" height="50"></svg>
<span style="font-size:200%">${his[0].uses}</span>
toot(s)&nbsp;
<a onclick=\"tl('tag','${escapeHTML(tag.name)}','${acct_id}','add')" class="pointer">
#${escapeHTML(tag.name)}
</a>&nbsp;` +
his[0].accounts +
lang.lang_src_people
} else { } else {
tags = '<br><br><svg version="1.1" viewbox="0 0 60 50" width="60" height="50">' + '<g><path d="M0,' + six + " L10," + five + " 20," + four + " 30," + three + " 40," + two + " 50," + one + " 60," + zero + '" style="stroke: #9e9e9e; stroke-width: 1;fill: none;"></path></g>' + '</svg><span style="font-size:200%">' + his[0].uses + "</span>toot&nbsp;<a onclick=\"tl('tag','" + escapeHTML(tag.name) + "','" + acct_id + "','add')\" class=\"pointer\">#" + escapeHTML(tag.name) + "</a>&nbsp;" + his[0].accounts + lang.lang_src_people; tags =
`<br><br>
<svg version="1.1" viewbox="0 0 60 50" width="60" height="50">
<g>
<path d="M0,${six} L10,${five} 20,${four} 30,${three} 40,${two} 50,${one} 60,${zero}"
style="stroke: #0f8c0c;fill: rgba(13,113,19,.25); stroke-width: 1;">
</path>
</g>
</svg>
<span style="font-size:200%">${his[0].uses}</span>
toot&nbsp;
<a onclick="tl('tag','${escapeHTML(tag.name)}','${acct_id}','add')" class="pointer">
#${escapeHTML(tag.name)}
</a>&nbsp;` +
his[0].accounts +
lang.lang_src_people
} }
return tags; return tags
} }
/* /*
<svg version="1.1" viewbox="0 0 50 300" width="100%" height="50"> <svg version="1.1" viewbox="0 0 50 300" width="100%" height="50">
@ -228,51 +269,74 @@ function graphDraw(tag, acct_id) {
</svg> </svg>
*/ */
function trend() { function trend() {
console.log("get trend"); console.log('get trend')
$("#src-contents").html(""); $('#src-contents').html('')
var acct_id = $("#src-acct-sel").val(); var acct_id = $('#src-acct-sel').val()
if (acct_id == "tootsearch") { if (acct_id == 'tootsearch') {
return false; return false
} }
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/trends"; var start = 'https://' + domain + '/api/v1/trends'
console.log(start); console.log(start)
fetch(start, { fetch(start, {
method: "GET", method: 'GET',
headers: { headers: {
"content-type": "application/json", 'content-type': 'application/json',
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) {
setLog(start, "JSON", error); setLog(start, 'JSON', error)
console.error(error); console.error(error)
}) })
.then(function(json) { .then(function(json) {
var tags = ""; var tags = ''
Object.keys(json).forEach(function(keye) { Object.keys(json).forEach(function(keye) {
var tag = json[keye]; var tag = json[keye]
var his = tag.history; var his = tag.history
var max = Math.max.apply(null, [his[0].uses, his[1].uses, his[2].uses, his[3].uses, his[4].uses, his[5].uses, his[6].uses]); var max = Math.max.apply(null, [
var six = 50 - (his[6].uses / max) * 50; his[0].uses,
var five = 50 - (his[5].uses / max) * 50; his[1].uses,
var four = 50 - (his[4].uses / max) * 50; his[2].uses,
var three = 50 - (his[3].uses / max) * 50; his[3].uses,
var two = 50 - (his[2].uses / max) * 50; his[4].uses,
var one = 50 - (his[1].uses / max) * 50; his[5].uses,
var zero = 50 - (his[0].uses / max) * 50; his[6].uses
tags = '<svg version="1.1" viewbox="0 0 60 50" width="60" height="50">' + '<g><path d="M-1,51, -1,' + six + ", 0," + six + " L10," + five + " 20," + four + " 30," + three + " 40," + two + " 50," + one + " 60," + zero + " 61," + zero + ' 61,51 -1,51" style="stroke: #0f8c0c;fill: rgba(13,113,19,.25); stroke-width: 1;"></path></g>' + '</svg><span style="font-size:200%">' + his[0].uses + "</span>toots&nbsp;<a onclick=\"tl('tag','" + tag.name + "','" + acct_id + "','add')\" class=\"pointer\">#" + tag.name + "</a>&nbsp;" + his[0].accounts + lang.lang_src_people + "<br><br>"; ])
var six = 50 - (his[6].uses / max) * 50
var five = 50 - (his[5].uses / max) * 50
var four = 50 - (his[4].uses / max) * 50
var three = 50 - (his[3].uses / max) * 50
var two = 50 - (his[2].uses / max) * 50
var one = 50 - (his[1].uses / max) * 50
var zero = 50 - (his[0].uses / max) * 50
tags =
`<svg version="1.1" viewbox="0 0 60 50" width="60" height="50">
<g>
<path d="M0,${six} L10,${five} 20,${four} 30,${three} 40,${two} 50,${one} 60,${zero}"
style="stroke: #0f8c0c;fill: rgba(13,113,19,.25); stroke-width: 1;">
</path>
</g>
</svg>
<span style="font-size:200%">${his[0].uses}</span>
toot&nbsp;
<a onclick="tl('tag','${escapeHTML(tag.name)}','${acct_id}','add')" class="pointer">
#${escapeHTML(tag.name)}
</a>&nbsp;` +
his[0].accounts +
lang.lang_src_people +
'<br><br>'
$("#src-contents").append(tags); $('#src-contents').append(tags)
}); })
}); })
} }

View File

@ -1,150 +1,181 @@
//タグ表示 //タグ表示
if (location.search) { if (location.search) {
var m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=(.+)/); var m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=(.+)/)
var mode = m[1]; var mode = m[1]
var codex = m[2]; var codex = m[2]
if (mode == "tag") { if (mode == 'tag') {
var acct_id = localStorage.getItem("main"); var acct_id = localStorage.getItem('main')
tl("tag", decodeURI(codex), acct_id, "add"); tl('tag', decodeURI(codex), acct_id, 'add')
} }
} }
//よく使うタグ //よく使うタグ
function tagShow(tag) { function tagShow(tag) {
$("[data-tag=" + decodeURI(tag).toLowerCase() + "]").toggleClass("hide"); $('[data-tag=' + decodeURI(tag).toLowerCase() + ']').toggleClass('hide')
} }
//タグ追加 //タグ追加
function tagPin(tag) { function tagPin(tag) {
var tags = localStorage.getItem("tag"); var tags = localStorage.getItem('tag')
if (!tags) { if (!tags) {
var obj = []; var obj = []
} else { } else {
var obj = JSON.parse(tags); var obj = JSON.parse(tags)
} }
var can; var can
Object.keys(obj).forEach(function(key) { Object.keys(obj).forEach(function(key) {
var tagT = obj[key]; var tagT = obj[key]
if (tagT == tag) { if (tagT == tag) {
can = true; can = true
} else { } else {
can = false; can = false
} }
}); })
if (!can) { if (!can) {
obj.push(tag); obj.push(tag)
} }
var json = JSON.stringify(obj); var json = JSON.stringify(obj)
localStorage.setItem("tag", json); localStorage.setItem('tag', json)
favTag(); favTag()
} }
//タグ削除 //タグ削除
function tagRemove(key) { function tagRemove(key) {
var tags = localStorage.getItem("tag"); var tags = localStorage.getItem('tag')
var obj = JSON.parse(tags); var obj = JSON.parse(tags)
obj.splice(key, 1); obj.splice(key, 1)
var json = JSON.stringify(obj); var json = JSON.stringify(obj)
localStorage.setItem("tag", json); localStorage.setItem('tag', json)
favTag(); favTag()
} }
function favTag() { function favTag() {
$("#taglist").html(""); $('#taglist').html('')
var tagarr = localStorage.getItem("tag"); var tagarr = localStorage.getItem('tag')
if (!tagarr) { if (!tagarr) {
var obj = []; var obj = []
} else { } else {
var obj = JSON.parse(tagarr); var obj = JSON.parse(tagarr)
} }
var tags = ""; var tags = ''
var nowPT = localStorage.getItem("stable"); var nowPT = localStorage.getItem('stable')
Object.keys(obj).forEach(function(key) { Object.keys(obj).forEach(function(key) {
var tag = obj[key]; var tag = obj[key]
if (nowPT != tag) { if (nowPT != tag) {
console.log("stable tags:" + nowPT + "/" + tag); console.log('stable tags:' + nowPT + '/' + tag)
var ptt = lang.lang_tags_realtime; var ptt = lang.lang_tags_realtime
var nowon = ""; var nowon = ''
} else { } else {
var ptt = lang.lang_tags_unrealtime; var ptt = lang.lang_tags_unrealtime
var nowon = "(" + lang.lang_tags_realtime + ")"; var nowon = '(' + lang.lang_tags_realtime + ')'
} }
tag = escapeHTML(tag); tag = escapeHTML(tag)
tags = tags + "<a onclick=\"tagShow('" + tag + '\')" class="pointer">#' + tag + "</a>" + nowon + '<span class="hide" data-tag="' + tag + "\"> <a onclick=\"tagTL('tag','" + tag + '\',false,\'add\')" class="pointer" title="' + lang.lang_parse_tagTL.replace("{{tag}}", "#" + tag) + '">TL</a> <a onclick="brInsert(\'#' + tag + '\')" class="pointer" title="' + lang.lang_parse_tagtoot.replace("{{tag}}", "#" + tag) + '">Toot</a> ' + "<a onclick=\"autoToot('" + tag + '\');" class="pointer" title="' + lang.lang_tags_always + lang.lang_parse_tagtoot.replace("{{tag}}", "#" + tag) + '">' + ptt + "</a> <a onclick=\"tagRemove('" + key + '\')" class="pointer" title="' + lang.lang_tags_tagunpin.replace("{{tag}}", "#" + tag) + '">' + lang.lang_del + "</a></span> "; tags =
}); tags +
`<a onclick="tagShow('${tag}')" class="pointer">#${tag}</a>
${nowon}<span class="hide" data-tag="${tag}"> 
<a onclick=\"tagTL('tag','${tag}',false,'add')" class="pointer" title="${lang.lang_parse_tagTL.replace('{{tag}}', '#' + tag)}">
TL
</a> 
<a onclick="brInsert('#${tag}')" class="pointer" title="${lang.lang_parse_tagtoot.replace('{{tag}}', '#' + tag)}">
Toot
</a> 
<a onclick="autoToot('${tag}');" class="pointer" title="${lang.lang_tags_always}${lang.lang_parse_tagtoot.replace('{{tag}}', '#' + tag)}">
${ptt}
</a> 
<a onclick="tagRemove('${key}')" class="pointer" title="${lang.lang_tags_tagunpin.replace('{{tag}}', '#' + tag)}">
${lang.lang_del}
</a>
</span> `
})
if (obj.length > 0) { if (obj.length > 0) {
$("#taglist").append("My Tags:" + tags); $('#taglist').append('My Tags:' + tags)
} else { } else {
$("#taglist").append(""); $('#taglist').append('')
} }
} }
function trendTag() { function trendTag() {
$(".trendtag").remove(); $('.trendtag').remove()
var domain = "imastodon.net"; var domain = 'imastodon.net'
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem('acct_' + acct_id + '_at')
var start = "https://" + domain + "/api/v1/trend_tags"; var start = 'https://' + domain + '/api/v1/trend_tags'
fetch(start, { fetch(start, {
method: "GET", method: 'GET',
headers: { headers: {
"content-type": "application/json", 'content-type': 'application/json',
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) { if (json) {
var tags = ""; var tags = ''
json = json.score; json = json.score
Object.keys(json).forEach(function(tag) { Object.keys(json).forEach(function(tag) {
tag = escapeHTML(tag); tag = escapeHTML(tag)
tags = tags + "<a onclick=\"tagShow('" + tag + '\')" class="pointer">#' + tag + '</a><span class="hide" data-tag="' + tag + "\"> <a onclick=\"tagTL('tag','" + tag + '\',false,\'add\')" class="pointer" title="#' + tag + 'のタイムライン">TL</a> <a onclick="show();brInsert(\'#' + tag + '\')" class="pointer" title="#' + tag + 'でトゥート">Toot</a></span> '; tags =
}); tags +
$("#taglist").append('<div class="trendtag">アイマストドントレンドタグ<i class="material-icons pointer" onclick="trendTag()" style="font-size:12px">refresh</i>:' + tags + "</div>"); `<a onclick="tagShow('${tag}')" class="pointer">#${tag}</a>
trendintervalset(); <span class="hide" data-tag="${tag}"> 
<a onclick=\"tagTL('tag','${tag}',false,'add')" class="pointer" title="#${tag}のタイムライン">TL</a> 
<a onclick="show();brInsert('#${tag}')" class="pointer" title="#${tag}でトゥート">
Toot
</a>
</span> `
})
$('#taglist').append(
'<div class="trendtag">アイマストドントレンドタグ<i class="material-icons pointer" onclick="trendTag()" style="font-size:12px">refresh</i>:' +
tags +
'</div>'
)
trendintervalset()
} else { } else {
$("#taglist").html(""); $('#taglist').html('')
} }
}); })
} }
function trendintervalset() { function trendintervalset() {
setTimeout(trendTag, 6000000); setTimeout(trendTag, 6000000)
} }
function tagTL(a, b, c, d) { function tagTL(a, b, c, d) {
var acct_id = $("#post-acct-sel").val(); var acct_id = $('#post-acct-sel').val()
tl(a, b, acct_id, d); tl(a, b, acct_id, d)
} }
function autoToot(tag) { function autoToot(tag) {
tag = escapeHTML(tag); tag = escapeHTML(tag)
var nowPT = localStorage.getItem("stable"); var nowPT = localStorage.getItem('stable')
if (nowPT == tag) { if (nowPT == tag) {
localStorage.removeItem("stable"); localStorage.removeItem('stable')
M.toast({ html: lang.lang_tags_unrealtime, displayLength: 3000 }); M.toast({ html: lang.lang_tags_unrealtime, displayLength: 3000 })
} else { } else {
localStorage.setItem("stable", tag); localStorage.setItem('stable', tag)
M.toast({ html: lang.lang_tags_tagwarn.replace("{{tag}}", tag).replace("{{tag}}", tag), displayLength: 3000 }); M.toast({
brInsert("#" + tag + " "); html: lang.lang_tags_tagwarn.replace('{{tag}}', tag).replace('{{tag}}', tag),
displayLength: 3000
})
brInsert('#' + tag + ' ')
} }
favTag(); favTag()
} }
//タグをフィーチャー //タグをフィーチャー
function tagFeature(name, acct_id) { function tagFeature(name, acct_id) {
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/featured_tags"; var start = 'https://' + domain + '/api/v1/featured_tags'
fetch(start, { fetch(start, {
method: "POST", method: 'POST',
headers: { headers: {
"content-type": "application/json", 'content-type': 'application/json',
Authorization: "Bearer " + at Authorization: 'Bearer ' + at
}, },
body: JSON.stringify({ body: JSON.stringify({
name: name name: name
@ -153,16 +184,16 @@ function tagFeature(name, acct_id) {
.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) {
return false; return false
}) })
.then(function(json) { .then(function(json) {
console.log(json); console.log(json)
M.toast({ html: "Complete: " + escapeHTML(name), displayLength: 3000 }); M.toast({ html: 'Complete: ' + escapeHTML(name), displayLength: 3000 })
}); })
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,259 +1,276 @@
/*イメージビューワー*/ /*イメージビューワー*/
//postのimg.jsとは異なります。 //postのimg.jsとは異なります。
function imgv(id, key, acct_id) { function imgv(id, key, acct_id) {
$("#imgprog").text(0); $('#imgprog').text(0)
$('#imgmodal').hide(); $('#imgmodal').hide()
$('#imgmodal').attr('src', '../../img/loading.svg'); $('#imgmodal').attr('src', '../../img/loading.svg')
var murl = $("#" + id + "-image-" + key).attr("data-url"); var murl = $('#' + id + '-image-' + key).attr('data-url')
var type = $("#" + id + "-image-" + key).attr("data-type"); var type = $('#' + id + '-image-' + key).attr('data-type')
$("#imagemodal").attr("data-id", id); $('#imagemodal').attr('data-id', id)
$("#imagemodal").attr("data-acct", acct_id); $('#imagemodal').attr('data-acct', acct_id)
$(document).ready(function() { $(document).ready(function() {
if (type == "image") { if (type == 'image') {
$('#imagemodal').modal('open'); $('#imagemodal').modal('open')
xhr = new XMLHttpRequest; xhr = new XMLHttpRequest()
xhr.open('GET', murl, true); xhr.open('GET', murl, true)
xhr.addEventListener('progress', function (event) { xhr.addEventListener(
'progress',
function(event) {
if (event.lengthComputable) { if (event.lengthComputable) {
var total = event.total; var total = event.total
var now = event.loaded; var now = event.loaded
var per = now / total * 100; var per = (now / total) * 100
$("#imgprog").text(Math.floor(per)); $('#imgprog').text(Math.floor(per))
} }
}, false); },
xhr.addEventListener('loadend', function (event) { false
var total = event.total; )
var now = event.loaded; xhr.addEventListener(
var per = now / total * 100; 'loadend',
$("#imgprog").text(Math.floor(per)); function(event) {
}, false); var total = event.total
xhr.send(); var now = event.loaded
$('#imgmodal').attr('src', murl); var per = (now / total) * 100
$('#imagewrap').dragScroll(); // ドラッグスクロール設定 $('#imgprog').text(Math.floor(per))
$('#imgmodal').show(); },
$('#imagemodal').attr('data-key', key); false
$('#imagemodal').attr('data-id', id); )
} else if (type == "video" || type == "gifv") { xhr.send()
$('#video').attr('src', murl); $('#imgmodal').attr('src', murl)
$('#videomodal').modal('open'); $('#imagewrap').dragScroll() // ドラッグスクロール設定
$('#imgmodal').show(); $('#imgmodal').show()
$('#imagemodal').attr('data-key', key)
$('#imagemodal').attr('data-id', id)
} else if (type == 'video' || type == 'gifv') {
$('#video').attr('src', murl)
$('#videomodal').modal('open')
$('#imgmodal').show()
} }
var element = new Image(); var element = new Image()
var width; var width
element.onload = function() { element.onload = function() {
var width = element.naturalWidth; var width = element.naturalWidth
var height = element.naturalHeight; var height = element.naturalHeight
var windowH = $(window).height(); var windowH = $(window).height()
var windowW = $(window).width(); var windowW = $(window).width()
$("#imagemodal").css("bottom", "0") $('#imagemodal').css('bottom', '0')
$("#imagemodal img").css("width", "auto") $('#imagemodal img').css('width', 'auto')
if (height < windowH) { if (height < windowH) {
$("#imagemodal").css("height", height + 60 + "px") $('#imagemodal').css('height', height + 60 + 'px')
$("#imagemodal img").css("height", "100%") $('#imagemodal img').css('height', '100%')
if (width > windowW * 0.8) { if (width > windowW * 0.8) {
$("#imagemodal").css("width", "80vw") $('#imagemodal').css('width', '80vw')
$("#imagemodal img").css("width", "100%") $('#imagemodal img').css('width', '100%')
var heightS = windowW * 0.8 / width * height; var heightS = ((windowW * 0.8) / width) * height
$("#imagemodal").css("height", heightS + 60 + "px") $('#imagemodal').css('height', heightS + 60 + 'px')
} else { } else {
$("#imagemodal").css("width", width + "px") $('#imagemodal').css('width', width + 'px')
} }
} else { } else {
$("#imagemodal img").css("width", "auto") $('#imagemodal img').css('width', 'auto')
var widthS = windowH / height * width; var widthS = (windowH / height) * width
if (widthS < windowW) { if (widthS < windowW) {
$("#imagemodal").css("width", widthS + "px") $('#imagemodal').css('width', widthS + 'px')
} else { } else {
$("#imagemodal").css("width", "100vw") $('#imagemodal').css('width', '100vw')
} }
$("#imagemodal").css("height", "100vh") $('#imagemodal').css('height', '100vh')
$("#imagemodal img").css("height", "calc(100vh - 60px)") $('#imagemodal img').css('height', 'calc(100vh - 60px)')
} }
} }
if ($("#" + id + "-image-" + (key * 1 + 1)).length == 0) { if ($('#' + id + '-image-' + (key * 1 + 1)).length == 0) {
$("#image-next").prop("disabled", true); $('#image-next').prop('disabled', true)
} else { } else {
$("#image-next").prop("disabled", false); $('#image-next').prop('disabled', false)
} }
if ($("#" + id + "-image-" + (key * 1 - 1)).length == 0) { if ($('#' + id + '-image-' + (key * 1 - 1)).length == 0) {
$("#image-prev").prop("disabled", true); $('#image-prev').prop('disabled', true)
} else { } else {
$("#image-prev").prop("disabled", false); $('#image-prev').prop('disabled', false)
} }
element.src = murl; element.src = murl
}); })
} }
//イメージビューワーの送り //イメージビューワーの送り
function imgCont(type) { function imgCont(type) {
$("#imgprog").text(0); $('#imgprog').text(0)
var key = $('#imagemodal').attr('data-key'); var key = $('#imagemodal').attr('data-key')
var id = $('#imagemodal').attr('data-id'); var id = $('#imagemodal').attr('data-id')
if (type == "next") { if (type == 'next') {
key++; key++
} else if (type == "prev") { } else if (type == 'prev') {
key = key * 1 - 1; key = key * 1 - 1
} }
var murl = $("#" + id + "-image-" + key).attr("data-url"); var murl = $('#' + id + '-image-' + key).attr('data-url')
if (murl) { if (murl) {
$('#imgmodal').attr('src', '../../img/loading.svg'); $('#imgmodal').attr('src', '../../img/loading.svg')
var type = $("#" + id + "-image-" + key).attr("data-type"); var type = $('#' + id + '-image-' + key).attr('data-type')
$(document).ready(function() { $(document).ready(function() {
if (type == "image") { if (type == 'image') {
xhr = new XMLHttpRequest; xhr = new XMLHttpRequest()
xhr.open('GET', murl, true); xhr.open('GET', murl, true)
xhr.responseType = "arraybuffer"; xhr.responseType = 'arraybuffer'
xhr.addEventListener('progress', function (event) { xhr.addEventListener(
'progress',
function(event) {
if (event.lengthComputable) { if (event.lengthComputable) {
var total = event.total; var total = event.total
var now = event.loaded; var now = event.loaded
var per = now / total * 100; var per = (now / total) * 100
$("#imgprog").text(Math.floor(per)); $('#imgprog').text(Math.floor(per))
} }
}, false); },
xhr.addEventListener('loadend', function (event) { false
var total = event.total; )
var now = event.loaded; xhr.addEventListener(
var per = now / total * 100; 'loadend',
$("#imgprog").text(Math.floor(per)); function(event) {
}, false); var total = event.total
xhr.send(); var now = event.loaded
$('#imgmodal').attr('src', murl); var per = (now / total) * 100
$('#imagewrap').dragScroll(); // ドラッグスクロール設定 $('#imgprog').text(Math.floor(per))
$('#imagemodal').attr('data-key', key); },
$('#imagemodal').attr('data-id', id); false
} else if (type == "video" || type == "gifv") { )
$('#video').attr('src', murl); xhr.send()
$('#videomodal').modal('open'); $('#imgmodal').attr('src', murl)
$('#imagewrap').dragScroll() // ドラッグスクロール設定
$('#imagemodal').attr('data-key', key)
$('#imagemodal').attr('data-id', id)
} else if (type == 'video' || type == 'gifv') {
$('#video').attr('src', murl)
$('#videomodal').modal('open')
} }
var element = new Image(); var element = new Image()
var width; var width
element.onload = function() { element.onload = function() {
var width = element.naturalWidth; var width = element.naturalWidth
var height = element.naturalHeight; var height = element.naturalHeight
var windowH = $(window).height(); var windowH = $(window).height()
var windowW = $(window).width(); var windowW = $(window).width()
$("#imagemodal").css("bottom", "0") $('#imagemodal').css('bottom', '0')
$("#imagemodal img").css("width", "auto") $('#imagemodal img').css('width', 'auto')
if (height < windowH) { if (height < windowH) {
$("#imagemodal").css("height", height + 60 + "px") $('#imagemodal').css('height', height + 60 + 'px')
$("#imagemodal img").css("height", "100%") $('#imagemodal img').css('height', '100%')
if (width > windowW * 0.8) { if (width > windowW * 0.8) {
$("#imagemodal").css("width", "80vw") $('#imagemodal').css('width', '80vw')
$("#imagemodal img").css("width", "100%") $('#imagemodal img').css('width', '100%')
var heightS = windowW * 0.8 / width * height; var heightS = ((windowW * 0.8) / width) * height
$("#imagemodal").css("height", heightS + 60 + "px") $('#imagemodal').css('height', heightS + 60 + 'px')
} else { } else {
$("#imagemodal").css("width", width + "px") $('#imagemodal').css('width', width + 'px')
} }
} else { } else {
$("#imagemodal img").css("width", "auto") $('#imagemodal img').css('width', 'auto')
var widthS = windowH / height * width; var widthS = (windowH / height) * width
if (widthS < windowW) { if (widthS < windowW) {
$("#imagemodal").css("width", widthS + "px") $('#imagemodal').css('width', widthS + 'px')
} else { } else {
$("#imagemodal").css("width", "100vw") $('#imagemodal').css('width', '100vw')
} }
$("#imagemodal").css("height", "100vh") $('#imagemodal').css('height', '100vh')
$("#imagemodal img").css("height", "calc(100vh - 60px)") $('#imagemodal img').css('height', 'calc(100vh - 60px)')
} }
} }
if ($("#" + id + "-image-" + (key * 1 + 1)).length === 0) { if ($('#' + id + '-image-' + (key * 1 + 1)).length === 0) {
$("#image-next").prop("disabled", true); $('#image-next').prop('disabled', true)
} else { } else {
$("#image-next").prop("disabled", false); $('#image-next').prop('disabled', false)
} }
if ($("#" + id + "-image-" + (key * 1 - 1)).length === 0) { if ($('#' + id + '-image-' + (key * 1 - 1)).length === 0) {
$("#image-prev").prop("disabled", true); $('#image-prev').prop('disabled', true)
} else { } else {
$("#image-prev").prop("disabled", false); $('#image-prev').prop('disabled', false)
} }
element.src = murl; element.src = murl
})
});
} }
} }
//ズームボタン(z:倍率) //ズームボタン(z:倍率)
function zoom(z) { function zoom(z) {
var wdth = $('#imagewrap img').width(); var wdth = $('#imagewrap img').width()
var wdth = wdth * z; var wdth = wdth * z
$('#imagewrap img').css("width", wdth + "px"); $('#imagewrap img').css('width', wdth + 'px')
var hgt = $('#imagewrap img').height(); var hgt = $('#imagewrap img').height()
var hgt = hgt * z; var hgt = hgt * z
$('#imagewrap img').css("height", hgt + "px"); $('#imagewrap img').css('height', hgt + 'px')
} }
//スマホ対応ドラッグ移動システム //スマホ対応ドラッグ移動システム
(function () { ;(function() {
$.fn.dragScroll = function() { $.fn.dragScroll = function() {
var target = this; var target = this
$(this).mousedown(function (event) { $(this)
.mousedown(function(event) {
$(this) $(this)
.data('down', true) .data('down', true)
.data('x', event.clientX) .data('x', event.clientX)
.data('y', event.clientY) .data('y', event.clientY)
.data('scrollLeft', this.scrollLeft) .data('scrollLeft', this.scrollLeft)
.data('scrollTop', this.scrollTop); .data('scrollTop', this.scrollTop)
return false; return false
}).css({ })
'overflow': 'hidden', // スクロールバー非表示 .css({
'cursor': 'move' overflow: 'hidden', // スクロールバー非表示
}); cursor: 'move'
})
// ウィンドウから外れてもイベント実行 // ウィンドウから外れてもイベント実行
$(document).mousemove(function (event) { $(document)
.mousemove(function(event) {
if ($(target).data('down') == true) { if ($(target).data('down') == true) {
// スクロール // スクロール
target.scrollLeft($(target).data('scrollLeft') + $(target).data('x') - target.scrollLeft($(target).data('scrollLeft') + $(target).data('x') - event.clientX)
event.clientX); target.scrollTop($(target).data('scrollTop') + $(target).data('y') - event.clientY)
target.scrollTop($(target).data('scrollTop') + $(target).data('y') - return false // 文字列選択を抑止
event.clientY);
return false; // 文字列選択を抑止
} }
}).mouseup(function (event) { })
$(target).data('down', false); .mouseup(function(event) {
}); $(target).data('down', false)
$(this).on('touchstart', function (event) { })
$(this)
.on('touchstart', function(event) {
$(this) $(this)
.data('down', true) .data('down', true)
.data('x', getX(event)) .data('x', getX(event))
.data('y', getY(event)) .data('y', getY(event))
.data('scrollLeft', this.scrollLeft) .data('scrollLeft', this.scrollLeft)
.data('scrollTop', this.scrollTop); .data('scrollTop', this.scrollTop)
return false; return false
}).css({ })
'overflow': 'hidden', // スクロールバー非表示 .css({
'cursor': 'move' overflow: 'hidden', // スクロールバー非表示
}); //指が触れたか検知 cursor: 'move'
}) //指が触れたか検知
$(this).on('touchmove', function(event) { $(this).on('touchmove', function(event) {
if ($(target).data('down') === true) { if ($(target).data('down') === true) {
// スクロール // スクロール
target.scrollLeft($(target).data('scrollLeft') + $(target).data('x') - target.scrollLeft($(target).data('scrollLeft') + $(target).data('x') - getX(event))
getX(event)); target.scrollTop($(target).data('scrollTop') + $(target).data('y') - getY(event))
target.scrollTop($(target).data('scrollTop') + $(target).data('y') - return false // 文字列選択を抑止
getY(event)); } else {
return false; // 文字列選択を抑止
} else { }
}); //指が動いたか検知
$(this).on('touchend', function (event) {
$(target).data('down', false);
});
return this;
} }
})(jQuery); }) //指が動いたか検知
$(this).on('touchend', function(event) {
$(target).data('down', false)
})
return this
}
})(jQuery)
function getX(event) { function getX(event) {
return event.originalEvent.touches[0].pageX; return event.originalEvent.touches[0].pageX
} }
function getY(event) { function getY(event) {
return event.originalEvent.touches[0].pageY; return event.originalEvent.touches[0].pageY
} }
//マウスホイールで拡大 //マウスホイールで拡大
var element = document.getElementById("imagemodal"); var element = document.getElementById('imagemodal')
element.onmousewheel = function(e) { element.onmousewheel = function(e) {
var delta = e.wheelDelta; var delta = e.wheelDelta
if (delta > 0) { if (delta > 0) {
zoom(1.1) zoom(1.1)
} else { } else {
@ -263,24 +280,23 @@ element.onmousewheel = function (e) {
//当該トゥート //当該トゥート
function detFromImg() { function detFromImg() {
var id = $("#imagemodal").attr("data-id"); var id = $('#imagemodal').attr('data-id')
var acct_id = $("#imagemodal").attr("data-acct"); var acct_id = $('#imagemodal').attr('data-acct')
$('#imagemodal').modal('close'); $('#imagemodal').modal('close')
details(id, acct_id); details(id, acct_id)
} }
//画像保存 //画像保存
function dlImg() { function dlImg() {
var url = $("#imgmodal").attr("src"); var url = $('#imgmodal').attr('src')
if (localStorage.getItem("savefolder")) { if (localStorage.getItem('savefolder')) {
var save = localStorage.getItem("savefolder"); var save = localStorage.getItem('savefolder')
} else { } else {
var save = ""; var save = ''
} }
postMessage(["generalDL", [url, save, false]], "*") postMessage(['generalDL', [url, save, false]], '*')
} }
function openFinder(dir) { function openFinder(dir) {
postMessage(["openFinder", dir], "*") postMessage(['openFinder', dir], '*')
} }
function stopVideo() { function stopVideo() {
document.getElementById('video').pause() document.getElementById('video').pause()

File diff suppressed because it is too large Load Diff