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
caa4fec2
Commit
caa4fec2
authored
Sep 01, 2011
by
François Billioud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comment and edit JIO Main class (avoid undefined option)
parent
e4793d89
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
30 deletions
+40
-30
UNGProject/unhosted/jio.js
UNGProject/unhosted/jio.js
+40
-30
No files found.
UNGProject/unhosted/jio.js
View file @
caa4fec2
...
...
@@ -15,48 +15,58 @@
return
$
!==
undefined
&&
sjcl
!==
undefined
&&
Base64
!==
undefined
;
// check jQuery, sjcl & Base64
});
function
script
()
{
/**
* JIO main object. Contains all IO methods
*/
var
JIO
=
{
jioFileContent
:
null
,
//content of jio.json file
storage
:
null
,
//the storage tree
/**
* JIO main object. Contains all IO methods
* prepare and return the jio object
* @param jioData : text or json content of jio.json or method to get it
* @param applicant : (optional) information about the person/application needing this JIO object (used to limit access)
* @return JIO object
*/
var
JIO
=
{
jioFileContent
:
null
,
//content of jio.json file
storage
:
null
,
//the storage tree
/**
* prepare and return the jio object
* @param jioData : text or json content of jio.json or method to get it
* @param applicant : (optional) information about the person/application needing this JIO object (used to limit access)
* @return JIO object
*/
initialize
:
function
(
jioData
,
applicant
)
{
initialize
:
function
(
jioData
,
applicant
)
{
if
(
!
dependenceLoaded
())
{
setTimeout
(
function
()
{
JIO
.
initialize
(
jioData
,
applicant
)},
50
);
}
else
{
switch
(
typeof
jioData
)
{
case
"
string
"
:
this
.
jioFileContent
=
jioData
;
break
;
case
"
object
"
:
this
.
jioFileContent
=
JSON
.
stringify
(
jioData
);
break
;
case
"
function
"
:
this
.
jioFileContent
=
jioData
();
break
;
default
:
alert
(
"
Error while getting jio.json content
"
);
break
;
}
this
.
storage
=
createStorage
(
JSON
.
parse
(
this
.
jioFileContent
),
applicant
)
//create the object allowing IO in storages
return
this
;
},
/**
* return the state of JIO object
* @return true if ready, false otherwise
*/
isReady
:
function
()
{
return
this
.
jioFileContent
&&
this
.
storage
},
//IO functions
userNameAvailable
:
function
(
name
,
option
)
{
return
this
.
storage
.
userNameAvailable
.
apply
(
this
.
storage
,
arguments
)},
loadDocument
:
function
(
fileName
,
option
)
{
return
this
.
storage
.
loadDocument
.
apply
(
this
.
storage
,
arguments
)},
saveDocument
:
function
(
data
,
fileName
,
option
)
{
return
this
.
storage
.
saveDocument
.
apply
(
this
.
storage
,
arguments
)},
deleteDocument
:
function
(
file
,
option
)
{
return
this
.
storage
.
deleteDocument
.
apply
(
this
.
storage
,
arguments
)},
getDocumentList
:
function
(
option
)
{
return
this
.
storage
.
getDocumentList
.
apply
(
this
.
storage
,
arguments
)}
this
.
storage
=
createStorage
(
JSON
.
parse
(
this
.
jioFileContent
),
applicant
);
//create the object allowing IO in storages
}
},
/**
* return the state of JIO object
* @return true if ready, false otherwise
*/
isReady
:
function
()
{
return
this
.
jioFileContent
&&
this
.
storage
},
//IO functions
getLocation
:
function
()
{
return
this
.
location
},
userNameAvailable
:
function
(
name
,
option
)
{
return
this
.
storage
.
userNameAvailable
(
name
,
option
||
{});
},
loadDocument
:
function
(
fileName
,
option
)
{
return
this
.
storage
.
loadDocument
(
fileName
,
option
||
{});
},
saveDocument
:
function
(
data
,
fileName
,
option
)
{
return
this
.
storage
.
saveDocument
(
data
,
fileName
,
option
||
{});
},
deleteDocument
:
function
(
file
,
option
)
{
return
this
.
storage
.
deleteDocument
(
file
,
option
||
{});
},
getDocumentList
:
function
(
option
)
{
return
this
.
storage
.
getDocumentList
(
option
||
{});
}
}
...
...
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