Commit 0e8ab6e4 authored by Tristan Cavelier's avatar Tristan Cavelier Committed by Sebastien Robin

JIO is now compatible with require.js.

parent b233a99c
...@@ -8,14 +8,13 @@ ...@@ -8,14 +8,13 @@
<body> <body>
<div id="qunit"></div> <div id="qunit"></div>
<script type="text/javascript" src="qunit/qunit-1.5.0.js"></script> <script type="text/javascript" src="qunit/qunit-1.5.0.js"></script>
<script type="text/javascript" src="js/jquery/jquery.js"></script>
<script type="text/javascript" src="unhosted/localorcookiestorage.js"></script>
<script type="text/javascript" src="unhosted/jio.js"></script>
<script type="text/javascript" src="unhosted/base64.js"></script>
<script type="text/javascript" src="jio.dummystorages.js"></script>
<script type="text/javascript" src="unhosted/jio.storage.js"></script>
<script type="text/javascript" src="sinon/sinon-1.3.4.js"></script> <script type="text/javascript" src="sinon/sinon-1.3.4.js"></script>
<script type="text/javascript" src="sinon/sinon-qunit-1.0.0.js"></script> <script type="text/javascript" src="sinon/sinon-qunit-1.0.0.js"></script>
<script type="text/javascript" src="jiotests.js"></script> <script type="text/javascript">
<!--
var require = {}; // IE compatibility
//-->
</script>
<script data-main="jiotests" src="require/require.js"></script>
</body> </body>
</html> </html>
...@@ -2,51 +2,21 @@ ...@@ -2,51 +2,21 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<title>Test</title> <title>JIO QUnit/Sinon Test</title>
<link rel="stylesheet" href="qunit/qunit-1.5.0.css" /> <link rel="stylesheet" href="qunit/qunit-1.5.0.css" />
</head> </head>
<body> <body>
<div id="qunit"></div>
<script type="text/javascript" src="qunit/qunit-1.5.0.js"></script>
<script type="text/javascript" src="sinon/sinon-1.3.4.js"></script>
<script type="text/javascript" src="sinon/sinon-qunit-1.0.0.js"></script>
<script type="text/javascript" src="js/jquery/jquery.js"></script> <script type="text/javascript" src="js/jquery/jquery.js"></script>
<script type="text/javascript" src="unhosted/localorcookiestorage.js"> <script type="text/javascript" src="unhosted/localorcookiestorage.js">
</script> </script>
<script type="text/javascript" src="unhosted/jio.js"></script> <script type="text/javascript" src="unhosted/jio.js"></script>
<script type="text/javascript" src="unhosted/base64.js"></script> <script type="text/javascript" src="unhosted/base64.js"></script>
<script type="text/javascript" src="jio.dummystorages.js"></script>
<script type="text/javascript" src="unhosted/jio.storage.js"></script> <script type="text/javascript" src="unhosted/jio.storage.js"></script>
<script type="text/javascript"> <script type="text/javascript" src="jiotests.js"></script>
<!--
var maClassPasProtegee = function () {
this.monAttributPasProtegee = 0;
};
maClassPasProtegee.prototype = {
getMonAttribut: function () {
return this.monAttributPasProtegee;
},
logMonAttribut: function () {
console.log (this.monAttributPasProtegee);
}
};
var maclass1 = new maClassPasProtegee();
maclass1.logMonAttribut();
maclass1.monAttributPasProtegee ++;
maclass1.logMonAttribut();
var maClassProtegee = function () {
var publ = {}, priv = {};
priv.monAttributProtegee = 0;
publ.getMonAttribut = function () {
return priv.monAttributProtegee;
};
publ.logMonAttribut = function () {
console.log (priv.monAttributProtegee);
};
return publ;
};
var maclass2 = new maClassProtegee();
maclass2.logMonAttribut();
maclass2.monAttributProtegee ++;
maclass2.logMonAttribut();
//-->
</script>
</body> </body>
</html> </html>
// Adds 3 dummy storages for Jio // Adds 3 dummy storages to JIO
// type: // type:
// - dummyallok // - dummyallok
// - dummyallfail // - dummyallfail
// - dummyallnotfound // - dummyallnotfound
// - dummyall3tries // - dummyall3tries
;(function ( Jio ) { (function () { var jio_dummy_storage_loader = function ( Jio ) {
// check dependencies
var errorDependencies=function(){$.error('Cannot find Jio');};
try{if (!Jio){
errorDependencies();return;
}} catch (e){
errorDependencies();return;}
////////////////////////////////////////////////////////////////////////////
// globals
var jioGlobalObj = Jio.getGlobalObject(),
// end globals
////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// Dummy Storage 1 : all ok // Dummy Storage 1 : all ok
...@@ -287,4 +274,12 @@ ...@@ -287,4 +274,12 @@
return DummyStorageAll3Tries(options); return DummyStorageAll3Tries(options);
}); });
})( JIO ); };
if (window.requirejs) {
define ('JIODummyStorages',['JIO'], jio_dummy_storage_loader);
} else {
jio_dummy_storage_loader ( JIO );
}
})();
\ No newline at end of file
(function () { var thisfun = function(loader) {
var JIO = loader.JIO,
LocalOrCookieStorage = loader.LocalOrCookieStorage,
Base64 = loader.Base64;
(function(){
//// clear jio localstorage //// clear jio localstorage
for (var k in LocalOrCookieStorage.getAll()) { for (var k in LocalOrCookieStorage.getAll()) {
var splitk = k.split('/'); var splitk = k.split('/');
...@@ -271,7 +274,7 @@ test ('Document save', function () { ...@@ -271,7 +274,7 @@ test ('Document save', function () {
// We launch a saving to localstorage and we check if the file is // We launch a saving to localstorage and we check if the file is
// realy saved. Then save again and check if // realy saved. Then save again and check if
var o = {}, clock = this.sandbox.useFakeTimers(), t = this, tmp, var o = {}, clock = this.sandbox.useFakeTimers(), t = this,
mytest = function (message,value,lmcd){ mytest = function (message,value,lmcd){
o.f = function (result) { o.f = function (result) {
deepEqual(result.isSaved,value,message);}; deepEqual(result.isSaved,value,message);};
...@@ -284,12 +287,13 @@ test ('Document save', function () { ...@@ -284,12 +287,13 @@ test ('Document save', function () {
ok(false, 'no response / too much results'); ok(false, 'no response / too much results');
else { else {
// check content // check content
tmp = LocalOrCookieStorage.getItem ('jio/local/MrSaveName/jiotests/file'); o.tmp = LocalOrCookieStorage.getItem (
tmp.lmcd = lmcd(tmp.creationDate,tmp.lastModified); 'jio/local/MrSaveName/jiotests/file');
delete tmp.lastModified; o.tmp.lmcd = lmcd(o.tmp.creationDate,o.tmp.lastModified);
delete tmp.creationDate; delete o.tmp.lastModified;
deepEqual (tmp,{'fileName':'file','fileContent':'content', delete o.tmp.creationDate;
'lmcd':true},'check content'); deepEqual (o.tmp,{'fileName':'file','fileContent':'content',
'lmcd':true},'check content');
} }
}; };
...@@ -397,8 +401,9 @@ test ('Document remove', function () { ...@@ -397,8 +401,9 @@ test ('Document remove', function () {
ok(false, 'no response / too much results'); ok(false, 'no response / too much results');
else { else {
// check if the file is still there // check if the file is still there
var tmp = LocalOrCookieStorage.getItem ('jio/local/MrRemoveName/jiotests/file'); o.tmp = LocalOrCookieStorage.getItem (
ok (!tmp, 'check no content'); 'jio/local/MrRemoveName/jiotests/file');
ok (!o.tmp, 'check no content');
} }
}; };
o.jio = JIO.createNew({'type':'local','userName':'MrRemoveName'}, o.jio = JIO.createNew({'type':'local','userName':'MrRemoveName'},
...@@ -502,10 +507,11 @@ test ('Document save', function () { ...@@ -502,10 +507,11 @@ test ('Document save', function () {
"PROPFIND","https://ca-davstorage:8080/dav/davsave/jiotests/file", "PROPFIND","https://ca-davstorage:8080/dav/davsave/jiotests/file",
[errnoprop,{'Content-Type':'text/xml; charset="utf-8"'}, [errnoprop,{'Content-Type':'text/xml; charset="utf-8"'},
davsave]); davsave]);
server.respondWith ("PUT", server.respondWith (
"https://ca-davstorage:8080/dav/davsave/jiotests/file", "PUT",
[errnoput, {'Content-Type':'x-www-form-urlencoded'}, "https://ca-davstorage:8080/dav/davsave/jiotests/file",
'content']); [errnoput, {'Content-Type':'x-www-form-urlencoded'},
'content']);
server.respondWith ( server.respondWith (
"GET","https://ca-davstorage:8080/dav/davsave/jiotests/file", "GET","https://ca-davstorage:8080/dav/davsave/jiotests/file",
[errnoprop===207?200:errnoprop,{},'content']); [errnoprop===207?200:errnoprop,{},'content']);
...@@ -514,7 +520,7 @@ test ('Document save', function () { ...@@ -514,7 +520,7 @@ test ('Document save', function () {
// server.respondWith ("MKCOL","https://ca-davstorage:8080/dav/davsave", // server.respondWith ("MKCOL","https://ca-davstorage:8080/dav/davsave",
// [200,{},'']); // [200,{},'']);
// server.respondWith ("MKCOL", // server.respondWith ("MKCOL",
// "https://ca-davstorage:8080/dav/davsave/jiotests", // "https://ca-davstorage:8080/dav/davsave/jiotests",
// [200,{},'']); // [200,{},'']);
o.f = function (result) { o.f = function (result) {
deepEqual (result.isSaved,value,message);}; deepEqual (result.isSaved,value,message);};
...@@ -681,7 +687,8 @@ test ('Check name availability', function () { ...@@ -681,7 +687,8 @@ test ('Check name availability', function () {
{'type':'dummyall3tries','userName':'3'}]}, {'type':'dummyall3tries','userName':'3'}]},
{'type':'dummyall3tries','userName':'4'}]}, {'type':'dummyall3tries','userName':'4'}]},
{'ID':'jiotests'}); {'ID':'jiotests'});
mytest('DummyStorageAll{3tries,{3tries,3tries},3tries} : name available',true); mytest('DummyStorageAll{3tries,{3tries,3tries},3tries} : name available'
,true);
o.jio.stop(); o.jio.stop();
}); });
...@@ -804,5 +811,31 @@ test ('Remove document', function () { ...@@ -804,5 +811,31 @@ test ('Remove document', function () {
mytest('DummyStorageAllOK,3tries: remove document .',true); mytest('DummyStorageAllOK,3tries: remove document .',true);
o.jio.stop(); o.jio.stop();
}); });
// end require
}; // end thisfun
if (window.requirejs) {
require.config ({
paths: {
jiotestsloader: 'jiotests.loader',
LocalOrCookieStorage: 'unhosted/localorcookiestorage',
jQuery: 'js/jquery/jquery',
JIO: 'unhosted/jio',
Base64: 'unhosted/base64',
JIODummyStorages: 'jio.dummystorages',
JIOStorages: 'unhosted/jio.storage',
QUnit: 'qunit/qunit-1.5.0',
Sinon: 'sinon/sinon-1.3.4',
SinonQUnit: 'sinon/sinon-qunit-1.0.0'
}
});
require(['jiotestsloader'],thisfun);
} else {
thisfun ({LocalOrCookieStorage:LocalOrCookieStorage,
JIO:JIO,
Base64:Base64});
}
})(); })();
define ('jiotestsloader',[
'LocalOrCookieStorage','JIO','Base64',
'JIODummyStorages','JIOStorages','jQuery'],
function (LocalOrCookieStorage,JIO,Base64) {
return {
LocalOrCookieStorage: LocalOrCookieStorage,
JIO: JIO,
Base64: Base64
};
});
/*
RequireJS 1.0.8 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
Available via the MIT or new BSD license.
see: http://github.com/jrburke/requirejs for details
*/
var requirejs,require,define;
(function(r){function K(a){return O.call(a)==="[object Function]"}function G(a){return O.call(a)==="[object Array]"}function $(a,c,l){for(var j in c)if(!(j in L)&&(!(j in a)||l))a[j]=c[j];return d}function P(a,c,d){a=Error(c+"\nhttp://requirejs.org/docs/errors.html#"+a);if(d)a.originalError=d;return a}function aa(a,c,d){var j,k,t;for(j=0;t=c[j];j++){t=typeof t==="string"?{name:t}:t;k=t.location;if(d&&(!k||k.indexOf("/")!==0&&k.indexOf(":")===-1))k=d+"/"+(k||t.name);a[t.name]={name:t.name,location:k||
t.name,main:(t.main||"main").replace(fa,"").replace(ba,"")}}}function V(a,c){a.holdReady?a.holdReady(c):c?a.readyWait+=1:a.ready(!0)}function ga(a){function c(b,f){var g,m;if(b&&b.charAt(0)===".")if(f){q.pkgs[f]?f=[f]:(f=f.split("/"),f=f.slice(0,f.length-1));g=b=f.concat(b.split("/"));var a;for(m=0;a=g[m];m++)if(a===".")g.splice(m,1),m-=1;else if(a==="..")if(m===1&&(g[2]===".."||g[0]===".."))break;else m>0&&(g.splice(m-1,2),m-=2);m=q.pkgs[g=b[0]];b=b.join("/");m&&b===g+"/"+m.main&&(b=g)}else b.indexOf("./")===
0&&(b=b.substring(2));return b}function l(b,f){var g=b?b.indexOf("!"):-1,m=null,a=f?f.name:null,h=b,e,d;g!==-1&&(m=b.substring(0,g),b=b.substring(g+1,b.length));m&&(m=c(m,a));b&&(m?e=(g=n[m])&&g.normalize?g.normalize(b,function(b){return c(b,a)}):c(b,a):(e=c(b,a),d=G[e],d||(d=i.nameToUrl(b,null,f),G[e]=d)));return{prefix:m,name:e,parentMap:f,url:d,originalName:h,fullName:m?m+"!"+(e||""):e}}function j(){var b=!0,f=q.priorityWait,g,a;if(f){for(a=0;g=f[a];a++)if(!s[g]){b=!1;break}b&&delete q.priorityWait}return b}
function k(b,f,g){return function(){var a=ha.call(arguments,0),c;if(g&&K(c=a[a.length-1]))c.__requireJsBuild=!0;a.push(f);return b.apply(null,a)}}function t(b,f,g){f=k(g||i.require,b,f);$(f,{nameToUrl:k(i.nameToUrl,b),toUrl:k(i.toUrl,b),defined:k(i.requireDefined,b),specified:k(i.requireSpecified,b),isBrowser:d.isBrowser});return f}function p(b){var f,g,a,c=b.callback,h=b.map,e=h.fullName,ca=b.deps;a=b.listeners;var j=q.requireExecCb||d.execCb;if(c&&K(c)){if(q.catchError.define)try{g=j(e,b.callback,
ca,n[e])}catch(k){f=k}else g=j(e,b.callback,ca,n[e]);if(e)(c=b.cjsModule)&&c.exports!==r&&c.exports!==n[e]?g=n[e]=b.cjsModule.exports:g===r&&b.usingExports?g=n[e]:(n[e]=g,H[e]&&(T[e]=!0))}else e&&(g=n[e]=c,H[e]&&(T[e]=!0));if(x[b.id])delete x[b.id],b.isDone=!0,i.waitCount-=1,i.waitCount===0&&(J=[]);delete M[e];if(d.onResourceLoad&&!b.placeholder)d.onResourceLoad(i,h,b.depArray);if(f)return g=(e?l(e).url:"")||f.fileName||f.sourceURL,a=f.moduleTree,f=P("defineerror",'Error evaluating module "'+e+'" at location "'+
g+'":\n'+f+"\nfileName:"+g+"\nlineNumber: "+(f.lineNumber||f.line),f),f.moduleName=e,f.moduleTree=a,d.onError(f);for(f=0;c=a[f];f++)c(g);return r}function u(b,f){return function(g){b.depDone[f]||(b.depDone[f]=!0,b.deps[f]=g,b.depCount-=1,b.depCount||p(b))}}function o(b,f){var g=f.map,a=g.fullName,c=g.name,h=N[b]||(N[b]=n[b]),e;if(!f.loading)f.loading=!0,e=function(b){f.callback=function(){return b};p(f);s[f.id]=!0;A()},e.fromText=function(b,f){var g=Q;s[b]=!1;i.scriptCount+=1;i.fake[b]=!0;g&&(Q=!1);
d.exec(f);g&&(Q=!0);i.completeLoad(b)},a in n?e(n[a]):h.load(c,t(g.parentMap,!0,function(b,a){var c=[],e,m;for(e=0;m=b[e];e++)m=l(m,g.parentMap),b[e]=m.fullName,m.prefix||c.push(b[e]);f.moduleDeps=(f.moduleDeps||[]).concat(c);return i.require(b,a)}),e,q)}function y(b){x[b.id]||(x[b.id]=b,J.push(b),i.waitCount+=1)}function D(b){this.listeners.push(b)}function v(b,f){var g=b.fullName,a=b.prefix,c=a?N[a]||(N[a]=n[a]):null,h,e;g&&(h=M[g]);if(!h&&(e=!0,h={id:(a&&!c?O++ +"__p@:":"")+(g||"__r@"+O++),map:b,
depCount:0,depDone:[],depCallbacks:[],deps:[],listeners:[],add:D},B[h.id]=!0,g&&(!a||N[a])))M[g]=h;a&&!c?(g=l(a),a in n&&!n[a]&&(delete n[a],delete R[g.url]),a=v(g,!0),a.add(function(){var f=l(b.originalName,b.parentMap),f=v(f,!0);h.placeholder=!0;f.add(function(b){h.callback=function(){return b};p(h)})})):e&&f&&(s[h.id]=!1,i.paused.push(h),y(h));return h}function C(b,f,a,c){var b=l(b,c),d=b.name,h=b.fullName,e=v(b),j=e.id,k=e.deps,o;if(h){if(h in n||s[j]===!0||h==="jquery"&&q.jQuery&&q.jQuery!==
a().fn.jquery)return;B[j]=!0;s[j]=!0;h==="jquery"&&a&&W(a())}e.depArray=f;e.callback=a;for(a=0;a<f.length;a++)if(j=f[a])j=l(j,d?b:c),o=j.fullName,f[a]=o,o==="require"?k[a]=t(b):o==="exports"?(k[a]=n[h]={},e.usingExports=!0):o==="module"?e.cjsModule=k[a]={id:d,uri:d?i.nameToUrl(d,null,c):r,exports:n[h]}:o in n&&!(o in x)&&(!(h in H)||h in H&&T[o])?k[a]=n[o]:(h in H&&(H[o]=!0,delete n[o],R[j.url]=!1),e.depCount+=1,e.depCallbacks[a]=u(e,a),v(j,!0).add(e.depCallbacks[a]));e.depCount?y(e):p(e)}function w(b){C.apply(null,
b)}function F(b,f){var a=b.map.fullName,c=b.depArray,d=!0,h,e,i,l;if(b.isDone||!a||!s[a])return l;if(f[a])return b;f[a]=!0;if(c){for(h=0;h<c.length;h++){e=c[h];if(!s[e]&&!ia[e]){d=!1;break}if((i=x[e])&&!i.isDone&&s[e])if(l=F(i,f))break}d||(l=r,delete f[a])}return l}function z(b,a){var g=b.map.fullName,c=b.depArray,d,h,e,i;if(b.isDone||!g||!s[g])return r;if(g){if(a[g])return n[g];a[g]=!0}if(c)for(d=0;d<c.length;d++)if(h=c[d])if((e=l(h).prefix)&&(i=x[e])&&z(i,a),(e=x[h])&&!e.isDone&&s[h])h=z(e,a),b.depCallbacks[d](h);
return n[g]}function E(){var b=q.waitSeconds*1E3,b=b&&i.startTime+b<(new Date).getTime(),a="",c=!1,l=!1,k=[],h,e;if(i.pausedCount>0)return r;if(q.priorityWait)if(j())A();else return r;for(h in s)if(!(h in L)&&(c=!0,!s[h]))if(b)a+=h+" ";else if(l=!0,h.indexOf("!")===-1){k=[];break}else(e=M[h]&&M[h].moduleDeps)&&k.push.apply(k,e);if(!c&&!i.waitCount)return r;if(b&&a)return b=P("timeout","Load timeout for modules: "+a),b.requireType="timeout",b.requireModules=a,b.contextName=i.contextName,d.onError(b);
if(l&&k.length)for(a=0;h=x[k[a]];a++)if(h=F(h,{})){z(h,{});break}if(!b&&(l||i.scriptCount)){if((I||da)&&!X)X=setTimeout(function(){X=0;E()},50);return r}if(i.waitCount){for(a=0;h=J[a];a++)z(h,{});i.paused.length&&A();Y<5&&(Y+=1,E())}Y=0;d.checkReadyState();return r}var i,A,q={waitSeconds:7,baseUrl:"./",paths:{},pkgs:{},catchError:{}},S=[],B={require:!0,exports:!0,module:!0},G={},n={},s={},x={},J=[],R={},O=0,M={},N={},H={},T={},Z=0;W=function(b){if(!i.jQuery&&(b=b||(typeof jQuery!=="undefined"?jQuery:
null))&&!(q.jQuery&&b.fn.jquery!==q.jQuery)&&("holdReady"in b||"readyWait"in b))if(i.jQuery=b,w(["jquery",[],function(){return jQuery}]),i.scriptCount)V(b,!0),i.jQueryIncremented=!0};A=function(){var b,a,c,l,k,h;i.takeGlobalQueue();Z+=1;if(i.scriptCount<=0)i.scriptCount=0;for(;S.length;)if(b=S.shift(),b[0]===null)return d.onError(P("mismatch","Mismatched anonymous define() module: "+b[b.length-1]));else w(b);if(!q.priorityWait||j())for(;i.paused.length;){k=i.paused;i.pausedCount+=k.length;i.paused=
[];for(l=0;b=k[l];l++)a=b.map,c=a.url,h=a.fullName,a.prefix?o(a.prefix,b):!R[c]&&!s[h]&&((q.requireLoad||d.load)(i,h,c),c.indexOf("empty:")!==0&&(R[c]=!0));i.startTime=(new Date).getTime();i.pausedCount-=k.length}Z===1&&E();Z-=1;return r};i={contextName:a,config:q,defQueue:S,waiting:x,waitCount:0,specified:B,loaded:s,urlMap:G,urlFetched:R,scriptCount:0,defined:n,paused:[],pausedCount:0,plugins:N,needFullExec:H,fake:{},fullExec:T,managerCallbacks:M,makeModuleMap:l,normalize:c,configure:function(b){var a,
c,d;b.baseUrl&&b.baseUrl.charAt(b.baseUrl.length-1)!=="/"&&(b.baseUrl+="/");a=q.paths;d=q.pkgs;$(q,b,!0);if(b.paths){for(c in b.paths)c in L||(a[c]=b.paths[c]);q.paths=a}if((a=b.packagePaths)||b.packages){if(a)for(c in a)c in L||aa(d,a[c],c);b.packages&&aa(d,b.packages);q.pkgs=d}if(b.priority)c=i.requireWait,i.requireWait=!1,A(),i.require(b.priority),A(),i.requireWait=c,q.priorityWait=b.priority;if(b.deps||b.callback)i.require(b.deps||[],b.callback)},requireDefined:function(b,a){return l(b,a).fullName in
n},requireSpecified:function(b,a){return l(b,a).fullName in B},require:function(b,c,g){if(typeof b==="string"){if(K(c))return d.onError(P("requireargs","Invalid require call"));if(d.get)return d.get(i,b,c);c=l(b,c);b=c.fullName;return!(b in n)?d.onError(P("notloaded","Module name '"+c.fullName+"' has not been loaded yet for context: "+a)):n[b]}(b&&b.length||c)&&C(null,b,c,g);if(!i.requireWait)for(;!i.scriptCount&&i.paused.length;)A();return i.require},takeGlobalQueue:function(){U.length&&(ja.apply(i.defQueue,
[i.defQueue.length-1,0].concat(U)),U=[])},completeLoad:function(b){var a;for(i.takeGlobalQueue();S.length;)if(a=S.shift(),a[0]===null){a[0]=b;break}else if(a[0]===b)break;else w(a),a=null;a?w(a):w([b,[],b==="jquery"&&typeof jQuery!=="undefined"?function(){return jQuery}:null]);d.isAsync&&(i.scriptCount-=1);A();d.isAsync||(i.scriptCount-=1)},toUrl:function(b,a){var c=b.lastIndexOf("."),d=null;c!==-1&&(d=b.substring(c,b.length),b=b.substring(0,c));return i.nameToUrl(b,d,a)},nameToUrl:function(b,a,g){var l,
k,h,e,j=i.config,b=c(b,g&&g.fullName);if(d.jsExtRegExp.test(b))a=b+(a?a:"");else{l=j.paths;k=j.pkgs;g=b.split("/");for(e=g.length;e>0;e--)if(h=g.slice(0,e).join("/"),l[h]){g.splice(0,e,l[h]);break}else if(h=k[h]){b=b===h.name?h.location+"/"+h.main:h.location;g.splice(0,e,b);break}a=g.join("/")+(a||".js");a=(a.charAt(0)==="/"||a.match(/^[\w\+\.\-]+:/)?"":j.baseUrl)+a}return j.urlArgs?a+((a.indexOf("?")===-1?"?":"&")+j.urlArgs):a}};i.jQueryCheck=W;i.resume=A;return i}function ka(){var a,c,d;if(C&&C.readyState===
"interactive")return C;a=document.getElementsByTagName("script");for(c=a.length-1;c>-1&&(d=a[c]);c--)if(d.readyState==="interactive")return C=d;return null}var la=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,ma=/require\(\s*["']([^'"\s]+)["']\s*\)/g,fa=/^\.\//,ba=/\.js$/,O=Object.prototype.toString,u=Array.prototype,ha=u.slice,ja=u.splice,I=!!(typeof window!=="undefined"&&navigator&&document),da=!I&&typeof importScripts!=="undefined",na=I&&navigator.platform==="PLAYSTATION 3"?/^complete$/:/^(complete|loaded)$/,
ea=typeof opera!=="undefined"&&opera.toString()==="[object Opera]",L={},D={},U=[],C=null,Y=0,Q=!1,ia={require:!0,module:!0,exports:!0},d,u={},J,y,v,E,o,w,F,B,z,W,X;if(typeof define==="undefined"){if(typeof requirejs!=="undefined")if(K(requirejs))return;else u=requirejs,requirejs=r;typeof require!=="undefined"&&!K(require)&&(u=require,require=r);d=requirejs=function(a,c,d){var j="_",k;!G(a)&&typeof a!=="string"&&(k=a,G(c)?(a=c,c=d):a=[]);if(k&&k.context)j=k.context;d=D[j]||(D[j]=ga(j));k&&d.configure(k);
return d.require(a,c)};d.config=function(a){return d(a)};require||(require=d);d.toUrl=function(a){return D._.toUrl(a)};d.version="1.0.8";d.jsExtRegExp=/^\/|:|\?|\.js$/;y=d.s={contexts:D,skipAsync:{}};if(d.isAsync=d.isBrowser=I)if(v=y.head=document.getElementsByTagName("head")[0],E=document.getElementsByTagName("base")[0])v=y.head=E.parentNode;d.onError=function(a){throw a;};d.load=function(a,c,l){d.resourcesReady(!1);a.scriptCount+=1;d.attach(l,a,c);if(a.jQuery&&!a.jQueryIncremented)V(a.jQuery,!0),
a.jQueryIncremented=!0};define=function(a,c,d){var j,k;typeof a!=="string"&&(d=c,c=a,a=null);G(c)||(d=c,c=[]);!c.length&&K(d)&&d.length&&(d.toString().replace(la,"").replace(ma,function(a,d){c.push(d)}),c=(d.length===1?["require"]:["require","exports","module"]).concat(c));if(Q&&(j=J||ka()))a||(a=j.getAttribute("data-requiremodule")),k=D[j.getAttribute("data-requirecontext")];(k?k.defQueue:U).push([a,c,d]);return r};define.amd={multiversion:!0,plugins:!0,jQuery:!0};d.exec=function(a){return eval(a)};
d.execCb=function(a,c,d,j){return c.apply(j,d)};d.addScriptToDom=function(a){J=a;E?v.insertBefore(a,E):v.appendChild(a);J=null};d.onScriptLoad=function(a){var c=a.currentTarget||a.srcElement,l;if(a.type==="load"||c&&na.test(c.readyState))C=null,a=c.getAttribute("data-requirecontext"),l=c.getAttribute("data-requiremodule"),D[a].completeLoad(l),c.detachEvent&&!ea?c.detachEvent("onreadystatechange",d.onScriptLoad):c.removeEventListener("load",d.onScriptLoad,!1)};d.attach=function(a,c,l,j,k,o){var p;
if(I)return j=j||d.onScriptLoad,p=c&&c.config&&c.config.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script"),p.type=k||c&&c.config.scriptType||"text/javascript",p.charset="utf-8",p.async=!y.skipAsync[a],c&&p.setAttribute("data-requirecontext",c.contextName),p.setAttribute("data-requiremodule",l),p.attachEvent&&!(p.attachEvent.toString&&p.attachEvent.toString().indexOf("[native code]")<0)&&!ea?(Q=!0,o?p.onreadystatechange=function(){if(p.readyState===
"loaded")p.onreadystatechange=null,p.attachEvent("onreadystatechange",j),o(p)}:p.attachEvent("onreadystatechange",j)):p.addEventListener("load",j,!1),p.src=a,o||d.addScriptToDom(p),p;else da&&(importScripts(a),c.completeLoad(l));return null};if(I){o=document.getElementsByTagName("script");for(B=o.length-1;B>-1&&(w=o[B]);B--){if(!v)v=w.parentNode;if(F=w.getAttribute("data-main")){if(!u.baseUrl)o=F.split("/"),w=o.pop(),o=o.length?o.join("/")+"/":"./",u.baseUrl=o,F=w.replace(ba,"");u.deps=u.deps?u.deps.concat(F):
[F];break}}}d.checkReadyState=function(){var a=y.contexts,c;for(c in a)if(!(c in L)&&a[c].waitCount)return;d.resourcesReady(!0)};d.resourcesReady=function(a){var c,l;d.resourcesDone=a;if(d.resourcesDone)for(l in a=y.contexts,a)if(!(l in L)&&(c=a[l],c.jQueryIncremented))V(c.jQuery,!1),c.jQueryIncremented=!1};d.pageLoaded=function(){if(document.readyState!=="complete")document.readyState="complete"};if(I&&document.addEventListener&&!document.readyState)document.readyState="loading",window.addEventListener("load",
d.pageLoaded,!1);d(u);if(d.isAsync&&typeof setTimeout!=="undefined")z=y.contexts[u.context||"_"],z.requireWait=!0,setTimeout(function(){z.requireWait=!1;z.scriptCount||z.resume();d.checkReadyState()},0)}})();
;var JIO = ;var JIO =
(function () { (function () { var jio_loader_function = function ( LocalOrCookieStorage ) {
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// constants // constants
...@@ -181,20 +181,7 @@ ...@@ -181,20 +181,7 @@
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// Tools // Tools
checkJioDependencies = function() {
var retval = true,
err = function (name) {
console.error ('Fail to load ' + name);
retval = false;
};
try { if (!JSON) { err('JSON'); } }
catch (e) { err('JSON'); }
try { if (!jQuery) { err('jQuery'); } }
catch (e) { err('jQuery'); }
try { if (!LocalOrCookieStorage) { err('LocalOrCookieStorage'); } }
catch (e) { err('LocalOrCookieStorage'); }
return retval;
},
// end Tools // end Tools
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
...@@ -204,9 +191,6 @@ ...@@ -204,9 +191,6 @@
// end Classes // end Classes
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// check dependencies
if (!checkJioDependencies()) { return; }
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// Publisher Subcriber // Publisher Subcriber
PubSub = function () { PubSub = function () {
...@@ -1206,4 +1190,13 @@ ...@@ -1206,4 +1190,13 @@
return new JioCreator(); return new JioCreator();
// end Jio Creator // end Jio Creator
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
})(); };
if (window.requirejs) {
define ('JIO',['LocalOrCookieStorage','jQuery'],jio_loader_function);
return undefined;
} else {
return jio_loader_function ( LocalOrCookieStorage, jQuery );
}
})();
\ No newline at end of file
// Adds 3 storages for Jio // Adds 3 storages to JIO
// type: // type:
// - local // - local
// - dav // - dav
// - replicate // - replicate
;(function ( Jio ) { (function () { var jio_storage_loader = function ( LocalOrCookieStorage, Jio ) {
////////////////////////////////////////////////////////////////////////////
// globals
var jioGlobalObj = Jio.getGlobalObject(),
// end globals
////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// Tools // Tools
checkJioDependencies = function() { var checkJioDependencies = function() {
var retval = true, var retval = true,
err = function (name) { err = function (name) {
console.error ('Fail to load ' + name); console.error ('Fail to load ' + name);
...@@ -51,7 +45,7 @@ ...@@ -51,7 +45,7 @@
setTimeout(function () { setTimeout(function () {
var localStorageObject = null; var localStorageObject = null;
localStorageObject = jioGlobalObj.localStorage.getAll(); localStorageObject = LocalOrCookieStorage.getAll();
for (var k in localStorageObject) { for (var k in localStorageObject) {
var splitk = k.split('/'); var splitk = k.split('/');
if (splitk[0] === 'jio' && if (splitk[0] === 'jio' &&
...@@ -77,7 +71,7 @@ ...@@ -77,7 +71,7 @@
var doc = null; var doc = null;
// reading // reading
doc = jioGlobalObj.localStorage.getItem( doc = LocalOrCookieStorage.getItem(
'jio/local/'+that.getStorageUserName()+'/'+ 'jio/local/'+that.getStorageUserName()+'/'+
that.getApplicantID()+'/'+ that.getApplicantID()+'/'+
that.getFileName()); that.getFileName());
...@@ -94,7 +88,7 @@ ...@@ -94,7 +88,7 @@
doc.lastModified = Date.now(); doc.lastModified = Date.now();
doc.fileContent = that.getFileContent(); doc.fileContent = that.getFileContent();
} }
jioGlobalObj.localStorage.setItem( LocalOrCookieStorage.setItem(
'jio/local/'+that.getStorageUserName()+'/'+ 'jio/local/'+that.getStorageUserName()+'/'+
that.getApplicantID()+'/'+ that.getApplicantID()+'/'+
that.getFileName(), doc); that.getFileName(), doc);
...@@ -116,7 +110,7 @@ ...@@ -116,7 +110,7 @@
var doc = null, settings = $.extend( var doc = null, settings = $.extend(
{'getContent':true},that.cloneOptionObject()); {'getContent':true},that.cloneOptionObject());
doc = jioGlobalObj.localStorage.getItem( doc = LocalOrCookieStorage.getItem(
'jio/local/'+that.getStorageUserName()+'/'+ 'jio/local/'+that.getStorageUserName()+'/'+
that.getApplicantID()+'/'+that.getFileName()); that.getApplicantID()+'/'+that.getFileName());
if (!doc) { if (!doc) {
...@@ -144,7 +138,7 @@ ...@@ -144,7 +138,7 @@
var list = [], localStorageObject = null, k = 'key', var list = [], localStorageObject = null, k = 'key',
splitk = ['splitedkey'], fileObject = {}; splitk = ['splitedkey'], fileObject = {};
localStorageObject = jioGlobalObj.localStorage.getAll(); localStorageObject = LocalOrCookieStorage.getAll();
for (k in localStorageObject) { for (k in localStorageObject) {
splitk = k.split('/'); splitk = k.split('/');
if (splitk[0] === 'jio' && if (splitk[0] === 'jio' &&
...@@ -170,7 +164,7 @@ ...@@ -170,7 +164,7 @@
setTimeout (function () { setTimeout (function () {
// deleting // deleting
jioGlobalObj.localStorage.deleteItem( LocalOrCookieStorage.deleteItem(
'jio/local/'+ 'jio/local/'+
that.getStorageUserName()+'/'+ that.getStorageUserName()+'/'+
that.getApplicantID()+'/'+ that.getApplicantID()+'/'+
...@@ -729,4 +723,14 @@ ...@@ -729,4 +723,14 @@
return new ReplicateStorage(options); return new ReplicateStorage(options);
}); });
})( JIO ); };
if (window.requirejs) {
define ('JIOStorages',
['LocalOrCookieStorage','JIO','jQuery'],
jio_storage_loader);
} else {
jio_storage_loader ( LocalOrCookieStorage, JIO, jQuery );
}
})();
\ No newline at end of file
;var LocalOrCookieStorage = ;var LocalOrCookieStorage =
(function () { (function () { var local_cookie_loader_function = function () {
// localorcookiestorage.js // localorcookiestorage.js
// Creates an object that can store persistent information in localStorage. // Creates an object that can store persistent information in localStorage.
// If it is not supported by the browser, it will store in cookies. // If it is not supported by the browser, it will store in cookies.
...@@ -88,5 +87,14 @@ ...@@ -88,5 +87,14 @@
} }
// end cookies & localStorages // end cookies & localStorages
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
})(); };
\ No newline at end of file
if (window.requirejs) {
define ('LocalOrCookieStorage',[], local_cookie_loader_function);
return undefined;
} else {
return local_cookie_loader_function ();
}
})();
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment