Fix: max_toot_chars, Add: custom max_chars, Add: domain list

This commit is contained in:
cutls 2019-12-19 01:00:17 +09:00
parent b2d98948d2
commit eccdee7446
7 changed files with 320 additions and 251 deletions

76
app/css/acct.css Normal file
View File

@ -0,0 +1,76 @@
.acct {
display: flex;
justify-content: space-around;
}
.card {
width: 400px;
background-color: #494949;
margin: 10px;
}
body,
html {
overflow-y: scroll;
}
#acct-list {
display: flex;
flex-wrap: wrap;
color: white;
align-items: flex-start;
}
.lts {
font-size: 150%;
}
.colorsel {
display: flex;
}
.card .colorsel div:not(.exc) {
width: 20px;
height: 20px;
}
.card .colorsel div.exc {
width: 40px;
height: 20px;
}
.first {
display: flex;
justify-content: center;
align-items: center;
}
.first .hide-first {
display: none;
}
#compt {
margin-top: 20px;
margin-bottom: 50px;
border: 1px solid;
border: 1px solid;
padding: 5px;
}
#compt li {
list-style-type: disc;
margin-left: 20px;
}
#domain-list {
width: 500px;
max-width: 100%;
}
i.left {
margin-right: 5px;
}
#domain-list .title {
font-size: 1.3rem;
}

View File

