Better JQuery integration

0 votes
asked Jan 4, 2013 in To be sorted by anonymous

Currently in file jqery_plantuml.js your code isn't very reusable because once you add your script in some web application, the rawdeflate.js will not be loaded because of the changed path.

I experienced this problem when I integrated your code in Redmine.


I changed the code so rawdeflate.js path is determined from the path of jqery_plantuml, so you can put them anywhere and reference only the first one. The change is related to rawdeflate_url variable. I suggest you to add this (or something similar) to the official release.  I used *= selector because Rails adds attributes to the end of the script name.



var rawdeflate_url = $('script[src*="jquery_plantuml.js"]').attr('src');
rawdeflate_url = rawdeflate_url.substring(0,rawdeflate_url.lastIndexOf("/")+1) + 

var deflater = window.SharedWorker && new SharedWorker(rawdeflate_url);
if (deflater) {
 deflater.port.addEventListener('message', done_deflating, false);
} else if (window.Worker) {
 deflater = new Worker(rawdeflate_url);
 deflater.onmessage = done_deflating;

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:

[Antispam2 Feature: please please wait 1 or 2 minutes (this message will disappear) before pressing the button otherwise it will fail](--------)
To avoid this verification in future, please log in or register.