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