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
b2fba5af
Commit
b2fba5af
authored
May 18, 2012
by
Tristan Cavelier
Committed by
Sebastien Robin
May 18, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Jio doesn't browse all localStorage anymore.
parent
a7cb5e61
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
35 deletions
+75
-35
OfficeJS/index.html
OfficeJS/index.html
+38
-8
OfficeJS/src/jio.js
OfficeJS/src/jio.js
+37
-27
No files found.
OfficeJS/index.html
View file @
b2fba5af
...
@@ -29,14 +29,20 @@
...
@@ -29,14 +29,20 @@
<script
id=
"login"
type=
"text/html"
>
<script
id=
"login"
type=
"text/html"
>
<
article
>
<
article
>
<
div
class
=
"
control-group
"
>
<
div
class
=
"
control-group
"
>
<
label
class
=
"
control-label
"
for
=
"
input_json_storage
"
>
JSON
Storage
<
/label
>
<
label
class
=
"
control-label
"
for
=
"
input_json_storage
"
>
JSON
Storage
<
/label
>
<
div
class
=
"
controls docs-input-sizes
"
>
<
div
class
=
"
controls docs-input-sizes
"
>
<
input
class
=
"
input-xlarge
"
<
input
class
=
"
input-xlarge
"
type
=
"
text
"
name
=
"
JSONstorage
"
id
=
"
input_json_storage
"
type
=
"
text
"
name
=
"
JSONstorage
"
id
=
"
input_json_storage
"
value
=
"
{"type":"local","userName":"tristan"}
"
value
=
"
{"type":"local","userName":"tristan"}
"
placeholder
=
"
storage
"
/>
placeholder
=
"
storage
"
/>
<
/div
>
<
/div
>
<
label
class
=
"
control-label
"
for
=
"
JSONapplicantID
"
>
JSON
Applicant
<
/label
>
<
label
class
=
"
control-label
"
for
=
"
JSONapplicantID
"
>
JSON
Applicant
<
/label
>
<
div
class
=
"
controls docs-input-sizes
"
>
<
div
class
=
"
controls docs-input-sizes
"
>
<
input
class
=
"
input-xlarge
"
<
input
class
=
"
input-xlarge
"
type
=
"
text
"
name
=
"
JSONapplicant
"
id
=
"
input_json_applicant
"
type
=
"
text
"
name
=
"
JSONapplicant
"
id
=
"
input_json_applicant
"
...
@@ -44,7 +50,9 @@
...
@@ -44,7 +50,9 @@
placeholder
=
"
applicant
"
/>
placeholder
=
"
applicant
"
/>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
button
type
=
"
submit
"
class
=
"
btn
"
onclick
=
"
OfficeJS.setJio()
"
>
Create
New
JIO
<
/button
>
<
button
type
=
"
submit
"
class
=
"
btn
"
onclick
=
"
OfficeJS.setJio()
"
>
Create
New
JIO
<
/button
>
<
/article
>
<
/article
>
</script>
</script>
<script
id=
"text_editor"
type=
"text/html"
>
<script
id=
"text_editor"
type=
"text/html"
>
...
@@ -60,10 +68,30 @@
...
@@ -60,10 +68,30 @@
<
input
type
=
"
text
"
name
=
"
fileContent
"
id
=
"
input_content
"
<
input
type
=
"
text
"
name
=
"
fileContent
"
id
=
"
input_content
"
value
=
""
placeholder
=
"
content
"
/>
value
=
""
placeholder
=
"
content
"
/>
<
/div
>
<
/div
>
<
button
type
=
"
submit
"
class
=
"
btn btn-primary
"
onclick
=
"
OfficeJS.save()
"
><
i
class
=
"
icon-download-alt icon-white
"
><
/i> Save</
button
>&
nbsp
;
<
button
type
=
"
submit
"
<
button
type
=
"
submit
"
class
=
"
btn
"
onclick
=
"
OfficeJS.load()
"
><
i
class
=
"
icon-upload
"
><
/i> Load</
button
>&
nbsp
;
class
=
"
btn btn-primary
"
<
button
type
=
"
submit
"
class
=
"
btn btn-danger
"
onclick
=
"
OfficeJS.remove()
"
><
i
class
=
"
icon-remove icon-white
"
><
/i> Remove</
button
>&
nbsp
;
onclick
=
"
OfficeJS.save()
"
>
<
button
type
=
"
submit
"
class
=
"
btn
"
onclick
=
"
OfficeJS.getlist()
"
><
i
class
=
"
icon-refresh
"
><
/i> Get List</
button
>&
nbsp
;
<
i
class
=
"
icon-download-alt icon-white
"
><
/i
>
Save
<
/button> 
;
<
button
type
=
"
submit
"
class
=
"
btn
"
onclick
=
"
OfficeJS.load()
"
>
<
i
class
=
"
icon-upload
"
><
/i
>
Load
<
/button> 
;
<
button
type
=
"
submit
"
class
=
"
btn btn-danger
"
onclick
=
"
OfficeJS.remove()
"
>
<
i
class
=
"
icon-remove icon-white
"
><
/i
>
Remove
<
/button> 
;
<
button
type
=
"
submit
"
class
=
"
btn
"
onclick
=
"
OfficeJS.getlist()
"
>
<
i
class
=
"
icon-refresh
"
><
/i
>
Get
List
<
/button> 
;
<
/div
>
<
/div
>
<
div
id
=
"
document_list
"
class
=
"
span4
"
>
<
div
id
=
"
document_list
"
class
=
"
span4
"
>
<
ul
>
<
ul
>
...
@@ -105,7 +133,9 @@
...
@@ -105,7 +133,9 @@
<li
class=
"nav-header"
>
Nav
</li>
<li
class=
"nav-header"
>
Nav
</li>
<li><a
href=
"#/login"
><i
class=
"icon-ok"
></i>
Login
</a></li>
<li><a
href=
"#/login"
><i
class=
"icon-ok"
></i>
Login
</a></li>
<li
class=
"nav-header"
>
Documents
</li>
<li
class=
"nav-header"
>
Documents
</li>
<li
class=
"texteditor"
><a
href=
"#/texteditor"
><i
class=
"icon-font"
></i>
Text Editor
</a></li>
<li
class=
"texteditor"
>
<a
href=
"#/texteditor"
><i
class=
"icon-font"
></i>
Text Editor
</a>
</li>
</ul>
</ul>
</div>
</div>
</div>
</div>
...
...
OfficeJS/src/jio.js
View file @
b2fba5af
...
@@ -249,20 +249,27 @@ var JIO =
...
@@ -249,20 +249,27 @@ var JIO =
// options.useLocalStorage: if true, save jobs into localStorage,
// options.useLocalStorage: if true, save jobs into localStorage,
// else only save on memory.
// else only save on memory.
var
that
=
{},
priv
=
{};
var
that
=
{},
priv
=
{},
jioIdArrayName
=
'
jio/idArray
'
;
that
.
init
=
function
(
options
)
{
that
.
init
=
function
(
options
)
{
// initialize the JobQueue
// initialize the JobQueue
// options.publisher : is the publisher to use to send events
// options.publisher : is the publisher to use to send events
// options.jioID : the jio ID
// options.jioID : the jio ID
var
k
,
emptyfun
=
function
(){};
var
k
,
emptyfun
=
function
(){},
jioIdArray
=
jioGlobalObj
.
localStorage
.
getItem
(
jioIdArrayName
);
if
(
jioIdArray
===
null
)
{
jioIdArray
=
[];
}
if
(
options
.
publisher
)
{
if
(
options
.
publisher
)
{
priv
.
publisher
=
publisher
;
priv
.
publisher
=
publisher
;
}
}
priv
.
jioID
=
options
.
jioID
;
priv
.
jioID
=
options
.
jioID
;
priv
.
jobObjectName
=
'
jio/jobObject/
'
+
options
.
jioID
;
priv
.
jobObjectName
=
'
jio/jobObject/
'
+
options
.
jioID
;
priv
.
jobObject
=
{};
priv
.
jobObject
=
{};
jioIdArray
.
push
(
priv
.
jioID
);
jioGlobalObj
.
localStorage
.
setItem
(
jioIdArrayName
,
jioIdArray
);
that
.
copyJobQueueToLocalStorage
();
that
.
copyJobQueueToLocalStorage
();
for
(
k
in
priv
.
recoveredJobObject
)
{
for
(
k
in
priv
.
recoveredJobObject
)
{
priv
.
recoveredJobObject
[
k
].
callback
=
emptyfun
;
priv
.
recoveredJobObject
[
k
].
callback
=
emptyfun
;
...
@@ -280,15 +287,12 @@ var JIO =
...
@@ -280,15 +287,12 @@ var JIO =
};
};
that
.
getNewQueueID
=
function
()
{
that
.
getNewQueueID
=
function
()
{
// Returns a new queueID
// Returns a new queueID
var
localStorageObject
=
jioGlobalObj
.
localStorage
.
getAll
(),
id
=
0
,
k
=
'
key
'
,
splitk
=
[
'
splitedkey
'
];
var
k
=
null
,
id
=
0
,
for
(
k
in
localStorageObject
)
{
jioIdArray
=
jioGlobalObj
.
localStorage
.
getItem
(
jioIdArrayName
);
splitk
=
k
.
split
(
'
/
'
);
for
(
k
in
jioIdArray
)
{
if
(
splitk
[
0
]
===
'
jio
'
&&
if
(
jioIdArray
[
k
]
>=
jioGlobalObj
.
queueID
)
{
splitk
[
1
]
===
'
id
'
)
{
jioGlobalObj
.
queueID
=
jioIdArray
[
k
]
+
1
;
if
(
JSON
.
parse
(
splitk
[
2
])
>=
jioGlobalObj
.
queueID
)
{
jioGlobalObj
.
queueID
=
JSON
.
parse
(
splitk
[
2
])
+
1
;
}
}
}
}
}
id
=
jioGlobalObj
.
queueID
;
id
=
jioGlobalObj
.
queueID
;
...
@@ -298,24 +302,30 @@ var JIO =
...
@@ -298,24 +302,30 @@ var JIO =
that
.
recoverOlderJobObject
=
function
()
{
that
.
recoverOlderJobObject
=
function
()
{
// recover job object from older inactive jio
// recover job object from older inactive jio
var
localStorageObject
=
jioGlobalObj
.
localStorage
.
getAll
(),
var
k
=
null
,
newJioIdArray
=
[],
jioIdArrayChanged
=
false
,
k
=
'
key
'
,
splitk
=
[
'
splitedkey
'
];
jioIdArray
=
jioGlobalObj
.
localStorage
.
getItem
(
jioIdArrayName
);
for
(
k
in
localStorageObject
)
{
for
(
k
in
jioIdArray
)
{
splitk
=
k
.
split
(
'
/
'
);
if
(
jioGlobalObj
.
localStorage
.
getItem
(
if
(
splitk
[
0
]
===
'
jio
'
&&
'
jio/id/
'
+
jioIdArray
[
k
])
<
Date
.
now
()
-
10000
)
{
splitk
[
1
]
===
'
id
'
)
{
// remove id from jioIdArray
if
(
localStorageObject
[
k
]
<
Date
.
now
()
-
10000
){
// 10 sec ? delete item
// 10000 sec ? delete item
jioGlobalObj
.
localStorage
.
deleteItem
(
k
);
jioGlobalObj
.
localStorage
.
deleteItem
(
'
jio/id/
'
+
// job recovery
jioIdArray
[
k
]);
priv
.
recoveredJobObject
=
jioGlobalObj
.
// job recovery
localStorage
.
getItem
(
'
jio/jioObject/
'
+
splitk
[
2
]);
priv
.
recoveredJobObject
=
jioGlobalObj
.
// remove ex job object
localStorage
.
getItem
(
'
jio/jioObject/
'
+
jioIdArray
[
k
]);
jioGlobalObj
.
localStorage
.
deleteItem
(
// remove ex job object
'
jio/jobObject/
'
+
splitk
[
2
]);
jioGlobalObj
.
localStorage
.
deleteItem
(
}
'
jio/jobObject/
'
+
jioIdArray
[
k
]);
jioIdArrayChanged
=
true
;
}
else
{
newJioIdArray
.
push
(
jioIdArray
[
k
]);
}
}
}
}
if
(
jioIdArrayChanged
)
{
jioGlobalObj
.
localStorage
.
setItem
(
jioIdArrayName
,
newJioIdArray
);
}
};
};
that
.
isThereJobsWhere
=
function
(
func
)
{
that
.
isThereJobsWhere
=
function
(
func
)
{
// Check if there is jobs, in the queue,
// Check if there is jobs, in the queue,
...
...
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