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
Show 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) {
...
@@ -23,20 +23,47 @@ var getXML = function (url) {
dataType
:
'
text
'
,
success
:
function
(
xml
){
tmp
=
xml
;}});
dataType
:
'
text
'
,
success
:
function
(
xml
){
tmp
=
xml
;}});
return
tmp
;
return
tmp
;
},
},
addPath
=
function
(
path
)
{
addFile
=
function
(
user
,
appid
,
file
)
{
var
array
=
LocalOrCookieStorage
.
getItem
(
'
jio/localfilearray
'
)
||
[];
var
i
,
l
,
found
=
false
,
filenamearray
,
array
.
push
(
path
);
userarray
=
LocalOrCookieStorage
.
getItem
(
'
jio/localuserarray
'
)
||
[];
LocalOrCookieStorage
.
setItem
(
'
jio/localfilearray
'
,
array
);
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
)
{
removeFile
=
function
(
user
,
appid
,
file
)
{
var
array
=
LocalOrCookieStorage
.
getItem
(
'
jio/localfilearray
'
)
||
[],
var
i
,
l
,
newarray
=
[],
newarray
=
[],
i
;
filenamearray
=
for
(
i
=
0
;
i
<
array
.
length
;
i
+=
1
)
{
LocalOrCookieStorage
.
getItem
(
if
(
array
[
i
]
!==
path
)
{
'
jio/localfilenamearray/
'
+
user
+
'
/
'
+
appid
)
||
[];
newarray
.
push
(
array
[
i
]);
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
//// end tools
...
@@ -281,11 +308,11 @@ test ('Check name availability', function () {
...
@@ -281,11 +308,11 @@ test ('Check name availability', function () {
{
"
ID
"
:
'
noid
'
});
{
"
ID
"
:
'
noid
'
});
// name must be available
// name must be available
remove
Path
(
'
jio/local/MrCheckName/jiotests/file
'
);
remove
File
(
'
MrCheckName
'
,
'
jiotests
'
,{
fileName
:
'
file
'
}
);
mytest
(
true
);
mytest
(
true
);
// name must be unavailable
// name must be unavailable
add
Path
(
'
jio/local/MrCheckName/jiotests/file
'
);
add
File
(
'
MrCheckName
'
,
'
jiotests
'
,{
fileName
:
'
file
'
}
);
mytest
(
false
);
mytest
(
false
);
o
.
jio
.
stop
();
o
.
jio
.
stop
();
...
@@ -401,10 +428,8 @@ test ('Get document list', function () {
...
@@ -401,10 +428,8 @@ test ('Get document list', function () {
'
lastModified
'
:
1
,
'
creationDate
'
:
0
};
'
lastModified
'
:
1
,
'
creationDate
'
:
0
};
doc2
=
{
'
fileName
'
:
'
memo
'
,
'
fileContent
'
:
'
test
'
,
doc2
=
{
'
fileName
'
:
'
memo
'
,
'
fileContent
'
:
'
test
'
,
'
lastModified
'
:
5
,
'
creationDate
'
:
2
};
'
lastModified
'
:
5
,
'
creationDate
'
:
2
};
addPath
(
'
jio/local/MrListName/jiotests/file
'
);
addFile
(
'
MrListName
'
,
'
jiotests
'
,
doc1
);
addPath
(
'
jio/local/MrListName/jiotests/memo
'
);
addFile
(
'
MrListName
'
,
'
jiotests
'
,
doc2
);
LocalOrCookieStorage
.
setItem
(
'
jio/local/MrListName/jiotests/file
'
,
doc1
);
LocalOrCookieStorage
.
setItem
(
'
jio/local/MrListName/jiotests/memo
'
,
doc2
);
delete
doc1
.
fileContent
;
delete
doc1
.
fileContent
;
delete
doc2
.
fileContent
;
delete
doc2
.
fileContent
;
mytest
([
doc1
,
doc2
]);
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