Commit 1c7b82ab authored by Lingnan Wu's avatar Lingnan Wu

clean code

parent d6b0bdef
...@@ -47,23 +47,3 @@ NewList = function (listnumber,listname,listcontent){ ...@@ -47,23 +47,3 @@ NewList = function (listnumber,listname,listcontent){
newFirstdiv.appendChild(newshadow); newFirstdiv.appendChild(newshadow);
} }
function CreateLists(){
//clean all the lists
var n = document.getElementById('textlist').childNodes.length;
for ( var i = 0; i < n; i++) {
document.getElementById('textlist').removeChild(
document.getElementById('textlist').firstChild);
}
//set the new lists
for(i=0;i<OfficeJS.list.length;i++){
NewList(i,OfficeJS.list[i].title,OfficeJS.list[i].text);
}
}
function get_list_value(element){
tr=document.all.para.value;
document.all.para.value=element.value;
var trid = element.value;
alert(trid);
}
...@@ -19,8 +19,6 @@ ...@@ -19,8 +19,6 @@
var that = {}, priv = {}; var that = {}, priv = {};
// Attributes // // Attributes //
that.list=new Array();//List for ListPage
that.currentContent="";
priv.preference_object = { priv.preference_object = {
document_lister:'slickgrid', document_lister:'slickgrid',
...@@ -444,12 +442,12 @@ that.currentContent=""; ...@@ -444,12 +442,12 @@ that.currentContent="";
// if there is not any jio created // if there is not any jio created
priv.jio = JIO.newJio (storage,applicant); priv.jio = JIO.newJio (storage,applicant);
// update left nav bar // update left nav bar
/* leftnavbar = priv.getRealApplication ('leftnavbar'); /*leftnavbar = priv.getRealApplication ('leftnavbar');
if (typeof leftnavbar.update !== 'undefined') { if (typeof leftnavbar.update !== 'undefined') {
leftnavbar.update(); leftnavbar.update();
}*/ }*/
//Forbid the list to avoid error //Forbid the list to avoid error
// that.getList(); //that.getList();
}; };
/** /**
...@@ -463,7 +461,7 @@ that.currentContent=""; ...@@ -463,7 +461,7 @@ that.currentContent="";
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,16 +471,15 @@ that.currentContent=""; ...@@ -473,16 +471,15 @@ that.currentContent="";
'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.length); //set the List
console.log(result.return_value[0]); for(var i=0;i<result.return_value.length;i++){
for(var i=0;i<result.return_value.length;i++){
NewList(i,result.return_value[i].name,"text-Editor"); NewList(i,result.return_value[i].name,"text-Editor");
} }
// priv.showDocumentListInsideLeftNavBar(); //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();
} }
...@@ -518,20 +515,7 @@ for(var i=0;i<result.return_value.length;i++){ ...@@ -518,20 +515,7 @@ for(var i=0;i<result.return_value.length;i++){
that.getList(); that.getList();
} }
});*/ });*/
var newone=true;
for(var i=0;i<that.list.length;i++){
if(basename==that.list[i].title){
newone=false;
that.list[i].text=content;
}
}
if(newone){
var newlist=new Object();//new object
newlist.title=basename;//object title and text
newlist.text=content;
newlist.number=that.list.length;
that.list.push(newlist);//save in the list
}
if (!priv.isJioSet()) { if (!priv.isJioSet()) {
console.error ('No Jio set yet.'); console.error ('No Jio set yet.');
return; return;
...@@ -549,25 +533,26 @@ for(var i=0;i<result.return_value.length;i++){ ...@@ -549,25 +533,26 @@ for(var i=0;i<result.return_value.length;i++){
* @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, '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 {console.log("content is :"+result.return_value.content); } else {
//set the content for the editor
setTextEditorInformation(basename,result.return_value.content); setTextEditorInformation(basename,result.return_value.content);
// current_editor.setContent( //current_editor.setContent(
// result.return_value.content); //result.return_value.content);
} }
// priv.loading_object.end_load(); //priv.loading_object.end_load();
} }
}); });
......
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