Commit d6b0bdef authored by Lingnan Wu's avatar Lingnan Wu

use the jio for the save and load ,also load list from jio (didn't clean code)

parent 8558e5c1
......@@ -62,7 +62,7 @@ $('#input_json_applicant').attr('value'));">
Tools
</li>
<li data-theme="c">
<a href="#list" data-transition="slide" onclick="CreateLists();">
<a href="#list" data-transition="slide" onclick="OfficeJS.getList();">
Document list
</a>
</li>
......
......@@ -24,10 +24,10 @@ NewList = function (listnumber,listname,listcontent){
newFirstdiv.appendChild(newSeconddiv);
//set a tag
newa = document.createElement("a");
newa.setAttribute("id",listnumber);
newa.setAttribute("id",listname);
newa.setAttribute("class","ui-link-inherit");
newa.setAttribute("href","#text");
newa.setAttribute("onclick","setTextEditorInformation(OfficeJS.list[this.id].title,OfficeJS.list[this.id].text);");
newa.setAttribute("onclick","OfficeJS.load(this.id);");
newSeconddiv.appendChild(newa);
//set head
newhead = document.createElement("h3");
......
......@@ -20,7 +20,7 @@
var that = {}, priv = {};
// Attributes //
that.list=new Array();//List for ListPage
that.currentContent="";
priv.preference_object = {
document_lister:'slickgrid',
......@@ -463,7 +463,7 @@
console.error ('No Jio set yet.');
return;
}
priv.loading_object.getlist();
// priv.loading_object.getlist();
priv.jio.getDocumentList({
'sort':{'last_modified':'descending',
'name':'ascending'},
......@@ -473,11 +473,16 @@
'onResponse':function (result) {
if (result.status === 'done') {
priv.data_object.documentList = result.return_value;
priv.showDocumentListInsideLeftNavBar();
console.log(result.return_value.length);
console.log(result.return_value[0]);
for(var i=0;i<result.return_value.length;i++){
NewList(i,result.return_value[i].name,"text-Editor");
}
// priv.showDocumentListInsideLeftNavBar();
} else {
console.error (result.message);
}
priv.loading_object.end_getlist();
// priv.loading_object.end_getlist();
if (typeof callback !== 'undefined') {
callback();
}
......@@ -527,6 +532,15 @@
newlist.number=that.list.length;
that.list.push(newlist);//save in the list
}
if (!priv.isJioSet()) {
console.error ('No Jio set yet.');
return;
}
priv.jio.saveDocument({
'name':basename,
'content':content
});
};
/**
......@@ -535,25 +549,28 @@
* @param {string} basename The document name without ext.
*/
that.load = function (basename) {
var current_editor = priv.data_object.currentEditor;
// var current_editor = priv.data_object.currentEditor;
if (!priv.isJioSet()) {
console.error ('No Jio set yet.');
return;
}
priv.loading_object.load();
// priv.loading_object.load();
priv.jio.loadDocument({
'name':basename+'.'+current_editor.ext,
'name':basename,
'maxtries':3,
'onResponse':function (result) {
if (result.status === 'fail') {
console.error (result.message);
} else {
current_editor.setContent(
result.return_value.content);
} else {console.log("content is :"+result.return_value.content);
setTextEditorInformation(basename,result.return_value.content);
// current_editor.setContent(
// result.return_value.content);
}
priv.loading_object.end_load();
// priv.loading_object.end_load();
}
});
};
/**
......
......@@ -465,6 +465,7 @@
'onResponse':function (result) {
if (result.status === 'done') {
priv.data_object.documentList = result.return_value;
console.log(result.return_value);
priv.showDocumentListInsideLeftNavBar();
} else {
console.error (result.message);
......
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