Commit 3c782416 authored by Tristan Cavelier's avatar Tristan Cavelier Committed by Sebastien Robin

Fix some reloading page bugs in officejs.js.

parent 72ae4caa
...@@ -23,7 +23,7 @@ require(['OfficeJS'],function (OJS) { ...@@ -23,7 +23,7 @@ require(['OfficeJS'],function (OJS) {
ich = OJS.ich, ich = OJS.ich,
// some vars // some vars
text_editor_loaded_once = false, text_editor_loaded_once = false,
current_hash = 'default', current_hash = '',
ich_object = {DocumentList:[],CurrentFileName:''}, ich_object = {DocumentList:[],CurrentFileName:''},
current_editor = null, current_editor = null,
route_param = {}, route_param = {},
...@@ -104,10 +104,13 @@ require(['OfficeJS'],function (OJS) { ...@@ -104,10 +104,13 @@ require(['OfficeJS'],function (OJS) {
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// change page according to the event // change page according to the event
hrefClicked = function () { hrefClicked = function () {
var new_hash = loadcurrentpage(), prev_hash = 'default'; 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) { if (routes[current_hash].template !== routes[new_hash].template) {
// check if it is necessary to repaint the page. // check if it is necessary to repaint the page.
prev_hash = current_hash;
current_hash = new_hash; current_hash = new_hash;
if (typeof routes[prev_hash].onunload === 'function') { if (typeof routes[prev_hash].onunload === 'function') {
routes[prev_hash].onunload(); routes[prev_hash].onunload();
...@@ -207,7 +210,7 @@ require(['OfficeJS'],function (OJS) { ...@@ -207,7 +210,7 @@ require(['OfficeJS'],function (OJS) {
'fileContent':filecontent, 'fileContent':filecontent,
'callback':function (result){ 'callback':function (result){
if (result.status === 'fail') { if (result.status === 'fail') {
console.error ('Error: ' + result.message); console.error (result.error);
} }
loading_object.end_save(); loading_object.end_save();
publ.getlist(); publ.getlist();
...@@ -224,12 +227,13 @@ require(['OfficeJS'],function (OJS) { ...@@ -224,12 +227,13 @@ require(['OfficeJS'],function (OJS) {
filename = $('#input_fileName').attr('value'); filename = $('#input_fileName').attr('value');
priv.jio.loadDocument({ priv.jio.loadDocument({
'fileName':filename, 'fileName':filename,
'maxtries':3,
'callback':function (result){ 'callback':function (result){
if (result.return_value.fileName) { if (result.return_value.fileName) {
getCurrentEditor().setHTML( getCurrentEditor().setHTML(
result.return_value.fileContent); result.return_value.fileContent);
} else { } else {
console.error ('Error: ' + result.message); console.error (result.error);
} }
loading_object.end_load(); loading_object.end_load();
} }
...@@ -247,7 +251,7 @@ require(['OfficeJS'],function (OJS) { ...@@ -247,7 +251,7 @@ require(['OfficeJS'],function (OJS) {
'fileName':filename, 'fileName':filename,
'callback':function (result) { 'callback':function (result) {
if (result.status === 'fail') { if (result.status === 'fail') {
console.error ('Error: ' + result.message); console.error (result.error);
} }
loading_object.end_remove(); loading_object.end_remove();
publ.getlist(); publ.getlist();
...@@ -263,27 +267,29 @@ require(['OfficeJS'],function (OJS) { ...@@ -263,27 +267,29 @@ require(['OfficeJS'],function (OJS) {
priv.jio.getDocumentList({ priv.jio.getDocumentList({
'maxtries':3, 'maxtries':3,
'callback':function (result) { 'callback':function (result) {
var htmlString = '', i, document_array = []; if (result.status === 'done') {
for (i = 0; i < result.return_value.length; i += 1) { var htmlString = '', i, document_array = [];
htmlString += '<li><a href="#/texteditor:fileName='+ for (i = 0; i < result.return_value.length; i += 1) {
result.return_value[i].fileName + '">\n' + htmlString += '<li><a href="#/texteditor:fileName='+
result.return_value[i].fileName; result.return_value[i].fileName + '">\n' +
result.return_value[i].creationDate = result.return_value[i].fileName;
(new Date(result.return_value[i].creationDate)). result.return_value[i].creationDate =
toLocaleString(); (new Date(result.return_value[i].creationDate)).
result.return_value[i].lastModified = toLocaleString();
(new Date(result.return_value[i].lastModified)). result.return_value[i].lastModified =
toLocaleString(); (new Date(result.return_value[i].lastModified)).
document_array.push (result.return_value[i]); toLocaleString();
htmlString += '</a></li>\n'; document_array.push (result.return_value[i]);
} htmlString += '</a></li>\n';
if (htmlString === '') { }
htmlString = 'No document'; if (htmlString === '') {
htmlString = 'No document';
}
ich_object.DocumentList = document_array;
document.querySelector ('#document_list').
innerHTML = htmlString;
loading_object.end_getlist();
} }
ich_object.DocumentList = document_array;
document.querySelector ('#document_list').
innerHTML = htmlString;
loading_object.end_getlist();
} }
}); });
}; };
......
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