Commit 916cae47 authored by Tristan Cavelier's avatar Tristan Cavelier Committed by Sebastien Robin

Make renderjs work with renderjs.

parent d5235038
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Aloha Editor Example</title>
<!-- load the Aloha Editor core and some plugins -->
<script src="http://cdn.aloha-editor.org/current/lib/aloha.js"
data-aloha-plugins="common/format,
common/list,
common/link,
common/highlighteditables">
</script>
<!-- load the Aloha Editor CSS styles -->
<link href="http://cdn.aloha-editor.org/current/css/aloha.css"
rel="stylesheet"
type="text/css" />
<!-- make all elements with class="editable" editable with Aloha Editor -->
<script type="text/javascript">
<!--
Aloha.ready( function() {
var $ = Aloha.jQuery;
$('.editable').aloha();
});
//-->
</script>
</head>
<body>
<h1 class="editable">Aloha Editor Example</h1>
<p class="editable">Click to edit this paragraph.</p>
<div class="editable">
<p>This is an editable div container.</p>
<p>Follow us on <a href="http://twitter.com/alohaeditor">Twitter</a>.</p>
<ul>
<li>list item one</li>
<li>list item two</li>
</ul>
</div>
<p>Use Aloha Editor your existing textarea elements:</p>
<textarea class="editable">An editable textarea.</textarea>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>elRTE</title>
<!-- jQuery and jQuery UI -->
<script src="lib/elrte/js/jquery-1.6.1.min.js"
type="text/javascript" charset="utf-8">
</script>
<script src="lib/elrte/js/jquery-ui-1.8.13.custom.min.js"
type="text/javascript" charset="utf-8">
</script>
<link rel="stylesheet"
href="lib/elrte/css/smoothness/jquery-ui-1.8.13.custom.css"
type="text/css"
media="screen"
charset="utf-8" />
<!-- elRTE -->
<script src="lib/elrte/js/elrte.min.js"
type="text/javascript" charset="utf-8">
</script>
<link rel="stylesheet"
href="lib/elrte/css/elrte.min.css"
type="text/css"
media="screen"
charset="utf-8" />
<!-- elRTE translation messages -->
<script src="lib/elrte/js/i18n/elrte.en.js"
type="text/javascript"
charset="utf-8">
</script>
<script type="text/javascript" charset="utf-8">
<!--
$().ready(function() {
var opts = {
cssClass : 'el-rte',
lang : 'en',
height : 450,
toolbar : 'complete',
cssfiles : ['lib/elrte/css/elrte-inner.css']
}
$('#elrte_editor').elrte(opts);
})
//-->
</script>
</head>
<body>
<div>
<input type="text"
name="fileName"
id="input_fileName"
value="{{CurrentFileName}}"
placeholder="File name here" />&nbsp;
<button type="submit"
class="btn btn-primary"
onclick="OfficeJS.save($('#input_fileName').attr('value'),OfficeJS.getContentOf('elrte'));">
<i class="icon-download-alt icon-white"></i>
Save
</button>&nbsp;
<button type="submit"
class="btn"
onclick="OfficeJS.load($('#input_fileName'));">
<i class="icon-upload"></i>
Load
</button>&nbsp;
<button type="submit"
class="btn btn-danger"
onclick="OfficeJS.remove($('#input_fileName'));">
<i class="icon-remove icon-white"></i>
Remove
</button>
</div>
<div id="elrte_editor">
<h1>OfficeJS elRTE texteditor</h1><p>This is a new document.<br></p>
</div>
</body>
</html>
<div class="container-fluid">
<div class="row-fluid">
<div class="well">
<ul class="nav nav-list">
<li class="nav-header">Nav</li>
<li>
<a href="#/login"
onclick="javascript:
TabbularGadget.addNewTabGadget(
'component/login.html','page-content');
return false;">
<i class="icon-ok">
</i>
Login
</a>
</li>
<li class="nav-header">Tools</li>
<li class="texteditor">
<a href="#/texteditor"
onclick="javascript:
TabbularGadget.addNewTabGadget(
OfficeJS.getPathOf(OfficeJS.getPreference('textEditor')),
'page-content');
return false;">
<i class="icon-font"></i>
Text Editor
</a>
</li>
<li class="nav-header"><a href="#/doclist">Document List</a></li>
<div id="document_list"></div>
</ul>
</div>
</div>
</div>
<article>
<div class="control-group">
<label class="control-label"
for="input_json_storage">
JSON Storage
</label>
<div class="controls docs-input-sizes">
<input class="input-xlarge"
value="{&quot;type&quot;:&quot;local&quot;,&quot;userName&quot;:&quot;tristan&quot;}"
type="text" name="JSONstorage" id="input_json_storage"
placeholder="storage" />
<!-- value="{&quot;type&quot;:&quot;replicate&quot;,&quot;storageArray&quot;:[{&quot;type&quot;:&quot;local&quot;,&quot;userName&quot;:&quot;tristan&quot;},{&quot;type&quot;:&quot;dav&quot;,&quot;userName&quot;:&quot;tristan&quot;,&quot;password&quot;:&quot;mdp&quot;,&quot;location&quot;:&quot;http://localhost:80&quot;}]}" -->
<!-- value="{&quot;type&quot;:&quot;dav&quot;,&quot;userName&quot;:&quot;tristan&quot;,&quot;password&quot;:&quot;mdp&quot;,&quot;location&quot;:&quot;http://localhost:80&quot;}" -->
</div>
<label class="control-label"
for="JSONapplicantID">
JSON Applicant
</label>
<div class="controls docs-input-sizes">
<input class="input-xlarge"
type="text" name="JSONapplicant" id="input_json_applicant"
value="{&quot;ID&quot;:&quot;jiotests&quot;}"
placeholder="applicant" />
</div>
</div>
<button type="submit"
class="btn"
onclick="OfficeJS.setJio(
$('#input_json_storage').attr('value'),
$('#input_json_applicant').attr('value'));">
Create New JIO
</button>
</article>
<div>
Test
</div>
<div id="texteditor_field"></div>
<script type="text/javascript">
<!--
TabbularGadget.addNewTabGadget(
'component/'+OfficeJS.getPreference('textEditor')+'.html',
'texteditor_field');
//-->
</script>
<div id="loading"
style="position:absolute;
right:10px;
top:10px;
width:100px;
height:40px;">
<div id="loading_spin"
style="background-image:url('img/icons/loading_spin_16.gif');
width:16px;
height:16px;
float:right;
display:none;">
</div>
<div id="loading_spin"
style="width:16px;
height:16px;
float:right;">
</div>
<div id="loading_getlist"
style="float:right;
display:none;">
<i class="icon-refresh icon-white"></i>
</div>
<div id="loading_save"
style="float:right;
display:none;">
<i class="icon-download-alt icon-white"></i>
</div>
<div id="loading_load"
style="float:right;
display:none;">
<i class="icon-upload icon-white"></i>
</div>
<div id="loading_remove"
style="float:right;
display:none;">
<i class="icon-remove icon-white"></i>
</div>
</div>
<div class="navbar">
<div class="navbar-inner">
<div class="container-fluid">
<div class="row-fluid">
<div class="span2">
<h1>OfficeJS</h1>
</div>
<div class="span10">
<ul class="nav">
<li><a href="#">Nav</a></li>
<li><a href="#/about">About</a></li>
<li><a href="#/contact">Contact</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<!-- js scripts -->
<script type="text/javascript">
<!--
_editor_url = window.location + '';
_editor_url = _editor_url.split('#')[0].split('/');
_editor_url.pop();
_editor_url = _editor_url.join('/') + '/lib/xinha';
_editor_lang = "en";
//-->
</script>
<script type="text/javascript" src="lib/xinha/XinhaCore.js">
</script>
<script type="text/javascript" src="js/XinhaConfig.js">
</script>
<article>
<div class="control-group">
<div class="controls docs-input-sizes" style="float: left">
<input type="text" name="fileName" id="input_fileName"
value="{{CurrentFileName}}" placeholder="file name" />
</div>
<div style="float: right;">
<button type="submit"
class="btn btn-primary"
onclick="OfficeJS.save()">
<i class="icon-download-alt icon-white"></i>
Save
</button>&nbsp;
<button type="submit"
class="btn"
onclick="OfficeJS.load()">
<i class="icon-upload"></i>
Load
</button>&nbsp;
<button type="submit"
class="btn btn-danger"
onclick="OfficeJS.remove()">
<i class="icon-remove icon-white"></i>
Remove
</button>&nbsp;
</div>
</div><br />
<textarea name="textEditor" id="textEditor"
rows="25" cols="50"
style="width:100%">
</textarea>
<script type="text/javascript">
<!--
xinha_init();
//-->
</script>
</article>
...@@ -6,181 +6,36 @@ ...@@ -6,181 +6,36 @@
<link rel="shortcut icon" href="img/icons/favicon.png" /> <link rel="shortcut icon" href="img/icons/favicon.png" />
<link rel="stylesheet" href="lib/bootstrap/css/bootstrap.min.css" /> <link rel="stylesheet" href="lib/bootstrap/css/bootstrap.min.css" />
<title>OfficeJS</title> <title>OfficeJS</title>
<!-- js scripts --> <script type="text/javascript" src="lib/jquery/jquery.js"></script>
<script type="text/javascript" src="lib/xinha/XinhaLoader.js?lang=en"> <script type="text/javascript" src="lib/jstorage/jstorage.js"></script>
</script> <script type="text/javascript" src="lib/renderjs/renderjs.js"></script>
<script type="text/javascript" src="js/XinhaConfig.js">
</script> <script type="text/javascript" src="src/localorcookiestorage.js"></script>
<script type="text/javascript" src="lib/icanhaz/ICanHaz.min.js"></script> <script type="text/javascript" src="src/jio.js"></script>
<script data-main="js/officejs" <script type="text/javascript" src="lib/base64/base64.js"></script>
type="text/javascript" <script type="text/javascript" src="src/jio.storage.js"></script>
src="lib/require/require.js"></script>
<!-- html scripts -->
<script id="home" type="text/html">
<article>
<p>
home
</p>
</article>
</script>
<script id="about" type="text/html">
<article>
<p>
about
</p>
</article>
</script>
<script id="login" type="text/html">
<article>
<div class="control-group">
<label class="control-label"
for="input_json_storage">
JSON Storage
</label>
<div class="controls docs-input-sizes">
<input class="input-xlarge"
type="text" name="JSONstorage" id="input_json_storage"
value="{&quot;type&quot;:&quot;replicate&quot;,&quot;storageArray&quot;:[{&quot;type&quot;:&quot;local&quot;,&quot;userName&quot;:&quot;tristan&quot;},{&quot;type&quot;:&quot;dav&quot;,&quot;userName&quot;:&quot;tristan&quot;,&quot;password&quot;:&quot;mdp&quot;,&quot;location&quot;:&quot;http://localhost:80&quot;}]}"
placeholder="storage" />
<!-- value="{&quot;type&quot;:&quot;dav&quot;,&quot;userName&quot;:&quot;tristan&quot;,&quot;password&quot;:&quot;mdp&quot;,&quot;location&quot;:&quot;http://localhost:80&quot;}" -->
<!-- value="{&quot;type&quot;:&quot;local&quot;,&quot;userName&quot;:&quot;tristan&quot;}" -->
</div>
<label class="control-label"
for="JSONapplicantID">
JSON Applicant
</label>
<div class="controls docs-input-sizes">
<input class="input-xlarge"
type="text" name="JSONapplicant" id="input_json_applicant"
value="{&quot;ID&quot;:&quot;jiotests&quot;}"
placeholder="applicant" />
</div>
</div>
<button type="submit"
class="btn"
onclick="OfficeJS.setJio()">Create New JIO</button>
</article>
</script>
<script id="text_editor" type="text/html">
<article>
<div class="control-group">
<div class="span5">
<!-- <label class="control-label" for="fileName">File Name</label> -->
<div class="controls docs-input-sizes">
<input type="text" name="fileName" id="input_fileName"
value="{{CurrentFileName}}" placeholder="file name" />
</div>
<!-- <label class="control-label" for="fileContent">File Content</label> -->
<!-- <div class="controls docs-input-sizes"> -->
<!-- <input type="text" name="fileContent" id="input_content" -->
<!-- value="" placeholder="content" /> -->
<!-- </div> -->
</div>
<div class="span5">
<button type="submit"
class="btn btn-primary"
onclick="OfficeJS.save()">
<i class="icon-download-alt icon-white"></i>
Save
</button>&nbsp;
<button type="submit"
class="btn"
onclick="OfficeJS.load()">
<i class="icon-upload"></i>
Load
</button>&nbsp;
<button type="submit"
class="btn btn-danger"
onclick="OfficeJS.remove()">
<i class="icon-remove icon-white"></i>
Remove
</button>&nbsp;
<!-- <button type="submit" -->
<!-- class="btn" -->
<!-- onclick="OfficeJS.getlist()"> -->
<!-- <i class="icon-refresh"></i> -->
<!-- Get List -->
<!-- </button>&nbsp; -->
</div>
</div>
<!-- <div id="document_list" class="span4"> -->
<!-- <ul> -->
<!-- {{#DocumentList}} -->
<!-- <li>{{fileName}}</li> -->
<!-- {{/DocumentList}} -->
<!-- </ul> -->
<!-- </div> -->
</article>
</script>
<script id="document_list" type="text/html">
<article>
<ul>
{{#DocumentList}}
<li><a href="#/texteditor:fileName={{fileName}}">{{fileName}}</a>, created: {{creationDate}}, last modified: {{lastModified}}</li>
{{/DocumentList}}
</ul>
</article>
</script>
</head> </head>
<body> <body>
<div id="loading" style="position:absolute;right:10px;top:10px;width:100px;height:40px;"> <header>
<div id="loading_spin" style="background-image:url('img/icons/loading_spin_16.gif');width:16px;height:16px;float:right;display:none;"></div> <div id="page-top_nav_bar"
<div id="loading_spin" style="width:16px;height:16px;float:right;"></div> gadget:property="{&quot;cacheable&quot;:&quot;1&quot;,
<div id="loading_getlist" style="float:right;display:none;"><i class="icon-refresh icon-white"></i></div> &quot;cache_id&quot;:&quot;top_nav_bar&quot;}" >
<div id="loading_save" style="float:right;display:none;"><i class="icon-download-alt icon-white"></i></div> </div>
<div id="loading_load" style="float:right;display:none;"><i class="icon-upload icon-white"></i></div> </header>
<div id="loading_remove" style="float:right;display:none;"><i class="icon-remove icon-white"></i></div>
</div> <nav class="span4">
<div class="navbar"> <div id="page-left_nav_bar"
<div class="navbar-inner"> gadget:property="{&quot;cacheable&quot;:&quot;1&quot;,
<div class="container-fluid"> &quot;cache_id&quot;:&quot;left_nav_bar&quot;}" >
<div class="row-fluid">
<div class="span2">
<h1>OfficeJS</h1>
</div>
<div class="span10">
<ul class="nav">
<li><a href="#">Nav</a></li>
<li><a href="#/about">About</a></li>
<li><a href="#/contact">Contact</a></li>
</ul>
</div>
</div>
</div>
</div> </div>
</div> </nav>
<div class="container-fluid"> <section class="span12">
<div class="row-fluid"> <div id="page-content">
<div class="span2">
<div class="well">
<ul class="nav nav-list">
<li class="nav-header">Nav</li>
<li><a href="#/login"><i class="icon-ok"></i>Login</a></li>
<li class="nav-header">Tools</li>
<li class="texteditor">
<a href="#/texteditor"><i class="icon-font"></i>Text Editor</a>
</li>
<li class="nav-header"><a href="#/doclist">Document List</a></li>
<div id="document_list"></div>
</ul>
</div>
</div>
<section class="span10" id="main">
<!-- Body content -->
<article>
<p>
Loading...
</p>
</article>
</section>
<section class="span10" id="text_editor" style="display: none">
<textarea name="textEditor" id="textEditor" rows="25" cols="50"
style="width: 100%">
</textarea>
</section>
</div> </div>
</div> </section>
<script type="text/javascript" src="js/officejs.js"></script>
</body> </body>
</html> </html>
define ('OfficeJS', define ('OfficeJS',['order!jQuery','order!jStorage','order!RenderJS'],
['LocalOrCookieStorage', function () {
'jQuery', return;
'JIO',
'Base64',
'JIOStorages'],
function (LocalOrCookieStorage,
jQuery,
JIO,
Base64) {
return {LocalOrCookieStorage: LocalOrCookieStorage,
jQuery: jQuery,
JIO: JIO,
Base64: Base64,
ich: window.ich};
}); });
// NEXEDI (function () {
// Author: Tristan Cavelier <tristan.cavelier@tiolive.com> // Tools
// Date: Wed May 16 14:31:08 2012 var extend = function (o1,o2) {
var key; for (key in o2) { o1[key] = o2[key]; } return o1;
};
require.config ({ /**
paths: { * OfficeJS Object
LocalOrCookieStorage: '../lib/jio/localorcookiestorage.min', */
jQueryAPI: '../lib/jquery/jquery', window.OfficeJS = (function () {
jQuery: '../js/jquery.requirejs_module', var that = {}, priv = {};
JIO: '../src/jio', // Attributes //
Base64API: '../lib/base64/base64', priv.preference_object = {
Base64: '../js/base64.requirejs_module', default_app:'login',
JIOStorages: '../src/jio.storage', login:'login',
topnavbar:'topnavbar',
OfficeJS: 'moduleloader' leftnavbar:'leftnavbar',
} textEditor:'elrte'
}); };
require(['OfficeJS'],function (OJS) { priv.app_object = {
// globals login: {
var JIO = OJS.JIO, path:'component/login.html',
$ = OJS.jQuery, gadgetid:'page-content',
Base64 = OJS.Base64, getContent: function () {
ich = OJS.ich, var tmp = {
// some vars userName: 'NoName',
text_editor_loaded_once = false, password: 'NoPwd'
current_hash = '', };
ich_object = {DocumentList:[],CurrentFileName:''}, // NOTE : stringify or not ?
current_editor = null, return JSON.stringify (tmp);
route_param = {},
// conf vars
routes = {
'default' : {template:'home'},
'/home' : {template:'home'},
'/about' : {template:'about'},
'/login' : {template:'login'},
'/doclist' : {template:'document_list'},
'/texteditor' : {
template:'text_editor',
onload:function(){
var intervalid;
if (!text_editor_loaded_once) {
xinha_init();
text_editor_loaded_once = true;
} }
document.querySelector('#text_editor').style.display = 'block'; },
current_editor = 'xinha'; elrte: {
if (typeof route_param.fileName !== 'undefined') { path:'component/elrte.html',
intervalid = setInterval(function(){ element:'#elrte_editor',
try { getContent: function () {
getCurrentEditor().getHTML(); $(this.element).elrte('updateSource');
} catch (e) { return $(this.element).elrte('val');
return; },
} onload: function () {},
$('#input_fileName').attr( onunload: function () {}
'value',route_param.fileName); }
OfficeJS.load(); };
clearInterval(intervalid); priv.data_object = {
},50); documentList:[]
};
priv.loading_object = {
spinstate: 0,
savestate: 0,
loadstate: 0,
getliststate: 0,
removestate: 0,
main: function (string){
if (this[string+'state'] === 0){
document.querySelector ('#loading_'+string).
style.display = 'block';
} }
this[string+'state'] ++;
}, },
onunload:function(){ end_main: function (string){
document.querySelector('#text_editor').style.display = 'none'; if (this[string+'state']>0) {
ich_object.CurrentFileName = $('#input_fileName').attr('value'); this[string+'state']--;
current_editor = null; }
if (this[string+'state']===0){
document.querySelector ('#loading_'+string).
style.display = 'none';
}
}, },
onrestart: function(){ spin:function(){this.main('spin');},
this.onload(); save:function(){this.main('save');this.spin();},
} load:function(){this.main('load');this.spin();},
} getlist:function(){this.main('getlist');this.spin();},
}, remove:function(){this.main('remove');this.spin();},
//////////////////////////////////////////////////////////////////////////// end_spin:function(){this.end_main('spin');},
// load current page end_save:function(){this.end_main('save');this.end_spin();},
loadcurrentpage = function () { end_load:function(){this.end_main('load');this.end_spin();},
var new_hash, params, i; end_getlist:function(){this.end_main('getlist');this.end_spin();},
// get new hash end_remove:function(){this.end_main('remove');this.end_spin();}
new_hash = location.hash.split('#'); };
if (typeof new_hash[1] !== "undefined") {
// new direction
new_hash = new_hash[1];
params = new_hash.split(':');
new_hash = params[0];
if (typeof routes[new_hash] === "undefined") {
return current_hash;
}
// set route_parameters
route_param = {};
for (i = 1; i < params.length; i += 1) {
var tmp = params[i].split('=');
route_param[tmp[0]] = tmp[1];
}
} else {
// default home
new_hash = 'default';
}
return new_hash;
},
// end load current page
////////////////////////////////////////////////////////////////////////////
// Repaint main page
repaint = function () {
$('#main').html(ich[routes[current_hash].template](ich_object,true));
},
// end repaint main page
////////////////////////////////////////////////////////////////////////////
// change page according to the event
hrefClicked = function () {
var new_hash = loadcurrentpage(), prev_hash = current_hash;
if (current_hash === '') {
current_hash = new_hash;
repaint();
}
if (routes[current_hash].template !== routes[new_hash].template) {
// check if it is necessary to repaint the page.
current_hash = new_hash;
if (typeof routes[prev_hash].onunload === 'function') {
routes[prev_hash].onunload();
}
repaint();
if (typeof routes[current_hash].onload === 'function') {
routes[current_hash].onload();
}
} else {
if (typeof routes[current_hash].onrestart === 'function') {
routes[current_hash].onrestart();
}
}
},
// end change page according to the event
////////////////////////////////////////////////////////////////////////////
// get the currrent editor
getCurrentEditor = function () {
switch (current_editor) {
case 'xinha':
return xinha_editors['textEditor'];
case 'svg':
return null;
case 'calc':
return null;
default:
return null;
}
},
// end get the current editor
////////////////////////////////////////////////////////////////////////////
// loading function
loading_object = {
spinstate: 0,savestate: 0,loadstate: 0,getliststate: 0,removestate: 0,
main: function (string){
if (this[string+'state'] === 0){
document.querySelector ('#loading_'+string).
style.display = 'block';
}
this[string+'state'] ++;
},
end_main: function (string){
if (this[string+'state']>0) {
this[string+'state']--;
}
if (this[string+'state']===0){
document.querySelector ('#loading_'+string).
style.display = 'none';
}
},
spin:function(){this.main('spin');},
save:function(){this.main('save');this.spin();},
load:function(){this.main('load');this.spin();},
getlist:function(){this.main('getlist');this.spin();},
remove:function(){this.main('remove');this.spin();},
end_spin:function(){this.end_main('spin');},
end_save:function(){this.end_main('save');this.end_spin();},
end_load:function(){this.end_main('load');this.end_spin();},
end_getlist:function(){this.end_main('getlist');this.end_spin();},
end_remove:function(){this.end_main('remove');this.end_spin();}
}
// end loading function
////////////////////////////////////////////////////////////////////////////
// repaint the page // Initializer //
hrefClicked(); priv.init = function() {
};
window.OfficeJS = (function () { // Methods //
var publ = {}, priv = {}; /**
* @method getPreference
* @param {string} key The preference
* @return {object} a clone of the preference object
*/
that.getPreference = function (key) {
return priv.preference_object[key];
};
/**
* @method jioIsSet
* @return {boolean} true if jio is set else false.
*/
priv.jioIsSet = function () { priv.jioIsSet = function () {
return (typeof priv.jio === 'object'); return (typeof priv.jio === 'object');
}; };
publ.setJio = function () {
/**
* @method getContentOf
* @param {string} app The application name
* @return {string} The content of the application, or null.
*/
that.getContentOf = function (app) {
if (priv.app_object[app] &&
typeof priv.app_object[app].getContent !== 'undefined') {
return priv.app_object[app].getContent();
}
return null;
};
/**
* @method getPathOf
* @param {string} app The application name
* @return {string} The path of the application component, or null.
*/
that.getPathOf = function (app) {
if (priv.app_object[app]) {
return priv.app_object[app].path;
}
return null;
};
/**
* @method setJio
* @param {object} storage The storage informations
* @param {object} applicant The applicant informations
*/
that.setJio = function (storage,applicant) {
if (priv.jioIsSet()) { if (priv.jioIsSet()) {
alert ('Jio already set.'); alert ('Jio already set.');
return; return;
} }
alert ($('#input_json_storage').attr('value'));
// if there is not any jio created // if there is not any jio created
priv.jio = JIO.createNew ( priv.jio = JIO.createNew (storage,applicant);
JSON.parse ( $('#input_json_storage').attr('value') ), that.getList();
JSON.parse ( $('#input_json_applicant').attr('value') )
);
publ.getlist();
}; };
publ.save = function () {
var filename, filecontent; /**
* Returns the array list in priv.data_object
* @method getList
*/
that.getList = function () {
if (!priv.jioIsSet()) { if (!priv.jioIsSet()) {
alert ('No Jio set yet.'); console.error ('No Jio set yet.');
return; return;
} }
loading_object.save(); priv.loading_object.getlist();
filename = $('#input_fileName').attr('value'); priv.jio.getDocumentList({
filecontent = getCurrentEditor().getHTML(); 'maxtries':3,
priv.jio.saveDocument({ 'callback':function (result) {
'fileName':filename, if (result.status === 'done') {
'fileContent':filecontent, priv.data_object = result.return_value;
'callback':function (result){ } else {
if (result.status === 'fail') { console.error (result.message);
console.error (result.error);
} }
loading_object.end_save(); priv.loading_object.end_getlist();
publ.getlist(); // TODO : show list somewhere
} }
}); });
}; };
publ.load = function () {
var filename; /**
* Saves the document.
* @method save
* @param {string} name The document name.
* @param {string} content The content of the document.
*/
that.save = function (name, content) {
if (!priv.jioIsSet()) { if (!priv.jioIsSet()) {
alert ('No Jio set yet.'); console.error ('No Jio set yet.');
return; return;
} }
loading_object.load(); priv.loading_object.save();
filename = $('#input_fileName').attr('value'); priv.jio.saveDocument({
priv.jio.loadDocument({ 'fileName':name,
'fileName':filename, 'fileContent':content,
'maxtries':3, 'callback':function (result) {
'callback':function (result){ if (result.status === 'fail') {
if (result.return_value.fileName) { console.error (result.message);
getCurrentEditor().setHTML(
result.return_value.fileContent);
} else {
console.error (result.error);
} }
loading_object.end_load(); priv.loading_object.end_save();
that.getList();
} }
}); });
}; };
publ.remove = function () {
var filename; /**
* Loads a document.
* @method load
* @param {string} name The document name.
*/
that.load = function (name) {
if (!priv.jioIsSet()) { if (!priv.jioIsSet()) {
alert ('No Jio set yet.'); console.error ('No Jio set yet.');
return; return;
} }
loading_object.remove(); priv.loading_object.load();
filename = $('#input_fileName').attr('value'); priv.jio.loadDocument({
priv.jio.removeDocument({ 'fileName':name,
'fileName':filename, 'maxtries':3,
'callback':function (result) { 'callback':function (result) {
if (result.status === 'fail') { if (result.status === 'fail') {
console.error (result.error); console.error (result.message);
} }
loading_object.end_remove(); priv.loading_object.end_load();
publ.getlist(); // TODO : show content somewhere
} }
}); });
}; };
publ.getlist = function () {
/**
* Removes a document.
* @method remove
* @param {string} name The document name.
*/
that.remove = function (name) {
if (!priv.jioIsSet()) { if (!priv.jioIsSet()) {
alert ('No Jio set yet.'); console.error ('No Jio set yet.');
return; return;
} }
loading_object.getlist(); priv.loading_object.remove();
priv.jio.getDocumentList({ priv.jio.removeDocument({
'maxtries':3, 'fileName':name,
'callback':function (result) { 'callback':function (result) {
if (result.status === 'done') { if (result.status === 'fail') {
var htmlString = '', i, document_array = []; console.error (result.message);
for (i = 0; i < result.return_value.length; i += 1) {
htmlString += '<li><a href="#/texteditor:fileName='+
result.return_value[i].fileName + '">\n' +
result.return_value[i].fileName;
result.return_value[i].creationDate =
(new Date(result.return_value[i].creationDate)).
toLocaleString();
result.return_value[i].lastModified =
(new Date(result.return_value[i].lastModified)).
toLocaleString();
document_array.push (result.return_value[i]);
htmlString += '</a></li>\n';
}
if (htmlString === '') {
htmlString = 'No document';
}
ich_object.DocumentList = document_array;
document.querySelector ('#document_list').
innerHTML = htmlString;
loading_object.end_getlist();
} }
priv.loading_object.end_remove();
that.getList();
} }
}); });
}; };
return publ;
}()); // End of class //
// When someone clicks on a <a href..>..</a>, the interface may change. priv.init();
$(window).bind('hashchange', hrefClicked); return that;
}); }()); // end OfficeJS
// show gadgets
TabbularGadget.addNewTabGadget(
'component/top_nav_bar.html',
'page-top_nav_bar',
undefined);
TabbularGadget.addNewTabGadget(
'component/left_nav_bar.html',
'page-left_nav_bar',
undefined);
TabbularGadget.addNewTabGadget(
'component/login.html',
'page-content',
undefined);
}());
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment