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

@ -56,12 +56,12 @@ async function ck() {
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')
} }
@ -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,30 +239,31 @@ 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() {

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,19 +41,21 @@ function load() {
</div> </div>
</div> </div>
` `
$('#acct-list').append(templete) colorpicker(i)
colorpicker(key)
})
domains = _.uniq(domains)
$('#domain-list').html('')
Object.keys(domains).forEach(function(key2) {
var domain = domains[key2]
if (localStorage.getItem('letters_' + key2)) {
var maxChars = localStorage.getItem('letters_' + key2)
} else {
var maxChars = 500
} }
var templete = ` document.querySelector('#acct-list').innerHTML = template
//lodash dependent
domains = _.uniq(domains)
document.querySelector('#domain-list').innerHTML = ''
const keymap = Object.keys(domains)
let templateDomainList = ''
for(let j = 0; j < domains.length; j++) {
const key = keymap[j]
const domain = domains[key]
let maxChars = 500
const thisLtrs = localStorage.getItem(`${domain}_letters`)
if(thisLtrs) maxChars = thisLtrs
templateDomainList = templateDomainList + `
<li class="collection-item transparent"> <li class="collection-item transparent">
<div> <div>
<p class="title">${domain}</p> <p class="title">${domain}</p>
@ -90,47 +66,36 @@ function load() {
<button class="btn-flat waves-effect secondary-content" onclick="data('${domain}', '${key2}')"> <button class="btn-flat waves-effect secondary-content" onclick="data('${domain}', '${key2}')">
<i class="material-icons left">info</i>${lang.lang_manager_info} <i class="material-icons left">info</i>${lang.lang_manager_info}
</button> </button>
</div></li> </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

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

@ -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 });
} }
//オールリセット //オールリセット

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>