Shinchoku

This commit is contained in:
cutls 2020-07-10 22:33:12 +09:00
parent fba3b99b54
commit 2c54e43e37
9 changed files with 7729 additions and 2771 deletions

View File

@ -1,10 +1,11 @@
async function getJson(start) {
async function getApi(start, at) {
let json = {}
let response = null
response = await fetch(start, {
method: 'GET',
headers: {
'content-type': 'application/json'
'content-type': 'application/json',
'Authorization': `Bearer ${at}`
}
})
if (!response.ok) {
@ -14,4 +15,24 @@ async function getJson(start) {
}
json = await response.json()
return json
}
async function postApi(url, body, at, ideKey) {
let json = {}
let response = null
response = await fetch(url, {
method: 'POST',
headers: {
'content-type': 'application/json',
'Authorization': `Bearer ${at}`,
'Idempotency-Key': ideKey
},
body: JSON.stringify(body)
})
if (!response.ok) {
response.text().then(function (text) {
setLog(response.url, response.status, text)
})
}
json = await response.json()
return json
}

View File

@ -1,5 +1,5 @@
//バージョンチェッカー
async function verck(ver, jp) {
async function verck(ver) {
console.log('%c Welcome😊 ' + ver, 'color: red;font-size:200%;')
document.querySelector('body').classList.add(localStorage.getItem('platform'))
const date = new Date()
@ -8,20 +8,7 @@ async function verck(ver, jp) {
showVer = true
console.log('%c Thank you for your update🎉', 'color: red;font-size:200%;')
if (localStorage.getItem('winstore') && !pwa) {
M.Modal.getInstance(document.querySelector('#releasenote')).open()
}
verp = ver.replace('(', '')
verp = verp.replace('.', '-')
verp = verp.replace('.', '-')
verp = verp.replace('[', '-')
verp = verp.replace(']', '')
verp = verp.replace(')', '')
verp = verp.replace(' ', '_')
console.log('%c ' + verp, 'color: red;font-size:200%;')
if (lang.language == 'ja') {
showElm(`#release-${verp}`)
} else {
showElm('#release-en')
openRN()
}
}
localStorage.setItem('ver', ver)
@ -73,12 +60,12 @@ async function verck(ver, jp) {
// 生成する文字列に含める文字セット
const c = 'abcdefghijklmnopqrstuvwxyz0123456789'
const cl = c.length
const r = ''
let r = ''
for (var i = 0; i < l; i++) {
r += c[Math.floor(Math.random() * cl)]
}
const start = 'https://thedesk.top/ver.json'
const mess = await getJson(start)
const mess = await getApi(start, null)
console.table(mess)
if (mess) {
let newest = null
@ -111,7 +98,7 @@ async function verck(ver, jp) {
lni = 0
}
const getNotice = 'https://thedesk.top/notice/index.php?since_id=' + lni
const notices = await getJson(getNotice)
const notices = await getApi(getNotice, null)
if (notices.length < 1) {
return false
} else {
@ -140,7 +127,10 @@ function infowebsocket() {
if (obj.type != 'counter') {
toastInterpret(obj)
} else {
document.querySelector('#persons').innerText = obj.text
const people = document.querySelector('#persons')
if(people) {
people.innerText = obj.text
}
}
}
infows.onerror = function (error) {
@ -195,11 +185,11 @@ async function toastInterpret(obj) {
displayLength: 86400
})
await sleep(500)
const targets = document.querySelectorAll('toast-action')
for (let j = 0; j < targets.length; i++) {
const targets = document.querySelectorAll('.toast-action')
for (let j = 0; j < targets.length; j++) {
const target = targets[j]
const toot = target.getAttribute('data-toot')
target.addEventListener('click', detEx(toot, 'main'))
target.addEventListener('click', () => detEx(toot, 'main'))
}
}
@ -207,6 +197,7 @@ async function toastInterpret(obj) {
}
}
function openRN() {
console.log(kirishima)
M.Modal.getInstance(document.querySelector('#releasenote')).open()
if (lang.language == 'ja') {
verp = ver.replace('(', '').replace('.', '-').replace('.', '-').replace('[', '-').replace(']', '').replace(')', '').replace(' ', '_')

View File

@ -1,5 +1,5 @@
var defaultemojiList = ['activity', 'flag', 'food', 'nature', 'object', 'people', 'place', 'symbol']
var defaultemoji = {
const defaultemojiList = ['activity', 'flag', 'food', 'nature', 'object', 'people', 'place', 'symbol']
const defaultemoji = {
activity: activity,
flag: flag,
food: food,
@ -9,8 +9,18 @@ var defaultemoji = {
place: place,
symbol: symbol
}
let defaultemojiname = {
activity: 'Activities',
flag: 'Flags',
food: 'Foods',
nature: 'Nature',
object: 'Tools',
people: 'People',
place: 'Places',
symbol: 'Symbols'
}
if (lang == 'ja') {
var defaultemojiname = {
defaultemojiname = {
activity: '活動',
flag: '国旗',
food: '食べ物',
@ -20,33 +30,23 @@ if (lang == 'ja') {
place: '場所',
symbol: '記号'
}
} else {
var defaultemojiname = {
activity: 'Activities',
flag: 'Flags',
food: 'Foods',
nature: 'Nature',
object: 'Tools',
people: 'People',
place: 'Places',
symbol: 'Symbols'
}
}
function defaultEmoji(target) {
var announcement = false
if ($('#media').val() == 'announcement') {
announcement = true
}
var json = defaultemoji[target]
var emojis = ''
Object.keys(json).forEach(function(key) {
var emoji = json[key]
if (announcement) {
var def = `<a onclick="emojiReactionDef('${emoji['shortcode']}')" class="pointer">`
} else {
var def = `<a onclick="defEmoji('${emoji['shortcode']}')" class="pointer">`
}
let announcement = false
if (document.querySelector('#media').value == 'announcement') {
announcement = true
}
const json = defaultemoji[target]
const keymap = Object.keys(json)
let emojis = ''
for (let i = 0; i < json.length; i++) {
const key = keymap[i]
const emoji = json[key]
let def = `<a data-shortcode="${emoji['shortcode']}" class="pointer defEmoji">`
if (announcement) {
def = `<a data-shortcode="${emoji['shortcode']}" class="pointer defEmoji">`
}
emojis =
emojis +
`${def}
@ -54,52 +54,39 @@ function defaultEmoji(target) {
width: 20px; height: 20px; display: inline-block; background-image: url('../../img/sheet.png'); background-size: 4900%;
background-position:${emoji['css']};"></span>
</a>`
})
$('#emoji-list').html(emojis)
$('#now-emoji').text(lang.lang_defaultemojis_text.replace('{{cat}}', defaultemojiname[target]))
$('.emoji-control').addClass('hide')
}
document.querySelector('#emoji-list').innerHTML = emojis
document.querySelector('#now-emoji').innerText = lang.lang_defaultemojis_text.replace('{{cat}}', defaultemojiname[target])
document.querySelector('.emoji-control').classList.add('hide')
const targets = document.querySelectorAll('.defEmoji')
for (let j = 0; j < targets.length; j++) {
const target = targets[j]
const sc = target.getAttribute('data-shortcode')
target.addEventListener('click', () => defEmoji(sc))
}
}
function customEmoji() {
$('#emoji-suggest').val('')
$('.emoji-control').removeClass('hide')
document.querySelector('#emoji-suggest').value = ''
document.querySelector('.emoji-control').classList.remove('hide')
emojiList('home')
}
function defEmoji(target) {
var selin = $('#textarea').prop('selectionStart')
const textarea = document.querySelector('#textarea')
let selin = textarea.selectionStart
if (!selin) {
selin = 0
}
var emojiraw = newpack.filter(function(item, index) {
if (item.short_name == target) return true
})
var hex = emojiraw[0].unified.split('-')
const hex = emojipack[target].unified.split('-')
let emoji = twemoji.convert.fromCodePoint(hex[0])
if (hex.length === 2) {
emoji = twemoji.convert.fromCodePoint(hex[0]) + twemoji.convert.fromCodePoint(hex[1])
} else {
emoji = twemoji.convert.fromCodePoint(hex[0])
}
var now = $('#textarea').val()
var before = now.substr(0, selin)
var after = now.substr(selin, now.length)
newt = before + emoji + after
$('#textarea').val(newt)
$('#textarea').focus()
}
function faicon() {
var json = faicons
var emojis = ''
Object.keys(json).forEach(function(key) {
var emoji = json[key]
var eje = emoji.replace(/fa-/g, '')
emojis =
emojis +
'<a onclick="emojiInsert(\'[faicon]' +
eje +
'[/faicon]\')" class="pointer white-text" style="font-size:24px"><i class="fa ' +
emoji +
'"></i></a>'
})
$('#emoji-list').html(emojis)
$('#now-emoji').text('faicon')
$('.emoji-control').addClass('hide')
const now = textarea.value
const before = now.substr(0, selin)
const after = now.substr(selin, now.length)
const newt = before + emoji + after
textarea.value = newt
textarea.focus()
}

File diff suppressed because one or more lines are too long

View File

@ -1,391 +1,119 @@
/*ログイン処理・認証までのJS*/
//最初に読むやつ
//アスタルテ判定初期化
localStorage.removeItem('kirishima')
localStorage.removeItem('quoters')
localStorage.removeItem('imas')
localStorage.removeItem('image')
//stable, 固定タグのことらしい。ふざけるな。
localStorage.removeItem('stable')
localStorage.setItem('mode_misskey.xyz', 'misskey')
function ck() {
var main = localStorage.getItem('main')
const main = localStorage.getItem('main')
if (!main) {
localStorage.setItem('main', 0)
}
//コード受信
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 == 'manager' || mode == 'login') {
code(codex, mode)
} else {
}
}
var multi = localStorage.getItem('multi')
const multi = localStorage.getItem('multi')
if (!multi || multi == '[]') {
var date = new Date()
const date = new Date()
localStorage.setItem('showSupportMe', date.getMonth() + 2)
location.href = 'acct.html?mode=first&code=true'
} else {
var obj = JSON.parse(multi)
var jp = false
Object.keys(obj).forEach(function(key) {
var acct = obj[key]
const obj = JSON.parse(multi)
const keymap = Object.keys(obj)
for (let i = 0; i < keymap.length; i++) {
const key = keymap[i]
const acct = obj[key]
if (acct.domain) {
refresh(key, true)
}
if (acct.domain == 'mstdn.jp') {
jp = true
}
})
}
if (obj[0].domain) {
$('#tl').show()
showElm('#tl')
ticker()
multiSelector(false)
verck(ver, jp)
$('.stw').show()
if (localStorage.getItem('tips')) {
tips(localStorage.getItem('tips'))
verck(ver)
showElm('.stw')
const tips = localStorage.getItem('tips')
if (tips) {
tips(tips)
}
$('#something-wrong img').attr('src', '../../img/thinking.svg')
document.querySelector('#something-wrong img').setAttribute('src', '../../img/thinking.svg')
}
}
}
ck()
//ログインポップアップ
function login(url) {
if ($('#linux:checked').val() == 'on') {
var red = 'urn:ietf:wg:oauth:2.0:oob'
} else {
var red = 'thedesk://login'
}
localStorage.setItem('redirect', red)
var start = 'https://' + url + '/api/v1/apps'
var httpreq = new XMLHttpRequest()
httpreq.open('POST', start, true)
httpreq.setRequestHeader('Content-Type', 'application/json')
httpreq.responseType = 'json'
httpreq.send(
JSON.stringify({
scopes: 'read write follow',
client_name: 'TheDesk(PC)',
redirect_uris: red,
website: 'https://thedesk.top'
})
)
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response
if (this.status !== 200) {
setLog(start, this.status, json)
}
var auth =
'https://' +
url +
'/oauth/authorize?client_id=' +
json['client_id'] +
'&client_secret=' +
json['client_secret'] +
'&response_type=code&redirect_uri=' +
red +
'&scope=read+write+follow'
localStorage.setItem('domain_' + acct_id, url)
localStorage.setItem('client_id', json['client_id'])
localStorage.setItem('client_secret', json['client_secret'])
$('#auth').show()
$('#masara').hide()
postMessage(['openUrl', auth], '*')
if ($('#linux:checked').val() == 'on') {
} else {
postMessage(['sendSinmpleIpc', 'quit'], '*')
}
}
}
}
//テキストボックスにURL入れた
function instance() {
var url = $('#url').val()
login(url)
}
//コードを入れた後認証
function code(code, mode) {
var red = localStorage.getItem('redirect')
localStorage.removeItem('redirect')
if (!code) {
var code = $('#code').val()
}
if (localStorage.getItem('domain_tmp')) {
var url = localStorage.getItem('domain_tmp')
} else {
var url = localStorage.getItem('domain_' + acct_id)
}
var start = 'https://' + url + '/oauth/token'
var id = localStorage.getItem('client_id')
var secret = localStorage.getItem('client_secret')
fetch(start, {
method: 'POST',
headers: {
'content-type': 'application/json'
},
body: JSON.stringify({
grant_type: 'authorization_code',
redirect_uri: red,
client_id: id,
client_secret: secret,
code: code
})
})
.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) {
todo(json)
if (json['access_token']) {
localStorage.setItem(url + '_at', json['access_token'])
if (mode == 'manager') {
getdataAdv(url, json['access_token'])
} else {
getdata()
}
}
})
}
//ユーザーデータ取得(最初)
function getdata() {
var acct_id = 0
var domain = localStorage.getItem('domain_' + acct_id)
var at = localStorage.getItem('acct_' + acct_id + '_at')
var start = 'https://' + domain + '/api/v1/accounts/verify_credentials'
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.error) {
console.error('Error:' + json.error)
M.toast({ html: lang.lang_fatalerroroccured + 'Error:' + json.error, displayLength: 5000 })
return
}
var avatar = json['avatar']
//missingがmissingなやつ
if (avatar == '/avatars/original/missing.png') {
avatar = './img/missing.svg'
}
var obj = [
{
at: at,
name: json['display_name'],
domain: domain,
user: json['acct'],
prof: avatar,
id: json['id'],
vis: json['source']['privacy']
}
]
var json = JSON.stringify(obj)
localStorage.setItem('multi', json)
localStorage.setItem('name_' + acct_id, json['display_name'])
localStorage.setItem('user_' + acct_id, json['acct'])
localStorage.setItem('user-id_' + acct_id, json['id'])
localStorage.setItem('prof_' + acct_id, avatar)
$('#masara').hide()
$('#auth').hide()
$('#tl').show()
parseColumn()
ckdb()
})
}
//ユーザーデータ取得(追加)
function getdataAdv(domain, at) {
var start = 'https://' + domain + '/api/v1/accounts/verify_credentials'
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.error) {
console.error('Error:' + json.error)
M.toast({ html: lang.lang_fatalerroroccured + 'Error:' + json.error, displayLength: 5000 })
return
}
var avatar = json['avatar']
//missingがmissingなやつ
if (avatar == '/avatars/original/missing.png') {
avatar = '../../img/missing.svg'
}
if (json['source']['privacy']) {
var priv = json['source']['privacy']
} else {
var priv = 'public'
}
var add = {
at: at,
name: json['display_name'],
domain: domain,
user: json['acct'],
prof: avatar,
id: json['id'],
vis: priv
}
var multi = localStorage.getItem('multi')
var obj = JSON.parse(multi)
var target = obj.lengtth
obj.push(add)
localStorage.setItem('name_' + target, json['display_name'])
localStorage.setItem('user_' + target, json['acct'])
localStorage.setItem('user-id_' + target, json['id'])
localStorage.setItem('prof_' + target, avatar)
var json = JSON.stringify(obj)
localStorage.setItem('multi', json)
location.href = 'index.html'
})
}
//ユーザーデータ更新
function refresh(target, loadskip) {
var multi = localStorage.getItem('multi')
var obj = JSON.parse(multi)
if (obj[target].mode == 'misskey') {
async function refresh(target, loadskip) {
const multi = localStorage.getItem('multi')
let obj = JSON.parse(multi)
const {mode, domain, at, background, text} = obj[target]
if (mode == 'misskey') {
return
}
var start = 'https://' + obj[target].domain + '/api/v1/accounts/verify_credentials'
fetch(start, {
method: 'GET',
headers: {
'content-type': 'application/json',
Authorization: 'Bearer ' + obj[target].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.error) {
console.error('Error:' + json.error)
M.toast({ html: lang.lang_fatalerroroccured + 'Error:' + json.error, displayLength: 5000 })
return
}
var avatar = json['avatar']
//missingがmissingなやつ
if (avatar == '/avatars/original/missing.png' || !avatar) {
avatar = './img/missing.svg'
}
var ref = {
at: obj[target].at,
name: json['display_name'],
domain: obj[target].domain,
user: json['acct'],
prof: avatar,
id: json['id'],
vis: json['source']['privacy']
}
if (obj[target].background) {
ref.background = obj[target].background
}
if (obj[target].text) {
ref.text = obj[target].text
}
localStorage.setItem('name_' + target, json['display_name'])
localStorage.setItem('user_' + target, json['acct'])
localStorage.setItem('user-id_' + target, json['id'])
localStorage.setItem('prof_' + target, avatar)
localStorage.setItem('follow_' + target, json['following_count'])
if (json['source']['sensitive']) {
localStorage.setItem('nsfw_' + target, 'true')
} else {
localStorage.removeItem('nsfw_' + target)
}
obj[target] = ref
var json = JSON.stringify(obj)
localStorage.setItem('multi', json)
if (!loadskip) {
load()
}
})
const start = `https://${domain}/api/v1/accounts/verify_credentials`
const json = await getApi(start, at)
if (json.error) {
console.error('Error:' + json.error)
M.toast({ html: lang.lang_fatalerroroccured + 'Error:' + json.error, displayLength: 5000 })
return
}
let avatar = json['avatar']
//missingがmissingなやつ
if (avatar == '/avatars/original/missing.png' || !avatar) {
avatar = './img/missing.svg'
}
let ref = {
at: at,
name: json['display_name'],
domain: domain,
user: json['acct'],
prof: avatar,
id: json['id'],
vis: json['source']['privacy']
}
if (background) {
ref.background = background
}
if (text) {
ref.text = text
}
if (json['source']['sensitive']) {
localStorage.setItem('nsfw_' + target, 'true')
} else {
localStorage.removeItem('nsfw_' + target)
}
obj[target] = ref
const save = JSON.stringify(obj)
localStorage.setItem('multi', save)
if (!loadskip) {
load()
}
}
//MarkdownやBBCodeの対応、文字数制限をチェック
//絶対ストリーミングを閉じさせないマン
function ckdb(acct_id) {
var domain = localStorage.getItem('domain_' + acct_id)
localStorage.removeItem('home_' + acct_id)
localStorage.removeItem('bb_' + acct_id)
localStorage.removeItem('md_' + acct_id)
localStorage.removeItem('local_' + acct_id)
localStorage.removeItem('public_' + acct_id)
localStorage.removeItem('notification_' + acct_id)
localStorage.removeItem('post_' + acct_id)
localStorage.removeItem('fav_' + acct_id)
localStorage.removeItem('bt_' + acct_id)
localStorage.removeItem('followlocale_' + acct_id)
const domain = localStorage.getItem(`domain_${acct_id}`)
if (domain == 'kirishima.cloud') {
localStorage.setItem('kirishima', 'true')
} else if (domain == 'imastodon.net') {
localStorage.setItem('imas', 'true')
$('.imasonly').show()
showElm('.imasonly')
}
var at = localStorage.getItem('acct_' + acct_id + '_at')
var bbcode = domain + '_bbcode'
var letters = domain + '_letters'
var quoteMarker = domain + '_quote'
const at = localStorage.getItem(`acct_${acct_id}_at`)
const letters = `${domain}_letters`
const quoteMarker = `${domain}_quote`
if (idata) {
//check and replace json to idata
var json = idata
@ -448,13 +176,13 @@ function ckdb(acct_id) {
'content-type': 'application/json'
}
})
.then(function(response) {
.then(function (response) {
return response.json()
})
.catch(function(error) {
.catch(function (error) {
console.error(error)
})
.then(function(json) {
.then(function (json) {
if (json.error) {
console.error(json.error)
return
@ -501,7 +229,7 @@ function multiSelector(parseC) {
$('#src-acct-sel').html('<option value="tootsearch">Tootsearch</option>')
$('#add-acct-sel').html('<option value="noauth">' + lang.lang_login_noauth + '</option>')
} else {
Object.keys(obj).forEach(function(key) {
Object.keys(obj).forEach(function (key) {
var acct = obj[key]
var list = key * 1 + 1
if (key + '' === last) {
@ -569,8 +297,8 @@ function multiSelector(parseC) {
$('#src-acct-sel').append('<option value="tootsearch">Tootsearch</option>')
$('#add-acct-sel').append(
'<option value="noauth">' +
lang.lang_login_noauth +
'</option><option value="webview">Twitter</option>'
lang.lang_login_noauth +
'</option><option value="webview">Twitter</option>'
)
$('#dir-acct-sel').append('<option value="noauth">' + lang.lang_login_noauth + '</option>')
}
@ -599,18 +327,18 @@ function ticker() {
'content-type': 'application/json'
}
})
.then(function(response) {
.then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
response.text().then(function (text) {
setLog(response.url, response.status, text)
})
}
return response.json()
})
.catch(function(error) {
.catch(function (error) {
console.error(error)
})
.then(function(json) {
.then(function (json) {
if (json) {
localStorage.setItem('ticker', JSON.stringify(json))
}

View File

@ -306,4 +306,12 @@ function showElm(query) {
target.style.display = 'inherit'
}
}
function setAllClasses(query, className, action) {
const allTarget = document.querySelectorAll(query)
for (let i = 0; i < allTarget.length; i++) {
const target = allTarget[i]
if(action == 'add') target.classList.add(className)
if(action == 'remove') target.classList.remove(className)
}
}
const sleep = msec => new Promise(resolve => setTimeout(resolve, msec));

View File

@ -108,7 +108,6 @@ async function media(b64, type, no, stamped) {
}
$('.toot-btn-group').prop('disabled', true)
$('#post-acct-sel').prop('disabled', true)
localStorage.setItem('image', 'busy')
todo('Image Upload...')
var media = toBlob(b64, type)
var fd = new FormData()
@ -159,7 +158,6 @@ async function media(b64, type, no, stamped) {
M.toast({ html: '<span>' + lang.lang_postimg_sync + '</span><button class="btn-flat toast-action" onclick="syncDetail()">Click</button>', displayLength: 3000 })
$('#imgup').text('')
$('#imgsel').show()
localStorage.removeItem('image')
}
} catch {
var start = 'https://' + domain + '/api/v1/media'

View File

@ -342,7 +342,6 @@ function clear() {
$('.mastodon-choice').map(function() {
$(this).val('')
})
localStorage.removeItem('image')
if (localStorage.getItem('mainuse') == 'main') {
$('#post-acct-sel').val(localStorage.getItem('main'))
}

View File

@ -1,65 +1,68 @@
//プロフ編集
//文字系
function profedit() {
var acct_id = $('#his-data').attr("use-acct");
todo("Updating...");
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v1/accounts/update_credentials";
var name = $("#his-name-val").val();
var des = $("#his-des-val").val();
var httpreq = new XMLHttpRequest();
httpreq.open('PATCH', start, true);
httpreq.setRequestHeader('Content-Type', 'application/json');
httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
httpreq.responseType = "json";
httpreq.send(JSON.stringify({
display_name: name,
note: des,
}));
var acct_id = $('#his-data').attr('use-acct')
todo('Updating...')
var domain = localStorage.getItem('domain_' + acct_id)
var at = localStorage.getItem('acct_' + acct_id + '_at')
var start = 'https://' + domain + '/api/v1/accounts/update_credentials'
var name = $('#his-name-val').val()
var des = $('#his-des-val').val()
var httpreq = new XMLHttpRequest()
httpreq.open('PATCH', start, true)
httpreq.setRequestHeader('Content-Type', 'application/json')
httpreq.setRequestHeader('Authorization', 'Bearer ' + at)
httpreq.responseType = 'json'
httpreq.send(
JSON.stringify({
display_name: name,
note: des,
})
)
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
$('#his-data').modal('close');
todc();
$('#his-data').modal('close')
todc()
}
}
}
//画像系
function imgChange(imgfile, target) {
var acct_id = $('#his-data').attr("use-acct");
todo("アップロードしています")
var acct_id = $('#his-data').attr('use-acct')
todo('アップロードしています')
if (!imgfile.files.length) {
console.warn("No Image to upload");
return;
console.warn('No Image to upload')
return
}
var file = imgfile.files[0];
var fr = new FileReader();
var file = imgfile.files[0]
var fr = new FileReader()
fr.onload = function (evt) {
var b64 = this.result;
var blob = toBlob(b64, 'image/png');
var fd = new FormData();
fd.append(target, blob);
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v1/accounts/update_credentials";
var httpreq = new XMLHttpRequest();
httpreq.open('PATCH', start, true);
httpreq.upload.addEventListener("progress", progshow, false);
httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
httpreq.responseType = "json";
httpreq.send(fd);
var b64 = this.result
var blob = toBlob(b64, 'image/png')
var fd = new FormData()
fd.append(target, blob)
var domain = localStorage.getItem('domain_' + acct_id)
var at = localStorage.getItem('acct_' + acct_id + '_at')
var start = 'https://' + domain + '/api/v1/accounts/update_credentials'
var httpreq = new XMLHttpRequest()
httpreq.open('PATCH', start, true)
httpreq.upload.addEventListener('progress', progshow, false)
httpreq.setRequestHeader('Authorization', 'Bearer ' + at)
httpreq.responseType = 'json'
httpreq.send(fd)
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, this.response); }
$('#his-data').modal('close');
todc();
localStorage.removeItem("image");
var json = httpreq.response
if (this.status !== 200) {
setLog(start, this.status, this.response)
}
$('#his-data').modal('close')
todc()
}
}
}
$("#prof-change").html($("#prof-change").html());
$("#header-change").html($("#header-change").html());
fr.readAsDataURL(file);
$('#prof-change').html($('#prof-change').html())
$('#header-change').html($('#header-change').html())
fr.readAsDataURL(file)
}