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
68c01140
Commit
68c01140
authored
May 22, 2012
by
Tristan Cavelier
Committed by
Sebastien Robin
Jun 07, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a document list tab to officejs.
parent
515f6023
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
7 deletions
+57
-7
OfficeJS/index.html
OfficeJS/index.html
+10
-1
OfficeJS/js/officejs.js
OfficeJS/js/officejs.js
+47
-6
No files found.
OfficeJS/index.html
View file @
68c01140
...
...
@@ -111,6 +111,15 @@
<!--
<
/div> --
>
<
/article
>
</script>
<script
id=
"document_list"
type=
"text/html"
>
<
article
>
<
ul
>
{{
#
DocumentList
}}
<
li
><
a
href
=
"
#/texteditor:fileName={{fileName}}
"
>
{{
fileName
}}
<
/a>, created: {{creationDate}}, last modified: {{lastModified}}</
li
>
{{
/
DocumentList
}}
<
/ul
>
<
/article
>
</script>
</head>
<body>
...
...
@@ -145,7 +154,7 @@
<li
class=
"texteditor"
>
<a
href=
"#/texteditor"
><i
class=
"icon-font"
></i>
Text Editor
</a>
</li>
<li
class=
"nav-header"
>
Document List
</li>
<li
class=
"nav-header"
>
<a
href=
"#/doclist"
>
Document List
</a>
</li>
<div
id=
"document_list"
></div>
</ul>
</div>
...
...
OfficeJS/js/officejs.js
View file @
68c01140
...
...
@@ -26,42 +26,68 @@ require(['OfficeJS'],function (OJS) {
current_hash
=
'
default
'
,
ich_object
=
{
DocumentList
:[],
CurrentFileName
:
''
},
current_editor
=
null
,
route_param
=
{},
// conf vars
routes
=
{
'
default
'
:
{
template
:
'
home
'
},
'
/home
'
:
{
template
:
'
home
'
},
'
/about
'
:
{
template
:
'
about
'
},
'
/login
'
:
{
template
:
'
login
'
},
'
/doclist
'
:
{
template
:
'
document_list
'
},
'
/texteditor
'
:
{
template
:
'
text_editor
'
,
onload
:
function
(){
// todo
var
intervalid
;
if
(
!
text_editor_loaded_once
)
{
xinha_init
();
text_editor_loaded_once
=
true
;
}
document
.
querySelector
(
'
#text_editor
'
).
style
.
display
=
'
block
'
;
current_editor
=
'
xinha
'
;
if
(
typeof
route_param
.
fileName
!==
'
undefined
'
)
{
intervalid
=
setInterval
(
function
(){
try
{
getCurrentEditor
().
getHTML
();
}
catch
(
e
)
{
return
;
}
$
(
'
#input_fileName
'
).
attr
(
'
value
'
,
route_param
.
fileName
);
OfficeJS
.
load
();
clearInterval
(
intervalid
);
},
50
);
}
},
onunload
:
function
(){
document
.
querySelector
(
'
#text_editor
'
).
style
.
display
=
'
none
'
;
ich_object
.
CurrentFileName
=
$
(
'
#input_fileName
'
).
attr
(
'
value
'
);
current_editor
=
null
;
},
onrestart
:
function
(){
this
.
onload
();
}
}
},
////////////////////////////////////////////////////////////////////////////
// load current page
loadcurrentpage
=
function
()
{
var
new_hash
;
var
new_hash
,
params
,
i
;
// get new hash
new_hash
=
location
.
hash
.
split
(
'
#
'
);
if
(
typeof
new_hash
[
1
]
!==
"
undefined
"
)
{
// new direction
new_hash
=
new_hash
[
1
];
params
=
new_hash
.
split
(
'
:
'
);
new_hash
=
params
[
0
];
if
(
typeof
routes
[
new_hash
]
===
"
undefined
"
)
{
return
current_hash
;
}
// set route_parameters
route_param
=
{};
for
(
i
=
1
;
i
<
params
.
length
;
i
+=
1
)
{
var
tmp
=
params
[
i
].
split
(
'
=
'
);
route_param
[
tmp
[
0
]]
=
tmp
[
1
];
}
}
else
{
// default home
new_hash
=
'
default
'
;
...
...
@@ -90,6 +116,10 @@ require(['OfficeJS'],function (OJS) {
if
(
typeof
routes
[
current_hash
].
onload
===
'
function
'
)
{
routes
[
current_hash
].
onload
();
}
}
else
{
if
(
typeof
routes
[
current_hash
].
onrestart
===
'
function
'
)
{
routes
[
current_hash
].
onrestart
();
}
}
},
// end change page according to the event
...
...
@@ -155,6 +185,7 @@ require(['OfficeJS'],function (OJS) {
alert
(
'
No Jio set yet.
'
);
return
;
}
loading_object
.
load
();
filename
=
$
(
'
#input_fileName
'
).
attr
(
'
value
'
);
priv
.
jio
.
loadDocument
({
'
fileName
'
:
filename
,
...
...
@@ -166,6 +197,7 @@ require(['OfficeJS'],function (OJS) {
}
else
{
alert
(
'
Error:
'
+
result
.
message
);
}
loading_object
.
end_load
();
}
});
};
...
...
@@ -193,15 +225,24 @@ require(['OfficeJS'],function (OJS) {
priv
.
jio
.
getDocumentList
({
'
maxtries
'
:
3
,
'
callback
'
:
function
(
result
)
{
var
htmlString
=
''
,
i
;
var
htmlString
=
''
,
i
,
document_array
=
[]
;
for
(
i
=
0
;
i
<
result
.
list
.
length
;
i
+=
1
)
{
htmlString
+=
'
<li>
\n
'
;
htmlString
+=
result
.
list
[
i
].
fileName
;
htmlString
+=
'
</li>
\n
'
;
htmlString
+=
'
<li><a href="#/texteditor:fileName=
'
+
result
.
list
[
i
].
fileName
+
'
">
\n
'
+
result
.
list
[
i
].
fileName
;
result
.
list
[
i
].
creationDate
=
(
new
Date
(
result
.
list
[
i
].
creationDate
)).
toLocaleString
();
result
.
list
[
i
].
lastModified
=
(
new
Date
(
result
.
list
[
i
].
lastModified
)).
toLocaleString
();
document_array
.
push
(
result
.
list
[
i
]);
htmlString
+=
'
</a></li>
\n
'
;
}
if
(
htmlString
===
''
)
{
htmlString
=
'
No document
'
;
}
ich_object
.
DocumentList
=
document_array
;
document
.
querySelector
(
'
#document_list
'
).
innerHTML
=
htmlString
;
}
...
...
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