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
a969eb49
Commit
a969eb49
authored
May 21, 2012
by
Tristan Cavelier
Committed by
Sebastien Robin
Jun 07, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Xinha text editor.
parent
21ddc353
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
106 additions
and
56 deletions
+106
-56
OfficeJS/index.html
OfficeJS/index.html
+41
-32
OfficeJS/js/officejs.js
OfficeJS/js/officejs.js
+65
-24
No files found.
OfficeJS/index.html
View file @
a969eb49
...
@@ -62,16 +62,19 @@
...
@@ -62,16 +62,19 @@
<script
id=
"text_editor"
type=
"text/html"
>
<script
id=
"text_editor"
type=
"text/html"
>
<
article
>
<
article
>
<
div
class
=
"
control-group
"
>
<
div
class
=
"
control-group
"
>
<
div
class
=
"
span5
"
>
<
label
class
=
"
control-label
"
for
=
"
fileName
"
>
File
Name
<
/label
>
<
label
class
=
"
control-label
"
for
=
"
fileName
"
>
File
Name
<
/label
>
<
div
class
=
"
controls docs-input-sizes
"
>
<
div
class
=
"
controls docs-input-sizes
"
>
<
input
type
=
"
text
"
name
=
"
fileName
"
id
=
"
input_fileName
"
<
input
type
=
"
text
"
name
=
"
fileName
"
id
=
"
input_fileName
"
value
=
""
placeholder
=
"
file name
"
/>
value
=
""
placeholder
=
"
file name
"
/>
<
/div
>
<
/div
>
<
label
class
=
"
control-label
"
for
=
"
fileContent
"
>
File
Content
<
/label
>
<!--
<
label
class
=
"
control-label
"
for
=
"
fileContent
"
>
File
Content
<
/label> --
>
<
div
class
=
"
controls docs-input-sizes
"
>
<!--
<
div
class
=
"
controls docs-input-sizes
"
>
-->
<
input
type
=
"
text
"
name
=
"
fileContent
"
id
=
"
input_content
"
<!--
<
input
type
=
"
text
"
name
=
"
fileContent
"
id
=
"
input_content
"
-->
value
=
""
placeholder
=
"
content
"
/>
<!--
value
=
""
placeholder
=
"
content
"
/>
-->
<!--
<
/div> --
>
<
/div
>
<
/div
>
<
div
class
=
"
span5
"
>
<
button
type
=
"
submit
"
<
button
type
=
"
submit
"
class
=
"
btn btn-primary
"
class
=
"
btn btn-primary
"
onclick
=
"
OfficeJS.save()
"
>
onclick
=
"
OfficeJS.save()
"
>
...
@@ -90,12 +93,13 @@
...
@@ -90,12 +93,13 @@
<
i
class
=
"
icon-remove icon-white
"
><
/i
>
<
i
class
=
"
icon-remove icon-white
"
><
/i
>
Remove
Remove
<
/button> 
;
<
/button> 
;
<
button
type
=
"
submit
"
<!--
<
button
type
=
"
submit
"
-->
class
=
"
btn
"
<!--
class
=
"
btn
"
-->
onclick
=
"
OfficeJS.getlist()
"
>
<!--
onclick
=
"
OfficeJS.getlist()
"
>
-->
<
i
class
=
"
icon-refresh
"
><
/i
>
<!--
<
i
class
=
"
icon-refresh
"
><
/i> --
>
Get
List
<!--
Get
List
-->
<
/button> 
;
<!--
<
/button> --
>
<
/div
>
<
/div
>
<
/div
>
<!--
<
div
id
=
"
document_list
"
class
=
"
span4
"
>
-->
<!--
<
div
id
=
"
document_list
"
class
=
"
span4
"
>
-->
<!--
<
ul
>
-->
<!--
<
ul
>
-->
...
@@ -153,6 +157,11 @@
...
@@ -153,6 +157,11 @@
</p>
</p>
</article>
</article>
</section>
</section>
<section
class=
"span10"
id=
"text_editor"
style=
"display: none"
>
<textarea
name=
"textEditor"
id=
"textEditor"
rows=
"25"
cols=
"50"
style=
"width: 100%"
>
</textarea>
</section>
</div>
</div>
</div>
</div>
</body>
</body>
...
...
OfficeJS/js/officejs.js
View file @
a969eb49
...
@@ -21,17 +21,34 @@ require(['OfficeJS'],function (OJS) {
...
@@ -21,17 +21,34 @@ require(['OfficeJS'],function (OJS) {
$
=
OJS
.
jQuery
,
$
=
OJS
.
jQuery
,
Base64
=
OJS
.
Base64
,
Base64
=
OJS
.
Base64
,
ich
=
OJS
.
ich
,
ich
=
OJS
.
ich
,
// some vars
text_editor_loaded_once
=
false
,
current_hash
=
'
default
'
,
ich_object
=
{
DocumentList
:[]},
current_editor
=
null
,
// conf vars
// conf vars
routes
=
{
routes
=
{
'
default
'
:
'
home
'
,
'
default
'
:
{
template
:
'
home
'
},
'
/home
'
:
'
home
'
,
'
/home
'
:
{
template
:
'
home
'
},
'
/about
'
:
'
about
'
,
'
/about
'
:
{
template
:
'
about
'
},
'
/login
'
:
'
login
'
,
'
/login
'
:
{
template
:
'
login
'
},
'
/texteditor
'
:
'
text_editor
'
'
/texteditor
'
:
{
template
:
'
text_editor
'
,
onload
:
function
(){
// todo
if
(
!
text_editor_loaded_once
)
{
xinha_init
();
text_editor_loaded_once
=
true
;
}
document
.
querySelector
(
'
#text_editor
'
).
style
.
display
=
'
block
'
;
current_editor
=
'
xinha
'
;
},
onunload
:
function
(){
document
.
querySelector
(
'
#text_editor
'
).
style
.
display
=
'
none
'
;
current_editor
=
null
;
},
}
},
},
// some vars
current_page
=
'
home
'
,
ich_object
=
{
DocumentList
:[]},
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// load current page
// load current page
loadcurrentpage
=
function
()
{
loadcurrentpage
=
function
()
{
...
@@ -42,36 +59,58 @@ require(['OfficeJS'],function (OJS) {
...
@@ -42,36 +59,58 @@ require(['OfficeJS'],function (OJS) {
// new direction
// new direction
new_hash
=
new_hash
[
1
];
new_hash
=
new_hash
[
1
];
if
(
typeof
routes
[
new_hash
]
===
"
undefined
"
)
{
if
(
typeof
routes
[
new_hash
]
===
"
undefined
"
)
{
return
current_
page
;
return
current_
hash
;
}
}
}
else
{
}
else
{
// default home
// default home
new_hash
=
'
default
'
;
new_hash
=
'
default
'
;
}
}
return
routes
[
new_hash
]
;
return
new_hash
;
},
},
// end load current page
// end load current page
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// Repaint main page
// Repaint main page
repaint
=
function
()
{
repaint
=
function
()
{
$
(
'
#main
'
).
html
(
ich
[
current_pag
e
](
ich_object
,
true
));
$
(
'
#main
'
).
html
(
ich
[
routes
[
current_hash
].
templat
e
](
ich_object
,
true
));
},
},
// end repaint main page
// end repaint main page
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// change page according to the event
// change page according to the event
hrefClicked
=
function
()
{
hrefClicked
=
function
()
{
var
new_
page
=
loadcurrentpage
()
;
var
new_
hash
=
loadcurrentpage
(),
prev_hash
=
'
default
'
;
if
(
current_page
!==
new_pag
e
)
{
if
(
routes
[
current_hash
].
template
!==
routes
[
new_hash
].
templat
e
)
{
// check if it is necessary to repaint the page.
// check if it is necessary to repaint the page.
current_page
=
new_page
;
prev_hash
=
current_hash
;
current_hash
=
new_hash
;
if
(
typeof
routes
[
prev_hash
].
onunload
===
'
function
'
)
{
routes
[
prev_hash
].
onunload
();
}
repaint
();
repaint
();
if
(
typeof
routes
[
current_hash
].
onload
===
'
function
'
)
{
routes
[
current_hash
].
onload
();
}
}
};
}
},
// end change page according to the event
// end change page according to the event
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// get the currrent editor
getCurrentEditor
=
function
()
{
switch
(
current_editor
)
{
case
'
xinha
'
:
return
xinha_editors
[
'
textEditor
'
];
case
'
svg
'
:
return
null
;
case
'
calc
'
:
return
null
;
default
:
return
null
;
}
};
// end get the current editor
////////////////////////////////////////////////////////////////////////////
current_page
=
loadcurrentpage
();
// repaint the page
repaint
();
hrefClicked
();
window
.
OfficeJS
=
(
function
()
{
window
.
OfficeJS
=
(
function
()
{
var
publ
=
{},
priv
=
{};
var
publ
=
{},
priv
=
{};
...
@@ -98,7 +137,7 @@ require(['OfficeJS'],function (OJS) {
...
@@ -98,7 +137,7 @@ require(['OfficeJS'],function (OJS) {
return
;
return
;
}
}
filename
=
$
(
'
#input_fileName
'
).
attr
(
'
value
'
);
filename
=
$
(
'
#input_fileName
'
).
attr
(
'
value
'
);
filecontent
=
$
(
'
#input_content
'
).
attr
(
'
value
'
);
filecontent
=
getCurrentEditor
().
getHTML
(
);
priv
.
jio
.
saveDocument
({
priv
.
jio
.
saveDocument
({
'
fileName
'
:
filename
,
'
fileName
'
:
filename
,
'
fileContent
'
:
filecontent
,
'
fileContent
'
:
filecontent
,
...
@@ -106,6 +145,7 @@ require(['OfficeJS'],function (OJS) {
...
@@ -106,6 +145,7 @@ require(['OfficeJS'],function (OJS) {
'
callback
'
:
function
(
result
){
'
callback
'
:
function
(
result
){
alert
(
result
.
isSaved
?
'
Document Saved.
'
:
alert
(
result
.
isSaved
?
'
Document Saved.
'
:
'
Error:
'
+
result
.
message
);
'
Error:
'
+
result
.
message
);
publ
.
getlist
();
}
}
});
});
};
};
...
@@ -121,8 +161,8 @@ require(['OfficeJS'],function (OJS) {
...
@@ -121,8 +161,8 @@ require(['OfficeJS'],function (OJS) {
'
maxtries
'
:
3
,
'
maxtries
'
:
3
,
'
callback
'
:
function
(
result
){
'
callback
'
:
function
(
result
){
if
(
result
.
document
.
fileName
)
{
if
(
result
.
document
.
fileName
)
{
$
(
'
#input_content
'
).
attr
(
getCurrentEditor
().
setHTML
(
'
value
'
,
result
.
document
.
fileContent
);
result
.
document
.
fileContent
);
alert
(
'
Document loaded
'
);
alert
(
'
Document loaded
'
);
}
else
{
}
else
{
alert
(
'
Error:
'
+
result
.
message
);
alert
(
'
Error:
'
+
result
.
message
);
...
@@ -143,6 +183,7 @@ require(['OfficeJS'],function (OJS) {
...
@@ -143,6 +183,7 @@ require(['OfficeJS'],function (OJS) {
'
callback
'
:
function
(
result
)
{
'
callback
'
:
function
(
result
)
{
alert
(
result
.
isRemoved
?
'
Document Removed.
'
:
alert
(
result
.
isRemoved
?
'
Document Removed.
'
:
'
Error:
'
+
result
.
message
);
'
Error:
'
+
result
.
message
);
publ
.
getlist
();
}
}
});
});
};
};
...
@@ -155,7 +196,7 @@ require(['OfficeJS'],function (OJS) {
...
@@ -155,7 +196,7 @@ require(['OfficeJS'],function (OJS) {
'
maxtries
'
:
3
,
'
maxtries
'
:
3
,
'
callback
'
:
function
(
result
)
{
'
callback
'
:
function
(
result
)
{
var
htmlString
=
''
,
i
;
var
htmlString
=
''
,
i
;
for
(
i
in
result
.
list
)
{
for
(
i
=
0
;
i
<
result
.
list
.
length
;
i
+=
1
)
{
htmlString
+=
'
<li>
\n
'
;
htmlString
+=
'
<li>
\n
'
;
htmlString
+=
result
.
list
[
i
].
fileName
;
htmlString
+=
result
.
list
[
i
].
fileName
;
htmlString
+=
'
</li>
\n
'
;
htmlString
+=
'
</li>
\n
'
;
...
...
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