Skip to content

Commit

Permalink
add keyboard shortcut list on index
Browse files Browse the repository at this point in the history
  • Loading branch information
cutls committed Apr 23, 2023
1 parent 161eb9a commit c6e9dcf
Show file tree
Hide file tree
Showing 13 changed files with 289 additions and 205 deletions.
43 changes: 14 additions & 29 deletions app/js/common/keyshortcut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { re } from '../post/useTxtBox'
import { isIVis } from '../post/secure'
import { hide, show } from '../ui/postBox'
import { nowplaying } from '../ui/spotify'
import { menu } from '../ui/menu'
import { keyShortcut, menu } from '../ui/menu'
import { parseColumn } from '../ui/layout'
import { profShow } from '../userdata/showOnTL'
import { imgCont } from '../ui/img'
Expand Down Expand Up @@ -116,12 +116,7 @@ export function initKeyboard() {
if (e.metaKey || e.ctrlKey) {
if (e.keyCode === 86) {
show()
}
}
//Ctrl+F:検索
if (e.metaKey || e.ctrlKey) {
if (e.keyCode === 70) {
srcBox('toggle')
document.getElementById('textarea')?.focus()
}
}
//X:開閉
Expand Down Expand Up @@ -157,28 +152,26 @@ export function initKeyboard() {
return false
}
}
//Ctrl+Space:読み込み
if (e.metaKey || e.ctrlKey) {
if (e.keyCode === 32) {
parseColumn()
return false
}
//?: キーボードショートカット一覧
if (e.key === '?') {
menu()
keyShortcut()
}
//Ctrl+Sift+S:設定
//Ctrl+Shift+S:設定
if ((e.metaKey || e.ctrlKey) && e.shiftKey) {
if (e.keyCode === 83) {
location.href = 'setting.html'
return false
}
}
//Ctrl+Sift+M:アカマネ
//Ctrl+Shift+M:アカマネ
if ((e.metaKey || e.ctrlKey) && e.shiftKey) {
if (e.keyCode === 77) {
location.href = 'acct.html'
return false
}
}
//Ctrl+Sift+P:プロフ
//Ctrl+Shift+P:プロフ
if ((e.metaKey || e.ctrlKey) && e.shiftKey) {
if (e.keyCode === 80) {
profShow()
Expand Down Expand Up @@ -235,15 +228,6 @@ export function initKeyboard() {
tootSelector(globalThis.selectedColumn, globalThis.selectedToot)
return false
}
//Ctrl+U:0,0選択
if (e.ctrlKey || e.metaKey) {
if (e.keyCode === 85) {
globalThis.selectedToot = 0
globalThis.selectedColumn = 0
tootSelector(0, 0)
return false
}
}
//選択時
if (e.keyCode === 70) {
const id = $('.selectedToot').attr('unique-id')
Expand Down Expand Up @@ -273,7 +257,7 @@ export function initKeyboard() {
//textareaフォーカス時
if (hasFocus2 && wv) {
if (e.metaKey || e.ctrlKey) {
//C+S+(No):ワンクリ
//Ctrl+Shift+(No):ワンクリ
if ((e.metaKey || e.ctrlKey) && e.shiftKey) {
if (e.keyCode >= 49 && e.keyCode <= 51) {
const no = e.keyCode - 48
Expand All @@ -286,7 +270,8 @@ export function initKeyboard() {
}
}
}
if (e.code === 'Tab') {
// Shift + Tab: アカウント選択
if (e.shiftKey && e.code === 'Tab') {
const elm = document.getElementById('post-acct-sel')
if (!elm) return console.log('no elm')
const instance = formSelectGetInstance(elm)
Expand All @@ -302,10 +287,10 @@ export function initKeyboard() {
}
//選択する
function tootSelector(column, toot) {
$('.cvo').removeClass('.selectedToot')
$('.cvo').removeClass('selectedToot')
$('#timeline_' + column + ' .cvo')
.eq(toot)
.addClass('.selectedToot')
.addClass('selectedToot')
const scr = $('.tl-box[tlid=' + column + ']').scrollTop() || 0
const elem = $('.selectedToot').offset()?.top || 0
let top = elem - ($('.tl-box').height() || 0) + scr
Expand Down
3 changes: 2 additions & 1 deletion app/js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ import {
colorAddMulti,
colorAdd,
} from './ui/layout'
import { menu, help } from './ui/menu'
import { menu, help, keyShortcut } from './ui/menu'
import { hide, mini, show, initPostbox, mdCheck } from './ui/postBox'
import { scrollEvent, scrollCk, goTop, goColumn } from './ui/scroll'
import {
Expand Down Expand Up @@ -415,6 +415,7 @@ globalThis.leftFoldRemove = leftFoldRemove
globalThis.resetWidth = resetWidth
globalThis.menu = menu
globalThis.help = help
globalThis.keyShortcut = keyShortcut
globalThis.hide = hide
globalThis.mini = mini
globalThis.show = show
Expand Down
41 changes: 29 additions & 12 deletions app/js/platform/first.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import { voiceSettingLoad } from '../tl/speech'
import { configLoad, climute, ctLoad, oksload, pluginLoad, wordemp, wordmute } from '../ui/settings'
import { checkSpotify } from '../ui/spotify'
import { migrate } from './migrate'
import { getMulti } from '../common/storage'
import { idata } from '../login/instance'
// Migrator: tagのnameだけから、any/none等対応の形にするのと、any, noneがstringになってるのをarrayにする
// 独自ロケールを削除
// wordmuteListにtagとかいう要素がある
Expand Down Expand Up @@ -66,19 +68,34 @@ async function init() {
})
}, 2000)
}

const isDarwin = localStorage.getItem('platform') === 'darwin'
if (isDarwin) {
$('.shift').text('⇧')
$('.ctrl').text('⌘')
$('.alt').text('⌥')
$('.esc').text('esc')
$('.enter').text('↩')
$('.tab').text('⇥')
}
const obj = getMulti()
const finder = obj.find((o) => idata[o.domain + '_glitch'])
if (finder) $('.onlyGlitch').removeClass('hide')
const onSetting = !!document.getElementById('envView')
if (!onSetting) return
//最初に読む
configLoad()
climute()
wordmute()
wordemp()
checkSpotify()
voiceSettingLoad()
oksload()
ctLoad()
pluginLoad()
$('body').addClass(localStorage.getItem('platform') || 'win')
if (onSetting) {
//最初に読む
configLoad()
climute()
wordmute()
wordemp()
checkSpotify()
voiceSettingLoad()
oksload()
ctLoad()
pluginLoad()
$('body').addClass(localStorage.getItem('platform') || 'win')
}

}

const size = localStorage.getItem('size')
Expand Down
3 changes: 2 additions & 1 deletion app/js/post/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import api from '../common/fetch'
import { alertProcessUnfinished } from './img'
import { pollCalc } from '../tl/poll'
import { hide, mdCheck } from '../ui/postBox'
import { idata } from '../login/instance'

export function sec() {
const modeRaw: string | null = localStorage.getItem('sec')
Expand Down Expand Up @@ -96,7 +97,7 @@ export async function post(postVis?: IVis, dry?: boolean, tagClear?: boolean ) {
if (!isIVis(vis)) return
if (vis !== 'inherit' && vis !== 'local') {
toot.visibility = vis
} else if (vis === 'local') {
} else if (vis === 'local' && idata[domain + '_glitch']) {
toot.status = str + '👁️'
}
if ($('#cw').hasClass('cw-avail')) {
Expand Down
10 changes: 8 additions & 2 deletions app/js/ui/menu.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import $ from 'jquery'
declare let jQuery
export function menu() {
export function menu(forceOpen?: boolean) {
localStorage.setItem('menu-done', 'true')
$('#fukidashi').addClass('hide')
if (!$('#menu').hasClass('appear')) {
if (!$('#menu').hasClass('appear') || forceOpen) {
$('#menu').addClass('appear')
const bodyWidth = $('body').width() || 0
const bodyHeight = $('body').height() || 0
Expand Down Expand Up @@ -83,3 +83,9 @@ export function help() {
$('#help-box').removeClass('hide')
postMessage(['sendSinmpleIpc', 'getLogs'], '*')
}
export function keyShortcut() {
$('#left-menu a').removeClass('active')
$('#ksMenu').addClass('active')
$('.menu-content').addClass('hide')
$('#ks-box').removeClass('hide')
}
Loading

0 comments on commit c6e9dcf

Please sign in to comment.