today shinchoku

This commit is contained in:
cutls 2020-07-21 12:44:53 +09:00
parent d92a9ae1ae
commit 541ebbbb19
9 changed files with 181 additions and 206 deletions

View File

@ -605,4 +605,4 @@ textarea {
.linux .win, .linux .win,
.darwin .win { .darwin .win {
display: none; display: none;
} }

View File

@ -38,10 +38,10 @@ async function ck() {
const acct = obj[key] const acct = obj[key]
if (acct.domain) { if (acct.domain) {
let refreshed = await refresh(key, true) let refreshed = await refresh(key, true)
if(refreshed) req = true if (refreshed) req = true
} }
} }
if(req) { if (req) {
Swal.fire({ Swal.fire({
title: 'Reload required', title: 'Reload required',
text: lang.lang_login_changedData, text: lang.lang_login_changedData,
@ -50,18 +50,18 @@ async function ck() {
confirmButtonText: lang.lang_no, confirmButtonText: lang.lang_no,
cancelButtonText: lang.lang_yesno cancelButtonText: lang.lang_yesno
}).then(result => { }).then(result => {
if(result) location.reload() if (result) location.reload()
}) })
} }
if (obj[0].domain) { if (obj[0].domain) {
showElm('#tl') showElm('#tl')
ticker() ticker()
multiSelector(false) parseColumn()
verck(ver) verck(ver)
showElm('.stw') showElm('.stw')
const tips = localStorage.getItem('tips') const tipsType = localStorage.getItem('tips')
if (tips) { if (tipsType) {
tips(tips) tips(tipsType)
} }
document.querySelector('#something-wrong img').setAttribute('src', '../../img/thinking.svg') document.querySelector('#something-wrong img').setAttribute('src', '../../img/thinking.svg')
} }
@ -78,7 +78,7 @@ async function refresh(target, loadskip) {
} }
const start = `https://${domain}/api/v1/accounts/verify_credentials` const start = `https://${domain}/api/v1/accounts/verify_credentials`
let json let json
try{ try {
json = await getApi(start, at) json = await getApi(start, at)
} catch { } catch {
return false return false
@ -88,7 +88,7 @@ async function refresh(target, loadskip) {
M.toast({ html: lang.lang_fatalerroroccured + 'Error:' + json.error, displayLength: 5000 }) M.toast({ html: lang.lang_fatalerroroccured + 'Error:' + json.error, displayLength: 5000 })
return return
} }
if(!json) return false if (!json) return false
let avatar = json['avatar'] let avatar = json['avatar']
//missingがmissingなやつ //missingがmissingなやつ
if (avatar == '/avatars/original/missing.png' || !avatar) { if (avatar == '/avatars/original/missing.png' || !avatar) {
@ -131,7 +131,7 @@ async function refresh(target, loadskip) {
} }
//MarkdownやBBCodeの対応、文字数制限をチェック //MarkdownやBBCodeの対応、文字数制限をチェック
//絶対ストリーミングを閉じさせないマン //絶対ストリーミングを閉じさせないマン
function ckdb(acct_id) { async function ckdb(acct_id) {
const domain = localStorage.getItem(`domain_${acct_id}`) const domain = localStorage.getItem(`domain_${acct_id}`)
if (domain == 'kirishima.cloud') { if (domain == 'kirishima.cloud') {
localStorage.setItem('kirishima', true) localStorage.setItem('kirishima', true)
@ -148,34 +148,39 @@ function ckdb(acct_id) {
var json = idata var json = idata
if (json[quoteMarker] == 'enabled') { if (json[quoteMarker] == 'enabled') {
localStorage.setItem('quoters', true) localStorage.setItem('quoters', true)
localStorage.setItem(`quote_${acct_id}`, true) localStorage.setItem(quoteMarker, true)
} }
} }
if (!isMisskey(domain)) { if (!isMisskey(domain)) {
const start = `https://${domain}/api/v1/instance` const start = `https://${domain}/api/v1/instance`
const json = getApi(start, null) let json
try {
json = await getApi(start, null)
} catch {
return null
}
if (!json || json.error) { if (!json || json.error) {
return return
} }
const mtc = json['max_toot_chars'] const mtc = json['max_toot_chars']
if (mtc) { if (mtc) {
localStorage.setItem(`letters_${acct_id}`, mtc) localStorage.setItem(letters, mtc)
} }
if (json['feature_quote']) { if (json['feature_quote']) {
localStorage.setItem(`quote_${acct_id}`, true) localStorage.setItem(quoteMarker, true)
} }
const str = json['urls']['streaming_api'] const str = json['urls']['streaming_api']
if (str) { if (str) {
localStorage.setItem(`streaming_${acct_id}`, str) localStorage.setItem(`streaming_${domain}`, str)
} }
} }
} }
//アカウントを選択…を実装 //アカウントを選択…を実装
function multiSelector(parseC) { function multiSelector() {
if (!acctList) return false let obj = acctList
const obj = acctList //if (!obj) obj = JSON.parse(localStorage.getItem('multi'))
let template let template = ''
//StringなのはlocalStorageがStringしか返さないから //StringなのはlocalStorageがStringしか返さないから
let lastUsed = '0' let lastUsed = '0'
if (localStorage.getItem('mainuse') == 'main') { if (localStorage.getItem('mainuse') == 'main') {
@ -195,7 +200,7 @@ function multiSelector(parseC) {
} else { } else {
for (let i = 0; i < obj.length; i++) { for (let i = 0; i < obj.length; i++) {
const acct = obj[i] const acct = obj[i]
const strKey = i?.toString() const strKey = i.toString()
if (strKey == lastUsed) { if (strKey == lastUsed) {
sel = 'selected' sel = 'selected'
const domain = acct.domain const domain = acct.domain
@ -205,7 +210,7 @@ function multiSelector(parseC) {
textarea.setAttribute('data-length', letters) textarea.setAttribute('data-length', letters)
} else { } else {
//手動でアカマネで変えれちゃうから //手動でアカマネで変えれちゃうから
const maxLetters = localStorage.getItem('letters_' + strKey) const maxLetters = localStorage.getItem(`${domain}_letters`)
if (maxLetters > 0) { if (maxLetters > 0) {
textarea.setAttribute('data-length', maxLetters) textarea.setAttribute('data-length', maxLetters)
} else { } else {
@ -234,36 +239,37 @@ function multiSelector(parseC) {
if (domain == 'imastodon.net') { if (domain == 'imastodon.net') {
trendTag() trendTag()
} else { } else {
if(document.querySelector('#trendtag')) this.innerHTML = '' if (document.querySelector('#trendtag')) document.querySelector('#trendtag').innerHTML = ''
} }
} else { } else {
sel = '' sel = ''
} }
template = ` template = template + `
<option value="${strKey}" data-icon="${acct.prof}" class="left circle" ${sel}> <option value="${strKey}" data-icon="${acct.prof}" class="left circle" ${sel}>@${acct.user}@${acct.domain}
@${acct.user} ${acct.domain}
</option> </option>
` `
appendPrepend('.acct-sel', template, 'append')
} }
appendPrepend('#src-acct-sel', '<option value="tootsearch">Tootsearch</option>', 'append') const forSrc = template + '<option value="tootsearch">Tootsearch</option>'
appendPrepend('#add-acct-sel', ` const forAdd = template + `
<option value="noauth">${lang.lang_login_noauth}</option> <option value="noauth">${lang.lang_login_noauth}</option>
<option value="webview">Twitter</option> <option value="webview">Twitter</option>
`, 'append') `
appendPrepend('#dir-acct-sel', `<option value="noauth">${lang.lang_login_noauth}</option>`, 'append') const forDir = template + `<option value="noauth">${lang.lang_login_noauth}</option>`
} document.querySelector('#post-acct-sel').innerHTML = template
const elems = document.querySelectorAll('select'); document.querySelector('#list-acct-sel').innerHTML = template
M.FormSelect.init(elems, null); document.querySelector('#filter-acct-sel').innerHTML = template
if (!parseC) { document.querySelector('#src-acct-sel').innerHTML = forSrc
parseColumn(null, true) document.querySelector('#add-acct-sel').innerHTML = forAdd
document.querySelector('#dir-acct-sel').innerHTML = forDir
} }
const elems = document.querySelectorAll('select')
M.FormSelect.init(elems, null)
} }
//インスタンスティッカー //インスタンスティッカー
async function ticker() { async function ticker() {
const start = 'https://toot-app.thedesk.top/toot/index.php' const start = 'https://toot-app.thedesk.top/toot/index.php'
const json = await getApi(start, null) const json = await getApi(start, null)
if(json) localStorage.setItem('ticker', JSON.stringify(json)) if (json) localStorage.setItem('ticker', JSON.stringify(json))
} }
function isMisskey(domain) { function isMisskey(domain) {
return localStorage.getItem(`mode_${domain}`) == 'misskey' return localStorage.getItem(`mode_${domain}`) == 'misskey'

View File

@ -1,56 +1,30 @@
//アカウントマネージャ //アカウントマネージャ
//最初に読むやつ //最初に読むやつ
function load() { function load() {
$('#acct-list').html('') document.querySelector('#acct-list').innerHTML = ''
if (location.search) { if (location.search) {
var m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=(.+)/) const m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=(.+)/)
var mode = m[1] const mode = m[1]
var codex = m[2] const codex = m[2]
if (mode == 'first' && codex == 'true') { if (mode == 'first' && codex == 'true') {
$('body').addClass('first') setAllClasses('body', 'first', 'add')
} else {
} }
} }
var prof = localStorage.getItem('prof') const multi = localStorage.getItem('multi')
$('.my-prof').attr('src', prof) if (!multi) return false
var name = localStorage.getItem('name') const obj = JSON.parse(multi)
$('#now-name').text(name) let domains = []
var user = localStorage.getItem('user') let template = ''
$('#now-user').text(user) document.querySelector('#acct-list').innerHTML = ''
var domain = localStorage.getItem('domain') for (let i = 0; i < obj.length; i++) {
$('.now-domain').text(domain) const acct = obj[i]
var multi = localStorage.getItem('multi') const list = (parseInt(i) + 1).toString()
if (!multi) { let style = ''
var obj = [] if (acct.background != 'def' && acct.text != 'def') style = `style="background-color:#${acct.background}; color:${acct.text};"`
} else { let name = acct.user
var obj = JSON.parse(multi) if (acct.name) name = acct.name
}
if (obj[0]) {
if (!obj[0].at) {
obj = []
localStorage.removeItem('multi')
}
}
console.table(obj)
var domains = []
var templete
$('#acct-list').html('')
Object.keys(obj).forEach(function(key) {
var acct = obj[key]
var list = key * 1 + 1
if (acct.background != 'def' && acct.text != 'def') {
var style = 'style="background-color:#' + acct.background + '; color:' + acct.text + ';"'
} else {
var style = ''
}
if (acct.name) {
var name = acct.name
} else {
var name = acct.user
}
domains.push(acct.domain) domains.push(acct.domain)
templete = ` template = template + `
<div id="acct_${key}" class="card" ${style}> <div id="acct_${key}" class="card" ${style}>
<div class="card-content "> <div class="card-content ">
<span class="lts">${list}.</span><img src="${acct.prof}" width="40" height="40" /> <span class="lts">${list}.</span><img src="${acct.prof}" width="40" height="40" />
@ -67,70 +41,61 @@ function load() {
</div> </div>
</div> </div>
` `
$('#acct-list').append(templete) colorpicker(i)
colorpicker(key) }
}) document.querySelector('#acct-list').innerHTML = template
//lodash dependent
domains = _.uniq(domains) domains = _.uniq(domains)
$('#domain-list').html('') document.querySelector('#domain-list').innerHTML = ''
Object.keys(domains).forEach(function(key2) { const keymap = Object.keys(domains)
var domain = domains[key2] let templateDomainList = ''
if (localStorage.getItem('letters_' + key2)) { for(let j = 0; j < domains.length; j++) {
var maxChars = localStorage.getItem('letters_' + key2) const key = keymap[j]
} else { const domain = domains[key]
var maxChars = 500 let maxChars = 500
} const thisLtrs = localStorage.getItem(`${domain}_letters`)
var templete = ` if(thisLtrs) maxChars = thisLtrs
<li class="collection-item transparent"> templateDomainList = templateDomainList + `
<div> <li class="collection-item transparent">
<p class="title">${domain}</p> <div>
${lang.lang_manager_maxChars} <input style="width: 100px" value="${maxChars}" id="maxChars${key2}"> <p class="title">${domain}</p>
<button class="btn-flat waves-effect" onclick="maxChars('${domain}', '${key2}')"> ${lang.lang_manager_maxChars} <input style="width: 100px" value="${maxChars}" id="maxChars${key2}">
<i class="material-icons">send</i> <button class="btn-flat waves-effect" onclick="maxChars('${domain}', '${key2}')">
</button> <i class="material-icons">send</i>
<button class="btn-flat waves-effect secondary-content" onclick="data('${domain}', '${key2}')"> </button>
<i class="material-icons left">info</i>${lang.lang_manager_info} <button class="btn-flat waves-effect secondary-content" onclick="data('${domain}', '${key2}')">
</button> <i class="material-icons left">info</i>${lang.lang_manager_info}
</div></li> </button>
</div>
</li>
` `
$('#domain-list').append(templete) }
}) document.querySelector('#domain-list').innnerHTML = templateDomainList
multisel() multisel()
var acctN = localStorage.getItem('acct') let acctN = localStorage.getItem('acct')
if (!acctN) { if (!acctN) {
localStorage.setItem('acct', 0) localStorage.setItem('acct', 0)
var acctN = 0 acctN = 0
} }
//全部チェックアリでいいと思うの
$('#linux').prop('checked', true)
} }
//最初に読む //最初に読む
load() load()
support() support()
function maxChars(domain, uid) { function maxChars(domain, uid) {
var value = $('#maxChars' + uid).val() const value = document.querySelector(`#maxChars${uid}`).value
if(value*1 < 1 || !Number.isInteger(value*1)) { if (parseInt(value) < 1 || !Number.isInteger(parseInt(value))) {
Swal.fire({ Swal.fire({
type: 'error', type: 'error',
title: 'Error' title: 'Error'
}) })
return false return false
} }
var multi = localStorage.getItem('multi') const multi = localStorage.getItem('multi')
if (!multi) { if(!multi) return false
var obj = [] const obj = JSON.parse(multi)
} else { for(let k = 0; k < obj.length; k++) {
var obj = JSON.parse(multi) if (obj[k].domain == domain) localStorage.setItem(`${domain}_letters`, value)
} }
if (obj[0]) {
if (!obj[0].at) {
obj = []
localStorage.removeItem('multi')
}
}
Object.keys(obj).forEach(function(key) {
if(obj[key].domain == domain) localStorage.setItem('letters_' + key, value)
})
console.log('#maxChars' + uid, value)
load() load()
} }
//instances.social/instances API //instances.social/instances API
@ -208,7 +173,7 @@ function multiDel(target) {
cancelButtonText: lang.lang_no cancelButtonText: lang.lang_no
}).then(result => { }).then(result => {
if (result.value) { if (result.value) {
Object.keys(obj).forEach(function(key) { Object.keys(obj).forEach(function (key) {
var nk = key - 1 var nk = key - 1
//公開範囲(差分のみ) //公開範囲(差分のみ)
if (key >= target) { if (key >= target) {
@ -243,7 +208,7 @@ function multiDel(target) {
var col = localStorage.getItem('column') var col = localStorage.getItem('column')
var oldcols = JSON.parse(col) var oldcols = JSON.parse(col)
var newcols = [] var newcols = []
Object.keys(oldcols).forEach(function(key) { Object.keys(oldcols).forEach(function (key) {
var nk = key - 1 var nk = key - 1
var oldcol = oldcols[key] var oldcol = oldcols[key]
if (target < oldcol.domain) { if (target < oldcol.domain) {
@ -253,19 +218,19 @@ function multiDel(target) {
} }
var type = oldcol.type var type = oldcol.type
var data = null var data = null
if(oldcol.data) { if (oldcol.data) {
data = oldcol.data data = oldcol.data
} }
var background = null var background = null
if(oldcol.background) { if (oldcol.background) {
background = oldcol.background background = oldcol.background
} }
var text = null var text = null
if(oldcol.text) { if (oldcol.text) {
text = oldcol.text text = oldcol.text
} }
var left_fold = false var left_fold = false
if(oldcol.left_fold) { if (oldcol.left_fold) {
left_fold = true left_fold = true
} }
//消した垢のコラムじゃないときコピー //消した垢のコラムじゃないときコピー
@ -303,7 +268,7 @@ function multiDel2(target) {
obj.splice(target, 1) obj.splice(target, 1)
var json = JSON.stringify(obj) var json = JSON.stringify(obj)
localStorage.setItem('multi', json) localStorage.setItem('multi', json)
Object.keys(obj).forEach(function(key) { Object.keys(obj).forEach(function (key) {
if (key >= target) { if (key >= target) {
var oldvis = localStorage.getItem('vis-memory-' + key) var oldvis = localStorage.getItem('vis-memory-' + key)
if (oldvis) { if (oldvis) {
@ -331,7 +296,7 @@ function multiDel2(target) {
} else { } else {
var cobj = JSON.parse(col) var cobj = JSON.parse(col)
} }
Object.keys(cobj).forEach(function(key) { Object.keys(cobj).forEach(function (key) {
var column = cobj[key] var column = cobj[key]
if (column.domain > target) { if (column.domain > target) {
var nk = key - 1 var nk = key - 1
@ -351,7 +316,7 @@ function multiDel2(target) {
//サポートインスタンス //サポートインスタンス
function support() { function support() {
Object.keys(idata).forEach(function(key) { Object.keys(idata).forEach(function (key) {
var instance = idata[key] var instance = idata[key]
if (instance == 'instance') { if (instance == 'instance') {
templete = templete =
@ -399,7 +364,7 @@ function login(url) {
website: 'https://thedesk.top' website: 'https://thedesk.top'
}) })
) )
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) {
@ -437,20 +402,20 @@ function versionChecker(url) {
'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) {
var version = json.version var version = json.version
if (version) { if (version) {
var reg = version.match(/^([0-9])\.[0-9]\.[0-9]/u) var reg = version.match(/^([0-9])\.[0-9]\.[0-9]/u)
@ -476,25 +441,25 @@ function versionCompat(prefix, ver, title, real) {
'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) {
var complete = false var complete = false
var ct = 0 var ct = 0
var jl = 0 var jl = 0
var jl2 = 0 var jl2 = 0
Object.keys(json).forEach(function(key) { Object.keys(json).forEach(function (key) {
var data = json[key] var data = json[key]
if (data) { if (data) {
jl++ jl++
@ -581,7 +546,7 @@ function misskeyLogin(url) {
] ]
}) })
) )
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) {
@ -605,7 +570,7 @@ function misskeyAuth(url, mkc) {
appSecret: mkc appSecret: mkc
}) })
) )
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) {
@ -657,7 +622,7 @@ function code(code) {
appSecret: localStorage.getItem('mkc') appSecret: localStorage.getItem('mkc')
}) })
) )
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) {
@ -716,7 +681,7 @@ function code(code) {
code: code code: code
}) })
) )
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) {
@ -741,20 +706,20 @@ function getdata(domain, at) {
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.error) { if (json.error) {
console.error('Error:' + json.error) console.error('Error:' + json.error)
M.toast({ html: lang.lang_fatalerroroccured + 'Error:' + json.error, displayLength: 5000 }) M.toast({ html: lang.lang_fatalerroroccured + 'Error:' + json.error, displayLength: 5000 })
@ -862,25 +827,25 @@ function refresh(target) {
Authorization: 'Bearer ' + obj[target].at Authorization: 'Bearer ' + obj[target].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)
}) })
} }
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.error) { if (json.error) {
console.error('Error:' + json.error) console.error('Error:' + json.error)
M.toast({ html: lang.lang_fatalerroroccured + 'Error:' + json.error, displayLength: 5000 }) M.toast({ html: lang.lang_fatalerroroccured + 'Error:' + json.error, displayLength: 5000 })
@ -934,7 +899,7 @@ function misskeyRefresh(obj, target, url) {
i: obj[target].at i: obj[target].at
}) })
) )
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) {
@ -983,7 +948,7 @@ function multisel() {
$('#src-acct-sel').html('<option value="tootsearch">Tootsearch</option>') $('#src-acct-sel').html('<option value="tootsearch">Tootsearch</option>')
$('#add-acct-sel').html('<option value="noauth">' + lang.lang_login_noauth + '</option>') $('#add-acct-sel').html('<option value="noauth">' + lang.lang_login_noauth + '</option>')
} else { } else {
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) {
@ -1073,10 +1038,10 @@ var oldSuggest
var suggest var suggest
input.addEventListener( input.addEventListener(
'focus', 'focus',
function() { function () {
$('#ins-suggest').html('') $('#ins-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 (prev_val != new_val) { if (prev_val != new_val) {
if (new_val.length > 3) { if (new_val.length > 3) {
@ -1089,23 +1054,23 @@ input.addEventListener(
'Bearer tC8F6xWGWBUwGScyNevYlx62iO6fdQ4oIK0ad68Oo7ZKB8GQdGpjW9TKxBnIh8grAhvd5rw3iyP9JPamoDpeLQdz62EToPJUW99hDx8rfuJfGdjQuimZPTbIOx0woA5M' 'Bearer tC8F6xWGWBUwGScyNevYlx62iO6fdQ4oIK0ad68Oo7ZKB8GQdGpjW9TKxBnIh8grAhvd5rw3iyP9JPamoDpeLQdz62EToPJUW99hDx8rfuJfGdjQuimZPTbIOx0woA5M'
} }
}) })
.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.error) { if (!json.error) {
var urls = 'Suggest:' var urls = 'Suggest:'
Object.keys(json.instances).forEach(function(key) { Object.keys(json.instances).forEach(function (key) {
var url = json.instances[key] var url = json.instances[key]
urls = urls =
urls + urls +
@ -1127,7 +1092,7 @@ input.addEventListener(
input.addEventListener( input.addEventListener(
'blur', 'blur',
function() { function () {
window.clearInterval(timer) window.clearInterval(timer)
}, },
false false

View File

@ -314,7 +314,7 @@ function appendPrepend(query, elm, action) {
const allTarget = document.querySelectorAll(query) const allTarget = document.querySelectorAll(query)
for (let i = 0; i < allTarget.length; i++) { for (let i = 0; i < allTarget.length; i++) {
const target = allTarget[i] const target = allTarget[i]
if (action == 'prepend') target.prependChild(document.createTextNode(elm)) if (action == 'prepend') target.insertBefore(elm, target.firstChild)
if (action == 'append') target.appendChild(document.createTextNode(elm)) if (action == 'append') target.appendChild(document.createTextNode(elm))
} }
} }

View File

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

View File

@ -42,7 +42,6 @@ function parseColumn(target, dontclose) {
var multi = localStorage.getItem('multi') var multi = localStorage.getItem('multi')
if (multi) { if (multi) {
var obj = JSON.parse(multi) var obj = JSON.parse(multi)
var templete var templete
Object.keys(obj).forEach(function (key) { Object.keys(obj).forEach(function (key) {
var acct = obj[key] var acct = obj[key]
@ -102,6 +101,7 @@ function parseColumn(target, dontclose) {
$('.box, .boxIn').resizable('destroy') $('.box, .boxIn').resizable('destroy')
} }
} }
console.log(obj)
var basekey = 0 var basekey = 0
for (var key = 0; key < obj.length; key++) { for (var key = 0; key < obj.length; key++) {
var next = key + 1 var next = key + 1
@ -508,6 +508,8 @@ function parseColumn(target, dontclose) {
} }
} }
} }
console.log('multiSelector')
multiSelector()
$('.box, .boxIn').resizable({ $('.box, .boxIn').resizable({
minHeight: 50, minHeight: 50,
minWidth: 50, minWidth: 50,

View File

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

View File

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

View File

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