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
c2b972be
Commit
c2b972be
authored
Jul 12, 2011
by
Siddhant Sanyam
Browse files
Options
Browse Files
Download
Plain Diff
Resolved the Error handler
parents
7d7b70af
15d6eafd
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
764 additions
and
3004 deletions
+764
-3004
.gitignore
.gitignore
+3
-0
UNGProject/css/editor.css
UNGProject/css/editor.css
+0
-1189
UNGProject/css/theme.css
UNGProject/css/theme.css
+0
-1189
UNGProject/css/ung.css
UNGProject/css/ung.css
+6
-2
UNGProject/js/image-editor.js
UNGProject/js/image-editor.js
+13
-9
UNGProject/js/text-editor.js
UNGProject/js/text-editor.js
+16
-10
UNGProject/js/theme.js
UNGProject/js/theme.js
+55
-48
UNGProject/js/tools.js
UNGProject/js/tools.js
+153
-56
UNGProject/js/ung.js
UNGProject/js/ung.js
+56
-39
UNGProject/theme.html
UNGProject/theme.html
+0
-1
UNGProject/ung.html
UNGProject/ung.html
+462
-461
No files found.
.gitignore
View file @
c2b972be
...
...
@@ -2,6 +2,9 @@
/UNGProject/nbproject/
/UNGProject/jquery_sheet_editor/
/UNGProject/js/jquery/
/UNGProject/css/images/
/UNGProject/svg-edit/
/UNGProject/dav
# buildout
/bin/
...
...
UNGProject/css/editor.css
deleted
100644 → 0
View file @
7d7b70af
This diff is collapsed.
Click to expand it.
UNGProject/css/theme.css
deleted
100644 → 0
View file @
7d7b70af
This diff is collapsed.
Click to expand it.
UNGProject/css/ung.css
View file @
c2b972be
...
...
@@ -121,8 +121,7 @@ div#wrapper_header {
/* left */
div
.header-left
{
margin-top
:
-4px
;
min-width
:
32em
;
width
:
40%
;
width
:
32em
;
position
:
absolute
;
}
div
.header-left
h2
{
...
...
@@ -156,6 +155,11 @@ div#wrapper_header div.field a[name="document_title"]:hover {
background
:
none
repeat
scroll
0
0
#FFFFD6
;
border
:
1px
solid
#AAAAAA
;
}
/* research bar */
div
.input
form
{
margin-top
:
0.5em
;
float
:
right
;
}
/* right */
div
.header-right
{
...
...
UNGProject/js/image-editor.js
View file @
c2b972be
...
...
@@ -25,20 +25,26 @@ SVGEditor = function() {
/**
* SVG documents
* editable documents must implements the following methods
* getType : returns the type of a document
*
* editable documents must implements the following arguments and methods
* type : a unique type ID
* saveEdition : set the argument as the new content of the document. Change last modification time and display the changes
* setAsCurrentDocument : set the document as currentDocument in the local storage and display its properties in the current page
*
* @param arg : a json JSONTextDocument object to load
*/
var
JSONIllustrationDocument
=
function
()
{
JSONDocument
.
call
(
this
);
//inherits properties from JSONDocument
this
.
type
=
"
illustration
"
;
var
JSONIllustrationDocument
=
function
(
arg
)
{
JSONDocument
.
call
(
this
,
arg
);
//inherits properties from JSONDocument
if
(
arg
)
{
this
.
load
(
arg
);}
else
{
this
.
type
=
"
illustration
"
;
}
}
JSONIllustrationDocument
.
prototype
=
new
JSONDocument
();
//inherits methods from JSONDocument
JSONIllustrationDocument
.
prototype
.
saveEdition
=
function
(
content
)
{
this
.
setLastUser
(
getCurrentUser
());
this
.
setLastUser
(
getCurrentUser
()
.
getName
()
);
this
.
setContent
(
content
);
this
.
setLastModification
(
currentTime
());
this
.
setAsCurrentDocument
();
...
...
@@ -53,8 +59,6 @@ JSONIllustrationDocument.prototype.setAsCurrentDocument = function() {
}
getCurrentDocument
=
function
()
{
var
doc
=
new
JSONIllustrationDocument
();
doc
.
load
(
JSON
.
parse
(
localStorage
.
getItem
(
"
currentDocument
"
)));
return
doc
;
return
new
JSONIllustrationDocument
(
JSON
.
parse
(
localStorage
.
getItem
(
"
currentDocument
"
)));
}
UNGProject/js/text-editor.js
View file @
c2b972be
...
...
@@ -31,21 +31,29 @@ var Xinha = function() {
/**
* Text documents
* editable documents must implements the following methods
* getType : returns the type of a document
*
* editable documents must implements the following arguments and methods
* type : a unique type ID
* saveEdition : set the argument as the new content of the document. Change last modification time and display the changes
* setAsCurrentDocument : set the document as currentDocument in the local storage and display its properties in the current page
*/
var
JSONTextDocument
=
function
()
{
JSONDocument
.
call
(
this
);
//inherits properties from JSONDocument
this
.
type
=
"
text
"
;
/**
* class JSONTextDocument
* @param arg : a json JSONTextDocument object to load
*/
var
JSONTextDocument
=
function
(
arg
)
{
JSONDocument
.
call
(
this
,
arg
);
//inherits properties from JSONDocument
if
(
arg
)
{
this
.
load
(
arg
);}
else
{
this
.
type
=
"
text
"
;
}
}
JSONTextDocument
.
prototype
=
new
JSONDocument
();
//inherits methods from JSONDocument
JSONTextDocument
.
prototype
.
saveEdition
=
function
(
content
)
{
this
.
setLastUser
(
getCurrentUser
());
this
.
setLastUser
(
getCurrentUser
()
.
getName
()
);
this
.
setContent
(
content
);
this
.
setLastModification
(
currentTime
());
this
.
setAsCurrentDocument
();
...
...
@@ -60,7 +68,5 @@ JSONTextDocument.prototype.setAsCurrentDocument = function() {
}
getCurrentDocument
=
function
()
{
var
doc
=
new
JSONTextDocument
();
doc
.
load
(
JSON
.
parse
(
localStorage
.
getItem
(
"
currentDocument
"
)));
return
doc
;
return
new
JSONTextDocument
(
JSON
.
parse
(
localStorage
.
getItem
(
"
currentDocument
"
)));
}
UNGProject/js/theme.js
View file @
c2b972be
...
...
@@ -21,7 +21,6 @@ var Page = function(page) {
this
.
html
=
window
.
document
;
this
.
xml
=
null
;
this
.
editor
=
null
;
//define as current page
currentPage
=
this
;
if
(
page
!=
undefined
)
{
this
.
loadXML
(
"
xml/
"
+
page
+
"
.xml
"
);}
...
...
@@ -139,13 +138,17 @@ setCurrentPage = function(page) {currentPage = page;}
/*
* User Class
* stores useful information about a user and provides methods to manipulate them
* @param arg : a json User object to load
*/
var
User
=
function
(
details
)
{
this
.
name
=
"
unknown
"
;
this
.
language
=
"
en
"
;
this
.
storage
=
"
http://www.unhosted-dav.com
"
;
this
.
identityProvider
=
"
http://www.webfinger.com
"
;
this
.
displayPreferences
=
15
;
//number of displayed document in the list
var
User
=
function
(
arg
)
{
if
(
arg
)
{
this
.
load
(
arg
);}
else
{
this
.
name
=
"
unknown
"
;
this
.
language
=
"
en
"
;
this
.
storage
=
"
http://www.unhosted-dav.com
"
;
this
.
identityProvider
=
"
http://www.webfinger.com
"
;
this
.
displayPreferences
=
15
;
//number of displayed document in the list
}
}
User
.
prototype
=
new
UngObject
();
//inherits from UngObject
User
.
prototype
.
load
({
//add methods thanks to the UngObject.load method
...
...
@@ -168,9 +171,7 @@ User.prototype.load({//add methods thanks to the UngObject.load method
});
getCurrentUser
=
function
()
{
var
user
=
new
User
();
user
.
load
(
JSON
.
parse
(
localStorage
.
getItem
(
"
currentUser
"
)));
return
user
;
return
new
User
(
JSON
.
parse
(
localStorage
.
getItem
(
"
currentUser
"
)));
}
setCurrentUser
=
function
(
user
)
{
localStorage
.
setItem
(
"
currentUser
"
,
JSON
.
stringify
(
user
));}
...
...
@@ -182,18 +183,24 @@ setCurrentUser = function(user) {localStorage.setItem("currentUser", JSON.string
* to manipulate these elements.
*/
/* JSON document */
var
JSONDocument
=
function
()
{
this
.
language
=
getCurrentUser
().
getLanguage
();
this
.
version
=
null
;
this
.
author
=
getCurrentUser
().
getName
();
this
.
lastUser
=
getCurrentUser
().
getName
();
this
.
title
=
"
Untitled
"
;
this
.
content
=
""
;
this
.
creation
=
currentTime
();
this
.
lastModification
=
currentTime
();
this
.
state
=
this
.
states
.
draft
;
/**
* JSON document
* @param arg : a json JSONDocument object to load
*/
var
JSONDocument
=
function
(
arg
)
{
if
(
arg
)
{
this
.
load
(
arg
);}
else
{
this
.
language
=
getCurrentUser
().
getLanguage
();
this
.
version
=
null
;
this
.
author
=
getCurrentUser
().
getName
();
this
.
lastUser
=
getCurrentUser
().
getName
();
this
.
title
=
"
Untitled
"
;
this
.
content
=
""
;
this
.
creation
=
currentTime
();
this
.
lastModification
=
currentTime
();
this
.
state
=
JSONDocument
.
prototype
.
states
.
draft
;
}
}
JSONDocument
.
prototype
=
new
UngObject
();
//inherits from UngObject
...
...
@@ -240,7 +247,8 @@ JSONDocument.prototype.load({//add methods thanks to the UngObject.load method
save
:
function
(
instruction
)
{
var
doc
=
this
;
saveFile
(
getDocumentAddress
(
this
),
doc
,
instruction
);
}
},
remove
:
function
(
instruction
)
{
deleteFile
(
getDocumentAddress
(
this
),
instruction
);}
});
JSONDocument
.
prototype
.
states
=
{
draft
:{
"
fr
"
:
"
Brouillon
"
,
"
en
"
:
"
Draft
"
},
...
...
@@ -248,9 +256,7 @@ JSONDocument.prototype.states = {
deleted
:{
"
fr
"
:
"
Supprimé
"
,
"
en
"
:
"
Deleted
"
}
}
getCurrentDocument
=
function
()
{
var
doc
=
new
JSONDocument
();
doc
.
load
(
JSON
.
parse
(
localStorage
.
getItem
(
"
currentDocument
"
)));
return
doc
;
return
new
JSONDocument
(
JSON
.
parse
(
localStorage
.
getItem
(
"
currentDocument
"
)));
}
setCurrentDocument
=
function
(
doc
)
{
localStorage
.
setItem
(
"
currentDocument
"
,
JSON
.
stringify
(
doc
));}
...
...
@@ -269,28 +275,29 @@ getDocumentAddress = function(doc) {return "http://sidunhosted.com/ungdav/"+doc.
* open a dialog box to edit document information
*/
editDocumentSettings
=
function
()
{
loadFile
(
"
xml/xmlElements.xml
"
,
"
html
"
,
function
(
data
)
{
$
(
"
rename
"
,
data
).
dialog
({
autoOpen
:
true
,
height
:
131
,
width
:
389
,
modal
:
true
,
buttons
:
{
"
Save
"
:
function
(){
var
doc
=
getCurrentDocument
();
doc
.
setTitle
(
$
(
this
).
find
(
"
#name
"
).
attr
(
"
value
"
));
doc
.
setLanguage
(
$
(
getCurrentDocument
()).
find
(
"
#language
"
).
attr
(
"
value
"
));
doc
.
setVersion
(
$
(
getCurrentDocument
()).
find
(
"
#version
"
).
attr
(
"
value
"
));
saveCurrentDocument
();
doc
.
setAsCurrentDocument
();
//diplay modifications
$
(
this
).
dialog
(
"
close
"
);
},
Cancel
:
function
()
{
$
(
this
).
dialog
(
"
close
"
);
}
}
});
}
saveCurrentDocument
();
loadFile
(
"
xml/xmlElements.xml
"
,
"
html
"
,
function
(
data
)
{
$
(
"
rename
"
,
data
).
dialog
({
autoOpen
:
true
,
height
:
131
,
width
:
389
,
modal
:
true
,
buttons
:
{
"
Save
"
:
function
(){
var
doc
=
getCurrentDocument
();
doc
.
setTitle
(
$
(
this
).
find
(
"
#name
"
).
attr
(
"
value
"
));
doc
.
setLanguage
(
$
(
getCurrentDocument
()).
find
(
"
#language
"
).
attr
(
"
value
"
));
doc
.
setVersion
(
$
(
getCurrentDocument
()).
find
(
"
#version
"
).
attr
(
"
value
"
));
saveCurrentDocument
();
doc
.
setAsCurrentDocument
();
//diplay modifications
$
(
this
).
dialog
(
"
close
"
);
},
Cancel
:
function
()
{
$
(
this
).
dialog
(
"
close
"
);
}
}
});
}
)}
saveCurrentDocument
=
function
()
{
...
...
UNGProject/js/tools.js
View file @
c2b972be
...
...
@@ -33,49 +33,132 @@ UngObject.prototype.inherits = function(superClass) {
this
.
prototype
.
load
(
superClass
.
prototype
);
}
/* return true only if two objects are equals */
UngObject
.
prototype
.
equals
=
function
(
object
)
{
for
(
var
property
in
object
)
{
if
(
this
.
hasOwnProperty
(
property
))
{
var
isEquals
=
this
[
property
]
&&
typeof
(
this
[
property
])
==
"
object
"
?
UngObject
.
prototype
.
equals
.
call
(
this
[
property
],
object
[
property
])
:
this
[
property
]
===
object
[
property
];
if
(
!
isEquals
)
{
return
false
}
}
}
return
true
;
}
/**
* Class List
* this class provides usual API to manipulate list structure
* @param arg : a json list object
* @param contentType : the type of the elements of the list
*/
var
List
=
function
(
arg
)
{
this
.
content
=
new
Array
();
if
(
arg
)
{
this
.
content
=
arg
;}
this
.
length
=
this
.
content
.
length
;
var
List
=
function
(
arg
,
contentType
)
{
if
(
arg
&&
arg
.
headElement
)
{
if
(
contentType
)
{
this
.
headElement
=
new
contentType
(
arg
.
headElement
);
}
else
{
this
.
headElement
=
arg
.
headElement
;
}
this
.
length
=
arg
.
length
;
this
.
previous
=
new
List
(
arg
.
previous
,
contentType
);
}
else
{
this
.
nullElement
();
}
}
List
.
prototype
=
new
UngObject
();
List
.
prototype
.
load
({
List
.
prototype
.
load
({
nullElement
:
function
()
{
this
.
headElement
=
null
;
this
.
previous
=
undefined
;
this
.
length
=
0
;
},
size
:
function
()
{
return
this
.
length
;},
put
:
function
(
key
,
value
)
{
if
(
!
this
.
content
[
key
])
{
this
.
length
=
this
.
length
+
1
;}
alert
(
""
+
this
.
length
+
this
.
content
[
key
]);
this
.
content
[
key
]
=
value
;
head
:
function
()
{
return
this
.
headElement
;},
tail
:
function
()
{
return
this
.
previous
;},
isEmpty
:
function
()
{
return
this
.
head
()
===
null
;},
equals
:
function
(
list
)
{
return
this
.
head
().
equals
(
list
.
head
())
&&
this
.
tail
().
equals
(
list
.
tail
());
},
add
:
function
(
element
)
{
this
.
put
(
this
.
size
(),
element
);},
get
:
function
(
i
)
{
return
this
.
content
[
i
];},
concat
:
function
(
list
)
{
while
(
!
list
.
isEmpty
())
{
this
.
add
(
list
.
pop
())}},
remove
:
function
(
i
)
{
delete
this
.
content
[
i
];
this
.
length
--
;},
isEmpty
:
function
()
{
return
this
.
size
()
==
0
;},
head
:
function
()
{
return
this
.
isEmpty
()
?
null
:
this
.
get
(
this
.
size
()
-
1
);},
pop
:
function
()
{
if
(
this
.
isEmpty
())
{
return
null
;}
var
element
=
this
.
get
(
this
.
size
()
-
1
);
this
.
remove
(
this
.
size
()
-
1
);
return
element
;
add
:
function
(
value
)
{
var
t
=
new
List
();
t
.
load
(
this
);
this
.
headElement
=
value
;
this
.
previous
=
t
;
this
.
length
=
t
.
size
()
+
1
;
},
recursiveCall
:
function
(
instruction
)
{
var
list
=
new
List
();
list
.
load
(
this
);
if
(
list
.
isEmpty
())
{
return
false
;}
var
result
=
instruction
(
list
.
pop
());
return
result
?
result
:
list
.
recursiveCall
(
instruction
);
get
:
function
(
i
)
{
if
(
i
>=
this
.
size
())
{
return
null
;}
if
(
i
==
0
)
{
return
this
.
head
();}
return
this
.
tail
().
get
(
i
-
1
);
},
set
:
function
(
i
,
element
)
{
if
(
i
>=
this
.
size
())
{
error
(
"
set out of bounds,
"
+
i
+
"
:
"
+
this
.
size
(),
this
);
return
}
if
(
i
==
0
)
{
this
.
headElement
=
element
;
}
else
{
this
.
tail
().
set
(
i
-
1
,
element
);
}
},
remove
:
function
(
i
)
{
if
(
i
>=
this
.
size
())
{
error
(
"
remove out of bounds,
"
+
i
+
"
:
"
+
this
.
size
(),
this
);
return
}
//particular case
if
(
i
==
0
)
{
this
.
pop
();
return
}
//particular case
if
(
i
==
1
)
{
//init
this
.
previous
=
this
.
tail
().
tail
();
}
else
{
//recursion
this
.
tail
().
remove
(
i
-
1
);
}
this
.
length
--
;
},
pop
:
function
()
{
if
(
this
.
isEmpty
())
{
error
(
"
pop on empty list
"
,
this
);
return
null
;}
var
h
=
this
.
head
();
this
.
load
(
this
.
tail
())
return
h
;
},
find
:
function
(
object
)
{
for
(
var
i
=
0
;
i
<
this
.
length
;
i
++
)
{
if
(
this
.
get
(
i
)
===
object
)
{
return
i
;}}
return
-
1
;
if
(
this
.
isEmpty
())
{
return
-
1
}
//init-false
var
elt
=
this
.
head
();
if
(
object
.
equals
)
{
//init-true
if
(
object
.
equals
(
this
.
head
()))
{
return
0
;}
//with an adapted comparator
}
else
{
if
(
object
===
this
.
head
())
{
return
0
;}
//with usual comparator
}
var
recursiveResult
=
this
.
tail
().
find
(
object
);
//recursion
return
recursiveResult
>=
0
?
this
.
tail
().
find
(
object
)
+
1
:
recursiveResult
;
},
contains
:
function
(
object
)
{
return
(
find
(
object
)
!=-
1
);
}
contains
:
function
(
object
)
{
if
(
this
.
isEmpty
())
{
return
false
}
else
{
return
object
===
this
.
head
()
?
true
:
this
.
tail
().
contains
(
object
)}},
insert
:
function
(
element
,
i
)
{
if
(
i
>
this
.
size
())
{
error
(
"
insert out of bounds,
"
+
i
+
"
:
"
+
this
.
size
(),
this
);
return
}
//particular case
if
(
i
==
0
)
{
//init
this
.
add
(
element
);
}
else
{
//recursion
this
.
tail
().
insert
(
element
,
i
-
1
);
this
.
length
++
;
}
},
replace
:
function
(
oldElement
,
newElement
)
{
if
(
this
.
isEmpty
())
{
error
(
"
<<element not found>> when trying to replace
"
,
this
);
return
}
//init-false
if
(
oldElement
===
this
.
head
())
{
this
.
set
(
0
,
newElement
);
//init-true
}
else
{
this
.
tail
().
replace
(
oldElement
,
newElement
);
//recursion
}
},
removeElement
:
function
(
element
)
{
//remove each occurence of the element in this list
if
(
this
.
isEmpty
())
{
return
}
this
.
tail
().
removeElement
(
element
);
if
(
element
.
equals
)
{
//init-true
if
(
element
.
equals
(
this
.
head
()))
{
this
.
pop
();}
//with an adapted comparator
}
else
{
if
(
element
===
this
.
head
())
{
this
.
pop
();}
//with usual comparator
}
}
});
error
:
function
(
message
,
object
)
{
errorObject
=
object
;
console
.
log
(
message
);
}
/**
* returns the current date
...
...
@@ -87,17 +170,17 @@ currentTime = function() {return (new Date()).toUTCString();}
// save
saveXHR
=
function
(
address
)
{
$
.
ajax
({
url
:
address
,
type
:
"
PUT
"
,
headers
:
{
Authorization
:
"
Basic
"
+
btoa
(
"
smik:asdf
"
)},
fields
:
{
withCredentials
:
"
true
"
},
data
:
JSON
.
stringify
(
getCurrentDocument
()),
success
:
function
(){
alert
(
"
saved
"
);},
error
:
function
(
xhr
)
{
alert
(
"
error while saving
"
);}
});
url
:
address
,
type
:
"
PUT
"
,
headers
:
{
Authorization
:
"
Basic
"
+
btoa
(
"
smik:asdf
"
)},
fields
:
{
withCredentials
:
"
true
"
},
data
:
JSON
.
stringify
(
getCurrentDocument
()),
success
:
function
(){
alert
(
"
saved
"
);},
error
:
function
(
xhr
)
{
alert
(
"
error while saving
"
);}
});
};
/**
...
...
@@ -108,13 +191,14 @@ saveXHR = function(address) {
*/
loadFile
=
function
(
address
,
type
,
instruction
)
{
$
.
ajax
({
url
:
address
,
type
:
"
GET
"
,
url
:
address
,
type
:
"
GET
"
,
dataType
:
type
,
headers
:
{
Authorization
:
"
Basic
"
+
btoa
(
"
smik:asdf
"
)},
fields
:
{
withCredentials
:
"
true
"
},
success
:
instruction
,
error
:
function
(
type
)
{
t
=
type
;
alert
(
"
er
"
);}
error
:
function
(
type
)
{
alert
(
"
Error
"
+
type
.
status
+
"
: fail while trying to load
"
+
address
);}
});
}
...
...
@@ -129,28 +213,41 @@ saveFile = function(address, content, instruction) {
fields
:
{
withCredentials
:
"
true
"
},
success
:
instruction
,
error
:
function
(
type
)
{
if
(
type
.
status
==
201
)
{
instruction
();}
//ajax thinks that 201 is an error...
if
(
type
.
status
==
201
||
type
.
status
==
204
)
{
instruction
();}
//ajax thinks that 201 is an error...
}
});
};
}
deleteFile
=
function
(
address
,
instruction
)
{
$
.
ajax
({
url
:
address
,
type
:
"
DELETE
"
,
headers
:
{
Authorization
:
"
Basic
"
+
btoa
(
"
smik:asdf
"
)},
fields
:
{
withCredentials
:
"
true
"
},
success
:
instruction
,
error
:
function
(
type
)
{
alert
(
type
.
status
);
//ajax thinks that 201 is an error...
}
});
}
// load
loadXHR
=
function
(
address
)
{
$
.
ajax
({
url
:
address
,
type
:
"
GET
"
,
url
:
address
,
type
:
"
GET
"
,
dataType
:
"
json
"
,
cache
:
false
,
headers
:
{
Authorization
:
"
Basic
"
+
btoa
(
"
smik:asdf
"
)},
cache
:
false
,
headers
:
{
Authorization
:
"
Basic
"
+
btoa
(
"
smik:asdf
"
)},
fields
:
{
withCredentials
:
"
true
"
withCredentials
:
"
true
"
},
success
:
function
(
data
){
var
cDoc
=
getCurrentDocument
();
cDoc
.
load
(
data
);
cDoc
.
setAsCurrentDocument
();
}
success
:
function
(
data
){
var
cDoc
=
getCurrentDocument
();
cDoc
.
load
(
data
);
cDoc
.
setAsCurrentDocument
();
}
});
}
...
...
UNGProject/js/ung.js
View file @
c2b972be
...
...
@@ -10,45 +10,62 @@ setCurrentDocumentID = function(ID) {return localStorage.setItem("currentDocumen
/**
* class DocumentList
* This class provides methods to manipulate the list of documents of the current user
* As the list is stored in the localStorage, we are obliged to call "setDocumentList" after
* any content modification
* @param arg : a documentList json object to load
*/
var
DocumentList
=
function
()
{
List
.
call
(
this
);
this
.
displayedPage
=
1
;
this
.
selectionList
=
new
List
();
var
DocumentList
=
function
(
arg
)
{
//List.call(this);
if
(
arg
)
{
this
.
load
(
arg
);
this
.
load
(
new
List
(
arg
,
JSONDocument
));
this
.
selectionList
=
new
List
(
arg
.
selectionList
,
JSONDocument
);
//load methods of selectionList
}
else
{
this
.
displayedPage
=
1
;
this
.
selectionList
=
new
List
();
}
}
DocumentList
.
prototype
=
new
List
();
DocumentList
.
prototype
.
load
({
/* override : returns the ith document */
get
:
function
(
i
)
{
var
doc
=
new
JSONDocument
();
doc
.
load
(
this
.
content
[
i
]);
return
doc
;
addDocument
:
function
(
doc
)
{
this
.
add
(
doc
);
setDocumentList
(
this
);
this
.
display
();
},
/* override : put an element at the specified position */
put
:
function
(
i
,
doc
)
{
this
.
content
[
i
]
=
doc
;
if
(
!
this
.
content
[
i
])
{
this
.
length
++
;}
removeDocument
:
function
(
doc
)
{
var
i
=
this
.
find
(
doc
);
this
.
get
(
i
).
remove
()
//delete the file
this
.
remove
(
i
);
//remove from the list
setDocumentList
(
this
);
this
.
display
();
},
getSelectionList
:
function
()
{
var
list
=
new
List
();
list
.
load
(
this
.
selectionList
);
return
list
;
},
getSelectionList
:
function
()
{
return
this
.
selectionList
;
},
resetSelectionList
:
function
()
{
this
.
selectionList
=
new
List
();
for
(
var
i
=
0
;
i
<
this
.
length
;
i
++
)
{
$
(
"
tr td.listbox-table-select-cell input#
"
+
i
).
attr
(
"
checked
"
,
false
);
for
(
var
i
=
0
;
i
<
this
.
size
()
;
i
++
)
{
$
(
"
tr td.listbox-table-select-cell input#
"
+
i
).
attr
(
"
checked
"
,
false
);
//uncheck
}
setDocumentList
(
this
);
$
(
"
span#selected_row_number a
"
).
html
(
0
);
//display the selected row number
},
checkAll
:
function
()
{
for
(
var
i
=
0
;
i
<
this
.
length
;
i
++
)
{
this
.
selectionList
.
put
(
i
,
this
.
get
(
i
));
$
(
"
tr td.listbox-table-select-cell input#
"
+
this
.
get
(
i
).
getID
()).
attr
(
"
checked
"
,
true
);
this
.
selectionList
=
new
List
();
for
(
var
i
=
0
;
i
<
this
.
size
();
i
++
)
{
this
.
getSelectionList
().
add
(
this
.
get
(
i
));
$
(
"
tr td.listbox-table-select-cell input#
"
+
i
).
attr
(
"
checked
"
,
true
);
}
setDocumentList
(
this
);
$
(
"
span#selected_row_number a
"
).
html
(
this
.
size
());
//display the selected row number
},
deleteSelectedDocuments
:
function
()
{
var
selection
=
this
.
getSelectionList
();
while
(
!
selection
.
isEmpty
())
{
var
doc
=
selection
.
pop
();
this
.
removeDocument
(
doc
);
}
},
getDisplayedPage
:
function
()
{
return
this
.
displayedPage
;},
...
...
@@ -56,6 +73,7 @@ DocumentList.prototype.load({
/* display the list of documents in the web page */
displayContent
:
function
()
{
$
(
"
table.listbox tbody
"
).
html
(
""
);
//empty the previous displayed list
var
n
=
this
.
size
();
for
(
var
i
=
0
;
i
<
n
;
i
++
)
{
var
ligne
=
new
Line
(
this
.
get
(
i
),
i
);
...
...
@@ -83,21 +101,22 @@ DocumentList.prototype.load({
/* update the ith document information */
update
:
function
(
i
)
{
var
li
ne
=
this
;
var
doc
=
li
ne
.
get
(
i
);
var
li
st
=
this
;
var
doc
=
li
st
.
get
(
i
);
loadFile
(
getDocumentAddress
(
doc
),
"
json
"
,
function
(
data
)
{
doc
.
load
(
data
);
//todo : replace by data.header
doc
.
setContent
(
""
);
//
line
.
put
(
i
,
doc
);
list
.
set
(
i
,
doc
);
setDocumentList
(
list
);
});
}
});
getDocumentList
=
function
()
{
var
list
=
new
DocumentList
();
list
.
load
(
JSON
.
parse
(
localStorage
.
getItem
(
"
documentList
"
)));
return
list
;
return
new
DocumentList
(
JSON
.
parse
(
localStorage
.
getItem
(
"
documentList
"
)));
}
setDocumentList
=
function
(
list
)
{
localStorage
.
setItem
(
"
documentList
"
,
JSON
.
stringify
(
list
));
}
setDocumentList
=
function
(
list
)
{
localStorage
.
setItem
(
"
documentList
"
,
JSON
.
stringify
(
list
));}
/**
...
...
@@ -120,20 +139,22 @@ Line.prototype = {
return
$
(
"
tr td.listbox-table-select-cell input#
"
+
this
.
getID
()).
attr
(
"
checked
"
);
},
/* add the document of this line to the list of selected documents */
addToSelection
:
function
()
{
var
list
=
getDocumentList
();
list
.
getSelectionList
().
put
(
this
.
getID
(),
this
);
list
.
getSelectionList
().
add
(
this
.
getDocument
()
);
setDocumentList
(
list
);
},
/* remove the document of this line from the list of selected documents */
removeFromSelection
:
function
()
{
var
list
=
getDocumentList
();
list
.
getSelectionList
().
remove
(
this
.
getID
());
list
.
getSelectionList
().
remove
Element
(
this
.
getDocument
());
setDocumentList
(
list
);
},
/* check or uncheck the line */
changeState
:
function
()
{
this
.
isSelected
()
?
this
.
addToSelection
()
:
this
.
removeFromSelection
();
test
=
getDocumentList
().
getSelectionList
();
$
(
"
span#selected_row_number a
"
).
html
(
getDocumentList
().
getSelectionList
().
size
());
$
(
"
span#selected_row_number a
"
).
html
(
getDocumentList
().
getSelectionList
().
size
());
//display the selected row number
},
/* load the document information in the html of a default line */
...
...
@@ -180,11 +201,7 @@ var createNewDocument = function(type) {
newDocument
.
setType
(
type
);
newDocument
.
save
(
function
()
{
getDocumentList
().
add
(
newDocument
);
getDocumentList
().
add
Document
(
newDocument
);
startDocumentEdition
(
newDocument
);
});
}
var
deleteSelectedDocuments
=
function
()
{
}
\ No newline at end of file
UNGProject/theme.html
View file @
c2b972be
...
...
@@ -36,7 +36,6 @@
var
initUser
=
function
()
{
var
user
=
getCurrentUser
();
if
(
!
user
)
{
user
=
new
User
();}
user
.
setAsCurrentUser
();
}
...
...
UNGProject/ung.html
View file @
c2b972be
This diff is collapsed.
Click to expand it.
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