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
9d773a3f
Commit
9d773a3f
authored
Jun 16, 2011
by
François Billioud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix __proto__
parent
270253a7
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
87 additions
and
46 deletions
+87
-46
UNGProject/js/editor.js
UNGProject/js/editor.js
+29
-25
UNGProject/js/theme.js
UNGProject/js/theme.js
+24
-18
UNGProject/js/tools.js
UNGProject/js/tools.js
+30
-0
UNGProject/theme.html
UNGProject/theme.html
+4
-3
No files found.
UNGProject/js/editor.js
View file @
9d773a3f
/**
* Editors
*/
var
Xinha
=
function
()
{
this
.
name
=
"
Xinha
"
;
this
.
load
=
function
()
{
_editor_url
=
"
xinha/
"
;
getCurrentPage
().
include
(
"
xinha/XinhaCore.js
"
,
"
script
"
);
getCurrentPage
().
include
(
"
xinha/config.js
"
,
"
script
"
);
xinha_init
();
}
this
.
saveEdition
=
function
()
{
var
textArea
=
getCurrentPage
().
getHTML
().
getElementById
(
"
input_area
"
);
getCurrentDocument
().
saveEdition
(
textArea
.
content
);
}
this
.
loadContent
=
function
()
{
var
textArea
=
getCurrentPage
().
getHTML
().
getElementById
(
"
input_area
"
);
textArea
.
content
=
getCurrentDocument
().
getContent
();
}
this
.
load
();
}
/**
* Text documents
...
...
@@ -16,7 +39,6 @@ JSONTextDocument.prototype.saveEdition = function(content) {
this
.
setLastModification
(
currentTime
());
setCurrentDocument
(
this
);
}
JSONTextDocument
.
prototype
.
setAsCurrentDocument
=
function
()
{
getCurrentPage
().
displayDocumentTitle
(
this
);
getCurrentPage
().
displayDocumentState
(
this
);
...
...
@@ -26,34 +48,16 @@ JSONTextDocument.prototype.setAsCurrentDocument = function() {
}
getCurrentDocument
=
function
()
{
var
doc
=
JSON
.
parse
(
localStorage
.
getItem
(
"
currentDocument
"
)
);
doc
.
__proto__
=
JSONTextDocument
.
prototype
;
var
doc
=
new
JSONTextDocument
(
);
doc
.
load
(
JSON
.
parse
(
localStorage
.
getItem
(
"
currentDocument
"
)))
;
return
doc
;
}
(
new
JSONTextDocument
()).
setAsCurrentDocument
();
//load the document (it's just for testing)
/**
* Editors
*/
var
Xinha
=
function
()
{
this
.
name
=
"
Xinha
"
;
this
.
load
=
function
()
{
_editor_url
=
"
http://www.ungproject.com/xinha/
"
;
getCurrentPage
().
include
(
"
xinha/XinhaCore.js
"
,
"
script
"
);
getCurrentPage
().
include
(
"
xinha/config.js
"
,
"
script
"
);
xinha_init
();
}
this
.
saveEdition
=
function
()
{
var
textArea
=
getCurrentPage
().
getHTML
().
getElementById
(
"
input_area
"
);
getCurrentDocument
().
setContent
(
textArea
.
content
);
//saveCurrentDocument(); : JIO function
}
this
.
loadContent
=
function
()
{
var
textArea
=
getCurrentPage
().
getHTML
().
getElementById
(
"
input_area
"
);
textArea
.
content
=
getCurrentDocument
().
getContent
();
}
this
.
load
();
saveCurrentDocument
=
function
()
{
getCurrentPage
().
getEditor
().
saveEdition
();
//saveJIO(); : JIO function
}
...
...
UNGProject/js/theme.js
View file @
9d773a3f
/*
* global variables
*/
...
...
@@ -32,6 +31,7 @@ Page.prototype = {
getTitle
:
function
()
{
return
$
(
this
.
getXML
()).
find
(
"
title
"
).
text
();},
getContent
:
function
()
{
return
$
(
this
.
getXML
()).
find
(
"
content
"
).
html
();},
getDependencies
:
function
()
{
return
$
(
this
.
getXML
()).
find
(
"
dependencies
"
);},
getEditor
:
function
()
{
return
this
.
editor
;},
//loaders
/* load the xml document which contains the web page information */
...
...
@@ -40,9 +40,9 @@ Page.prototype = {
type
:
"
GET
"
,
url
:
source
,
dataType
:
"
html
"
,
async
:
tru
e
,
async
:
fals
e
,
success
:
function
(
data
)
{
currentPage
.
setXML
(
data
);
getCurrentPage
()
.
setXML
(
data
);
}
});
},
...
...
@@ -94,9 +94,7 @@ Page.prototype = {
}
this
.
getHTML
().
getElementById
(
"
available_languages
"
).
innerHTML
=
avLang
;
},
displayUserName
:
function
(
user
)
{
//alert($(this.getHTML()).find("html").html());
this
.
getHTML
().
getElementById
(
"
user_name
"
).
innerHTML
=
user
.
getName
();},
displayUserName
:
function
(
user
)
{
this
.
getHTML
().
getElementById
(
"
userName
"
).
innerHTML
=
user
.
getName
();},
//document information
displayAuthorName
:
function
(
doc
)
{
this
.
getHTML
().
getElementById
(
"
author
"
).
innerHTML
=
doc
.
getAuthor
();},
...
...
@@ -117,10 +115,10 @@ Page.prototype = {
pageContent
.
innerHTML
=
this
.
getContent
();
}
}
getCurrentPage
=
function
()
{
return
currentPage
;}
setCurrentPage
=
function
(
page
)
{
currentPage
=
new
Page
(
page
);
//window.location.reload();
}
/*
...
...
@@ -131,6 +129,8 @@ var User = function() {
this
.
language
=
"
en
"
;
this
.
storage
=
"
http://www.unhosted-dav.com
"
;
this
.
identityProvider
=
"
http://www.webfinger.com
"
;
this
.
setAsCurrentUser
();
}
User
.
prototype
=
{
getName
:
function
()
{
return
this
.
name
;},
...
...
@@ -148,18 +148,17 @@ User.prototype = {
setAsCurrentUser
:
function
()
{
getCurrentPage
().
displayUserName
(
this
);
getCurrentPage
().
displayLanguages
(
this
);
setCurrentUser
(
this
);
}
}
getCurrentUser
=
function
()
{
var
user
=
JSON
.
parse
(
localStorage
.
getItem
(
"
currentUser
"
)
);
user
.
__proto__
=
User
.
prototype
;
var
user
=
new
User
(
);
user
.
load
(
JSON
.
parse
(
localStorage
.
getItem
(
"
currentUser
"
)))
return
user
;
}
setCurrentUser
=
function
(
user
)
{
localStorage
.
setItem
(
"
currentUser
"
,
JSON
.
stringify
(
user
));
user
.
setAsCurrentUser
();
}
//setCurrentUser(new User());
setCurrentUser
=
function
(
user
)
{
localStorage
.
setItem
(
"
currentUser
"
,
JSON
.
stringify
(
user
));}
/**
...
...
@@ -175,6 +174,8 @@ var JSONDocument = function() {
this
.
creation
=
currentTime
();
this
.
lastModification
=
currentTime
();
this
.
state
=
Document
.
states
.
draft
;
this
.
setAsCurrentDocument
();
//temp
}
JSONDocument
.
prototype
=
{
//type
...
...
@@ -203,7 +204,9 @@ JSONDocument.prototype = {
setAsCurrentDocument
:
function
()
{
setCurrentDocument
(
this
);
}
},
save
:
function
()
{}
}
Document
.
states
=
{
draft
:{
"
fr
"
:
"
Brouillon
"
,
"
en
"
:
"
Draft
"
},
...
...
@@ -211,8 +214,8 @@ Document.states = {
deleted
:{
"
fr
"
:
"
Supprimé
"
,
"
en
"
:
"
Deleted
"
}
}
getCurrentDocument
=
function
()
{
var
doc
=
JSON
.
parse
(
localStorage
.
getItem
(
"
currentDocument
"
)
);
doc
.
__proto__
=
JSONDocument
.
prototype
;
var
doc
=
new
JSONDocument
(
);
doc
.
load
(
JSON
.
parse
(
localStorage
.
getItem
(
"
currentDocument
"
)))
;
return
doc
;
}
setCurrentDocument
=
function
(
doc
)
{
localStorage
.
setItem
(
"
currentDocument
"
,
JSON
.
stringify
(
doc
));}
...
...
@@ -221,7 +224,10 @@ setCurrentDocument = function(doc) {localStorage.setItem("currentDocument",JSON.
/*
* tools
*/
currentTime
=
function
()
{
return
(
new
Date
()).
toUTCString
();}
cancel_sharing
=
function
()
{
alert
(
"
cancel
"
);}
translate
=
function
()
{
alert
(
"
translate
"
);}
submit
=
function
()
{
alert
(
"
submit
"
);}
//test = new User();
\ No newline at end of file
UNGProject/js/tools.js
0 → 100644
View file @
9d773a3f
/***
* return true if this object implements the interface
*/
Object
.
prototype
.
Implements
=
function
(
myInterface
)
{
for
(
var
property
in
myInterface
)
{
if
(
typeof
myInterface
[
property
]
!=
"
string
"
)
continue
;
if
(
this
[
property
]
==
undefined
||
typeof
this
[
property
]
!=
myInterface
[
property
]
)
return
false
;
}
return
true
;
};
/**
* Load a JSON data into an object
*/
Object
.
prototype
.
load
=
function
(
data
)
{
for
(
var
property
in
data
)
{
this
[
property
]
=
data
[
property
];
}
};
/**
* returns the current date
*/
currentTime
=
function
()
{
return
(
new
Date
()).
toUTCString
();}
\ No newline at end of file
UNGProject/theme.html
View file @
9d773a3f
...
...
@@ -28,14 +28,15 @@
<script
type=
"text/javascript"
src=
"js/base64.js"
></script>
<script
type=
"text/javascript"
src=
"js/tools.js"
></script>
<script
type=
"text/javascript"
src=
"js/theme.js"
></script>
<script
type=
"text/javascript"
src=
"js/editor.js"
></script>
<script
type=
"text/javascript"
>
// initialize
init
=
function
()
{
setCurrentPage
(
"
editor
"
);
new
User
();
doc
=
new
document
.
JSONTextDocument
();
//load the document (it's just for testing)
//
doc.setAsCurrentDocument();
doc
=
new
JSONTextDocument
();
//load the document (it's just for testing)
doc
.
setAsCurrentDocument
();
}
$
(
document
).
ready
(
init
);
</script>
...
...
@@ -44,7 +45,7 @@
<body>
<form
id=
"main_form"
class=
"main_form"
onsubmit=
"changed=false; return true"
action=
"javascript:save
_current_doc
()"
action=
"javascript:save
CurrentDocument
()"
method=
"post"
>
<div
class=
"container"
>
...
...
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