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
03ea1fa8
Commit
03ea1fa8
authored
Jun 22, 2011
by
Siddhant Sanyam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added preliminary JIO with proper namespace. Made loadXHR with . hardcoded addressOfTestDoc
parent
f9cec3d9
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 @
03ea1fa8
/*
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 @
03ea1fa8
...
@@ -71,36 +71,20 @@ saveXHR = function(address) {
...
@@ -71,36 +71,20 @@ saveXHR = function(address) {
// load
// load
loadXHR
=
function
(
address
)
{
loadXHR
=
function
(
address
)
{
alert
(
'
loadXHR
'
);
//create request
$
.
ajax
({
var
xhr
=
null
;
url
:
address
,
try
type
:
"
GET
"
,
{
cache
:
false
,
xhr
=
new
XMLHttpRequest
();
/* username: "smik",
}
catch
(
e
)
password: "asdf",*/
{
success
:
function
(
data
){
try
{
xhr
=
new
ActiveXObject
(
"
Msxml2.XMLHTTP
"
);}
alert
(
data
);
catch
(
e2
)
var
cDoc
=
getCurrentDocument
();
{
cDoc
.
load
(
JSON
.
parse
(
data
));
try
{
xhr
=
new
ActiveXObject
(
"
Microsoft.XMLHTTP
"
);}
cDoc
.
setAsCurrentDocument
();
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
();
}
}
/*
/*
...
...
UNGProject/theme.html
View file @
03ea1fa8
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
<script
type=
"text/javascript"
src=
"js/base64.js"
></script>
<script
type=
"text/javascript"
src=
"js/base64.js"
></script>
<script
type=
"text/javascript"
src=
"js/tools.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"
src=
"js/theme.js"
></script>
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
...
@@ -34,7 +34,7 @@
...
@@ -34,7 +34,7 @@
var
initPage
=
function
()
{
var
initPage
=
function
()
{
var
pageIWantToTest
=
"
editor
"
;
var
pageIWantToTest
=
"
editor
"
;
addressOfTestDocument
=
"
dav/temp.json
"
;
addressOfTestDocument
=
"
http://sidunhosted.com/webdav/emacs
"
;
setCurrentPage
(
pageIWantToTest
);
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