File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -539,6 +539,12 @@ let get_textitems_spans = function(e) {
539
539
return $ ( `span.textitem[data-${ attr_name } ="${ attr_value } "]` ) . toArray ( ) ;
540
540
} ;
541
541
542
+ let handle_bookmark = function ( ) {
543
+ // Function defined in read/index.html ... yuck, need to reorganize this js code.
544
+ // TODO javascript: reorganize, or make modules.
545
+ add_bookmark ( ) ;
546
+ }
547
+
542
548
/** Copy the text of the textitemspans to the clipboard, and add a
543
549
* color flash. */
544
550
let handle_copy = function ( e ) {
@@ -787,6 +793,7 @@ function handle_keydown (e) {
787
793
const kRIGHT = 39 ;
788
794
const kUP = 38 ;
789
795
const kDOWN = 40 ;
796
+ const kB = 66 ; // B)ookmark
790
797
const kC = 67 ; // C)opy
791
798
const kT = 84 ; // T)ranslate
792
799
const kM = 77 ; // The(M)e
@@ -821,6 +828,7 @@ function handle_keydown (e) {
821
828
map [ kRIGHT ] = ( ) => move_cursor ( right_increment ) ;
822
829
map [ kUP ] = ( ) => increment_status_for_selected_elements ( e , + 1 ) ;
823
830
map [ kDOWN ] = ( ) => increment_status_for_selected_elements ( e , - 1 ) ;
831
+ map [ kB ] = ( ) => handle_bookmark ( ) ;
824
832
map [ kC ] = ( ) => handle_copy ( e ) ;
825
833
map [ kT ] = ( ) => show_sentence_translation ( e ) ;
826
834
map [ kM ] = ( ) => next_theme ( ) ;
Original file line number Diff line number Diff line change @@ -530,15 +530,12 @@ <h2>🎉</h2>
530
530
}
531
531
532
532
function add_bookmark ( ) {
533
- const text_id = document . querySelector ( '#text_id' ) ?. value ;
534
533
const book_id = document . querySelector ( '#book_id' ) ?. value ;
535
534
const page_num = document . querySelector ( '#page_num' ) ?. value ;
536
- let title = prompt ( `Enter a bookmark title for page ${ page_num } ` ) ;
535
+ let title = prompt ( `Enter bookmark title, or Cancel to quit ` ) ;
537
536
538
- if ( ! book_id || ! page_num || ! title ) {
539
- alert ( `Missing bookmark data. No bookmark added.` ) ;
540
- return
541
- }
537
+ if ( ! title )
538
+ return ;
542
539
543
540
fetch ( `/bookmarks/add` , {
544
541
method : "POST" ,
You can’t perform that action at this time.
0 commit comments