diff options
author | Kruti Shah | 2012-05-31 10:44:45 -0700 |
---|---|---|
committer | Kruti Shah | 2012-05-31 10:44:45 -0700 |
commit | c350cc1c060fdf17357ddadce024267943784593 (patch) | |
tree | 453f86e88f1ee1dfda6fb4b7cc7b17e306e39536 /js/io/system/coreioapi.js | |
parent | fdc4f5c7f81ae3b9adeca2232e60268b4be594a2 (diff) | |
parent | 121d0e616f48aa7cd048763554089c20a1883d7a (diff) | |
download | ninja-c350cc1c060fdf17357ddadce024267943784593.tar.gz |
Merge branch 'refs/heads/TimelineUberjd' into TimelineUber
Conflicts:
js/panels/Timeline/Layer.reel/Layer.js
Signed-off-by: Kruti Shah <kruti.shah@motorola.com>
Diffstat (limited to 'js/io/system/coreioapi.js')
-rwxr-xr-x | js/io/system/coreioapi.js | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js index a06f45c6..1e6518fe 100755 --- a/js/io/system/coreioapi.js +++ b/js/io/system/coreioapi.js | |||
@@ -193,6 +193,23 @@ exports.CoreIoApi = Montage.create(Component, { | |||
193 | this._fileServiceURL = value; | 193 | this._fileServiceURL = value; |
194 | } | 194 | } |
195 | }, | 195 | }, |
196 | //////////////////////////////////////////////////////////////////// | ||
197 | //File service API URL | ||
198 | _webServiceURL: { | ||
199 | enumerable: false, | ||
200 | value: '/web' | ||
201 | }, | ||
202 | //////////////////////////////////////////////////////////////////// | ||
203 | // | ||
204 | webServiceURL: { | ||
205 | enumerable: false, | ||
206 | get: function() { | ||
207 | return String(this.rootUrl+this._webServiceURL); | ||
208 | }, | ||
209 | set: function(value) { | ||
210 | this._webServiceURL = value; | ||
211 | } | ||
212 | }, | ||
196 | //////////////////////////////////////////////////////////////////// | 213 | //////////////////////////////////////////////////////////////////// |
197 | //Directory service API URL | 214 | //Directory service API URL |
198 | _directoryServiceURL: { | 215 | _directoryServiceURL: { |
@@ -647,6 +664,53 @@ exports.CoreIoApi = Montage.create(Component, { | |||
647 | } | 664 | } |
648 | }, | 665 | }, |
649 | //////////////////////////////////////////////////////////////////// | 666 | //////////////////////////////////////////////////////////////////// |
667 | // Reads an external file (cross-domain) | ||
668 | // Parameters: | ||
669 | // the file parameter must contain the following properties | ||
670 | // url: string value containing the full file path/URL i.e. "http://google.com/motorola.html" | ||
671 | // binary parameter is optional if the content is to be binary | ||
672 | // Return values: | ||
673 | // returns an object with two properties | ||
674 | // success: boolean indicating if the call succeeded or failed | ||
675 | // content: string containing the file contents | ||
676 | // status: int indicating the request HTTP status code | ||
677 | // 200 - the file was read and its contents were returned | ||
678 | // 404 - the file does not exist | ||
679 | // 500 - unknown server error occurred | ||
680 | readExternalFile: { | ||
681 | enumerable: false, | ||
682 | value: function(file) { | ||
683 | // | ||
684 | var retValue = {success:null, content:null, status:null}; | ||
685 | // | ||
686 | if(file && file.url && file.url.length) { | ||
687 | try { | ||
688 | var serviceURL = this._prepareServiceURL(this.webServiceURL, ''), | ||
689 | xhr = new XMLHttpRequest(); | ||
690 | // | ||
691 | xhr.open("GET", serviceURL+"?url="+file.url, false); | ||
692 | if (file.binary) xhr.setRequestHeader("return-type", "binary"); | ||
693 | xhr.setRequestHeader("Content-Type", "text/plain"); | ||
694 | xhr.send(); | ||
695 | // | ||
696 | if (xhr.readyState === 4) { | ||
697 | retValue.status = xhr.status; | ||
698 | if(xhr.status == 200) { | ||
699 | retValue.content = xhr.response; | ||
700 | } | ||
701 | retValue.success = true; | ||
702 | } | ||
703 | } | ||
704 | catch(error) { | ||
705 | xhr = null; | ||
706 | retValue.success = false; | ||
707 | } | ||
708 | } | ||
709 | // | ||
710 | return retValue; | ||
711 | } | ||
712 | }, | ||
713 | //////////////////////////////////////////////////////////////////// | ||
650 | // Create a new directory/folder | 714 | // Create a new directory/folder |
651 | // Parameters: | 715 | // Parameters: |
652 | // the dir parameter must contain the following properties | 716 | // the dir parameter must contain the following properties |