Skip to content

Commit 8628ce1

Browse files
committed
js: get hash for current view
1 parent ace5b9a commit 8628ce1

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

share/pdf2htmlEX.js.in

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ var DEFAULT_CONFIG = {
6262
'render_timeout' : 100,
6363
// zoom ratio step for each zoom in/out event
6464
'scale_step' : 0.9,
65-
// register global key handler
65+
// register global key handler, allowing navigation by keyboard
6666
'key_handler' : true,
67-
// register hashchange handler
67+
// register hashchange handler, navigate to the location specified by the hash
6868
'hashchange_handler' : true,
6969

7070
'__dummy__' : 'no comma'
@@ -884,7 +884,6 @@ Viewer.prototype = {
884884

885885
this.rescale(zoom, false);
886886

887-
888887
var self = this;
889888
/**
890889
* page should of type Page
@@ -927,6 +926,26 @@ Viewer.prototype = {
927926
var container = this.container;
928927
container.scrollLeft += pos[0] - cur_target_pos[0];
929928
container.scrollTop += pos[1] - cur_target_pos[1];
929+
},
930+
931+
/**
932+
* generate the hash for the current view
933+
*/
934+
get_current_view_hash : function() {
935+
var detail = [];
936+
var cur_page = this.pages[this.cur_page_idx];
937+
938+
detail.push(cur_page.num);
939+
detail.push('XYZ');
940+
941+
var cur_pos = cur_page.view_position();
942+
cur_pos[1] = cur_page.height() - cur_pos[1];
943+
detail.push(cur_pos[0] / this.scale);
944+
detail.push(cur_pos[1] / this.scale);
945+
946+
detail.push(this.scale);
947+
948+
return JSON.stringify(detail);
930949
}
931950
};
932951

0 commit comments

Comments
 (0)