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
27646bab
Commit
27646bab
authored
May 24, 2012
by
Tristan Cavelier
Committed by
Sebastien Robin
Jun 07, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Redesigning classes and var names.
parent
806c6e95
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
541 additions
and
511 deletions
+541
-511
OfficeJS/lib/jio/jio.js
OfficeJS/lib/jio/jio.js
+233
-224
OfficeJS/lib/jio/jio.min.js
OfficeJS/lib/jio/jio.min.js
+2
-2
OfficeJS/lib/jio/jio.storage.js
OfficeJS/lib/jio/jio.storage.js
+22
-17
OfficeJS/lib/jio/jio.storage.min.js
OfficeJS/lib/jio/jio.storage.min.js
+2
-2
OfficeJS/lib/jio/localorcookiestorage.js
OfficeJS/lib/jio/localorcookiestorage.js
+1
-1
OfficeJS/lib/jio/localorcookiestorage.min.js
OfficeJS/lib/jio/localorcookiestorage.min.js
+1
-1
OfficeJS/src/jio.dummystorages.js
OfficeJS/src/jio.dummystorages.js
+12
-12
OfficeJS/src/jio.js
OfficeJS/src/jio.js
+232
-223
OfficeJS/src/jio.storage.js
OfficeJS/src/jio.storage.js
+20
-13
OfficeJS/test/jiotests.js
OfficeJS/test/jiotests.js
+16
-16
No files found.
OfficeJS/lib/jio/jio.js
View file @
27646bab
This diff is collapsed.
Click to expand it.
OfficeJS/lib/jio/jio.min.js
View file @
27646bab
This diff is collapsed.
Click to expand it.
OfficeJS/lib/jio/jio.storage.js
View file @
27646bab
/*! JIO Storage - v0.1.0 - 2012-05-2
3
/*! JIO Storage - v0.1.0 - 2012-05-2
4
* Copyright (c) 2012 Nexedi; Licensed */
...
...
@@ -12,21 +12,28 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
////////////////////////////////////////////////////////////////////////////
// Tools
var
extend
=
function
(
o1
,
o2
)
{
var
key
;
for
(
key
in
o2
)
{
o1
[
key
]
=
o2
[
key
];
}
return
o1
;
},
// end Tools
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// Classes
var
LocalStorage
,
DAVStorage
,
ReplicateStorage
;
newLocalStorage
,
newDAVStorage
,
new
ReplicateStorage
;
// end Classes
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// Local Storage
LocalStorage
=
function
(
args
)
{
newLocalStorage
=
function
(
spec
,
my
)
{
// LocalStorage constructor
var
that
=
Jio
.
newBaseStorage
(
args
),
priv
=
{};
var
that
=
Jio
.
newBaseStorage
(
spec
,
my
),
priv
=
{};
that
.
checkNameAvailability
=
function
()
{
// checks the availability of the [job.userName].
...
...
@@ -99,7 +106,7 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
// wait a little in order to simulate asynchronous operation
setTimeout
(
function
()
{
var
doc
=
null
,
settings
=
$
.
extend
(
var
doc
=
null
,
settings
=
extend
(
{
'
getContent
'
:
true
},
that
.
cloneOptionObject
());
doc
=
LocalOrCookieStorage
.
getItem
(
...
...
@@ -174,8 +181,8 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
////////////////////////////////////////////////////////////////////////////
// DAVStorage
DAVStorage
=
function
(
args
)
{
var
that
=
Jio
.
newBaseStorage
(
args
);
newDAVStorage
=
function
(
spec
,
my
)
{
var
that
=
Jio
.
newBaseStorage
(
spec
,
my
);
that
.
mkcol
=
function
(
options
)
{
// create folders in dav storage, synchronously
...
...
@@ -188,7 +195,7 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
// TODO this method is not working !!!
var
settings
=
$
.
extend
({
var
settings
=
extend
({
'
success
'
:
function
(){},
'
error
'
:
function
(){}},
options
),
splitpath
=
[
'
splitedpath
'
],
tmppath
=
'
temp/path
'
;
...
...
@@ -321,7 +328,7 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
// 'creationDate':date,'lastModified':date}
var
doc
=
{},
settings
=
$
.
extend
({
'
getContent
'
:
true
},
that
.
cloneOptionObject
()),
settings
=
extend
({
'
getContent
'
:
true
},
that
.
cloneOptionObject
()),
// TODO check if job's features are good
getContent
=
function
()
{
...
...
@@ -476,12 +483,10 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
that
.
getStorageUserName
()
+
'
:
'
+
that
.
getStoragePassword
()
)},
// xhrFields: {withCredentials: 'true'}, // cross domain
success
:
function
(
a
)
{
console
.
log
(
a
);
success
:
function
()
{
that
.
done
();
},
error
:
function
(
type
)
{
console
.
log
(
type
);
if
(
type
.
status
===
404
)
{
that
.
done
();
}
else
{
...
...
@@ -499,8 +504,8 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
////////////////////////////////////////////////////////////////////////////
// ReplicateStorage
ReplicateStorage
=
function
(
args
)
{
var
that
=
Jio
.
newBaseStorage
(
args
),
priv
=
{};
newReplicateStorage
=
function
(
spec
,
my
)
{
var
that
=
Jio
.
newBaseStorage
(
spec
,
my
),
priv
=
{};
priv
.
storageArray
=
that
.
getStorageArray
();
// TODO Add a tests that check if there is no duplicate storages.
...
...
@@ -706,13 +711,13 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
// add key to storageObjectType of global jio
Jio
.
addStorageType
(
'
local
'
,
function
(
options
)
{
return
new
LocalStorage
(
options
);
return
newLocalStorage
(
options
);
});
Jio
.
addStorageType
(
'
dav
'
,
function
(
options
)
{
return
new
DAVStorage
(
options
);
return
newDAVStorage
(
options
);
});
Jio
.
addStorageType
(
'
replicate
'
,
function
(
options
)
{
return
new
ReplicateStorage
(
options
);
return
newReplicateStorage
(
options
);
});
};
...
...
OfficeJS/lib/jio/jio.storage.min.js
View file @
27646bab
This diff is collapsed.
Click to expand it.
OfficeJS/lib/jio/localorcookiestorage.js
View file @
27646bab
/*! Local Or Cookie Storage - v0.1.0 - 2012-05-2
3
/*! Local Or Cookie Storage - v0.1.0 - 2012-05-2
4
* Copyright (c) 2012 Nexedi; Licensed */
var
LocalOrCookieStorage
=
...
...
OfficeJS/lib/jio/localorcookiestorage.min.js
View file @
27646bab
/*! Local Or Cookie Storage - v0.1.0 - 2012-05-2
3
/*! Local Or Cookie Storage - v0.1.0 - 2012-05-2
4
* Copyright (c) 2012 Nexedi; Licensed */
var
LocalOrCookieStorage
=
function
(){
var
a
=
function
(){
var
a
=
function
(){};
a
.
prototype
=
{
getItem
:
function
(
a
){
return
JSON
.
parse
(
localStorage
.
getItem
(
a
))},
setItem
:
function
(
a
,
b
){
if
(
a
)
return
localStorage
.
setItem
(
a
,
JSON
.
stringify
(
b
))},
getAll
:
function
(){
return
localStorage
},
deleteItem
:
function
(
a
){
a
&&
delete
localStorage
[
a
]}};
var
b
=
function
(){};
b
.
prototype
=
{
getItem
:
function
(
a
){
var
b
=
document
.
cookie
.
split
(
"
;
"
),
c
;
for
(
c
=
0
;
c
<
b
.
length
;
c
+=
1
){
var
d
=
b
[
c
].
substr
(
0
,
b
[
c
].
indexOf
(
"
=
"
)),
e
=
b
[
c
].
substr
(
b
[
c
].
indexOf
(
"
=
"
)
+
1
);
d
=
d
.
replace
(
/^
\s
+|
\s
+$/g
,
""
);
if
(
d
===
a
)
return
unescape
(
e
)}
return
null
},
setItem
:
function
(
a
,
b
){
return
b
!==
undefined
?(
document
.
cookie
=
a
+
"
=
"
+
JSON
.
stringify
(
b
)
+
"
;domain=
"
+
window
.
location
.
hostname
+
"
;path=
"
+
window
.
location
.
pathname
,
!
0
):
!
1
},
getAll
:
function
(){
var
a
=
{},
b
,
c
=
document
.
cookie
.
split
(
"
:
"
);
for
(
b
=
0
;
b
<
c
.
length
;
b
+=
1
){
var
d
=
c
[
b
].
substr
(
0
,
c
[
b
].
indexOf
(
"
=
"
)),
e
=
c
[
b
].
substr
(
c
[
b
].
indexOf
(
"
=
"
)
+
1
);
d
=
d
.
replace
(
/^
\s
+|
\s
+$/g
,
""
),
a
[
d
]
=
unescape
(
e
)}
return
a
},
deleteItem
:
function
(
a
){
document
.
cookie
=
a
+
"
=null;domain=
"
+
window
.
location
.
hostname
+
"
;path=
"
+
window
.
location
.
pathname
+
"
;expires=Thu, 01-Jan-1970 00:00:01 GMT
"
}};
try
{
return
localStorage
.
getItem
?
new
a
:
new
b
}
catch
(
c
){
return
new
b
}};
return
window
.
requirejs
?(
define
(
"
LocalOrCookieStorage
"
,[],
a
),
undefined
):
a
()}();
\ No newline at end of file
OfficeJS/src/jio.dummystorages.js
View file @
27646bab
...
...
@@ -9,8 +9,8 @@
////////////////////////////////////////////////////////////////////////////
// Dummy Storage 1 : all ok
var
DummyStorageAllOk
=
function
(
args
)
{
var
that
=
Jio
.
newBaseStorage
(
args
);
var
newDummyStorageAllOk
=
function
(
spec
,
my
)
{
var
that
=
Jio
.
newBaseStorage
(
spec
,
my
);
that
.
checkNameAvailability
=
function
()
{
// The [job.userName] IS available.
...
...
@@ -81,8 +81,8 @@
////////////////////////////////////////////////////////////////////////////
// Dummy Storage 2 : all fail
DummyStorageAllFail
=
function
(
args
)
{
var
that
=
Jio
.
newBaseStorage
(
args
);
newDummyStorageAllFail
=
function
(
spec
,
my
)
{
var
that
=
Jio
.
newBaseStorage
(
spec
,
my
);
that
.
checkNameAvailability
=
function
()
{
// Fails to check [job.userName].
...
...
@@ -147,8 +147,8 @@
////////////////////////////////////////////////////////////////////////////
// Dummy Storage 3 : all not found
DummyStorageAllNotFound
=
function
(
args
)
{
var
that
=
Jio
.
newBaseStorage
(
args
);
newDummyStorageAllNotFound
=
function
(
spec
,
my
)
{
var
that
=
Jio
.
newBaseStorage
(
spec
,
my
);
that
.
checkNameAvailability
=
function
()
{
// [job.userName] not found, so the name is available.
...
...
@@ -211,8 +211,8 @@
////////////////////////////////////////////////////////////////////////////
// Dummy Storage 4 : all 3 tries
DummyStorageAll3Tries
=
function
(
args
)
{
var
that
=
Jio
.
newBaseStorage
(
args
),
priv
=
{};
newDummyStorageAll3Tries
=
function
(
spec
,
my
)
{
var
that
=
Jio
.
newBaseStorage
(
spec
,
my
),
priv
=
{};
priv
.
doJob
=
function
(
ifokreturn
)
{
// wait a little in order to simulate asynchronous operation
...
...
@@ -270,16 +270,16 @@
// add key to storageObjectType of global jio
Jio
.
addStorageType
(
'
dummyallok
'
,
function
(
options
)
{
return
new
DummyStorageAllOk
(
options
);
return
newDummyStorageAllOk
(
options
);
});
Jio
.
addStorageType
(
'
dummyallfail
'
,
function
(
options
)
{
return
new
DummyStorageAllFail
(
options
);
return
newDummyStorageAllFail
(
options
);
});
Jio
.
addStorageType
(
'
dummyallnotfound
'
,
function
(
options
)
{
return
new
DummyStorageAllNotFound
(
options
);
return
newDummyStorageAllNotFound
(
options
);
});
Jio
.
addStorageType
(
'
dummyall3tries
'
,
function
(
options
)
{
return
new
DummyStorageAll3Tries
(
options
);
return
newDummyStorageAll3Tries
(
options
);
});
};
...
...
OfficeJS/src/jio.js
View file @
27646bab
This diff is collapsed.
Click to expand it.
OfficeJS/src/jio.storage.js
View file @
27646bab
...
...
@@ -9,21 +9,28 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
////////////////////////////////////////////////////////////////////////////
// Tools
var
extend
=
function
(
o1
,
o2
)
{
var
key
;
for
(
key
in
o2
)
{
o1
[
key
]
=
o2
[
key
];
}
return
o1
;
},
// end Tools
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// Classes
var
LocalStorage
,
DAVStorage
,
ReplicateStorage
;
newLocalStorage
,
newDAVStorage
,
new
ReplicateStorage
;
// end Classes
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// Local Storage
LocalStorage
=
function
(
args
)
{
newLocalStorage
=
function
(
spec
,
my
)
{
// LocalStorage constructor
var
that
=
Jio
.
newBaseStorage
(
args
),
priv
=
{};
var
that
=
Jio
.
newBaseStorage
(
spec
,
my
),
priv
=
{};
that
.
checkNameAvailability
=
function
()
{
// checks the availability of the [job.userName].
...
...
@@ -96,7 +103,7 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
// wait a little in order to simulate asynchronous operation
setTimeout
(
function
()
{
var
doc
=
null
,
settings
=
$
.
extend
(
var
doc
=
null
,
settings
=
extend
(
{
'
getContent
'
:
true
},
that
.
cloneOptionObject
());
doc
=
LocalOrCookieStorage
.
getItem
(
...
...
@@ -171,8 +178,8 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
////////////////////////////////////////////////////////////////////////////
// DAVStorage
DAVStorage
=
function
(
args
)
{
var
that
=
Jio
.
newBaseStorage
(
args
);
newDAVStorage
=
function
(
spec
,
my
)
{
var
that
=
Jio
.
newBaseStorage
(
spec
,
my
);
that
.
mkcol
=
function
(
options
)
{
// create folders in dav storage, synchronously
...
...
@@ -185,7 +192,7 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
// TODO this method is not working !!!
var
settings
=
$
.
extend
({
var
settings
=
extend
({
'
success
'
:
function
(){},
'
error
'
:
function
(){}},
options
),
splitpath
=
[
'
splitedpath
'
],
tmppath
=
'
temp/path
'
;
...
...
@@ -318,7 +325,7 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
// 'creationDate':date,'lastModified':date}
var
doc
=
{},
settings
=
$
.
extend
({
'
getContent
'
:
true
},
that
.
cloneOptionObject
()),
settings
=
extend
({
'
getContent
'
:
true
},
that
.
cloneOptionObject
()),
// TODO check if job's features are good
getContent
=
function
()
{
...
...
@@ -494,8 +501,8 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
////////////////////////////////////////////////////////////////////////////
// ReplicateStorage
ReplicateStorage
=
function
(
args
)
{
var
that
=
Jio
.
newBaseStorage
(
args
),
priv
=
{};
newReplicateStorage
=
function
(
spec
,
my
)
{
var
that
=
Jio
.
newBaseStorage
(
spec
,
my
),
priv
=
{};
priv
.
storageArray
=
that
.
getStorageArray
();
// TODO Add a tests that check if there is no duplicate storages.
...
...
@@ -701,13 +708,13 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
// add key to storageObjectType of global jio
Jio
.
addStorageType
(
'
local
'
,
function
(
options
)
{
return
new
LocalStorage
(
options
);
return
newLocalStorage
(
options
);
});
Jio
.
addStorageType
(
'
dav
'
,
function
(
options
)
{
return
new
DAVStorage
(
options
);
return
newDAVStorage
(
options
);
});
Jio
.
addStorageType
(
'
replicate
'
,
function
(
options
)
{
return
new
ReplicateStorage
(
options
);
return
newReplicateStorage
(
options
);
});
};
...
...
OfficeJS/test/jiotests.js
View file @
27646bab
...
...
@@ -5,15 +5,15 @@
$
=
loader
.
jQuery
;
//// clear jio localstorage
(
function
()
{
var
k
,
storageObject
=
LocalOrCookieStorage
.
getAll
();
for
(
k
in
storageObject
)
{
var
splitk
=
k
.
split
(
'
/
'
);
if
(
splitk
[
0
]
===
'
jio
'
)
{
LocalOrCookieStorage
.
deleteItem
(
k
);
}
(
function
()
{
var
k
,
storageObject
=
LocalOrCookieStorage
.
getAll
();
for
(
k
in
storageObject
)
{
var
splitk
=
k
.
split
(
'
/
'
);
if
(
splitk
[
0
]
===
'
jio
'
)
{
LocalOrCookieStorage
.
deleteItem
(
k
);
}
}());
}
}());
//// end clear jio localstorage
//// Tools
...
...
@@ -152,12 +152,12 @@ test ('Simple Job Elimination', function () {
id
=
o
.
jio
.
getID
();
o
.
jio
.
saveDocument
({
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
,
'
callback
'
:
o
.
f1
,
'
maxtries
'
:
1
});
ok
(
LocalOrCookieStorage
.
getItem
(
'
jio/job
O
bject/
'
+
id
)[
'
1
'
],
ok
(
LocalOrCookieStorage
.
getItem
(
'
jio/job
o
bject/
'
+
id
)[
'
1
'
],
'
job creation
'
);
clock
.
tick
(
10
);
o
.
jio
.
removeDocument
({
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
,
'
callback
'
:
o
.
f2
,
'
maxtries
'
:
1
});
o
.
tmp
=
LocalOrCookieStorage
.
getItem
(
'
jio/job
O
bject/
'
+
id
)[
'
1
'
];
o
.
tmp
=
LocalOrCookieStorage
.
getItem
(
'
jio/job
o
bject/
'
+
id
)[
'
1
'
];
ok
(
!
o
.
tmp
||
o
.
tmp
.
status
===
'
fail
'
,
'
job elimination
'
);
});
...
...
@@ -180,7 +180,7 @@ test ('Simple Job Replacement', function () {
o
.
jio
.
saveDocument
({
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
,
'
callback
'
:
o
.
f2
,
'
maxtries
'
:
1
});
deepEqual
(
LocalOrCookieStorage
.
getItem
(
'
jio/job
O
bject/
'
+
id
)[
'
1
'
].
date
,
10
,
'
jio/job
o
bject/
'
+
id
)[
'
1
'
].
date
,
10
,
'
The first job date have to be equal to the second job date.
'
);
clock
.
tick
(
500
);
deepEqual
([
o
.
f1
.
calledOnce
,
o
.
status
],[
true
,
'
fail
'
],
...
...
@@ -205,16 +205,16 @@ test ('Simple Job Waiting', function () {
o
.
jio
.
saveDocument
({
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
,
'
callback
'
:
o
.
f4
,
'
maxtries
'
:
1
});
ok
(
LocalOrCookieStorage
.
getItem
(
'
jio/job
O
bject/
'
+
id
)[
'
2
'
]
&&
'
jio/job
o
bject/
'
+
id
)[
'
2
'
]
&&
LocalOrCookieStorage
.
getItem
(
'
jio/job
O
bject/
'
+
id
)[
'
1
'
].
status
===
'
ongoing
'
,
'
jio/job
o
bject/
'
+
id
)[
'
1
'
].
status
===
'
ongoing
'
,
'
The second job must not overwrite the first ongoing one.
'
);
ok
(
LocalOrCookieStorage
.
getItem
(
'
jio/job
O
bject/
'
+
id
)[
'
2
'
].
status
===
'
wait
'
&&
'
jio/job
o
bject/
'
+
id
)[
'
2
'
].
status
===
'
wait
'
&&
LocalOrCookieStorage
.
getItem
(
'
jio/job
O
bject/
'
+
id
)[
'
2
'
].
waitingFor
&&
'
jio/job
o
bject/
'
+
id
)[
'
2
'
].
waitingFor
&&
JSON
.
stringify
(
LocalOrCookieStorage
.
getItem
(
'
jio/job
O
bject/
'
+
id
)[
'
2
'
].
waitingFor
.
jobIdArray
)
===
'
["1"]
'
,
'
jio/job
o
bject/
'
+
id
)[
'
2
'
].
waitingFor
.
jobIdArray
)
===
'
["1"]
'
,
'
The second job must be waiting for the first to end
'
);
clock
.
tick
(
500
);
ok
(
o
.
f3
.
calledOnce
,
'
first request passed
'
);
...
...
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