');
- });
+ // open error popup
+ printMessage("Please compare documents first");
}
+}
- $('#gd-cancel-button-' + prefix).on(userMouseClick, function() {
- // get selected files
- var button = $(this);
- // remove table row
- button.closest('div').parent().parent().parent().remove();
-
- clearAndShowSelection(prefix);
- });
-
- $("#gd-dropZone-" + prefix).hide();
+function addCloseSection(prefix) {
+ var close = '';
+ if ($("#gd-upload-section-" + prefix).find(".gd-close-dad-area").length == 0) {
+ $("#gd-upload-section-" + prefix).find(".gd-compare-area-head").append(close);
+ }
+}
- $("#gd-open-document-" + prefix).hide();
- if(isMobile()){
- $.each($(".swiper-slide"), function(index, slide){
- $(slide).removeClass("gd-desktop");
- });
- //initialize swiper when document ready
- var swiper = new Swiper ('.swiper-container');
- } else {
- $.each($(".swiper-slide"), function(index, slide){
- $(slide).removeClass("swiper-slide-cancel");
- });
+function convertIndexToString(index) {
+ switch (index) {
+ case 1:
+ return "first";
+ break;
+ case 2:
+ return "second";
+ break;
+ case 3:
+ return "third";
+ break;
+ case 4:
+ return "fourth";
+ break;
}
}
/**
- * Fill variables with data of first or second files
- *
- * @param prefix 'first' or 'second'
- * @param file file data
- * @param url url to file
- * @param path path to file
- */
-function fillFileVariables(prefix, file, url, path) {
- compareFileMap[prefix] = file;
- compareFileGuidMap[prefix] = path;
- compareFileUrlMap[prefix] = url;
+ * Get HTML content for drag and drop area
+ **/
+function getHtmlCompareSection(prefix) {
+ // drag and drop section
+ var htmlSection = '' +
+ '
' +
+ '
' +
+ '' +
+ '' +
+ '' +
+ '
' +
+ '
' +
+ '' +
+ '' +
+ '
' +
+ '
' +
+
+ '
' +
+ '
' +
+ '' +
+ '
' +
+ '
Drop your document here or click to select a file
' +
+ '
' +
+
+ //// pages BEGIN
+ '
' +
+ '
Loading... Please wait.
' +
+ '
' +
+ // // pages END
+ '';
+ return htmlSection;
}
/**
- * Upload document
- * @param {file} file - File for uploading
- * @param {int} index - Number of the file to upload
- * @param {string} url - URL of the file, set it if URL used instead of file
+ * Init remove button for selection area
+ * @param prefix - prefix for selection area
*/
-function uploadDocument(file, index, url = ''){
- // prepare form data for uploading
- var formData = new FormData();
- // add local file for uploading
- formData.append("file", file);
- // add URL if set
- formData.append("url", url);
- formData.append("rewrite", rewrite);
- $.ajax({
- // callback function which updates upload progress bar
- xhr: function()
- {
- var xhr = new window.XMLHttpRequest();
- // upload progress
- xhr.upload.addEventListener("progress", function(event){
- if (event.lengthComputable) {
- $(".gd-modal-close-action").off(userMouseClick);
- $("#gd-open-document").prop("disabled", true);
- // increase progress
- $("#gd-pregress-bar-" + index).addClass("p"+ Math.round(event.loaded / event.total * 100));
- if(event.loaded == event.total){
- $("#gd-pregress-bar-" + index).fadeOut();
- $("#gd-upload-complete-" + index).fadeIn();
- $('.gd-modal-close-action').on(userMouseClick, closeModal);
- $("#gd-open-document").prop("disabled", false);
- }
- }
- }, false);
- return xhr;
- },
- type: 'POST',
- url: getApplicationPath('uploadDocument'),
- data: formData,
- cache: false,
- contentType: false,
- processData: false,
- success: function(returnedData) {
- if(returnedData.message != undefined){
- // open error popup
- printMessage(returnedData.message);
- $("#gd-upload-complete-" + index).fadeOut();
- $("#gd-upload-failure-" + index).fadeIn();
- return;
+function initCloseButton() {
+ $(".gd-comparison-bar-wrapper").on(userMouseClick, '.gd-close-dad-area', function (e) {
+ closeDifferences();
+ $(".highlight-difference").remove();
+ var prefix = $(e.target).attr("id").split("-").pop();
+ if ($('#gd-upload-section-' + prefix).find(".gd-wrapper").length > 0) {
+ clearDocumentPreview(prefix);
+ removeDocInfoHead(prefix);
+ if ($(".gd-compare-section").length == 2) {
+ $('#gd-upload-section-' + prefix).find(".gd-close-dad-area").remove();
}
- },
- error: function(xhr, status, error) {
- if (xhr && xhr.responseText) {
- var err = eval("(" + xhr.responseText + ")");
- console.log(err.message);
- // open error popup
- printMessage(err.message);
+ } else {
+ $('#gd-upload-section-' + prefix).remove();
+ $(".gd-comparison-bar-wrapper").removeClass("full");
+ $(".gd-drag-n-drop-wrap-compare").removeClass("full");
+ $(".gd-compare-section").css("width", "inherit");
+ if ($(".gd-compare-section").length == 2 && $(".gd-compare-section").find(".gd-wrapper").length == 0) {
+ $('.gd-compare-section').find(".gd-close-dad-area").remove();
}
- $("#gd-upload-complete-" + index).fadeOut();
- $("#gd-upload-failure-" + index).fadeIn();
+ reIndexSections();
}
});
}
- /**
- * Print results
- */
- function printResults(){
- // get current document content
- var documentContainer = $("#gd-panzoom");
- // force each document page to be printed as a new page
- var cssPrint = '';
- // open print dialog
- var windowObject = window.open('', "PrintWindow", "width=750,height=650,top=50,left=50,toolbars=yes,scrollbars=yes,status=yes,resizable=yes");
- // add current document into the print window
- windowObject.document.writeln(cssPrint);
- // add current document into the print window
- windowObject.document.writeln(documentContainer[0].innerHTML);
- windowObject.document.close();
- windowObject.focus();
- windowObject.print();
- windowObject.close();
- }
-
- /**
- * Close modal
- */
- function closeModal(){
- toggleModalDialog(false, '');
- }
-
- /**
- * Get HTML content for file browser modal
- **/
- function getHtmlFileBrowser(){
- return ''+
- '
Loading... Please wait.
'+
- '
'+
- ''+
- '
'+
- '
'+
- '
Document
'+
- '
Format
'+
- '
Size
'+
- '
'+
- ''+
- ''+
- '
'+
- '
'+
- '
...
'+
- '
'+
- '
'+
- '
' +
- // list of files
- ''+
- '
'+
- '';
- }
-
- /**
- * Get HTML content for drag and drop area
- **/
- function getHtmlDragAndDropArea(prefix){
- // close icon for multi comparing
- var close = '';
- if (prefix && prefix.startsWith('idx')) {
- close = '
';
}
- // drag and drop section
- var htmlSection = ''+
- close +
- '
'+
- '
'+
- '
Drag & Drop the ' + replacePrefix(prefix) + ' file here
';
+ }
- return (deltas.left * deltas.right) >= x && (deltas.top * deltas.bottom) >= y;
- };
+ function getHtmlNavDownloadPanel() {
- /*
- ******************************************************************
- ******************************************************************
- CHECK IF MOBILE
- ******************************************************************
- ******************************************************************
- */
- var isMobile = function(){
- return 'ontouchstart' in window // works on most browsers
- || 'onmsgesturechange' in window; // works on ie10
- };
\ No newline at end of file
+ return '
Download
';
+ }
+})(jQuery);
\ No newline at end of file
diff --git a/viewer.html b/viewer.html
index 40f048d..0586481 100755
--- a/viewer.html
+++ b/viewer.html
@@ -20,7 +20,7 @@
$('#element').viewer({
applicationPath: 'http://' + host + ':8080/viewer/',
defaultDocument: '',
- preloadPageCount: 0,
+ preloadPageCount: 2,
rewrite: true,
zoom: true,
pageSelector: true,