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
c89b863e
Commit
c89b863e
authored
Apr 16, 2012
by
Tristan Cavelier
Committed by
Sebastien Robin
May 18, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JIO does not include its dependencies inside <head> anymore.
We must now include them manually.
parent
fcce672d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
53 deletions
+10
-53
UNGProject/unhosted/jio.js
UNGProject/unhosted/jio.js
+10
-53
No files found.
UNGProject/unhosted/jio.js
View file @
c89b863e
...
...
@@ -7,13 +7,16 @@
/**
* load dependencies
*/
var
dependenceLoaded
=
includeJS
([
//files to load
"
unhosted/sjcl.js
"
,
"
js/jquery/jquery.js
"
,
"
unhosted/base64.js
"
],
function
()
{
// return true only if dependencies are loaded
return
(
window
.
$
&&
window
.
sjcl
&&
window
.
Base64
)
// check jQuery, sjcl & Base64
});
var
dependenceLoaded
=
function
()
{
try
{
// check jQuery, sjcl & Base64
if
(
window
.
$
&&
window
.
sjcl
&&
window
.
Base64
)
return
true
;
else
return
false
;
}
catch
(
e
)
{
return
false
;
}
};
/**
* JIO main object. Contains all IO methods
...
...
@@ -1048,50 +1051,4 @@
window
.
JIO
=
JIO
;
//the name to use for the framework. Ex : JIO.initialize(...), JIO.loadDocument...
/****************************************************************
*************************** Loader *****************************/
/**
* include js files
* @param url : path or array of paths of the js file(s)
* @param ready : (optional) array of elements allowing to know if dependencies are ready
* @param instruction : (optional) instruction to execute when dependencies are loaded
* @return the ready function
* @example : includeJS("js/jquery/jquery.js",[$]);
*/
function
includeJS
(
url
,
ready
,
instruction
)
{
//path = findURL("jio.js");
typeof
url
!=
"
object
"
?
includeElement
(
url
)
:
onEach
(
url
,
includeElement
);
if
(
instruction
)
{
(
function
waitUntilLoaded
()
{
!
ready
()
?
setTimeout
(
waitUntilLoaded
,
50
)
:
instruction
();})()
}
return
ready
;
function
includeElement
(
element
)
{
//include a js file
var
head
=
window
.
document
.
getElementsByTagName
(
'
head
'
)[
0
];
var
script
=
window
.
document
.
createElement
(
'
script
'
);
script
.
setAttribute
(
'
src
'
,
element
);
script
.
setAttribute
(
'
type
'
,
'
text/javascript
'
);
head
.
appendChild
(
script
);
}
function
onEach
(
array
,
f
)
{
var
head
=
array
.
pop
();
if
(
head
===
undefined
)
{
return
true
}
var
rep1
=
f
(
head
);
var
rep2
=
onEach
(
array
,
f
);
return
rep1
&&
rep2
;
}
function
findURL
(
fileName
)
{
var
elements
=
window
.
document
.
getElementsByName
(
"
script
"
);
var
jioRegExp
=
new
RegExp
(
"
^((.*)/)?
"
+
fileName
+
"
$
"
);
for
(
var
e
in
elements
)
{
if
(
jioRegExp
.
test
(
e
.
src
))
{
return
e
.
src
.
replace
(
jioRegExp
,
"
$1
"
)}
}
return
""
;
}
}
})();
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