From 8a192e03e0f59a9aa62787cbdda6af6e8e393663 Mon Sep 17 00:00:00 2001 From: Lu Wang Date: Sun, 10 Nov 2013 16:54:43 +0800 Subject: [PATCH] clean js --- TODO | 2 -- share/pdf2htmlEX.js.in | 22 ++++++++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/TODO b/TODO index 65dc079..3d0851a 100644 --- a/TODO +++ b/TODO @@ -7,8 +7,6 @@ more information on demo page: page idx vs no tracking current page -more js annoatation -pdf:mobile device pdf:miui tmp dir: use pid remove page from dom -- UI option diff --git a/share/pdf2htmlEX.js.in b/share/pdf2htmlEX.js.in index 7522429..53cc561 100644 --- a/share/pdf2htmlEX.js.in +++ b/share/pdf2htmlEX.js.in @@ -73,6 +73,9 @@ var EPS = 1e-6; /************************************/ /* utility function */ +/** + * @param{Array.} ctm + */ function invert(ctm) { var det = ctm[0] * ctm[3] - ctm[1] * ctm[2]; return [ ctm[3] / det @@ -83,6 +86,10 @@ function invert(ctm) { ,(ctm[1] * ctm[4] - ctm[0] * ctm[5]) / det ]; }; +/** + * @param{Array.} ctm + * @param{Array.} pos + */ function transform(ctm, pos) { return [ctm[0] * pos[0] + ctm[2] * pos[1] + ctm[4] ,ctm[1] * pos[0] + ctm[3] * pos[1] + ctm[5]]; @@ -175,6 +182,9 @@ Page.prototype = { this.shown = true; } }, + /** + * @param{number} ratio + */ rescale : function(ratio) { if(ratio == 0) { // reset scale @@ -234,9 +244,10 @@ Page.prototype = { /** * export pdf2htmlEX.Viewer * @constructor + * @param{Object=} config */ function Viewer(config) { - this.config = clone_and_extend_objs(DEFAULT_CONFIG, config); + this.config = clone_and_extend_objs(DEFAULT_CONFIG, (arguments.length > 0 ? config : {})); this.pages_loading = []; this.init_before_loading_content(); @@ -446,8 +457,8 @@ Viewer.prototype = { } }, - /* - * renew: renew the existing schedule instead of using the old one + /** + * @param{boolean} renew renew the existing schedule instead of using the old one */ schedule_render : function(renew) { if(this.render_timer !== undefined) { @@ -663,6 +674,9 @@ Viewer.prototype = { return null; }, + /** + * @param{Event} e + */ link_handler : function (e) { var target = e.target; @@ -762,7 +776,7 @@ Viewer.prototype = { /** * @param{number} page_idx - * @param{Array=} pos [x,y] in UNSCALED COORDINATION, where (0,0) is the top-left corner + * @param{Array.=} pos [x,y] in UNSCALED COORDINATION, where (0,0) is the top-left corner */ scroll_to : function(page_idx, pos) { var target_page = this.pages[page_idx];