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
10a18668
Commit
10a18668
authored
May 31, 2012
by
Tristan Cavelier
Committed by
Sebastien Robin
Jun 07, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improving LocalStorage + updating Qunit tests.
parent
d0ac8107
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
162 additions
and
110 deletions
+162
-110
OfficeJS/src/jio.storage.js
OfficeJS/src/jio.storage.js
+120
-93
OfficeJS/test/jiotests.js
OfficeJS/test/jiotests.js
+42
-17
No files found.
OfficeJS/src/jio.storage.js
View file @
10a18668
This diff is collapsed.
Click to expand it.
OfficeJS/test/jiotests.js
View file @
10a18668
...
...
@@ -23,20 +23,47 @@ var getXML = function (url) {
dataType
:
'
text
'
,
success
:
function
(
xml
){
tmp
=
xml
;}});
return
tmp
;
},
addPath
=
function
(
path
)
{
var
array
=
LocalOrCookieStorage
.
getItem
(
'
jio/localfilearray
'
)
||
[];
array
.
push
(
path
);
LocalOrCookieStorage
.
setItem
(
'
jio/localfilearray
'
,
array
);
addFile
=
function
(
user
,
appid
,
file
)
{
var
i
,
l
,
found
=
false
,
filenamearray
,
userarray
=
LocalOrCookieStorage
.
getItem
(
'
jio/localuserarray
'
)
||
[];
for
(
i
=
0
,
l
=
userarray
.
length
;
i
<
l
;
i
+=
1
)
{
if
(
userarray
[
i
]
===
user
)
{
found
=
true
;
}
}
if
(
!
found
)
{
userarray
.
push
(
user
);
LocalOrCookieStorage
.
setItem
(
'
jio/localuserarray
'
,
userarray
);
LocalOrCookieStorage
.
setItem
(
'
jio/localfilenamearray/
'
+
user
+
'
/
'
+
appid
,
[
file
.
fileName
]);
}
else
{
filenamearray
=
LocalOrCookieStorage
.
getItem
(
'
jio/localfilenamearray/
'
+
user
+
'
/
'
+
appid
)
||
[];
filenamearray
.
push
(
file
.
fileName
);
LocalOrCookieStorage
.
setItem
(
'
jio/localfilenamearray/
'
+
user
+
'
/
'
+
appid
,
filenamearray
);
LocalOrCookieStorage
.
setItem
(
'
jio/local/
'
+
user
+
'
/
'
+
appid
+
'
/
'
+
file
.
fileName
,
file
);
}
LocalOrCookieStorage
.
setItem
(
'
jio/local/
'
+
user
+
'
/
'
+
appid
+
'
/
'
+
file
.
fileName
,
file
);
},
removePath
=
function
(
path
)
{
var
array
=
LocalOrCookieStorage
.
getItem
(
'
jio/localfilearray
'
)
||
[],
newarray
=
[],
i
;
for
(
i
=
0
;
i
<
array
.
length
;
i
+=
1
)
{
if
(
array
[
i
]
!==
path
)
{
newarray
.
push
(
array
[
i
]);
removeFile
=
function
(
user
,
appid
,
file
)
{
var
i
,
l
,
newarray
=
[],
filenamearray
=
LocalOrCookieStorage
.
getItem
(
'
jio/localfilenamearray/
'
+
user
+
'
/
'
+
appid
)
||
[];
for
(
i
=
0
,
l
=
filenamearray
.
length
;
i
<
l
;
i
+=
1
)
{
if
(
filenamearray
[
i
]
!==
file
.
fileName
)
{
newarray
.
push
(
filenamearray
[
i
]);
}
}
LocalOrCookieStorage
.
setItem
(
'
jio/localfilearray
'
,
newarray
);
LocalOrCookieStorage
.
setItem
(
'
jio/localfilenamearray/
'
+
user
+
'
/
'
+
appid
,
newarray
);
LocalOrCookieStorage
.
deleteItem
(
'
jio/local/
'
+
user
+
'
/
'
+
appid
+
'
/
'
+
file
.
fileName
);
};
//// end tools
...
...
@@ -281,11 +308,11 @@ test ('Check name availability', function () {
{
"
ID
"
:
'
noid
'
});
// name must be available
remove
Path
(
'
jio/local/MrCheckName/jiotests/file
'
);
remove
File
(
'
MrCheckName
'
,
'
jiotests
'
,{
fileName
:
'
file
'
}
);
mytest
(
true
);
// name must be unavailable
add
Path
(
'
jio/local/MrCheckName/jiotests/file
'
);
add
File
(
'
MrCheckName
'
,
'
jiotests
'
,{
fileName
:
'
file
'
}
);
mytest
(
false
);
o
.
jio
.
stop
();
...
...
@@ -401,10 +428,8 @@ test ('Get document list', function () {
'
lastModified
'
:
1
,
'
creationDate
'
:
0
};
doc2
=
{
'
fileName
'
:
'
memo
'
,
'
fileContent
'
:
'
test
'
,
'
lastModified
'
:
5
,
'
creationDate
'
:
2
};
addPath
(
'
jio/local/MrListName/jiotests/file
'
);
addPath
(
'
jio/local/MrListName/jiotests/memo
'
);
LocalOrCookieStorage
.
setItem
(
'
jio/local/MrListName/jiotests/file
'
,
doc1
);
LocalOrCookieStorage
.
setItem
(
'
jio/local/MrListName/jiotests/memo
'
,
doc2
);
addFile
(
'
MrListName
'
,
'
jiotests
'
,
doc1
);
addFile
(
'
MrListName
'
,
'
jiotests
'
,
doc2
);
delete
doc1
.
fileContent
;
delete
doc2
.
fileContent
;
mytest
([
doc1
,
doc2
]);
...
...
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