fetch the data with dialog

This commit is contained in:
cutls 2021-04-18 19:11:39 +09:00
parent 5de0ede4e1
commit 8acf86d9cb
10 changed files with 46 additions and 41 deletions

View File

@ -29,7 +29,7 @@ $(document).on('click', 'a', e => {
acct_id = 0
}
$a.parent().addClass('loadp')
$a.parent().text('Loading...')
detEx(url, acct_id)
}
} else if (tags) {

View File

@ -637,42 +637,48 @@ function brws() {
postMessage(['openUrl', url], '*')
}
//外部からトゥート開く
function detEx(url, acct_id) {
async function detEx(url, acct_id) {
if (acct_id == 'main') {
acct_id = localStorage.getItem('main')
}
var domain = localStorage.getItem('domain_' + acct_id)
var at = localStorage.getItem('acct_' + acct_id + '_at')
var start = 'https://' + domain + '/api/v2/search?resolve=true&q=' + encodeURIComponent(url)
fetch(start, {
Swal.fire({
title: 'Loading...',
html: lang.lang_details_fetch,
showConfirmButton: false,
showCloseButton: true,
onBeforeOpen: () => {
Swal.showLoading()
},
onClose: () => { },
}).then((result) => { })
const json = await detExCore(url, acct_id)
Swal.close()
if (!json.statuses) {
postMessage(['openUrl', url], '*')
} else {
var id = json.statuses[0].id
$('.loadp').text($('.loadp').attr('href'))
$('.loadp').removeClass('loadp')
details(id, acct_id, 0)
}
return
}
async function detExCore(url, acct_id) {
const domain = localStorage.getItem('domain_' + acct_id)
const start = 'https://' + domain + '/api/v2/search?resolve=true&q=' + encodeURIComponent(url)
const at = localStorage.getItem('acct_' + acct_id + '_at')
let promise = await fetch(start, {
method: 'GET',
headers: {
'content-type': 'application/json',
Authorization: 'Bearer ' + at
}
})
.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.statuses) {
postMessage(['openUrl', url], '*')
} else {
var id = json.statuses[0].id
$('.loadp').text($('.loadp').attr('href'))
$('.loadp').removeClass('loadp')
details(id, acct_id, 0)
}
})
return
const json = await promise.json()
if (json) {
return json
} else {
return false
}
}

View File

@ -89,7 +89,7 @@ function list() {
</a>/
<a onclick="listUser('${list.id}','${acct_id}')" class="pointer">
${lang.lang_list_users}
'</a><br>`
</a><br>`
})
$('#lists').html(lists)
} else {

View File

@ -659,8 +659,6 @@ function removeColumn(tlid) {
$('#timeline_box_' + tlid + '_parentBox').remove()
}
}
$('#sort-box').removeClass('hide')
$('#sort-box').addClass('show')
})
}

View File

@ -103,6 +103,7 @@
"lang_details_embed": "Embed HTML is cliped.",
"lang_details_url": "URL of this toot is cliped.",
"lang_details_txt": "Content of this toot is cliped.",
"lang_details_fetch": "Fetcging toot data...",
"lang_filter_nodata": "No data",
"lang_filter_errordegree": "Please check a context",
"lang_list_nodata": "No data",

View File

@ -102,6 +102,7 @@
"lang_details_embed": "埋め込みHTMLがコピーされたで。",
"lang_details_url": "トゥートURLがコピーされたで。",
"lang_details_txt": "トゥート本文がコピーされたで。",
"lang_details_fetch": "トゥートの情報を引っ張って来とるで…",
"lang_filter_nodata": "フィルターは無いで",
"lang_filter_errordegree": "適応範囲は一つ以上チェックせなあかんで。",
"lang_list_nodata": "リストは無いで",

View File

@ -104,6 +104,7 @@
"lang_details_embed": "埋め込みHTMLがコピーされました。",
"lang_details_url": "トゥートURLがコピーされました。",
"lang_details_txt": "トゥート本文がコピーされました。",
"lang_details_fetch": "トゥートの情報を読み込んでいます",
"lang_filter_nodata": "フィルターはありません",
"lang_filter_errordegree": "適応範囲を最低一つ以上チェックしてください。",
"lang_list_nodata": "リストはありません",

View File

@ -27,7 +27,7 @@
<body class="">
<script>
var ver = '22.2.0 (Koume)'
var gitHash = 'b047c8076821314419fdd11573d1f4337567b53d'
var gitHash = '5de0ede4e1a99358a9078c5f560f3b650fcf94b8'
//betaを入れるとバージョンチェックしない
//var ver="beta";
var acct_id = 0

File diff suppressed because one or more lines are too long

View File

@ -103,12 +103,10 @@
</div>
<h5>Czcionka</h5>
Select your favorite font to 'Select'(Windows/ macOS only)<br>
<button class="btn waves-effect" style="width:7.7rem;" onclick="font()">Wybierz</button><br>
<div id="fonts" class="hide" style="overflow-y:scroll; width:22rem; height:40rem;"></div>
<br>
<button class="btn waves-effect orange darken-2" style="width:7.7rem;" onclick="font()">Wybierz</button>
<input type="text" style="width:11.5rem" id="font">
<button class="btn waves-effect" style="width:7.7rem;" onclick="settings()">Zapisz</button>
<br>
<div id="fonts" class="hide"></div>
<h5>Folder to save</h5>
TheDesk uses this value when it try to save pictures or take screenshots.<br>
<button class="btn waves-effect" style="width:7.7rem;" onclick="savefolder()">Zmień</button>
@ -690,7 +688,7 @@
style="width:100%; max-width:40rem;"><img src="../../img/desk_full.svg" class="left" width="25"
style="padding-top:5px;">Main author: Cutls@cutls.com</a>
<br>
TheDesk @ <a href="https://github.com/cutls/TheDesk/commits/b047c8076821314419fdd11573d1f4337567b53d">b047c8076821314419fdd11573d1f4337567b53d</a> - <a
TheDesk @ <a href="https://github.com/cutls/TheDesk/commits/5de0ede4e1a99358a9078c5f560f3b650fcf94b8">5de0ede4e1a99358a9078c5f560f3b650fcf94b8</a> - <a
onclick="checkupd(); return localStorage.removeItem('new-ver-skip'); location.href='index.html';"
class="pointer pwa">Sprawdź aktualizacje</a><br>
<br>
@ -700,7 +698,7 @@
<img src="https://status.cutls.com/badge-service?site=thedesk.top">
</a><br>
<h5>OSS License</h5>
<a href="https://app.fossa.com/projects/git%2Bgithub.com%2Fcutls%2FTheDesk/refs/branch/master/b047c8076821314419fdd11573d1f4337567b53d"
<a href="https://app.fossa.com/projects/git%2Bgithub.com%2Fcutls%2FTheDesk/refs/branch/master/5de0ede4e1a99358a9078c5f560f3b650fcf94b8"
alt="FOSSA Status"><img
src="https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcutls%2FTheDesk.svg?type=small" /></a>
<br>