PHP File Manager
Editing File: print-commander.js
/** * Optionally used to deploy multiple versions of the applet for mixed * environments. Oracle uses document.write(), which puts the applet at the * top of the page, bumping all HTML content down. */ deployQZ(); /** * Deploys different versions of the applet depending on Java version. * Useful for removing warning dialogs for Java 6. This function is optional * however, if used, should replace the <applet> method. Needed to address * MANIFEST.MF TrustedLibrary=true discrepency between JRE6 and JRE7. */ function deployQZ() { var attributes = { id: 'qz', code: 'qz.PrintApplet.class', archive: '/assets/qz-print/qz-print.jar', width: 1, height: 1 }; var parameters = { jnlp_href: '/assets/qz-print/qz-print_jnlp.jnlp', cache_option: 'plugin', disable_logging: 'false', initial_focus: 'false' }; if(deployJava.versionCheck("1.7+") == true){} else if(deployJava.versionCheck("1.6+") == true) { delete parameters['jnlp_href']; } deployJava.runApplet(attributes, parameters, '1.5'); } /** * Automatically gets called when applet has loaded. */ function qzReady() { // Setup our global qz object window["qz"] = document.getElementById('qz'); } /** * Returns is the applet is not loaded properly */ function isLoaded(callback) { if(!qz) { callback(false); return false; } else { try { if(!qz.isActive()) { callback(false); return false; } } catch(err) { callback(false); return false; } } callback(true); } /** * Automatically gets called when "qz.print()" is finished. */ function qzDonePrinting() { if(qz.getException()) { $(window).triggerHandler('print-error', [ qz.getException().getLocalizedMessage() ]); qz.clearException(); return; } $(window).triggerHandler('print-success'); } function findPrinter(name, callback) { qz.findPrinter(name); window['qzDoneFinding'] = function() { var printer = qz.getPrinter(); window['qzDoneFinding'] = null; if(typeof callback === 'function') { callback((printer !== null)); } }; } function findPrinters(callback) { isLoaded(function(loaded) { qz.findPrinter('\\{bogus_printer\\}'); window['qzDoneFinding'] = function() { callback(qz.getPrinters().split(',')); window['qzDoneFinding'] = null; }; }); } function sendPrintCommand(command, callback) { isLoaded(function(loaded) { for(i = 0; i < command.length; i++) { qz.append(command[i]); } while(!qz.isDoneAppending()){} qz.print(); callback(); }); } /*************************************************************************** * Gets the current url's path, such as http://site.com/example/dist/ ***************************************************************************/ function getPath() { var path = window.location.href; return path.substring(0, path.lastIndexOf("/")) + "/"; } /** * Fixes some html formatting for printing. Only use on text, not on tags! * Very important! * 1. HTML ignores white spaces, this fixes that * 2. The right quotation mark breaks PostScript print formatting * 3. The hyphen/dash autoflows and breaks formatting */ function fixHTML(html) { return html.replace(/ /g, " ").replace(/’/g, "'").replace(/-/g,"‑"); } /** * Equivelant of VisualBasic CHR() function */ function chr(i) { return String.fromCharCode(i); } /*************************************************************************** * Prototype function for allowing the applet to run multiple instances. * IE and Firefox may benefit from this setting if using heavy AJAX to * rewrite the page. Use with care; * Usage: * qz.allowMultipleInstances(true); ***************************************************************************/ function allowMultiple() { isLoaded(function() { var multiple = qz.getAllowMultipleInstances(); qz.allowMultipleInstances(!multiple); alert('Allowing of multiple applet instances set to "' + !multiple + '"'); }); }
Cancel