Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
officejs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
officejs
Commits
0e8ab6e4
Commit
0e8ab6e4
authored
May 11, 2012
by
Tristan Cavelier
Committed by
Sebastien Robin
May 18, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JIO is now compatible with require.js.
parent
b233a99c
Changes
9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
176 additions
and
78 deletions
+176
-78
jiotest/index.html
jiotest/index.html
+6
-7
jiotest/index_withoutrequirejs.html
jiotest/index_withoutrequirejs.html
+22
-0
jiotest/jio.dummystorages.js
jiotest/jio.dummystorages.js
+11
-16
jiotest/jiotests.js
jiotest/jiotests.js
+49
-16
jiotest/jiotests.loader.js
jiotest/jiotests.loader.js
+11
-0
jiotest/require/require.js
jiotest/require/require.js
+33
-0
jiotest/unhosted/jio.js
jiotest/unhosted/jio.js
+12
-19
jiotest/unhosted/jio.storage.js
jiotest/unhosted/jio.storage.js
+20
-16
jiotest/unhosted/localorcookiestorage.js
jiotest/unhosted/localorcookiestorage.js
+12
-4
No files found.
jiotest/index.html
View file @
0e8ab6e4
...
...
@@ -8,14 +8,13 @@
<body>
<div
id=
"qunit"
></div>
<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-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>
</html>
jiotest/
debug
.html
→
jiotest/
index_withoutrequirejs
.html
View file @
0e8ab6e4
...
...
@@ -2,51 +2,21 @@
<html
lang=
"en"
>
<head>
<meta
charset=
"utf-8"
/>
<title>
Test
</title>
<title>
JIO QUnit/Sinon
Test
</title>
<link
rel=
"stylesheet"
href=
"qunit/qunit-1.5.0.css"
/>
</head>
<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=
"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"
>
<!--
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>
<script
type=
"text/javascript"
src=
"jiotests.js"
></script>
</body>
</html>
jiotest/jio.dummystorages.js
View file @
0e8ab6e4
// Adds 3 dummy storages
for Jio
// Adds 3 dummy storages
to JIO
// type:
// - dummyallok
// - dummyallfail
// - dummyallnotfound
// - dummyall3tries
;(
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
////////////////////////////////////////////////////////////////////////////
(
function
()
{
var
jio_dummy_storage_loader
=
function
(
Jio
)
{
////////////////////////////////////////////////////////////////////////////
// Dummy Storage 1 : all ok
...
...
@@ -287,4 +274,12 @@
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
jiotest/jiotests.js
View file @
0e8ab6e4
(
function
()
{
var
thisfun
=
function
(
loader
)
{
var
JIO
=
loader
.
JIO
,
LocalOrCookieStorage
=
loader
.
LocalOrCookieStorage
,
Base64
=
loader
.
Base64
;
(
function
(){
//// clear jio localstorage
for
(
var
k
in
LocalOrCookieStorage
.
getAll
())
{
var
splitk
=
k
.
split
(
'
/
'
);
...
...
@@ -271,7 +274,7 @@ test ('Document save', function () {
// We launch a saving to localstorage and we check if the file is
// 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
){
o
.
f
=
function
(
result
)
{
deepEqual
(
result
.
isSaved
,
value
,
message
);};
...
...
@@ -284,11 +287,12 @@ test ('Document save', function () {
ok
(
false
,
'
no response / too much results
'
);
else
{
// check content
tmp
=
LocalOrCookieStorage
.
getItem
(
'
jio/local/MrSaveName/jiotests/file
'
);
tmp
.
lmcd
=
lmcd
(
tmp
.
creationDate
,
tmp
.
lastModified
);
delete
tmp
.
lastModified
;
delete
tmp
.
creationDate
;
deepEqual
(
tmp
,{
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
,
o
.
tmp
=
LocalOrCookieStorage
.
getItem
(
'
jio/local/MrSaveName/jiotests/file
'
);
o
.
tmp
.
lmcd
=
lmcd
(
o
.
tmp
.
creationDate
,
o
.
tmp
.
lastModified
);
delete
o
.
tmp
.
lastModified
;
delete
o
.
tmp
.
creationDate
;
deepEqual
(
o
.
tmp
,{
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
,
'
lmcd
'
:
true
},
'
check content
'
);
}
};
...
...
@@ -397,8 +401,9 @@ test ('Document remove', function () {
ok
(
false
,
'
no response / too much results
'
);
else
{
// check if the file is still there
var
tmp
=
LocalOrCookieStorage
.
getItem
(
'
jio/local/MrRemoveName/jiotests/file
'
);
ok
(
!
tmp
,
'
check no content
'
);
o
.
tmp
=
LocalOrCookieStorage
.
getItem
(
'
jio/local/MrRemoveName/jiotests/file
'
);
ok
(
!
o
.
tmp
,
'
check no content
'
);
}
};
o
.
jio
=
JIO
.
createNew
({
'
type
'
:
'
local
'
,
'
userName
'
:
'
MrRemoveName
'
},
...
...
@@ -502,7 +507,8 @@ test ('Document save', function () {
"
PROPFIND
"
,
"
https://ca-davstorage:8080/dav/davsave/jiotests/file
"
,
[
errnoprop
,{
'
Content-Type
'
:
'
text/xml; charset="utf-8"
'
},
davsave
]);
server
.
respondWith
(
"
PUT
"
,
server
.
respondWith
(
"
PUT
"
,
"
https://ca-davstorage:8080/dav/davsave/jiotests/file
"
,
[
errnoput
,
{
'
Content-Type
'
:
'
x-www-form-urlencoded
'
},
'
content
'
]);
...
...
@@ -681,7 +687,8 @@ test ('Check name availability', function () {
{
'
type
'
:
'
dummyall3tries
'
,
'
userName
'
:
'
3
'
}]},
{
'
type
'
:
'
dummyall3tries
'
,
'
userName
'
:
'
4
'
}]},
{
'
ID
'
:
'
jiotests
'
});
mytest
(
'
DummyStorageAll{3tries,{3tries,3tries},3tries} : name available
'
,
true
);
mytest
(
'
DummyStorageAll{3tries,{3tries,3tries},3tries} : name available
'
,
true
);
o
.
jio
.
stop
();
});
...
...
@@ -804,5 +811,31 @@ test ('Remove document', function () {
mytest
(
'
DummyStorageAllOK,3tries: remove document .
'
,
true
);
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
});
}
})();
jiotest/jiotests.loader.js
0 → 100644
View file @
0e8ab6e4
define
(
'
jiotestsloader
'
,[
'
LocalOrCookieStorage
'
,
'
JIO
'
,
'
Base64
'
,
'
JIODummyStorages
'
,
'
JIOStorages
'
,
'
jQuery
'
],
function
(
LocalOrCookieStorage
,
JIO
,
Base64
)
{
return
{
LocalOrCookieStorage
:
LocalOrCookieStorage
,
JIO
:
JIO
,
Base64
:
Base64
};
});
jiotest/require/require.js
0 → 100644
View file @
0e8ab6e4
This diff is collapsed.
Click to expand it.
jiotest/unhosted/jio.js
View file @
0e8ab6e4
;
var
JIO
=
(
function
()
{
(
function
()
{
var
jio_loader_function
=
function
(
LocalOrCookieStorage
)
{
////////////////////////////////////////////////////////////////////////////
// constants
...
...
@@ -181,20 +181,7 @@
////////////////////////////////////////////////////////////////////////////
// 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
////////////////////////////////////////////////////////////////////////////
...
...
@@ -204,9 +191,6 @@
// end Classes
////////////////////////////////////////////////////////////////////////////
// check dependencies
if
(
!
checkJioDependencies
())
{
return
;
}
////////////////////////////////////////////////////////////////////////////
// Publisher Subcriber
PubSub
=
function
()
{
...
...
@@ -1206,4 +1190,13 @@
return
new
JioCreator
();
// 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
jiotest/unhosted/jio.storage.js
View file @
0e8ab6e4
// Adds 3 storages
for Jio
// Adds 3 storages
to JIO
// type:
// - local
// - dav
// - replicate
;(
function
(
Jio
)
{
////////////////////////////////////////////////////////////////////////////
// globals
var
jioGlobalObj
=
Jio
.
getGlobalObject
(),
// end globals
////////////////////////////////////////////////////////////////////////////
(
function
()
{
var
jio_storage_loader
=
function
(
LocalOrCookieStorage
,
Jio
)
{
////////////////////////////////////////////////////////////////////////////
// Tools
checkJioDependencies
=
function
()
{
var
checkJioDependencies
=
function
()
{
var
retval
=
true
,
err
=
function
(
name
)
{
console
.
error
(
'
Fail to load
'
+
name
);
...
...
@@ -51,7 +45,7 @@
setTimeout
(
function
()
{
var
localStorageObject
=
null
;
localStorageObject
=
jioGlobalObj
.
local
Storage
.
getAll
();
localStorageObject
=
LocalOrCookie
Storage
.
getAll
();
for
(
var
k
in
localStorageObject
)
{
var
splitk
=
k
.
split
(
'
/
'
);
if
(
splitk
[
0
]
===
'
jio
'
&&
...
...
@@ -77,7 +71,7 @@
var
doc
=
null
;
// reading
doc
=
jioGlobalObj
.
local
Storage
.
getItem
(
doc
=
LocalOrCookie
Storage
.
getItem
(
'
jio/local/
'
+
that
.
getStorageUserName
()
+
'
/
'
+
that
.
getApplicantID
()
+
'
/
'
+
that
.
getFileName
());
...
...
@@ -94,7 +88,7 @@
doc
.
lastModified
=
Date
.
now
();
doc
.
fileContent
=
that
.
getFileContent
();
}
jioGlobalObj
.
local
Storage
.
setItem
(
LocalOrCookie
Storage
.
setItem
(
'
jio/local/
'
+
that
.
getStorageUserName
()
+
'
/
'
+
that
.
getApplicantID
()
+
'
/
'
+
that
.
getFileName
(),
doc
);
...
...
@@ -116,7 +110,7 @@
var
doc
=
null
,
settings
=
$
.
extend
(
{
'
getContent
'
:
true
},
that
.
cloneOptionObject
());
doc
=
jioGlobalObj
.
local
Storage
.
getItem
(
doc
=
LocalOrCookie
Storage
.
getItem
(
'
jio/local/
'
+
that
.
getStorageUserName
()
+
'
/
'
+
that
.
getApplicantID
()
+
'
/
'
+
that
.
getFileName
());
if
(
!
doc
)
{
...
...
@@ -144,7 +138,7 @@
var
list
=
[],
localStorageObject
=
null
,
k
=
'
key
'
,
splitk
=
[
'
splitedkey
'
],
fileObject
=
{};
localStorageObject
=
jioGlobalObj
.
local
Storage
.
getAll
();
localStorageObject
=
LocalOrCookie
Storage
.
getAll
();
for
(
k
in
localStorageObject
)
{
splitk
=
k
.
split
(
'
/
'
);
if
(
splitk
[
0
]
===
'
jio
'
&&
...
...
@@ -170,7 +164,7 @@
setTimeout
(
function
()
{
// deleting
jioGlobalObj
.
local
Storage
.
deleteItem
(
LocalOrCookie
Storage
.
deleteItem
(
'
jio/local/
'
+
that
.
getStorageUserName
()
+
'
/
'
+
that
.
getApplicantID
()
+
'
/
'
+
...
...
@@ -729,4 +723,14 @@
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
jiotest/unhosted/localorcookiestorage.js
View file @
0e8ab6e4
;
var
LocalOrCookieStorage
=
(
function
()
{
(
function
()
{
var
local_cookie_loader_function
=
function
()
{
// localorcookiestorage.js
// Creates an object that can store persistent information in localStorage.
// If it is not supported by the browser, it will store in cookies.
...
...
@@ -89,4 +88,13 @@
// end cookies & localStorages
////////////////////////////////////////////////////////////////////////////
};
if
(
window
.
requirejs
)
{
define
(
'
LocalOrCookieStorage
'
,[],
local_cookie_loader_function
);
return
undefined
;
}
else
{
return
local_cookie_loader_function
();
}
})();
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment