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
fe1379fb
Commit
fe1379fb
authored
May 22, 2012
by
Tristan Cavelier
Committed by
Sebastien Robin
Jun 07, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Jiotests modified according to ReplicateStorage + grunt tests ok.
parent
d93b826b
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
59 additions
and
110 deletions
+59
-110
OfficeJS/lib/jio/jio.js
OfficeJS/lib/jio/jio.js
+8
-4
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
+43
-98
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/test/jiotests.js
OfficeJS/test/jiotests.js
+2
-2
No files found.
OfficeJS/lib/jio/jio.js
View file @
fe1379fb
/*! JIO - v0.1.0 - 2012-05-2
1
/*! JIO - v0.1.0 - 2012-05-2
2
* Copyright (c) 2012 Nexedi; Licensed */
* Copyright (c) 2012 Nexedi; Licensed */
...
@@ -177,7 +177,8 @@ var JIO =
...
@@ -177,7 +177,8 @@ var JIO =
},
},
'
localStorage
'
:
null
,
// where the browser stores data
'
localStorage
'
:
null
,
// where the browser stores data
'
queueID
'
:
1
,
'
queueID
'
:
1
,
'
storageTypeObject
'
:
{}
// ex: {'type':'local','creator': fun ...}
'
storageTypeObject
'
:
{},
// ex: {'type':'local','creator': fun ...}
'
max_wait_time
'
:
10000
},
},
// end jio globals
// end jio globals
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
...
@@ -764,9 +765,12 @@ var JIO =
...
@@ -764,9 +765,12 @@ var JIO =
// Change the job status to wait for time.
// Change the job status to wait for time.
// The listener will invoke this job later.
// The listener will invoke this job later.
var
time
=
(
priv
.
job
.
tries
*
priv
.
job
.
tries
*
1000
);
if
(
time
>
jioGlobalObj
.
max_wait_time
)
{
time
=
jioGlobalObj
.
max_wait_time
;
}
priv
.
job
.
status
=
'
wait
'
;
priv
.
job
.
status
=
'
wait
'
;
priv
.
job
.
waitingFor
=
{
'
time
'
:
Date
.
now
()
+
priv
.
job
.
waitingFor
=
{
'
time
'
:
Date
.
now
()
+
time
};
(
priv
.
job
.
tries
*
priv
.
job
.
tries
*
1000
)};
};
};
//// end Private Methods
//// end Private Methods
...
...
OfficeJS/lib/jio/jio.min.js
View file @
fe1379fb
This diff is collapsed.
Click to expand it.
OfficeJS/lib/jio/jio.storage.js
View file @
fe1379fb
/*! JIO Storage - v0.1.0 - 2012-05-2
1
/*! JIO Storage - v0.1.0 - 2012-05-2
2
* Copyright (c) 2012 Nexedi; Licensed */
* Copyright (c) 2012 Nexedi; Licensed */
...
@@ -505,6 +505,17 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
...
@@ -505,6 +505,17 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
that
.
setMaxTries
(
1
);
that
.
setMaxTries
(
1
);
priv
.
execJobsFromStorageArray
=
function
(
callback
)
{
var
newjob
=
{},
i
;
for
(
i
=
0
;
i
<
priv
.
storageArray
.
length
;
i
+=
1
)
{
newjob
=
that
.
cloneJob
();
newjob
.
maxtries
=
priv
.
maxtries
;
newjob
.
storage
=
priv
.
storageArray
[
i
];
newjob
.
callback
=
callback
;
that
.
addJob
(
newjob
)
;
}
};
that
.
checkNameAvailability
=
function
()
{
that
.
checkNameAvailability
=
function
()
{
// Checks the availability of the [job.userName].
// Checks the availability of the [job.userName].
// if the name already exists in a storage, it is not available.
// if the name already exists in a storage, it is not available.
...
@@ -524,14 +535,7 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
...
@@ -524,14 +535,7 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
that
.
done
(
isavailable
);
that
.
done
(
isavailable
);
}
}
};
};
priv
.
execJobsFromStorageArray
(
callback
);
for
(
i
=
0
;
i
<
priv
.
storageArray
.
length
;
i
+=
1
)
{
newjob
=
that
.
cloneJob
();
newjob
.
maxtries
=
priv
.
maxtries
;
newjob
.
storage
=
priv
.
storageArray
[
i
];
newjob
.
callback
=
callback
;
that
.
addJob
(
newjob
)
;
}
};
};
that
.
saveDocument
=
function
()
{
that
.
saveDocument
=
function
()
{
// Save a single document in several storages.
// Save a single document in several storages.
...
@@ -544,29 +548,22 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
...
@@ -544,29 +548,22 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
// this.job.fileContent: the document content.
// this.job.fileContent: the document content.
// TODO
// TODO
var
newjob
=
{},
res
=
{
'
status
'
:
'
done
'
},
i
=
'
id
'
,
var
newjob
=
{},
res
=
{
'
status
'
:
'
done
'
},
i
=
'
id
'
,
done
=
false
,
callback
=
function
(
result
)
{
callback
=
function
(
result
)
{
priv
.
returnsValuesArray
.
push
(
result
);
priv
.
returnsValuesArray
.
push
(
result
);
if
(
result
.
status
===
'
fail
'
)
{
if
(
!
done
)
{
res
.
status
=
'
fail
'
;
if
(
result
.
status
!==
'
fail
'
)
{
}
that
.
done
();
if
(
priv
.
returnsValuesArray
.
length
===
priv
.
length
)
{
done
=
true
;
// if this is the last callback
if
(
res
.
status
===
'
fail
'
)
{
that
.
fail
(
'
Unable to save all files.
'
,
0
);
}
else
{
}
else
{
that
.
done
();
if
(
priv
.
returnsValuesArray
.
length
===
priv
.
length
)
{
that
.
fail
(
'
Unable to save any file.
'
,
0
);
}
}
}
}
}
};
};
priv
.
execJobsFromStorageArray
(
callback
);
for
(
i
=
0
;
i
<
priv
.
storageArray
.
length
;
i
+=
1
)
{
newjob
=
that
.
cloneJob
();
newjob
.
maxtries
=
priv
.
maxtries
;
newjob
.
storage
=
priv
.
storageArray
[
i
];
newjob
.
callback
=
callback
;
that
.
addJob
(
newjob
)
;
}
};
};
that
.
loadDocument
=
function
()
{
that
.
loadDocument
=
function
()
{
...
@@ -586,60 +583,22 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
...
@@ -586,60 +583,22 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
// TODO
// TODO
var
newjob
=
{},
aredifferent
=
false
,
doc
=
{},
i
=
'
id
'
,
var
newjob
=
{},
aredifferent
=
false
,
doc
=
{},
i
=
'
id
'
,
done
=
false
,
res
=
{
'
status
'
:
'
done
'
},
callback
=
function
(
result
)
{
res
=
{
'
status
'
:
'
done
'
},
callback
=
function
(
result
)
{
priv
.
returnsValuesArray
.
push
(
result
);
priv
.
returnsValuesArray
.
push
(
result
);
if
(
result
.
status
===
'
fail
'
)
{
if
(
!
done
)
{
res
.
status
=
'
fail
'
;
if
(
result
.
status
!==
'
fail
'
)
{
}
else
{
that
.
done
(
result
.
document
);
// check if the file are different
done
=
true
;
if
(
!
doc
.
fileContent
&&
!
doc
.
creationDate
&&
!
doc
.
lastModified
)
{
// if it is the first document loaded
doc
=
$
.
extend
({},
result
.
document
);
}
else
{
if
(
doc
.
fileContent
!==
result
.
document
.
fileContent
)
{
// if the document is different from the
// previous one
aredifferent
=
true
;
}
if
(
doc
.
creationDate
>
result
.
document
.
creationDate
)
{
// get older creation date
doc
.
creationDate
=
result
.
document
.
creationDate
;
}
if
(
doc
.
lastModified
<
result
.
document
.
lastModified
)
{
// get newer last modified
doc
.
fileContent
=
result
.
document
.
fileContent
;
doc
.
lastModified
=
result
.
document
.
lastModified
;
}
}
}
if
(
priv
.
returnsValuesArray
.
length
===
priv
.
length
)
{
// if this is the last callback
if
(
res
.
status
===
'
fail
'
)
{
that
.
fail
(
'
Unable to load all files.
'
,
0
);
}
else
{
}
else
{
if
(
!
aredifferent
)
{
if
(
priv
.
returnsValuesArray
.
length
===
that
.
done
(
doc
);
priv
.
length
)
{
}
else
{
that
.
fail
(
'
Unable to load any file.
'
,
0
);
// TODO the files are different! Give options
// to know what do we do now!
// console.warn ('The files are different.');
that
.
done
(
doc
);
}
}
}
}
}
}
};
};
priv
.
execJobsFromStorageArray
(
callback
);
for
(
i
=
0
;
i
<
priv
.
storageArray
.
length
;
i
+=
1
)
{
newjob
=
that
.
cloneJob
();
newjob
.
maxtries
=
priv
.
maxtries
;
newjob
.
storage
=
priv
.
storageArray
[
i
];
newjob
.
callback
=
callback
;
that
.
addJob
(
newjob
)
;
}
};
};
that
.
getDocumentList
=
function
()
{
that
.
getDocumentList
=
function
()
{
...
@@ -670,14 +629,7 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
...
@@ -670,14 +629,7 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
}
}
}
}
};
};
priv
.
execJobsFromStorageArray
(
callback
);
for
(
i
=
0
;
i
<
priv
.
storageArray
.
length
;
i
+=
1
)
{
newjob
=
that
.
cloneJob
();
newjob
.
maxtries
=
priv
.
maxtries
;
newjob
.
storage
=
priv
.
storageArray
[
i
];
newjob
.
callback
=
callback
;
that
.
addJob
(
newjob
)
;
}
};
};
that
.
removeDocument
=
function
()
{
that
.
removeDocument
=
function
()
{
...
@@ -690,29 +642,22 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
...
@@ -690,29 +642,22 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
// this.job.applicant.ID: the applicant id.
// this.job.applicant.ID: the applicant id.
// TODO
// TODO
var
newjob
=
{},
res
=
{
'
status
'
:
'
done
'
},
i
=
'
key
'
,
var
newjob
=
{},
res
=
{
'
status
'
:
'
done
'
},
i
=
'
key
'
,
done
=
false
,
callback
=
function
(
result
)
{
callback
=
function
(
result
)
{
priv
.
returnsValuesArray
.
push
(
result
);
priv
.
returnsValuesArray
.
push
(
result
);
if
(
result
.
status
===
'
fail
'
)
{
if
(
!
done
)
{
res
.
status
=
'
fail
'
;
if
(
result
.
status
!==
'
fail
'
)
{
}
that
.
done
();
if
(
priv
.
returnsValuesArray
.
length
===
priv
.
length
)
{
done
=
true
;
// if this is the last callback
if
(
res
.
status
===
'
fail
'
)
{
that
.
fail
(
'
Unable remove all files.
'
,
0
);
}
else
{
}
else
{
that
.
done
();
if
(
priv
.
returnsValuesArray
.
length
===
priv
.
length
)
{
that
.
fail
(
'
Unable to remove any file.
'
,
0
);
}
}
}
}
}
};
};
priv
.
execJobsFromStorageArray
(
callback
);
for
(
i
=
0
;
i
<
priv
.
storageArray
.
length
;
i
+=
1
)
{
newjob
=
that
.
cloneJob
();
newjob
.
maxtries
=
priv
.
maxtries
;
newjob
.
storage
=
priv
.
storageArray
[
i
];
newjob
.
callback
=
callback
;
that
.
addJob
(
newjob
)
;
}
};
};
return
that
;
return
that
;
};
};
...
...
OfficeJS/lib/jio/jio.storage.min.js
View file @
fe1379fb
This diff is collapsed.
Click to expand it.
OfficeJS/lib/jio/localorcookiestorage.js
View file @
fe1379fb
/*! Local Or Cookie Storage - v0.1.0 - 2012-05-2
1
/*! Local Or Cookie Storage - v0.1.0 - 2012-05-2
2
* Copyright (c) 2012 Nexedi; Licensed */
* Copyright (c) 2012 Nexedi; Licensed */
var
LocalOrCookieStorage
=
var
LocalOrCookieStorage
=
...
...
OfficeJS/lib/jio/localorcookiestorage.min.js
View file @
fe1379fb
/*! Local Or Cookie Storage - v0.1.0 - 2012-05-2
1
/*! Local Or Cookie Storage - v0.1.0 - 2012-05-2
2
* Copyright (c) 2012 Nexedi; Licensed */
* 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
()}();
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/test/jiotests.js
View file @
fe1379fb
...
@@ -737,8 +737,8 @@ test ('Document load', function () {
...
@@ -737,8 +737,8 @@ test ('Document load', function () {
{
'
type
'
:
'
dummyall3tries
'
,
'
userName
'
:
'
2
'
}]},
{
'
type
'
:
'
dummyall3tries
'
,
'
userName
'
:
'
2
'
}]},
{
'
ID
'
:
'
jiotests
'
});
{
'
ID
'
:
'
jiotests
'
});
mytest
(
'
DummyStorageAllOK,3tries: load 2 different files
'
,{
mytest
(
'
DummyStorageAllOK,3tries: load 2 different files
'
,{
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
2
'
,
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
,
'
lastModified
'
:
1
7
000
,
'
lastModified
'
:
1
5
000
,
'
creationDate
'
:
10000
});
'
creationDate
'
:
10000
});
o
.
jio
.
stop
();
o
.
jio
.
stop
();
...
...
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