@ -785,6 +785,7 @@ audio {
padding-right: 3px; padding-right: 3px;
border-radius: 3px; border-radius: 3px;
border: 1px solid var(--color); border: 1px solid var(--color);
user-select: none;
} }
.vis-data { .vis-data {
font-size: 1rem !important; font-size: 1rem !important;

View File

@ -33,7 +33,9 @@ function load() {
} }
console.table(obj) console.table(obj)
var domains = []
var templete var templete
$('#acct-list').html('')
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
@ -47,6 +49,7 @@ function load() {
} else { } else {
var name = acct.user var name = acct.user
} }
domains.push(acct.domain)
templete = ` templete = `
<div id="acct_${key}" class="card" ${style}> <div id="acct_${key}" class="card" ${style}>
<div class="card-content "> <div class="card-content ">
@ -54,15 +57,12 @@ function load() {
<span class="card-title">${name}</span>${escapeHTML(acct.user)}@${acct.domain} <span class="card-title">${name}</span>${escapeHTML(acct.user)}@${acct.domain}
</div> </div>
<div class="card-action"> <div class="card-action">
<a class="waves-effect disTar pointer white-text" onclick="data('${acct.domain}')"> <button class="btn-flat waves-effect disTar pointer white-text" onclick="refresh('${key}')">
<i class="material-icons">info</i>${lang.lang_manager_info} <i class="material-icons left">refresh</i>${lang.lang_manager_refresh}
</a> </button>
<a class="waves-effect disTar pointer white-text" onclick="refresh('${key}')"> <button class="btn-flat waves-effect disTar pointer red-text" onclick="multiDel('${key}')">
<i class="material-icons">refresh</i>${lang.lang_manager_refresh} <i class="material-icons left">delete</i>${lang.lang_manager_delete}
</a> </button><br />${lang.lang_manager_color}
<a class="waves-effect disTar pointer red-text" onclick="multiDel('${key}')">
<i class="material-icons">delete</i>${lang.lang_manager_delete}"
</a><br />${lang.lang_manager_color}
<div id="colorsel_${key}" class="colorsel"></div> <div id="colorsel_${key}" class="colorsel"></div>
</div> </div>
</div> </div>
@ -70,6 +70,30 @@ function load() {
$('#acct-list').append(templete) $('#acct-list').append(templete)
colorpicker(key) 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 = `
<li class="collection-item transparent">
<div>
<p class="title">${domain}</p>
${lang.lang_manager_maxChars} <input style="width: 100px" value="${maxChars}" id="maxChars${key2}">
<button class="btn-flat waves-effect" onclick="maxChars('${domain}', '${key2}')">
<i class="material-icons">send</i>
</button>
<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>
`
$('#domain-list').append(templete)
})
multisel() multisel()
var acctN = localStorage.getItem('acct') var acctN = localStorage.getItem('acct')
if (!acctN) { if (!acctN) {
@ -82,9 +106,35 @@ function load() {
//最初に読む //最初に読む
load() load()
support() support()
function maxChars(domain, uid) {
var value = $('#maxChars' + uid).val()
if(value*1 < 1 || !Number.isInteger(value*1)) {
Swal.fire({
type: 'error',
title: 'Error'
})
return false
}
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')
}
}
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 //instances.social/instances API
function data(domain) { async function data(domain, acct_id) {
$('#ins-upd').text('Loading...') $('#ins-upd').text('Loading...')
$('#ins-add').text('Loading...') $('#ins-add').text('Loading...')
$('#ins-connect').text('Loading...') $('#ins-connect').text('Loading...')
@ -96,7 +146,7 @@ function data(domain) {
$('#ins-name').text('Loading...') $('#ins-name').text('Loading...')
$('#ins-prof').attr('src', '../../img/loading.svg') $('#ins-prof').attr('src', '../../img/loading.svg')
var start = 'https://instances.social/api/1.0/instances/show?name=' + domain var start = 'https://instances.social/api/1.0/instances/show?name=' + domain
fetch(start, { let promise = await fetch(start, {
method: 'GET', method: 'GET',
headers: { headers: {
'content-type': 'application/json', 'content-type': 'application/json',
@ -104,74 +154,42 @@ function data(domain) {
'Bearer tC8F6xWGWBUwGScyNevYlx62iO6fdQ4oIK0ad68Oo7ZKB8GQdGpjW9TKxBnIh8grAhvd5rw3iyP9JPamoDpeLQdz62EToPJUW99hDx8rfuJfGdjQuimZPTbIOx0woA5M' 'Bearer tC8F6xWGWBUwGScyNevYlx62iO6fdQ4oIK0ad68Oo7ZKB8GQdGpjW9TKxBnIh8grAhvd5rw3iyP9JPamoDpeLQdz62EToPJUW99hDx8rfuJfGdjQuimZPTbIOx0woA5M'
} }
}) })
.then(function(response) { var json = await promise.json()
if (!response.ok) { $('#ins-name').text(json.name)
response.text().then(function(text) { $('#ins-upd').text(date(json.checked_at, 'full'))
setLog(response.url, response.status, text) $('#ins-add').text(date(json.added_at, 'full'))
}) $('#ins-connect').text(json.connections)
} $('#ins-toot').text(json.statuses)
return response.json() $('#ins-sys').text(date(json.updated_at, 'full'))
}) $('#ins-per').text(json.uptime * 100)
.catch(function(error) { $('#ins-user').text(json.users)
todo(error) $('#ins-ver').text(json.version)
setLog(start, 'JSON', error)
console.error(error)
})
.then(function(json) {
if (!json.error) {
$('#ins-name').text(json.name)
$('#ins-upd').text(date(json.checked_at, 'full'))
$('#ins-add').text(date(json.added_at, 'full'))
$('#ins-connect').text(json.connections)
$('#ins-toot').text(json.statuses)
$('#ins-sys').text(date(json.updated_at, 'full'))
$('#ins-per').text(json.uptime * 100)
$('#ins-user').text(json.users)
$('#ins-ver').text(json.version)
} else {
console.error(json.error)
}
})
var start = 'https://' + domain + '/api/v1/instance' var start = 'https://' + domain + '/api/v1/instance'
fetch(start, { let promise2 = await fetch(start, {
method: 'GET', method: 'GET',
headers: { headers: {
'content-type': 'application/json' 'content-type': 'application/json'
} }
}) })
.then(function(response) { var json = await promise2.json()
if (!response.ok) { $('#ins-title').text(json.title)
response.text().then(function(text) { $('#ins-desc').html(json.description)
setLog(response.url, response.status, text) $('#ins-email').text(json.email)
}) $('#ins-toot').text(json.stats.status_count)
} $('#ins-user').text(json.stats.user_count)
return response.json() $('#ins-ver').text(json.version)
}) $('#ins-prof').attr('src', json.thumbnail)
.catch(function(error) { $('#ins-admin').text(
todo(error) escapeHTML(json.contact_account.display_name) + '(' + json.contact_account.acct + ')'
setLog(start, 'JSON', error) )
console.error(error) $('#ins-admin').attr(
}) 'href',
.then(function(json) { 'index.html?mode=user&code=' + json.contact_account.username + '@' + domain
if (!json.error) { )
$('#ins-title').text(json.title) if (json['max_toot_chars']) {
$('#ins-desc').html(json.description) localStorage.setItem('letters_' + acct_id, json['max_toot_chars'])
$('#ins-email').text(json.email) load()
$('#ins-toot').text(json.stats.status_count) }
$('#ins-user').text(json.stats.user_count)
$('#ins-ver').text(json.version)
$('#ins-prof').attr('src', json.thumbnail)
$('#ins-admin').text(
escapeHTML(json.contact_account.display_name) + '(' + json.contact_account.acct + ')'
)
$('#ins-admin').attr(
'href',
'index.html?mode=user&code=' + json.contact_account.username + '@' + domain
)
} else {
console.error(json.error)
}
})
} }
//アカウントデータ 消す //アカウントデータ 消す

View File

@ -50,7 +50,12 @@ 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 {
$('#textarea').attr('data-length', 500) var maxletters = localStorage.getItem('letters_' + acct_id)
if (maxletters > 0) {
$('#textarea').attr('data-length', maxletters)
} else {
$('#textarea').attr('data-length', 500)
}
} }
if (idata[domain + '_glitch'] === 'true') { if (idata[domain + '_glitch'] === 'true') {
$('#local-button').removeClass('hide') $('#local-button').removeClass('hide')

View File

@ -1,178 +1,145 @@
<!doctype html> <!DOCTYPE html>
<html lang="@@lang@@"> <html lang="@@lang@@">
<head>
<title>Account Manager - TheDesk</title>
<meta content="width=device-width,initial-scale=1.0" name="viewport" />
<link
href="../../node_modules/materialize-css/dist/css/materialize.css"
type="text/css"
rel="stylesheet"
/>
<link href="../../css/themes.css" type="text/css" rel="stylesheet" />
<link href="../../css/master.css" type="text/css" rel="stylesheet" />
<link href="../../css/tl.css" rel="stylesheet" type="text/css" />
<link href="../../css/userdata.css" rel="stylesheet" type="text/css" />
<link
href="../../node_modules/@fortawesome/fontawesome-free/css/all.min.css"
type="text/css"
rel="stylesheet"
/>
<link href="../../css/acct.css" rel="stylesheet" type="text/css" />
<meta charset="utf-8" />
@@comment-start@@
<script type="text/javascript">
var _jipt = []
_jipt.push(['project', 'thedesk'])
</script>
<script type="text/javascript" src="https://cdn.crowdin.com/jipt/jipt.js"></script>
@@comment-end@@
</head>
<head> <body id="mainView">
<title>Account Manager - TheDesk</title> <script type="text/javascript" src="../../node_modules/jquery/dist/jquery.js"></script>
<meta content="width=device-width,initial-scale=1.0" name="viewport"> <script type="text/javascript" src="../../js/platform/first.js"></script>
<link href="../../node_modules/materialize-css/dist/css/materialize.css" type="text/css" rel="stylesheet"> <script
<link href="../../css/themes.css" type="text/css" rel="stylesheet"> type="text/javascript"
<link href="../../css/master.css" type="text/css" rel="stylesheet"> src="../../node_modules/materialize-css/dist/js/materialize.js"
<link href="../../css/tl.css" rel="stylesheet" type="text/css"> ></script>
<link href="../../css/userdata.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="main.js"></script>
<link href="../../node_modules/@fortawesome/fontawesome-free/css/all.min.css" type="text/css" rel="stylesheet"> <script
<style> type="text/javascript"
.acct { src="../../node_modules/sweetalert2/dist/sweetalert2.all.min.js"
display: flex; ></script>
justify-content: space-around; <script>
} var misskeytoken = false
</script>
.card { <script type="text/javascript" src="../../js/common/time.js"></script>
width: 400px; <div class="hide-first">
background-color: #9e9e9e; <a href="index.html" class="btn waves-effect orange nex" style="width:100%; max-width:200px;"
margin: 10px; >@@back@@</a
} ><br />
<h5>@@list@@</h5>
body, <div id="acct-list"></div>
html { <div class="divider"></div>
overflow-y: scroll; </div>
} <div>
<h5>@@add@@</h5>
#acct-list { <br />
display: flex; <div id="add">
flex-wrap: wrap; <div class="row">
color: white; <div class="col s8">
align-items: flex-start <input type="text" id="url" style="width:70%" placeholder="ex)mstdn.jp" />
} <div id="ins-suggest"></div>
@@codesetupwarn@@<br />
.lts { <label>
font-size: 150% <input type="checkbox" class="filled-in" id="linux" />
} <span>@@codesetup@@</span>
</label>
.colorsel { <br />
display: flex; <label>
} <input type="checkbox" class="filled-in" id="misskey" />
<span>@@thisismisskey@@</span> </label
.card .colorsel div:not(.exc) { ><br />
width: 20px; <button class="btn waves-effect" onclick="instance()">Login</button><br />
height: 20px; </div>
} <div class="col s4">
<span style="font-family:Open Sans;">Supports</span>
.card .colorsel div.exc { <div id="support" class="collection transparent"></div>
width: 40px; </div>
height: 20px; </div>
} </div>
<div id="auth" style="display:none">
.first { @@codepastewarn@@<br />
display: flex; <input type="text" id="code" placeholder="@@codepaste@@" required />
justify-content: center; <button class="btn waves-effect" onclick="code()">Auth</button><br />
align-items: center <br />
} <a onclick="atSetup()" class="pointer">@@accessTokenSetup@@</a>
<div id="compt" style="display:none">
.first .hide-first { <h5>ログイン前に必ずご確認ください</h5>
display: none; <span id="compt-instance"></span>はバージョンが<span id="compt-ver"></span
} >のため以下の機能がご利用いただけません。
<span id="compt-warn" style="display:none"
#compt { >また、このインスタンスはMastodonではなくそのAPI上の互換実装であり、TheDeskでは利用を想定していないため非保証となります。</span
margin-top: 20px; >
margin-bottom: 50px; <ul id="compt-list"></ul>
border: 1px solid; </div>
border: 1px solid; </div>
padding: 5px; <div id="misskeylogin" style="display:none">
} <h5>AppSecret</h5>
@@misskeylogin@@<br />
#compt li { <input type="hidden" id="misskey-url" />
list-style-type: disc; <input type="text" id="misskey-key" placeholder="@@codepaste@@" required />
margin-left: 20px; <button class="btn waves-effect" onclick="misskeyLogin()">Auth</button><br />
} <br />
</style> <a onclick="atSetup('misskey')" class="pointer">@@accessTokenSetup@@</a>
<meta charset="utf-8"> </div>
@@comment-start@@ </div>
<script type="text/javascript"> <div class="hide-first">
var _jipt = []; <h5>@@mainacct@@</h5>
_jipt.push(['project', 'thedesk']); <div class="input-field" style="width:300px">
</script> <span data-trans="your_acct">@@selacct@@</span>
<script type="text/javascript" src="https://cdn.crowdin.com/jipt/jipt.js"></script> <br />
@@comment-end@@ <select
</head> id="main-acct-sel"
class="acct-sel"
<body id="mainView"> style="color:black"
<script type="text/javascript" src="../../node_modules/jquery/dist/jquery.js"></script> onchange="mainacct()"
<script type="text/javascript" src="../../js/platform/first.js"></script> ></select>
<script type="text/javascript" src="../../node_modules/materialize-css/dist/js/materialize.js"></script> <label></label>
<script type="text/javascript" src="main.js"></script> </div>
<script type="text/javascript" src="../../node_modules/sweetalert2/dist/sweetalert2.all.min.js"></script> <ul id="domain-list" class="collection transparent"></ul>
<script> <div id="instance-data">
var misskeytoken = false; Some instance data by
</script> <a href="https://instances.social" target="_blank">instances.social API</a><br />
<script type="text/javascript" src="../../js/common/time.js"></script> <h5 id="ins-title"></h5>
<div class="hide-first"> Administered by:<a id="ins-admin"></a><br />
<a href="index.html" class="btn waves-effect orange nex" <span id="ins-desc"></span><br />
style="width:100%; max-width:200px;">@@back@@</a><br> <img src="../../img/loading.svg" id="ins-prof" width="200" /><br />
<h5>@@list@@</h5> <br />
<div id="acct-list"></div> @@domain@@:<span id="ins-name"></span><br />
<div class="divider"></div> @@connect@@:<span id="ins-connect"></span>@@ko@@<br />
</div> @@toots@@:<span id="ins-toot"></span>@@ko@@<br />
<div> @@users@@:<span id="ins-user"></span>@@users@@<br />
<h5>@@add@@</h5><br> @@safety@@:<span id="ins-per"></span>%<br />
<div id="add"> @@ver@@:<span id="ins-ver"></span>@<span id="ins-upd"></span><br />
<div class="row"> </div>
<div class="col s8"> </div>
<input type="text" id="url" style="width:70%" placeholder="ex)mstdn.jp"> <script type="text/javascript" src="../../js/ui/theme.js"></script>
<div id="ins-suggest"></div> <script type="text/javascript" src="../../js/platform/end.js"></script>
@@codesetupwarn@@<br> <script type="text/javascript" src="../../js/common/sha256.js"></script>
<label> <script type="text/javascript" src="../../node_modules/lodash/lodash.min.js"></script>
<input type="checkbox" class="filled-in" id="linux" /> <script type="text/javascript" src="../../js/login/instance.js"></script>
<span>@@codesetup@@</span> <script type="text/javascript" src="../../js/login/manager.js"></script>
</label> <script type="text/javascript" src="../../js/tl/date.js"></script>
<br> </body>
<label> </html>
<input type="checkbox" class="filled-in" id="misskey" />
<span>@@thisismisskey@@</span>
</label><br>
<button class="btn waves-effect" onclick="instance()">Login</button><br>
</div>
<div class="col s4">
<span style="font-family:Open Sans;">Supports</span>
<div id="support" class="collection transparent"></div>
</div>
</div>
</div>
<div id="auth" style="display:none">
@@codepastewarn@@<br>
<input type="text" id="code" placeholder="@@codepaste@@" required>
<button class="btn waves-effect" onclick="code()">Auth</button><br>
<br>
<a onclick="atSetup()" class="pointer">@@accessTokenSetup@@</a>
<div id="compt" style="display:none">
<h5>ログイン前に必ずご確認ください</h5>
<span id="compt-instance"></span>はバージョンが<span id="compt-ver"></span>のため以下の機能がご利用いただけません。
<span id="compt-warn" style="display:none">また、このインスタンスはMastodonではなくそのAPI上の互換実装であり、TheDeskでは利用を想定していないため非保証となります。</span>
<ul id="compt-list"></ul>
</div>
</div>
<div id="misskeylogin" style="display:none">
<h5>AppSecret</h5>
@@misskeylogin@@<br>
<input type="hidden" id="misskey-url">
<input type="text" id="misskey-key" placeholder="@@codepaste@@" required>
<button class="btn waves-effect" onclick="misskeyLogin()">Auth</button><br>
<br>
<a onclick="atSetup('misskey')" class="pointer">@@accessTokenSetup@@</a>
</div>
</div>
<div class="hide-first">
<h5>@@mainacct@@</h5>
<div class="input-field" style="width:300px"><span data-trans="your_acct">@@selacct@@</span>
<br>
<select id="main-acct-sel" class="acct-sel" style="color:black" onchange="mainacct()"></select>
<label></label>
</div>
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>
<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>
</div>
<script type="text/javascript" src="../../js/ui/theme.js"></script>
<script type="text/javascript" src="../../js/platform/end.js"></script>
<script type="text/javascript" src="../../js/common/sha256.js"></script>
<script type="text/javascript" src="../../js/login/instance.js"></script>
<script type="text/javascript" src="../../js/login/manager.js"></script>
<script type="text/javascript" src="../../js/tl/date.js"></script>

View File

@ -48,6 +48,7 @@
"lang_manager_none": "None", "lang_manager_none": "None",
"lang_manager_godev": "Open DevCenter of Misskey. We show also an official documents to refer.", "lang_manager_godev": "Open DevCenter of Misskey. We show also an official documents to refer.",
"lang_manager_logout": "Logout", "lang_manager_logout": "Logout",
"lang_manager_maxChars": "Max chars of toots",
"lang_bbmd_misskey": "TheDesk regards \"@\" as reply, but put other parameter. Unlisted on Mastodon means Home on Misskey.", "lang_bbmd_misskey": "TheDesk regards \"@\" as reply, but put other parameter. Unlisted on Mastodon means Home on Misskey.",
"lang_emoji_get": "Get emojis", "lang_emoji_get": "Get emojis",
"lang_emoji_custom": "Custom emojis", "lang_emoji_custom": "Custom emojis",

View File

@ -48,6 +48,7 @@
"lang_manager_none": "なし", "lang_manager_none": "なし",
"lang_manager_godev": "MisskeyのDevセンターに移動します。同時に開かれるドキュメントを参考にログインしてください。", "lang_manager_godev": "MisskeyのDevセンターに移動します。同時に開かれるドキュメントを参考にログインしてください。",
"lang_manager_logout": "ログアウト", "lang_manager_logout": "ログアウト",
"lang_manager_maxChars": "投稿最大文字数",
"lang_bbmd_misskey": "TheDeskにおけるMisskeyでは、@を返信として扱いますが、全ての@は消去され別パラメータに入力されます。また、「未収載」を「ホーム」として扱います。", "lang_bbmd_misskey": "TheDeskにおけるMisskeyでは、@を返信として扱いますが、全ての@は消去され別パラメータに入力されます。また、「未収載」を「ホーム」として扱います。",
"lang_emoji_get": "絵文字リストを取得", "lang_emoji_get": "絵文字リストを取得",
"lang_emoji_custom": "カスタム絵文字", "lang_emoji_custom": "カスタム絵文字",