diff options
author | Jose Antonio Marquez | 2012-03-22 16:23:40 -0700 |
---|---|---|
committer | Jose Antonio Marquez | 2012-03-22 16:24:33 -0700 |
commit | d87cded11dcc0faf41a4a3e6b587e5549c0da6df (patch) | |
tree | a6ab56d0ad88566b19d1472452657ab20c92a14b /js/mediators | |
parent | e9c6c5e333e097dfeadc944d9b7fcd8f4d3a06f6 (diff) | |
download | ninja-d87cded11dcc0faf41a4a3e6b587e5549c0da6df.tar.gz |
Adding Ninja URL method to io-mediator
Diffstat (limited to 'js/mediators')
-rw-r--r-- | js/mediators/io-mediator.js | 56 |
1 files changed, 52 insertions, 4 deletions
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index d81f4543..df0a41df 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js | |||
@@ -470,8 +470,6 @@ function loadWebGL (e) {\n\ | |||
470 | getUrlfromNinjaUrl: { | 470 | getUrlfromNinjaUrl: { |
471 | enumerable: false, | 471 | enumerable: false, |
472 | value: function (url, fileRootUrl, fileUrl) { | 472 | value: function (url, fileRootUrl, fileUrl) { |
473 | //console.log("Params: ", url, fileRootUrl, fileUrl); | ||
474 | //console.log("Getting: " + url); | ||
475 | // | 473 | // |
476 | if (url.indexOf(fileRootUrl) !== -1) { | 474 | if (url.indexOf(fileRootUrl) !== -1) { |
477 | url = url.replace(new RegExp(fileRootUrl.replace(/\//gi, '\\\/'), 'gi'), ''); | 475 | url = url.replace(new RegExp(fileRootUrl.replace(/\//gi, '\\\/'), 'gi'), ''); |
@@ -499,13 +497,63 @@ function loadWebGL (e) {\n\ | |||
499 | // | 497 | // |
500 | url = (path+newURL).replace(/\/\//gi, '/'); | 498 | url = (path+newURL).replace(/\/\//gi, '/'); |
501 | } | 499 | } |
502 | //console.log("Returning: " + url); | ||
503 | //console.log("-----"); | ||
504 | // | 500 | // |
505 | return url; | 501 | return url; |
506 | } | 502 | } |
507 | }, | 503 | }, |
508 | //////////////////////////////////////////////////////////////////// | 504 | //////////////////////////////////////////////////////////////////// |
505 | // | ||
506 | getDocRootUrl: { | ||
507 | value: function () { | ||
508 | return this.application.ninja.coreIoApi.rootUrl+escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]).replace(/\/\//gi, '/')); | ||
509 | } | ||
510 | }, | ||
511 | //////////////////////////////////////////////////////////////////// | ||
512 | // | ||
513 | getNinjaPropUrlRedirect: { | ||
514 | enumerable: false, | ||
515 | value: function (prop/* , root */) { | ||
516 | //Checking for property value to not contain a full direct URL | ||
517 | 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)) { | ||
518 | //Checking for attributes and type of source | ||
519 | if (prop.indexOf('href') !== -1 || prop.indexOf('src') !== -1) { | ||
520 | //From HTML attribute | ||
521 | //if (root) { | ||
522 | //prop = (root+prop).replace(/"([^"]*)"/gi, this.getNinjaUrlPrepend.bind(this)); | ||
523 | //} else { | ||
524 | prop = prop.replace(/"([^"]*)"/gi, this.getNinjaUrlPrepend.bind(this)); | ||
525 | //} | ||
526 | } else if (prop.indexOf('url') !== -1) { | ||
527 | //From CSS property | ||
528 | //if (root) { | ||
529 | //prop = (root+prop).replace(/[^()\\""\\'']+/g, cssUrlToNinjaUrl.bind(this)); | ||
530 | //} else { | ||
531 | prop = prop.replace(/[^()\\""\\'']+/g, cssUrlToNinjaUrl.bind(this)); | ||
532 | //} | ||
533 | function cssUrlToNinjaUrl (s) { | ||
534 | if (s !== 'url') { | ||
535 | s = this.getDocRootUrl() + s; | ||
536 | } | ||
537 | return s; | ||
538 | } | ||
539 | } | ||
540 | } | ||
541 | return prop; | ||
542 | } | ||
543 | }, | ||
544 | //////////////////////////////////////////////////////////////////// | ||
545 | // | ||
546 | getNinjaUrlPrepend: { | ||
547 | enumerable: false, | ||
548 | value: function (url) { | ||
549 | if (url.indexOf('data:') !== -1) { | ||
550 | return url; | ||
551 | } else { | ||
552 | return '"'+this.getDocRootUrl()+url.replace(/\"/gi, '')+'"'; | ||
553 | } | ||
554 | } | ||
555 | }, | ||
556 | //////////////////////////////////////////////////////////////////// | ||
509 | //Method to return a string from CSS rules (to be saved to a file) | 557 | //Method to return a string from CSS rules (to be saved to a file) |
510 | getCssFromRules: { | 558 | getCssFromRules: { |
511 | enumerable: false, | 559 | enumerable: false, |