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) {
showElm('#tl')
ticker()
multiSelector(false)
parseColumn()
verck(ver)
showElm('.stw')
const tips = localStorage.getItem('tips')
if (tips) {
tips(tips)
const tipsType = localStorage.getItem('tips')
if (tipsType) {
tips(tipsType)
}
document.querySelector('#something-wrong img').setAttribute('src', '../../img/thinking.svg')
}
@ -131,7 +131,7 @@ async function refresh(target, loadskip) {
}
//MarkdownやBBCodeの対応、文字数制限をチェック
//絶対ストリーミングを閉じさせないマン
function ckdb(acct_id) {
async function ckdb(acct_id) {
const domain = localStorage.getItem(`domain_${acct_id}`)
if (domain == 'kirishima.cloud') {
localStorage.setItem('kirishima', true)
@ -148,34 +148,39 @@ function ckdb(acct_id) {
var json = idata
if (json[quoteMarker] == 'enabled') {
localStorage.setItem('quoters', true)
localStorage.setItem(`quote_${acct_id}`, true)
localStorage.setItem(quoteMarker, true)
}
}
if (!isMisskey(domain)) {
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) {
return
}
const mtc = json['max_toot_chars']
if (mtc) {
localStorage.setItem(`letters_${acct_id}`, mtc)
localStorage.setItem(letters, mtc)
}
if (json['feature_quote']) {
localStorage.setItem(`quote_${acct_id}`, true)
localStorage.setItem(quoteMarker, true)
}
const str = json['urls']['streaming_api']
if (str) {
localStorage.setItem(`streaming_${acct_id}`, str)
localStorage.setItem(`streaming_${domain}`, str)
}
}
}
//アカウントを選択…を実装
function multiSelector(parseC) {
if (!acctList) return false
const obj = acctList
let template
function multiSelector() {
let obj = acctList
//if (!obj) obj = JSON.parse(localStorage.getItem('multi'))
let template = ''
//StringなのはlocalStorageがStringしか返さないから
let lastUsed = '0'
if (localStorage.getItem('mainuse') == 'main') {
@ -195,7 +200,7 @@ function multiSelector(parseC) {
} else {
for (let i = 0; i < obj.length; i++) {
const acct = obj[i]
const strKey = i?.toString()
const strKey = i.toString()
if (strKey == lastUsed) {
sel = 'selected'
const domain = acct.domain
@ -205,7 +210,7 @@ function multiSelector(parseC) {
textarea.setAttribute('data-length', letters)
} else {
//手動でアカマネで変えれちゃうから
const maxLetters = localStorage.getItem('letters_' + strKey)
const maxLetters = localStorage.getItem(`${domain}_letters`)
if (maxLetters > 0) {
textarea.setAttribute('data-length', maxLetters)
} else {
@ -234,30 +239,31 @@ function multiSelector(parseC) {
if (domain == 'imastodon.net') {
trendTag()
} else {
if(document.querySelector('#trendtag')) this.innerHTML = ''
if (document.querySelector('#trendtag')) document.querySelector('#trendtag').innerHTML = ''
}
} else {
sel = ''
}
template = `
<option value="${strKey}" data-icon="${acct.prof}" class="left circle" ${sel}>
@${acct.user} ${acct.domain}
template = template + `
<option value="${strKey}" data-icon="${acct.prof}" class="left circle" ${sel}>@${acct.user}@${acct.domain}
</option>
`
appendPrepend('.acct-sel', template, 'append')
}
appendPrepend('#src-acct-sel', '<option value="tootsearch">Tootsearch</option>', 'append')
appendPrepend('#add-acct-sel', `
const forSrc = template + '<option value="tootsearch">Tootsearch</option>'
const forAdd = template + `
<option value="noauth">${lang.lang_login_noauth}</option>
<option value="webview">Twitter</option>
`, 'append')
appendPrepend('#dir-acct-sel', `<option value="noauth">${lang.lang_login_noauth}</option>`, 'append')
}
const elems = document.querySelectorAll('select');
M.FormSelect.init(elems, null);
if (!parseC) {
parseColumn(null, true)
`
const forDir = template + `<option value="noauth">${lang.lang_login_noauth}</option>`
document.querySelector('#post-acct-sel').innerHTML = template
document.querySelector('#list-acct-sel').innerHTML = template
document.querySelector('#filter-acct-sel').innerHTML = template
document.querySelector('#src-acct-sel').innerHTML = forSrc
document.querySelector('#add-acct-sel').innerHTML = forAdd
document.querySelector('#dir-acct-sel').innerHTML = forDir
}
const elems = document.querySelectorAll('select')
M.FormSelect.init(elems, null)
}
//インスタンスティッカー
async function ticker() {

View File

@ -1,56 +1,30 @@
//アカウントマネージャ
//最初に読むやつ
function load() {
$('#acct-list').html('')
document.querySelector('#acct-list').innerHTML = ''
if (location.search) {
var m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=(.+)/)
var mode = m[1]
var codex = m[2]
const m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=(.+)/)
const mode = m[1]
const codex = m[2]
if (mode == 'first' && codex == 'true') {
$('body').addClass('first')
} else {
setAllClasses('body', 'first', 'add')
}
}
var prof = localStorage.getItem('prof')
$('.my-prof').attr('src', prof)
var name = localStorage.getItem('name')
$('#now-name').text(name)
var user = localStorage.getItem('user')
$('#now-user').text(user)
var domain = localStorage.getItem('domain')
$('.now-domain').text(domain)
var multi = localStorage.getItem('multi')
if (!multi) {
var obj = []
} else {
var obj = JSON.parse(multi)
}
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
}
const multi = localStorage.getItem('multi')
if (!multi) return false
const obj = JSON.parse(multi)
let domains = []
let template = ''
document.querySelector('#acct-list').innerHTML = ''
for (let i = 0; i < obj.length; i++) {
const acct = obj[i]
const list = (parseInt(i) + 1).toString()
let style = ''
if (acct.background != 'def' && acct.text != 'def') style = `style="background-color:#${acct.background}; color:${acct.text};"`
let name = acct.user
if (acct.name) name = acct.name
domains.push(acct.domain)
templete = `
template = template + `
<div id="acct_${key}" class="card" ${style}>
<div class="card-content ">
<span class="lts">${list}.</span><img src="${acct.prof}" width="40" height="40" />
@ -67,19 +41,21 @@ function load() {
</div>
</div>
`
$('#acct-list').append(templete)
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
colorpicker(i)
}
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">
<div>
<p class="title">${domain}</p>
@ -90,47 +66,36 @@ function load() {
<button class="btn-flat waves-effect secondary-content" onclick="data('${domain}', '${key2}')">
<i class="material-icons left">info</i>${lang.lang_manager_info}
</button>
</div></li>
</div>
</li>
`
$('#domain-list').append(templete)
})
}
document.querySelector('#domain-list').innnerHTML = templateDomainList
multisel()
var acctN = localStorage.getItem('acct')
let acctN = localStorage.getItem('acct')
if (!acctN) {
localStorage.setItem('acct', 0)
var acctN = 0
acctN = 0
}
//全部チェックアリでいいと思うの
$('#linux').prop('checked', true)
}
//最初に読む
load()
support()
function maxChars(domain, uid) {
var value = $('#maxChars' + uid).val()
if(value*1 < 1 || !Number.isInteger(value*1)) {
const value = document.querySelector(`#maxChars${uid}`).value
if (parseInt(value) < 1 || !Number.isInteger(parseInt(value))) {
Swal.fire({
type: 'error',
title: 'Error'
})
return false
}
var multi = localStorage.getItem('multi')
if (!multi) {
var obj = []
} else {
var obj = JSON.parse(multi)
const multi = localStorage.getItem('multi')
if(!multi) return false
const obj = JSON.parse(multi)
for(let k = 0; k < obj.length; k++) {
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()
}
//instances.social/instances API

View File

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

View File

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

View File

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

View File

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

View File

@ -482,7 +482,7 @@ function profbrws() {
function setMain() {
var acct_id = $("#his-data").attr("use-acct");
localStorage.setItem("main", acct_id);
multiSelector(true);
multiSelector();
M.toast({ html: lang.lang_manager_mainAcct, displayLength: 3000 });
}
//オールリセット

View File

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