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 @@
<link rel="shortcut icon" href="img/icons/favicon.png" />
<link rel="stylesheet" href="lib/bootstrap/css/bootstrap.min.css" />
<title>OfficeJS</title>
<!-- js scripts -->
<script type="text/javascript" src="lib/xinha/XinhaLoader.js?lang=en">
</script>
<script type="text/javascript" src="js/XinhaConfig.js">
</script>
<script type="text/javascript" src="lib/icanhaz/ICanHaz.min.js"></script>
<script data-main="js/officejs"
type="text/javascript"
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>
<script type="text/javascript" src="lib/jquery/jquery.js"></script>
<script type="text/javascript" src="lib/jstorage/jstorage.js"></script>
<script type="text/javascript" src="lib/renderjs/renderjs.js"></script>
<script type="text/javascript" src="src/localorcookiestorage.js"></script>
<script type="text/javascript" src="src/jio.js"></script>
<script type="text/javascript" src="lib/base64/base64.js"></script>
<script type="text/javascript" src="src/jio.storage.js"></script>
</head>
<body>
<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>
<header>
<div id="page-top_nav_bar"
gadget:property="{&quot;cacheable&quot;:&quot;1&quot;,
&quot;cache_id&quot;:&quot;top_nav_bar&quot;}" >
</div>
</header>
<nav class="span4">
<div id="page-left_nav_bar"
gadget:property="{&quot;cacheable&quot;:&quot;1&quot;,
&quot;cache_id&quot;:&quot;left_nav_bar&quot;}" >
</div>
</div>
</nav>
<div class="container-fluid">
<div class="row-fluid">
<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>
<section class="span12">
<div id="page-content">
</div>
</div>
</section>
<script type="text/javascript" src="js/officejs.js"></script>
</body>
</html>
define ('OfficeJS',
['LocalOrCookieStorage',
'jQuery',
'JIO',
'Base64',
'JIOStorages'],
function (LocalOrCookieStorage,
jQuery,
JIO,
Base64) {
return {LocalOrCookieStorage: LocalOrCookieStorage,
jQuery: jQuery,
JIO: JIO,
Base64: Base64,
ich: window.ich};
define ('OfficeJS',['order!jQuery','order!jStorage','order!RenderJS'],
function () {
return;
});
// NEXEDI
// Author: Tristan Cavelier <tristan.cavelier@tiolive.com>
// Date: Wed May 16 14:31:08 2012
(function () {
// Tools
var extend = function (o1,o2) {
var key; for (key in o2) { o1[key] = o2[key]; } return o1;
};
require.config ({
paths: {
LocalOrCookieStorage: '../lib/jio/localorcookiestorage.min',
jQueryAPI: '../lib/jquery/jquery',
jQuery: '../js/jquery.requirejs_module',
JIO: '../src/jio',
Base64API: '../lib/base64/base64',
Base64: '../js/base64.requirejs_module',
JIOStorages: '../src/jio.storage',
OfficeJS: 'moduleloader'
}
});
require(['OfficeJS'],function (OJS) {
// globals
var JIO = OJS.JIO,
$ = OJS.jQuery,
Base64 = OJS.Base64,
ich = OJS.ich,
// some vars
text_editor_loaded_once = false,
current_hash = '',
ich_object = {DocumentList:[],CurrentFileName:''},
current_editor = null,
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;
/**
* OfficeJS Object
*/
window.OfficeJS = (function () {
var that = {}, priv = {};
// Attributes //
priv.preference_object = {
default_app:'login',
login:'login',
topnavbar:'topnavbar',
leftnavbar:'leftnavbar',
textEditor:'elrte'
};
priv.app_object = {
login: {
path:'component/login.html',
gadgetid:'page-content',
getContent: function () {
var tmp = {
userName: 'NoName',
password: 'NoPwd'
};
// NOTE : stringify or not ?
return JSON.stringify (tmp);
}
document.querySelector('#text_editor').style.display = 'block';
current_editor = 'xinha';
if (typeof route_param.fileName !== 'undefined') {
intervalid = setInterval(function(){
try {
getCurrentEditor().getHTML();
} catch (e) {
return;
}
$('#input_fileName').attr(
'value',route_param.fileName);
OfficeJS.load();
clearInterval(intervalid);
},50);
},
elrte: {
path:'component/elrte.html',
element:'#elrte_editor',
getContent: function () {
$(this.element).elrte('updateSource');
return $(this.element).elrte('val');
},
onload: function () {},
onunload: function () {}
}
};
priv.data_object = {
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(){
document.querySelector('#text_editor').style.display = 'none';
ich_object.CurrentFileName = $('#input_fileName').attr('value');
current_editor = null;
end_main: function (string){
if (this[string+'state']>0) {
this[string+'state']--;
}
if (this[string+'state']===0){
document.querySelector ('#loading_'+string).
style.display = 'none';
}
},
onrestart: function(){
this.onload();
}
}
},
////////////////////////////////////////////////////////////////////////////
// load current page
loadcurrentpage = function () {
var new_hash, params, i;
// get new hash
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
////////////////////////////////////////////////////////////////////////////
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();}
};
// repaint the page
hrefClicked();
// Initializer //
priv.init = function() {
};
window.OfficeJS = (function () {
var publ = {}, priv = {};
// Methods //
/**
* @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 () {
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()) {
alert ('Jio already set.');
return;
}
alert ($('#input_json_storage').attr('value'));
// if there is not any jio created
priv.jio = JIO.createNew (
JSON.parse ( $('#input_json_storage').attr('value') ),
JSON.parse ( $('#input_json_applicant').attr('value') )
);
publ.getlist();
priv.jio = JIO.createNew (storage,applicant);
that.getList();
};
publ.save = function () {
var filename, filecontent;
/**
* Returns the array list in priv.data_object
* @method getList
*/
that.getList = function () {
if (!priv.jioIsSet()) {
alert ('No Jio set yet.');
console.error ('No Jio set yet.');
return;
}
loading_object.save();
filename = $('#input_fileName').attr('value');
filecontent = getCurrentEditor().getHTML();
priv.jio.saveDocument({
'fileName':filename,
'fileContent':filecontent,
'callback':function (result){
if (result.status === 'fail') {
console.error (result.error);
priv.loading_object.getlist();
priv.jio.getDocumentList({
'maxtries':3,
'callback':function (result) {
if (result.status === 'done') {
priv.data_object = result.return_value;
} else {
console.error (result.message);
}
loading_object.end_save();
publ.getlist();
priv.loading_object.end_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()) {
alert ('No Jio set yet.');
console.error ('No Jio set yet.');
return;
}
loading_object.load();
filename = $('#input_fileName').attr('value');
priv.jio.loadDocument({
'fileName':filename,
'maxtries':3,
'callback':function (result){
if (result.return_value.fileName) {
getCurrentEditor().setHTML(
result.return_value.fileContent);
} else {
console.error (result.error);
priv.loading_object.save();
priv.jio.saveDocument({
'fileName':name,
'fileContent':content,
'callback':function (result) {
if (result.status === 'fail') {
console.error (result.message);
}
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()) {
alert ('No Jio set yet.');
console.error ('No Jio set yet.');
return;
}
loading_object.remove();
filename = $('#input_fileName').attr('value');
priv.jio.removeDocument({
'fileName':filename,
priv.loading_object.load();
priv.jio.loadDocument({
'fileName':name,
'maxtries':3,
'callback':function (result) {
if (result.status === 'fail') {
console.error (result.error);
console.error (result.message);
}
loading_object.end_remove();
publ.getlist();
priv.loading_object.end_load();
// 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()) {
alert ('No Jio set yet.');
console.error ('No Jio set yet.');
return;
}
loading_object.getlist();
priv.jio.getDocumentList({
'maxtries':3,
priv.loading_object.remove();
priv.jio.removeDocument({
'fileName':name,
'callback':function (result) {
if (result.status === 'done') {
var htmlString = '', i, document_array = [];
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();
if (result.status === 'fail') {
console.error (result.message);
}
priv.loading_object.end_remove();
that.getList();
}
});
};
return publ;
}());
// When someone clicks on a <a href..>..</a>, the interface may change.
$(window).bind('hashchange', hrefClicked);
});
// End of class //
priv.init();
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