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;
border-radius: 3px;
border: 1px solid var(--color);
user-select: none;
}
.vis-data {
font-size: 1rem !important;

View File

@ -33,7 +33,9 @@ function load() {
}
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
@ -47,6 +49,7 @@ function load() {
} else {
var name = acct.user
}
domains.push(acct.domain)
templete = `
<div id="acct_${key}" class="card" ${style}>
<div class="card-content ">
@ -54,15 +57,12 @@ function load() {
<span class="card-title">${name}</span>${escapeHTML(acct.user)}@${acct.domain}
</div>
<div class="card-action">
<a class="waves-effect disTar pointer white-text" onclick="data('${acct.domain}')">
<i class="material-icons">info</i>${lang.lang_manager_info}
</a>
<a class="waves-effect disTar pointer white-text" onclick="refresh('${key}')">
<i class="material-icons">refresh</i>${lang.lang_manager_refresh}
</a>
<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}
<button class="btn-flat waves-effect disTar pointer white-text" onclick="refresh('${key}')">
<i class="material-icons left">refresh</i>${lang.lang_manager_refresh}
</button>
<button class="btn-flat waves-effect disTar pointer red-text" onclick="multiDel('${key}')">
<i class="material-icons left">delete</i>${lang.lang_manager_delete}
</button><br />${lang.lang_manager_color}
<div id="colorsel_${key}" class="colorsel"></div>
</div>
</div>
@ -70,6 +70,30 @@ function load() {
$('#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
}
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()
var acctN = localStorage.getItem('acct')
if (!acctN) {
@ -82,9 +106,35 @@ function load() {
//最初に読む
load()
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
function data(domain) {
async function data(domain, acct_id) {
$('#ins-upd').text('Loading...')
$('#ins-add').text('Loading...')
$('#ins-connect').text('Loading...')
@ -96,7 +146,7 @@ function data(domain) {
$('#ins-name').text('Loading...')
$('#ins-prof').attr('src', '../../img/loading.svg')
var start = 'https://instances.social/api/1.0/instances/show?name=' + domain
fetch(start, {
let promise = await fetch(start, {
method: 'GET',
headers: {
'content-type': 'application/json',
@ -104,21 +154,7 @@ function data(domain) {
'Bearer tC8F6xWGWBUwGScyNevYlx62iO6fdQ4oIK0ad68Oo7ZKB8GQdGpjW9TKxBnIh8grAhvd5rw3iyP9JPamoDpeLQdz62EToPJUW99hDx8rfuJfGdjQuimZPTbIOx0woA5M'
}
})
.then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text)
})
}
return response.json()
})
.catch(function(error) {
todo(error)
setLog(start, 'JSON', error)
console.error(error)
})
.then(function(json) {
if (!json.error) {
var json = await promise.json()
$('#ins-name').text(json.name)
$('#ins-upd').text(date(json.checked_at, 'full'))
$('#ins-add').text(date(json.added_at, 'full'))
@ -128,32 +164,14 @@ function data(domain) {
$('#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'
fetch(start, {
let promise2 = await fetch(start, {
method: 'GET',
headers: {
'content-type': 'application/json'
}
})
.then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text)
})
}
return response.json()
})
.catch(function(error) {
todo(error)
setLog(start, 'JSON', error)
console.error(error)
})
.then(function(json) {
if (!json.error) {
var json = await promise2.json()
$('#ins-title').text(json.title)
$('#ins-desc').html(json.description)
$('#ins-email').text(json.email)
@ -168,10 +186,10 @@ function data(domain) {
'href',
'index.html?mode=user&code=' + json.contact_account.username + '@' + domain
)
} else {
console.error(json.error)
if (json['max_toot_chars']) {
localStorage.setItem('letters_' + acct_id, json['max_toot_chars'])
load()
}
})
}
//アカウントデータ 消す

View File

@ -49,9 +49,14 @@ function mdCheck() {
}
if (idata[domain + '_letters']) {
$('#textarea').attr('data-length', idata[domain + '_letters'])
} else {
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') {
$('#local-button').removeClass('hide')
} else {

View File

@ -1,85 +1,28 @@
<!doctype html>
<!DOCTYPE html>
<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">
<style>
.acct {
display: flex;
justify-content: space-around;
}
.card {
width: 400px;
background-color: #9e9e9e;
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;
}
</style>
<meta charset="utf-8">
<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']);
var _jipt = []
_jipt.push(['project', 'thedesk'])
</script>
<script type="text/javascript" src="https://cdn.crowdin.com/jipt/jipt.js"></script>
@@comment-end@@
@ -88,38 +31,46 @@
<body id="mainView">
<script type="text/javascript" src="../../node_modules/jquery/dist/jquery.js"></script>
<script type="text/javascript" src="../../js/platform/first.js"></script>
<script type="text/javascript" src="../../node_modules/materialize-css/dist/js/materialize.js"></script>
<script
type="text/javascript"
src="../../node_modules/materialize-css/dist/js/materialize.js"
></script>
<script type="text/javascript" src="main.js"></script>
<script type="text/javascript" src="../../node_modules/sweetalert2/dist/sweetalert2.all.min.js"></script>
<script
type="text/javascript"
src="../../node_modules/sweetalert2/dist/sweetalert2.all.min.js"
></script>
<script>
var misskeytoken = false;
var misskeytoken = false
</script>
<script type="text/javascript" src="../../js/common/time.js"></script>
<div class="hide-first">
<a href="index.html" class="btn waves-effect orange nex"
style="width:100%; max-width:200px;">@@back@@</a><br>
<a href="index.html" class="btn waves-effect orange nex" style="width:100%; max-width:200px;"
>@@back@@</a
><br />
<h5>@@list@@</h5>
<div id="acct-list"></div>
<div class="divider"></div>
</div>
<div>
<h5>@@add@@</h5><br>
<h5>@@add@@</h5>
<br />
<div id="add">
<div class="row">
<div class="col s8">
<input type="text" id="url" style="width:70%" placeholder="ex)mstdn.jp">
<input type="text" id="url" style="width:70%" placeholder="ex)mstdn.jp" />
<div id="ins-suggest"></div>
@@codesetupwarn@@<br>
@@codesetupwarn@@<br />
<label>
<input type="checkbox" class="filled-in" id="linux" />
<span>@@codesetup@@</span>
</label>
<br>
<br />
<label>
<input type="checkbox" class="filled-in" id="misskey" />
<span>@@thisismisskey@@</span>
</label><br>
<button class="btn waves-effect" onclick="instance()">Login</button><br>
<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>
@ -128,51 +79,67 @@
</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>
@@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>
<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>
@@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>
<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>
<ul id="domain-list" class="collection transparent"></ul>
<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>
<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>
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>
</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="../../node_modules/lodash/lodash.min.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>
</body>
</html>

View File

@ -48,6 +48,7 @@
"lang_manager_none": "None",
"lang_manager_godev": "Open DevCenter of Misskey. We show also an official documents to refer.",
"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_emoji_get": "Get emojis",
"lang_emoji_custom": "Custom emojis",

View File

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