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 @@
<script
id=
"login"
type=
"text/html"
>
<
article
>
<
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
"
>
<
input
class
=
"
input-xlarge
"
type
=
"
text
"
name
=
"
JSONstorage
"
id
=
"
input_json_storage
"
value
=
"
{"type":"local","userName":"tristan"}
"
placeholder
=
"
storage
"
/>
<
/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
"
>
<
input
class
=
"
input-xlarge
"
type
=
"
text
"
name
=
"
JSONapplicant
"
id
=
"
input_json_applicant
"
...
...
@@ -44,7 +50,9 @@
placeholder
=
"
applicant
"
/>
<
/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
>
</script>
<script
id=
"text_editor"
type=
"text/html"
>
...
...
@@ -60,10 +68,30 @@
<
input
type
=
"
text
"
name
=
"
fileContent
"
id
=
"
input_content
"
value
=
""
placeholder
=
"
content
"
/>
<
/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
"
class
=
"
btn
"
onclick
=
"
OfficeJS.load()
"
><
i
class
=
"
icon-upload
"
><
/i> Load</
button
>&
nbsp
;
<
button
type
=
"
submit
"
class
=
"
btn btn-danger
"
onclick
=
"
OfficeJS.remove()
"
><
i
class
=
"
icon-remove icon-white
"
><
/i> Remove</
button
>&
nbsp
;
<
button
type
=
"
submit
"
class
=
"
btn
"
onclick
=
"
OfficeJS.getlist()
"
><
i
class
=
"
icon-refresh
"
><
/i> Get List</
button
>&
nbsp
;
<
button
type
=
"
submit
"
class
=
"
btn btn-primary
"
onclick
=
"
OfficeJS.save()
"
>
<
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
id
=
"
document_list
"
class
=
"
span4
"
>
<
ul
>
...
...
@@ -105,7 +133,9 @@
<li
class=
"nav-header"
>
Nav
</li>
<li><a
href=
"#/login"
><i
class=
"icon-ok"
></i>
Login
</a></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>
</div>
</div>
...
...
OfficeJS/src/jio.js
View file @
b2fba5af
...
...
@@ -249,20 +249,27 @@ var JIO =
// options.useLocalStorage: if true, save jobs into localStorage,
// else only save on memory.
var
that
=
{},
priv
=
{};
var
that
=
{},
priv
=
{},
jioIdArrayName
=
'
jio/idArray
'
;
that
.
init
=
function
(
options
)
{
// initialize the JobQueue
// options.publisher : is the publisher to use to send events
// 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
)
{
priv
.
publisher
=
publisher
;
}
priv
.
jioID
=
options
.
jioID
;
priv
.
jobObjectName
=
'
jio/jobObject/
'
+
options
.
jioID
;
priv
.
jobObject
=
{};
jioIdArray
.
push
(
priv
.
jioID
);
jioGlobalObj
.
localStorage
.
setItem
(
jioIdArrayName
,
jioIdArray
);
that
.
copyJobQueueToLocalStorage
();
for
(
k
in
priv
.
recoveredJobObject
)
{
priv
.
recoveredJobObject
[
k
].
callback
=
emptyfun
;
...
...
@@ -280,15 +287,12 @@ var JIO =
};
that
.
getNewQueueID
=
function
()
{
// Returns a new queueID
var
localStorageObject
=
jioGlobalObj
.
localStorage
.
getAll
(),
id
=
0
,
k
=
'
key
'
,
splitk
=
[
'
splitedkey
'
];
for
(
k
in
localStorageObject
)
{
splitk
=
k
.
split
(
'
/
'
);
if
(
splitk
[
0
]
===
'
jio
'
&&
splitk
[
1
]
===
'
id
'
)
{
if
(
JSON
.
parse
(
splitk
[
2
])
>=
jioGlobalObj
.
queueID
)
{
jioGlobalObj
.
queueID
=
JSON
.
parse
(
splitk
[
2
])
+
1
;
}
var
k
=
null
,
id
=
0
,
jioIdArray
=
jioGlobalObj
.
localStorage
.
getItem
(
jioIdArrayName
);
for
(
k
in
jioIdArray
)
{
if
(
jioIdArray
[
k
]
>=
jioGlobalObj
.
queueID
)
{
jioGlobalObj
.
queueID
=
jioIdArray
[
k
]
+
1
;
}
}
id
=
jioGlobalObj
.
queueID
;
...
...
@@ -298,24 +302,30 @@ var JIO =
that
.
recoverOlderJobObject
=
function
()
{
// recover job object from older inactive jio
var
localStorageObject
=
jioGlobalObj
.
localStorage
.
getAll
(),
k
=
'
key
'
,
splitk
=
[
'
splitedkey
'
];
for
(
k
in
localStorageObject
)
{
splitk
=
k
.
split
(
'
/
'
);
if
(
splitk
[
0
]
===
'
jio
'
&&
splitk
[
1
]
===
'
id
'
)
{
if
(
localStorageObject
[
k
]
<
Date
.
now
()
-
10000
){
// 10 sec ? delete item
jioGlobalObj
.
localStorage
.
deleteItem
(
k
);
// job recovery
priv
.
recoveredJobObject
=
jioGlobalObj
.
localStorage
.
getItem
(
'
jio/jioObject/
'
+
splitk
[
2
]);
// remove ex job object
jioGlobalObj
.
localStorage
.
deleteItem
(
'
jio/jobObject/
'
+
splitk
[
2
]);
}
var
k
=
null
,
newJioIdArray
=
[],
jioIdArrayChanged
=
false
,
jioIdArray
=
jioGlobalObj
.
localStorage
.
getItem
(
jioIdArrayName
);
for
(
k
in
jioIdArray
)
{
if
(
jioGlobalObj
.
localStorage
.
getItem
(
'
jio/id/
'
+
jioIdArray
[
k
])
<
Date
.
now
()
-
10000
)
{
// remove id from jioIdArray
// 10000 sec ? delete item
jioGlobalObj
.
localStorage
.
deleteItem
(
'
jio/id/
'
+
jioIdArray
[
k
]);
// job recovery
priv
.
recoveredJobObject
=
jioGlobalObj
.
localStorage
.
getItem
(
'
jio/jioObject/
'
+
jioIdArray
[
k
]);
// remove ex job object
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
)
{
// 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