2020-07-10 15:16:39 +10:00
|
|
|
let selectedColumn = 0
|
|
|
|
let selectedToot = 0
|
|
|
|
$(function ($) {
|
2018-01-31 03:43:01 +11:00
|
|
|
//キーボードショートカット
|
2020-07-10 15:16:39 +10:00
|
|
|
$(window).keydown(function (e) {
|
|
|
|
const hasFocus = isFocused('input')
|
|
|
|
const hasFocus2 = isFocused('textarea')
|
|
|
|
const postBox = document.querySelector('#textarea')
|
|
|
|
let wv = false
|
2020-02-09 01:51:46 +11:00
|
|
|
if (document.getElementById('webview')) {
|
2020-07-10 15:16:39 +10:00
|
|
|
if (document.querySelector('#webviewsel:checked').value) {
|
|
|
|
wv = false
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2020-07-10 15:16:39 +10:00
|
|
|
wv = true
|
2019-05-19 17:39:30 +10:00
|
|
|
}
|
|
|
|
} else {
|
2020-07-10 15:16:39 +10:00
|
|
|
wv = true
|
2018-09-10 03:06:00 +10:00
|
|
|
}
|
2019-10-20 22:57:22 +11:00
|
|
|
//Enter
|
|
|
|
if (e.keyCode === 13) {
|
2020-07-10 15:16:39 +10:00
|
|
|
if (isFocused('#src')) {
|
2019-10-20 22:57:22 +11:00
|
|
|
src()
|
2020-02-09 01:51:46 +11:00
|
|
|
return false
|
2019-10-20 22:57:22 +11:00
|
|
|
}
|
2020-07-10 15:16:39 +10:00
|
|
|
if (isFocused('#list-add')) {
|
2019-10-20 22:57:22 +11:00
|
|
|
makeNewList()
|
2020-02-09 01:51:46 +11:00
|
|
|
return false
|
2019-10-20 22:57:22 +11:00
|
|
|
}
|
|
|
|
}
|
2018-09-17 21:55:00 +10:00
|
|
|
//Ctrl+Shift+Enter:Lgen
|
2020-02-09 01:51:46 +11:00
|
|
|
if (event.metaKey || (event.ctrlKey && wv)) {
|
2018-09-17 21:55:00 +10:00
|
|
|
if (event.shiftKey) {
|
|
|
|
if (e.keyCode === 13) {
|
2020-02-09 01:51:46 +11:00
|
|
|
post('local')
|
|
|
|
return false
|
2018-09-17 21:55:00 +10:00
|
|
|
}
|
2018-01-31 03:43:01 +11:00
|
|
|
}
|
|
|
|
}
|
2018-09-17 21:55:00 +10:00
|
|
|
//Ctrl+Enter:投稿
|
2020-02-09 01:51:46 +11:00
|
|
|
if (event.metaKey || (event.ctrlKey && wv)) {
|
2018-02-05 01:56:31 +11:00
|
|
|
if (e.keyCode === 13) {
|
2020-02-09 01:51:46 +11:00
|
|
|
post()
|
|
|
|
return false
|
2018-02-05 01:56:31 +11:00
|
|
|
}
|
|
|
|
}
|
2019-03-09 22:17:08 +11:00
|
|
|
//Alt+Enter:セカンダリー
|
2020-02-09 01:51:46 +11:00
|
|
|
if (event.metaKey || (event.altKey && wv)) {
|
2019-03-09 22:17:08 +11:00
|
|
|
if (e.keyCode === 13) {
|
2020-02-09 01:51:46 +11:00
|
|
|
sec()
|
|
|
|
return false
|
2019-03-09 22:17:08 +11:00
|
|
|
}
|
|
|
|
}
|
2018-01-31 03:43:01 +11:00
|
|
|
//Esc:消す
|
2018-09-11 04:59:44 +10:00
|
|
|
if (e.keyCode === 27 && wv) {
|
2020-02-09 01:51:46 +11:00
|
|
|
hide()
|
|
|
|
return false
|
2018-01-31 03:43:01 +11:00
|
|
|
}
|
2018-02-09 03:43:11 +11:00
|
|
|
//F5リロード
|
2018-09-11 04:59:44 +10:00
|
|
|
if (e.keyCode === 116 && wv) {
|
2020-02-09 01:51:46 +11:00
|
|
|
location.href = 'index.html'
|
|
|
|
return false
|
2018-01-31 03:43:01 +11:00
|
|
|
}
|
2018-03-21 16:36:02 +11:00
|
|
|
//Ctrl+Sift+C:全消し
|
2020-02-09 01:51:46 +11:00
|
|
|
if ((event.metaKey || event.ctrlKey) && event.shiftKey && wv) {
|
2018-03-21 16:36:02 +11:00
|
|
|
if (e.keyCode === 67) {
|
2020-02-09 01:51:46 +11:00
|
|
|
clear()
|
|
|
|
return false
|
2018-03-21 16:36:02 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//Ctrl+Sift+N:NowPlaying
|
2020-02-09 01:51:46 +11:00
|
|
|
if ((event.metaKey || event.ctrlKey) && event.shiftKey && wv) {
|
2018-03-21 16:36:02 +11:00
|
|
|
if (e.keyCode === 78) {
|
2020-02-09 01:51:46 +11:00
|
|
|
show()
|
2018-03-21 16:36:02 +11:00
|
|
|
nowplaying()
|
2020-02-09 01:51:46 +11:00
|
|
|
return false
|
2018-03-21 16:36:02 +11:00
|
|
|
}
|
|
|
|
}
|
2018-01-31 03:43:01 +11:00
|
|
|
//input/textareaにフォーカスなし時
|
2020-02-09 01:51:46 +11:00
|
|
|
if (!hasFocus && !hasFocus2 && wv) {
|
2019-05-19 17:39:30 +10:00
|
|
|
if (!wv) {
|
2020-02-09 01:51:46 +11:00
|
|
|
return true
|
2018-09-11 04:59:44 +10:00
|
|
|
}
|
2018-07-28 07:25:12 +10:00
|
|
|
//Ctrl+V:いつもの
|
2018-08-23 03:29:39 +10:00
|
|
|
if (event.metaKey || event.ctrlKey) {
|
2018-07-28 07:25:12 +10:00
|
|
|
if (e.keyCode === 86) {
|
2020-02-09 01:51:46 +11:00
|
|
|
show()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//Ctrl+F:検索
|
|
|
|
if (event.metaKey || event.ctrlKey) {
|
|
|
|
if (e.keyCode === 70) {
|
|
|
|
srcBox()
|
2018-07-28 07:25:12 +10:00
|
|
|
}
|
|
|
|
}
|
2018-01-31 03:43:01 +11:00
|
|
|
//X:開閉
|
|
|
|
if (e.keyCode === 88) {
|
2020-07-10 15:16:39 +10:00
|
|
|
if (!document.querySelector('#post-box').classList.contains('appear')) {
|
2020-02-09 01:51:46 +11:00
|
|
|
show()
|
|
|
|
$('textarea').focus()
|
2018-01-31 03:43:01 +11:00
|
|
|
} else {
|
2020-02-09 01:51:46 +11:00
|
|
|
hide()
|
2018-01-31 03:43:01 +11:00
|
|
|
}
|
2020-02-09 01:51:46 +11:00
|
|
|
return false
|
2018-01-31 03:43:01 +11:00
|
|
|
}
|
|
|
|
//N:新トゥート
|
|
|
|
if (e.keyCode === 78) {
|
2020-07-10 15:16:39 +10:00
|
|
|
if (!document.querySelector('#post-box').classList.contains('appear')) {
|
2020-02-09 01:51:46 +11:00
|
|
|
show()
|
2018-01-31 03:43:01 +11:00
|
|
|
}
|
2020-07-10 15:16:39 +10:00
|
|
|
postBox.focus()
|
2020-02-09 01:51:46 +11:00
|
|
|
return false
|
2018-01-31 03:43:01 +11:00
|
|
|
}
|
2018-07-28 07:25:12 +10:00
|
|
|
//Ctrl+E:全ての通知未読を既読にする
|
2018-08-23 03:29:39 +10:00
|
|
|
if (event.metaKey || event.ctrlKey) {
|
2018-07-28 07:25:12 +10:00
|
|
|
if (e.keyCode === 69) {
|
2020-02-09 01:51:46 +11:00
|
|
|
allNotfRead()
|
|
|
|
return false
|
2018-07-28 07:25:12 +10:00
|
|
|
}
|
2018-01-31 03:43:01 +11:00
|
|
|
}
|
2020-04-22 00:56:04 +10:00
|
|
|
//Ctrl+K:メニュー開閉
|
|
|
|
if (event.metaKey || event.ctrlKey) {
|
|
|
|
if (e.keyCode === 75) {
|
|
|
|
menu()
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
2018-01-31 03:43:01 +11:00
|
|
|
//Ctrl+Space:読み込み
|
2018-08-23 03:29:39 +10:00
|
|
|
if (event.metaKey || event.ctrlKey) {
|
2018-01-31 03:43:01 +11:00
|
|
|
if (e.keyCode === 32) {
|
2020-02-09 01:51:46 +11:00
|
|
|
parseColumn()
|
|
|
|
return false
|
2018-01-31 03:43:01 +11:00
|
|
|
}
|
|
|
|
}
|
2018-03-21 16:36:02 +11:00
|
|
|
//Ctrl+Sift+S:設定
|
2018-08-23 03:29:39 +10:00
|
|
|
if ((event.metaKey || event.ctrlKey) && event.shiftKey) {
|
2018-03-21 16:36:02 +11:00
|
|
|
if (e.keyCode === 83) {
|
2020-02-09 01:51:46 +11:00
|
|
|
location.href = 'setting.html'
|
|
|
|
return false
|
2018-03-21 16:36:02 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//Ctrl+Sift+M:アカマネ
|
2018-08-23 03:29:39 +10:00
|
|
|
if ((event.metaKey || event.ctrlKey) && event.shiftKey) {
|
2018-03-21 16:36:02 +11:00
|
|
|
if (e.keyCode === 77) {
|
2020-02-09 01:51:46 +11:00
|
|
|
location.href = 'acct.html'
|
|
|
|
return false
|
2018-03-21 16:36:02 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//Ctrl+Sift+P:プロフ
|
2019-07-13 01:00:26 +10:00
|
|
|
if ((event.metaKey || event.ctrlKey) && event.shiftKey) {
|
2018-03-21 16:36:02 +11:00
|
|
|
if (e.keyCode === 80) {
|
|
|
|
profShow()
|
2020-02-09 01:51:46 +11:00
|
|
|
return false
|
2018-01-31 03:43:01 +11:00
|
|
|
}
|
|
|
|
}
|
2018-03-27 13:39:35 +11:00
|
|
|
//数字:TL
|
2018-08-23 03:29:39 +10:00
|
|
|
if (event.metaKey || event.ctrlKey) {
|
2019-05-19 17:39:30 +10:00
|
|
|
if (e.keyCode >= 49 && e.keyCode <= 57) {
|
2020-07-10 15:16:39 +10:00
|
|
|
const kz = e.keyCode - 49
|
2020-02-09 01:51:46 +11:00
|
|
|
goColumn(kz)
|
|
|
|
return false
|
2019-05-19 17:39:30 +10:00
|
|
|
}
|
2018-03-27 13:39:35 +11:00
|
|
|
}
|
2019-07-12 01:53:55 +10:00
|
|
|
//矢印:選択
|
2020-02-09 01:51:46 +11:00
|
|
|
if (e.code == 'ArrowLeft') {
|
2019-07-12 01:53:55 +10:00
|
|
|
//left
|
2020-07-10 15:16:39 +10:00
|
|
|
if (document.querySelector('#imagemodal').classList.contains('open')) {
|
2020-02-09 01:51:46 +11:00
|
|
|
imgCont('prev')
|
|
|
|
return false
|
2019-07-29 02:13:53 +10:00
|
|
|
}
|
2019-07-12 01:53:55 +10:00
|
|
|
if (selectedColumn > 0) {
|
|
|
|
selectedColumn--
|
|
|
|
}
|
|
|
|
tootSelector(selectedColumn, selectedToot)
|
2020-02-09 01:51:46 +11:00
|
|
|
return false
|
|
|
|
} else if (e.code == 'ArrowUp') {
|
2019-07-12 01:53:55 +10:00
|
|
|
//up
|
2020-07-10 15:16:39 +10:00
|
|
|
if (document.querySelector('#imagemodal').classList.contains('open')) {
|
2020-02-09 01:51:46 +11:00
|
|
|
return false
|
2019-07-29 02:13:53 +10:00
|
|
|
}
|
2019-07-12 01:53:55 +10:00
|
|
|
if (selectedToot > 0) {
|
|
|
|
selectedToot--
|
|
|
|
}
|
|
|
|
tootSelector(selectedColumn, selectedToot)
|
2020-02-09 01:51:46 +11:00
|
|
|
return false
|
|
|
|
} else if (e.code == 'ArrowRight') {
|
2019-07-12 01:53:55 +10:00
|
|
|
//right
|
2020-07-10 15:16:39 +10:00
|
|
|
if (document.querySelector('#imagemodal').classList.contains('open')) {
|
2020-02-09 01:51:46 +11:00
|
|
|
imgCont('next')
|
|
|
|
return false
|
2019-07-29 02:13:53 +10:00
|
|
|
}
|
2020-02-09 01:51:46 +11:00
|
|
|
if (selectedColumn < $('.tl-box').length - 1) {
|
2019-07-12 01:53:55 +10:00
|
|
|
selectedColumn++
|
|
|
|
}
|
|
|
|
tootSelector(selectedColumn, selectedToot)
|
2020-02-09 01:51:46 +11:00
|
|
|
return false
|
|
|
|
} else if (e.code == 'ArrowDown') {
|
2019-07-12 01:53:55 +10:00
|
|
|
//down
|
2020-07-10 15:16:39 +10:00
|
|
|
if (document.querySelector('#imagemodal').classList.contains('open')) {
|
2020-02-09 01:51:46 +11:00
|
|
|
return false
|
2019-07-29 02:13:53 +10:00
|
|
|
}
|
2019-07-12 01:53:55 +10:00
|
|
|
selectedToot++
|
|
|
|
tootSelector(selectedColumn, selectedToot)
|
2020-02-09 01:51:46 +11:00
|
|
|
return false
|
2019-07-12 01:53:55 +10:00
|
|
|
}
|
2019-07-13 01:00:26 +10:00
|
|
|
//Ctrl+U:0,0選択
|
|
|
|
if (event.ctrlKey || event.metaKey) {
|
|
|
|
if (e.keyCode === 85) {
|
|
|
|
selectedToot = 0
|
|
|
|
selectedColumn = 0
|
|
|
|
tootSelector(0, 0)
|
2020-02-09 01:51:46 +11:00
|
|
|
return false
|
2019-07-13 01:00:26 +10:00
|
|
|
}
|
|
|
|
}
|
2019-07-12 01:53:55 +10:00
|
|
|
//選択時
|
2020-07-10 15:16:39 +10:00
|
|
|
const selectedId = document.querySelector('.selectedToot').getAttribute('unique-id')
|
|
|
|
const selectedAcctIds = document.querySelector(`#timeline_${selectedColumn}`).getAttribute('data-acct')
|
2019-07-12 01:53:55 +10:00
|
|
|
if (e.keyCode == 70) {
|
2020-07-10 15:16:39 +10:00
|
|
|
fav(selectedId, selectedAcctIds, false)
|
2020-02-09 01:51:46 +11:00
|
|
|
return false
|
2019-07-12 01:53:55 +10:00
|
|
|
}
|
|
|
|
if (e.keyCode == 66) {
|
2020-07-10 15:16:39 +10:00
|
|
|
rt(selectedId, selectedAcctIds, false)
|
2020-02-09 01:51:46 +11:00
|
|
|
return false
|
2019-07-12 01:53:55 +10:00
|
|
|
}
|
|
|
|
if (e.keyCode == 82) {
|
2020-07-10 15:16:39 +10:00
|
|
|
const target = document.querySelector('.selectedToot .rep-btn')
|
|
|
|
const ats_cm = target.getAttribute('data-men')
|
|
|
|
const mode = target.getAttribute('data-visen')
|
|
|
|
re(selectedId, ats_cm, selectedAcctIds, mode)
|
2020-02-09 01:51:46 +11:00
|
|
|
return false
|
2019-07-12 01:53:55 +10:00
|
|
|
}
|
2018-01-31 03:43:01 +11:00
|
|
|
}
|
|
|
|
//textareaフォーカス時
|
2018-09-11 04:59:44 +10:00
|
|
|
if (hasFocus2 && wv) {
|
2018-08-23 03:29:39 +10:00
|
|
|
if (event.metaKey || event.ctrlKey) {
|
2018-06-12 01:44:28 +10:00
|
|
|
//C+S+(No):ワンクリ
|
2018-08-23 03:29:39 +10:00
|
|
|
if ((event.metaKey || event.ctrlKey) && event.shiftKey) {
|
2018-06-12 01:44:28 +10:00
|
|
|
if (e.keyCode >= 49 && e.keyCode <= 51) {
|
2020-07-10 15:16:39 +10:00
|
|
|
const no = e.keyCode - 48
|
|
|
|
const oks = localStorage.getItem('oks-' + no)
|
|
|
|
if (oks) {
|
|
|
|
postBox.value = postBox.value + oks
|
2020-02-09 01:51:46 +11:00
|
|
|
}
|
|
|
|
return false
|
2018-06-12 01:44:28 +10:00
|
|
|
}
|
|
|
|
}
|
2018-01-31 03:43:01 +11:00
|
|
|
}
|
|
|
|
}
|
2020-02-09 01:51:46 +11:00
|
|
|
})
|
2018-01-31 03:43:01 +11:00
|
|
|
//クリアボタン
|
2020-07-10 15:16:39 +10:00
|
|
|
document.getElementById('clear').addEventListener('click', clear)
|
2020-02-09 01:51:46 +11:00
|
|
|
})
|
2019-07-12 01:53:55 +10:00
|
|
|
//選択する
|
|
|
|
function tootSelector(column, toot) {
|
2020-07-10 15:16:39 +10:00
|
|
|
const selectedToot = document.querySelector('.selectedToot')
|
|
|
|
let rect = {top: 0}
|
|
|
|
if (selectedToot) {
|
|
|
|
selectedToot.classList.remove('selectedToot')
|
|
|
|
rect = selectedToot.getBoundingClientRect()
|
|
|
|
}
|
|
|
|
document.querySelectorAll(`#timeline_${column} .cvo`)[toot].classList.add('selectedToot')
|
|
|
|
const scr = document.querySelector(`#tlBox${column}`).scrollTop
|
|
|
|
const elem = rect.top + document.body.scrollTop
|
|
|
|
let top = elem - getHeight('.tl-box') + scr
|
2019-07-12 01:53:55 +10:00
|
|
|
if (top > 0) {
|
2020-07-10 15:16:39 +10:00
|
|
|
top = top + getHeight('.selectedToot')
|
2019-07-13 01:00:26 +10:00
|
|
|
if (top > scr) {
|
2020-07-10 15:16:39 +10:00
|
|
|
$(`#tlBox${column}`).animate({ scrollTop: top })
|
2019-07-12 01:53:55 +10:00
|
|
|
}
|
|
|
|
} else if (elem < 0) {
|
2020-07-10 15:16:39 +10:00
|
|
|
const to = scr + elem - getHeight('.selectedToot')
|
2019-07-12 01:53:55 +10:00
|
|
|
if (to < scr) {
|
2020-07-10 15:16:39 +10:00
|
|
|
$(`#tlBox${column}`).animate({ scrollTop: to })
|
2019-07-12 01:53:55 +10:00
|
|
|
}
|
|
|
|
}
|
2020-07-10 15:16:39 +10:00
|
|
|
}
|