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
4cf62395
Commit
4cf62395
authored
Jun 22, 2011
by
François Billioud
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://git.erp5.org/repos/ung
parents
61a07f31
03ea1fa8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
107 additions
and
32 deletions
+107
-32
UNGProject/js/jio.js
UNGProject/js/jio.js
+91
-0
UNGProject/js/tools.js
UNGProject/js/tools.js
+14
-30
UNGProject/theme.html
UNGProject/theme.html
+2
-2
No files found.
UNGProject/js/jio.js
View file @
4cf62395
/*
JIO: Javascript I/O. A library to load, edit, save documents to
multiple storage backends using a common interface
*/
/*
JIO Namespace. Everything related to JIO happens over here
*/
var
JIO
=
(
function
()
{
/* Function returns us a JIOStorage, a basic stensil for other kind of storage*/
var
JIOStorage
=
function
(
store_info
){
var
J
=
{};
// dummy object. We will augment it and return it
J
=
{
"
initialize
"
:
function
(
server
,
path
,
username
,
password
){
/*
Basic initilization or pre-rituals
*/
},
"
loadDocument
"
:
function
(
doc_id
,
handler
)
{
/*
Calls handler with an object associated with requested document of the `doc_id`
.hash of the object is the MD5 hash of the data
.data of the object is the data itself
*/
},
"
saveDocument
"
:
function
(
doc_id
,
data
,
hash
,
overwrite
,
async
)
{
/*
Saves the document with a particular `docid`
If `docid` is `0` then the function assigns a docid automatically
`hash` is used to check if the document was last changed by someone else,
If it was, it will raise a JIOContentChanged exception
If `hash` is not supplied, the document will be overwritten.
If `overwrite` is true the content will be overwritten without any exception
*/
},
"
getDocumentList
"
:
function
(
storage_id
,
query
,
order_by
,
metadata
)
{
/*
Storage implementation should provide this function which will
return the list of documents which are stored on the storage
beased on `query`.
TODO Define how `query` is specified
`ordered_by` how the results should be sorted
*/
}
};
return
J
;
};
//JIOStorage
/* DAVStorage : Does JIO on a WebDAV server*/
var
DAVStorage
=
function
(
store_info
){
if
(
!
store_info
.
serverSore
)
throw
Error
(
"
No server specified for DAVStorage
"
);
store_info
.
path
=
store_info
.
path
||
''
;
var
auth
=
false
;
if
(
store_info
.
user
){
if
(
!
store_info
.
pass
)
throw
Error
(
"
No password specified of user for DAVStorage
"
);
auth
=
true
;
}
var
J
=
JIOStorage
(
store_info
);
// we will return this object at the end
J
.
loadDocument
=
function
(
doc_id
,
handler
)
{
ajaxsetting
=
{
/* server,path should all be in correct format http://foo.com/ some/dir/*/
url
:
store_info
.
server
+
store_info
.
path
+
doc_id
;
};
};
};
})();
JIOStorage
=
}
var
JIODAVStorage
=
Object
.
create
(
JIOStorage
);
JIODAVStorage
.
initialize
=
function
(
server
,
path
,
user
,
pass
){
this
.
server
=
server
;
this
.
path
=
path
||
'
/
'
;
if
(
user
)
{
this
.
user
=
user
;
this
.
pass
=
pass
;
}
JIODAVStorage
.
loadDocument
=
function
(
doc_name
){
\ No newline at end of file
UNGProject/js/tools.js
View file @
4cf62395
...
...
@@ -71,36 +71,20 @@ saveXHR = function(address) {
// load
loadXHR
=
function
(
address
)
{
//create request
var
xhr
=
null
;
try
{
xhr
=
new
XMLHttpRequest
();
}
catch
(
e
)
{
try
{
xhr
=
new
ActiveXObject
(
"
Msxml2.XMLHTTP
"
);}
catch
(
e2
)
{
try
{
xhr
=
new
ActiveXObject
(
"
Microsoft.XMLHTTP
"
);}
catch
(
e
)
{}
}
}
xhr
.
open
(
"
GET
"
,
address
,
true
);
xhr
.
onreadystatechange
=
function
()
{
if
(
xhr
.
readyState
==
4
)
{
var
cDoc
=
getCurrentDocument
();
if
(
xhr
.
status
==
200
)
{
cDoc
.
load
(
JSON
.
parse
(
xhr
.
responseText
));
}
else
{
alert
(
"
error: got status
"
+
xhr
.
status
+
"
when doing basic auth GET on url
"
+
"
nom:test
"
+
"
"
+
xhr
.
statusText
);
}
cDoc
.
setAsCurrentDocument
();
}
}
xhr
.
send
();
alert
(
'
loadXHR
'
);
$
.
ajax
({
url
:
address
,
type
:
"
GET
"
,
cache
:
false
,
/* username: "smik",
password: "asdf",*/
success
:
function
(
data
){
alert
(
data
);
var
cDoc
=
getCurrentDocument
();
cDoc
.
load
(
JSON
.
parse
(
data
));
cDoc
.
setAsCurrentDocument
();
}
});
}
/*
...
...
UNGProject/theme.html
View file @
4cf62395
...
...
@@ -26,7 +26,7 @@
<script
type=
"text/javascript"
src=
"js/base64.js"
></script>
<script
type=
"text/javascript"
src=
"js/tools.js"
></script>
<script
type=
"text/javascript"
src=
"js/jio.js"
></script>
<script
type=
"text/javascript"
src=
"js/theme.js"
></script>
<script
type=
"text/javascript"
>
...
...
@@ -34,7 +34,7 @@
var
initPage
=
function
()
{
var
pageIWantToTest
=
"
editor
"
;
addressOfTestDocument
=
"
dav/temp.json
"
;
addressOfTestDocument
=
"
http://sidunhosted.com/webdav/emacs
"
;
setCurrentPage
(
pageIWantToTest
);
}
...
...
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