aboutsummaryrefslogtreecommitdiff
path: root/js/mediators/io-mediator.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/mediators/io-mediator.js')
-rw-r--r--js/mediators/io-mediator.js56
1 files changed, 52 insertions, 4 deletions
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js
index 18a517a5..cbed3a99 100644
--- a/js/mediators/io-mediator.js
+++ b/js/mediators/io-mediator.js
@@ -532,8 +532,6 @@ function loadWebGL (e) {\n\
532 getUrlfromNinjaUrl: { 532 getUrlfromNinjaUrl: {
533 enumerable: false, 533 enumerable: false,
534 value: function (url, fileRootUrl, fileUrl) { 534 value: function (url, fileRootUrl, fileUrl) {
535 //console.log("Params: ", url, fileRootUrl, fileUrl);
536 //console.log("Getting: " + url);
537 // 535 //
538 if (url.indexOf(fileRootUrl) !== -1) { 536 if (url.indexOf(fileRootUrl) !== -1) {
539 url = url.replace(new RegExp(fileRootUrl.replace(/\//gi, '\\\/'), 'gi'), ''); 537 url = url.replace(new RegExp(fileRootUrl.replace(/\//gi, '\\\/'), 'gi'), '');
@@ -561,13 +559,63 @@ function loadWebGL (e) {\n\
561 // 559 //
562 url = (path+newURL).replace(/\/\//gi, '/'); 560 url = (path+newURL).replace(/\/\//gi, '/');
563 } 561 }
564 //console.log("Returning: " + url);
565 //console.log("-----");
566 // 562 //
567 return url; 563 return url;
568 } 564 }
569 }, 565 },
570 //////////////////////////////////////////////////////////////////// 566 ////////////////////////////////////////////////////////////////////
567 //
568 getDocRootUrl: {
569 value: function () {
570 return this.application.ninja.coreIoApi.rootUrl+escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]).replace(/\/\//gi, '/'));
571 }
572 },
573 ////////////////////////////////////////////////////////////////////
574 //
575 getNinjaPropUrlRedirect: {
576 enumerable: false,
577 value: function (prop/* , root */) {
578 //Checking for property value to not contain a full direct URL
579 if (!prop.match(/(\b(?:(?:https?|ftp|file|[A-Za-z]+):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$]))/gi)) {
580 //Checking for attributes and type of source
581 if (prop.indexOf('href') !== -1 || prop.indexOf('src') !== -1) {
582 //From HTML attribute
583 //if (root) {
584 //prop = (root+prop).replace(/"([^"]*)"/gi, this.getNinjaUrlPrepend.bind(this));
585 //} else {
586 prop = prop.replace(/"([^"]*)"/gi, this.getNinjaUrlPrepend.bind(this));
587 //}
588 } else if (prop.indexOf('url') !== -1) {
589 //From CSS property
590 //if (root) {
591 //prop = (root+prop).replace(/[^()\\""\\'']+/g, cssUrlToNinjaUrl.bind(this));
592 //} else {
593 prop = prop.replace(/[^()\\""\\'']+/g, cssUrlToNinjaUrl.bind(this));
594 //}
595 function cssUrlToNinjaUrl (s) {
596 if (s !== 'url') {
597 s = this.getDocRootUrl() + s;
598 }
599 return s;
600 }
601 }
602 }
603 return prop;
604 }
605 },
606 ////////////////////////////////////////////////////////////////////
607 //
608 getNinjaUrlPrepend: {
609 enumerable: false,
610 value: function (url) {
611 if (url.indexOf('data:') !== -1) {
612 return url;
613 } else {
614 return '"'+this.getDocRootUrl()+url.replace(/\"/gi, '')+'"';
615 }
616 }
617 },
618 ////////////////////////////////////////////////////////////////////
571 //Method to return a string from CSS rules (to be saved to a file) 619 //Method to return a string from CSS rules (to be saved to a file)
572 getCssFromRules: { 620 getCssFromRules: {
573 enumerable: false, 621 enumerable: false,