CP: search when selected or Ctrl+F

This commit is contained in:
cutls 2020-02-08 23:51:46 +09:00
parent 5d9327d3d3
commit 56fe5e6345
2 changed files with 109 additions and 99 deletions

View File

@ -3,189 +3,195 @@ selectedToot = 0
$(function($) { $(function($) {
//キーボードショートカット //キーボードショートカット
$(window).keydown(function(e) { $(window).keydown(function(e) {
var hasFocus = $('input').is(':focus'); var hasFocus = $('input').is(':focus')
var hasFocus2 = $('textarea').is(':focus'); var hasFocus2 = $('textarea').is(':focus')
if (document.getElementById("webview")) { if (document.getElementById('webview')) {
if ($("#webviewsel:checked").val()) { if ($('#webviewsel:checked').val()) {
var wv = false; var wv = false
} else { } else {
var wv = true; var wv = true
} }
} else { } else {
var wv = true; var wv = true
} }
//Enter //Enter
if (e.keyCode === 13) { if (e.keyCode === 13) {
if($("#src").is(':focus')){ if ($('#src').is(':focus')) {
src() src()
return false; return false
} }
if($("#list-add").is(':focus')){ if ($('#list-add').is(':focus')) {
makeNewList() makeNewList()
return false; return false
} }
} }
//Ctrl+Shift+Enter:Lgen //Ctrl+Shift+Enter:Lgen
if (event.metaKey || event.ctrlKey && wv) { if (event.metaKey || (event.ctrlKey && wv)) {
if (event.shiftKey) { if (event.shiftKey) {
if (e.keyCode === 13) { if (e.keyCode === 13) {
post('local'); post('local')
return false; return false
} }
} }
} }
//Ctrl+Enter:投稿 //Ctrl+Enter:投稿
if (event.metaKey || event.ctrlKey && wv) { if (event.metaKey || (event.ctrlKey && wv)) {
if (e.keyCode === 13) { if (e.keyCode === 13) {
post(); post()
return false; return false
} }
} }
//Alt+Enter:セカンダリー //Alt+Enter:セカンダリー
if (event.metaKey || event.altKey && wv) { if (event.metaKey || (event.altKey && wv)) {
if (e.keyCode === 13) { if (e.keyCode === 13) {
sec(); sec()
return false; return false
} }
} }
//Esc:消す //Esc:消す
if (e.keyCode === 27 && wv) { if (e.keyCode === 27 && wv) {
hide(); hide()
return false; return false
} }
//F5リロード //F5リロード
if (e.keyCode === 116 && wv) { if (e.keyCode === 116 && wv) {
location.href = "index.html"; location.href = 'index.html'
return false; return false
} }
//Ctrl+Sift+C:全消し //Ctrl+Sift+C:全消し
if (((event.metaKey || event.ctrlKey) && event.shiftKey) && wv) { if ((event.metaKey || event.ctrlKey) && event.shiftKey && wv) {
if (e.keyCode === 67) { if (e.keyCode === 67) {
clear(); clear()
return false; return false
} }
} }
//Ctrl+Sift+N:NowPlaying //Ctrl+Sift+N:NowPlaying
if (((event.metaKey || event.ctrlKey) && event.shiftKey) && wv) { if ((event.metaKey || event.ctrlKey) && event.shiftKey && wv) {
if (e.keyCode === 78) { if (e.keyCode === 78) {
show(); show()
nowplaying() nowplaying()
return false; return false
} }
} }
//input/textareaにフォーカスなし時 //input/textareaにフォーカスなし時
if ((!hasFocus && !hasFocus2) && wv) { if (!hasFocus && !hasFocus2 && wv) {
if (!wv) { if (!wv) {
return true; return true
} }
//Ctrl+V:いつもの //Ctrl+V:いつもの
if (event.metaKey || event.ctrlKey) { if (event.metaKey || event.ctrlKey) {
if (e.keyCode === 86) { if (e.keyCode === 86) {
show(); show()
}
}
//Ctrl+F:検索
if (event.metaKey || event.ctrlKey) {
if (e.keyCode === 70) {
srcBox()
} }
} }
//X:開閉 //X:開閉
if (e.keyCode === 88) { if (e.keyCode === 88) {
if (!$("#post-box").hasClass("appear")) { if (!$('#post-box').hasClass('appear')) {
show(); show()
$('textarea').focus(); $('textarea').focus()
} else { } else {
hide(); hide()
} }
return false; return false
} }
//N:新トゥート //N:新トゥート
if (e.keyCode === 78) { if (e.keyCode === 78) {
if (!$("#post-box").hasClass("appear")) { if (!$('#post-box').hasClass('appear')) {
show(); show()
} }
$('textarea').focus(); $('textarea').focus()
return false; return false
} }
//Ctrl+E:全ての通知未読を既読にする //Ctrl+E:全ての通知未読を既読にする
if (event.metaKey || event.ctrlKey) { if (event.metaKey || event.ctrlKey) {
if (e.keyCode === 69) { if (e.keyCode === 69) {
allNotfRead(); allNotfRead()
return false; return false
} }
} }
//Ctrl+Space:読み込み //Ctrl+Space:読み込み
if (event.metaKey || event.ctrlKey) { if (event.metaKey || event.ctrlKey) {
if (e.keyCode === 32) { if (e.keyCode === 32) {
parseColumn(); parseColumn()
return false; return false
} }
} }
//Ctrl+Sift+S:設定 //Ctrl+Sift+S:設定
if ((event.metaKey || event.ctrlKey) && event.shiftKey) { if ((event.metaKey || event.ctrlKey) && event.shiftKey) {
if (e.keyCode === 83) { if (e.keyCode === 83) {
location.href = "setting.html"; location.href = 'setting.html'
return false; return false
} }
} }
//Ctrl+Sift+M:アカマネ //Ctrl+Sift+M:アカマネ
if ((event.metaKey || event.ctrlKey) && event.shiftKey) { if ((event.metaKey || event.ctrlKey) && event.shiftKey) {
if (e.keyCode === 77) { if (e.keyCode === 77) {
location.href = "acct.html"; location.href = 'acct.html'
return false; return false
} }
} }
//Ctrl+Sift+P:プロフ //Ctrl+Sift+P:プロフ
if ((event.metaKey || event.ctrlKey) && event.shiftKey) { if ((event.metaKey || event.ctrlKey) && event.shiftKey) {
if (e.keyCode === 80) { if (e.keyCode === 80) {
profShow() profShow()
return false; return false
} }
} }
//数字:TL //数字:TL
if (event.metaKey || event.ctrlKey) { if (event.metaKey || event.ctrlKey) {
if (e.keyCode >= 49 && e.keyCode <= 57) { if (e.keyCode >= 49 && e.keyCode <= 57) {
var kz = e.keyCode - 49; var kz = e.keyCode - 49
goColumn(kz); goColumn(kz)
return false; return false
} }
} }
//矢印:選択 //矢印:選択
if (e.code == "ArrowLeft") { if (e.code == 'ArrowLeft') {
//left //left
if ($("#imagemodal").hasClass("open")) { if ($('#imagemodal').hasClass('open')) {
imgCont('prev'); imgCont('prev')
return false; return false
} }
if (selectedColumn > 0) { if (selectedColumn > 0) {
selectedColumn-- selectedColumn--
} }
tootSelector(selectedColumn, selectedToot) tootSelector(selectedColumn, selectedToot)
return false; return false
} else if (e.code == "ArrowUp") { } else if (e.code == 'ArrowUp') {
//up //up
if ($("#imagemodal").hasClass("open")) { if ($('#imagemodal').hasClass('open')) {
return false; return false
} }
if (selectedToot > 0) { if (selectedToot > 0) {
selectedToot-- selectedToot--
} }
tootSelector(selectedColumn, selectedToot) tootSelector(selectedColumn, selectedToot)
return false; return false
} else if (e.code == "ArrowRight") { } else if (e.code == 'ArrowRight') {
//right //right
if ($("#imagemodal").hasClass("open")) { if ($('#imagemodal').hasClass('open')) {
imgCont('next'); imgCont('next')
return false; return false
} }
if (selectedColumn < $(".tl-box").length - 1) { if (selectedColumn < $('.tl-box').length - 1) {
selectedColumn++ selectedColumn++
} }
tootSelector(selectedColumn, selectedToot) tootSelector(selectedColumn, selectedToot)
return false; return false
} else if (e.code == "ArrowDown") { } else if (e.code == 'ArrowDown') {
//down //down
if ($("#imagemodal").hasClass("open")) { if ($('#imagemodal').hasClass('open')) {
return false; return false
} }
selectedToot++ selectedToot++
tootSelector(selectedColumn, selectedToot) tootSelector(selectedColumn, selectedToot)
return false; return false
} }
//Ctrl+U:0,0選択 //Ctrl+U:0,0選択
if (event.ctrlKey || event.metaKey) { if (event.ctrlKey || event.metaKey) {
@ -193,29 +199,29 @@ $(function ($) {
selectedToot = 0 selectedToot = 0
selectedColumn = 0 selectedColumn = 0
tootSelector(0, 0) tootSelector(0, 0)
return false; return false
} }
} }
//選択時 //選択時
if (e.keyCode == 70) { if (e.keyCode == 70) {
var id = $(".selectedToot").attr('unique-id') var id = $('.selectedToot').attr('unique-id')
var acct_id = $('#timeline_' + selectedColumn).attr("data-acct") var acct_id = $('#timeline_' + selectedColumn).attr('data-acct')
fav(id, acct_id, false) fav(id, acct_id, false)
return false; return false
} }
if (e.keyCode == 66) { if (e.keyCode == 66) {
var id = $(".selectedToot").attr('unique-id') var id = $('.selectedToot').attr('unique-id')
var acct_id = $('#timeline_' + selectedColumn).attr("data-acct") var acct_id = $('#timeline_' + selectedColumn).attr('data-acct')
rt(id, acct_id, false) rt(id, acct_id, false)
return false; return false
} }
if (e.keyCode == 82) { if (e.keyCode == 82) {
var id = $(".selectedToot").attr('unique-id') var id = $('.selectedToot').attr('unique-id')
var acct_id = $('#timeline_' + selectedColumn).attr("data-acct") var acct_id = $('#timeline_' + selectedColumn).attr('data-acct')
var ats_cm = $('.selectedToot .rep-btn').attr("data-men") var ats_cm = $('.selectedToot .rep-btn').attr('data-men')
var mode = $('.selectedToot .rep-btn').attr("data-visen") var mode = $('.selectedToot .rep-btn').attr('data-visen')
re(id, ats_cm, acct_id, mode) re(id, ats_cm, acct_id, mode)
return false; return false
} }
} }
//textareaフォーカス時 //textareaフォーカス時
@ -224,23 +230,27 @@ $(function ($) {
//C+S+(No):ワンクリ //C+S+(No):ワンクリ
if ((event.metaKey || event.ctrlKey) && event.shiftKey) { if ((event.metaKey || event.ctrlKey) && event.shiftKey) {
if (e.keyCode >= 49 && e.keyCode <= 51) { if (e.keyCode >= 49 && e.keyCode <= 51) {
var no = e.keyCode - 48; var no = e.keyCode - 48
if (localStorage.getItem("oks-" + no)) { $("#textarea").val($("#textarea").val() + localStorage.getItem("oks-" + no)) } if (localStorage.getItem('oks-' + no)) {
return false; $('#textarea').val($('#textarea').val() + localStorage.getItem('oks-' + no))
}
return false
} }
} }
} }
} }
}); })
//クリアボタン //クリアボタン
$("#clear").click(function () { $('#clear').click(function() {
clear(); clear()
}); })
}); })
//選択する //選択する
function tootSelector(column, toot) { function tootSelector(column, toot) {
$('.cvo').removeClass("selectedToot") $('.cvo').removeClass('selectedToot')
$('#timeline_' + column + ' .cvo').eq(toot).addClass("selectedToot") $('#timeline_' + column + ' .cvo')
.eq(toot)
.addClass('selectedToot')
var scr = $('.tl-box[tlid=' + column + ']').scrollTop() var scr = $('.tl-box[tlid=' + column + ']').scrollTop()
var elem = $('.selectedToot').offset().top var elem = $('.selectedToot').offset().top
var top = elem - $('.tl-box').height() + scr var top = elem - $('.tl-box').height() + scr

View File

@ -36,7 +36,7 @@
<textarea id="copy" style="top:-100px; position:fixed;"></textarea> <textarea id="copy" style="top:-100px; position:fixed;"></textarea>
<canvas id="canvas" style="top:-100px; position:fixed;width:32px;height:32px" width="32" height="32"></canvas> <canvas id="canvas" style="top:-100px; position:fixed;width:32px;height:32px" width="32" height="32"></canvas>
<div id="pageSrc" class="hide z-depth-5"> <div id="pageSrc" class="hide z-depth-5">
<input type="text" id="pageSrcInput"> <input type="text" id="pageSrcInput" placeholder="@@search@@">
<button class="btn waves-effect" onclick="doSrc('web')" title="@@webSrc@@"><i class="material-icons">open_in_browser</i></button> <button class="btn waves-effect" onclick="doSrc('web')" title="@@webSrc@@"><i class="material-icons">open_in_browser</i></button>
<button class="btn waves-effect" onclick="doSrc('ts')" title="@@tsSrc@@"><i class="material-icons">chat</i></button> <button class="btn waves-effect" onclick="doSrc('ts')" title="@@tsSrc@@"><i class="material-icons">chat</i></button>
</div> </div>