Mercurial > hg > extraction-interface
diff develop/views/Extractapp/taggingtext.php @ 29:fc7342914cdf
develop_v0
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Thu, 05 Mar 2015 15:08:09 +0100 |
parents | e6e9bdc4f256 |
children |
line wrap: on
line diff
--- a/develop/views/Extractapp/taggingtext.php Tue Mar 03 18:13:20 2015 +0100 +++ b/develop/views/Extractapp/taggingtext.php Thu Mar 05 15:08:09 2015 +0100 @@ -73,13 +73,13 @@ // ==== -handleFileVersionConflict(); -// Popup to proceeding the saving situations + +// TODO: Popup to proceeding the saving situations function handleFileVersionConflict() { var info = JSON.parse('<?php echo json_encode($info) ?>'); - console.log(info['current_fileId']); + console.log("currentFileId="+info['current_fileId']); - if (info['current_fileId'] != 0){ + if (info['current_fileId'] != 0 && info['current_fileId'] != info['file_id']){ // -- there might be conflicts between different version var retVal = confirm('There were something happened/someone editing in the between of time.\nDo you want to force saving? (There might be conflicts between two versions.)'); if( retVal == true ){ @@ -89,38 +89,61 @@ }else{ var loadLastest = confirm("Do you want to reload for the lastest version? (Your current editing will lost.)"); + + console.log("loadLastest="+loadLastest); + /* + var form = document.createElement("form"); + form.setAttribute("method", "post"); + form.setAttribute("action", "./TaggingText"); // hand to controller + form.setAttribute("target", "_blank"); + + var topic_id = JSON.parse('<?php echo json_encode($default_topic_id) ?>'); + + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("name", "topic"); + hiddenField.setAttribute("value", topic_id); + form.appendChild(hiddenField); + + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("name", "func"); + hiddenField.setAttribute("value", "Reload"); // reload + form.appendChild(hiddenField); + + _postForContineTagging(form); + + alert("You will reload the latest version."); + */ + /* if (loadLastest == true) { // TODO: reload page with the currentFileId - alert("You will reload the latest version."); - - var form = document.createElement("form"); - form.setAttribute("method", "post"); - form.setAttribute("action", "./TaggingText"); // hand to controller - form.setAttribute("target", "_blank"); - - var topic_id = JSON.parse('<?php echo json_encode($default_topic_id) ?>'); + console.log('loadLastest is true'); + $.ajax({ + type : 'POST', + url : './TaggingText', + async : false, + data : 'func=Reload', + success: function (result) { + //var lastest_editing = jQuery.parseJSON(result); + console.log("lastest_editing string:"+result); + // change text to the new one + //var el = document.getElementById("editable-area"); + //el.innerHTML = lastest_editing; + //alert("Reload the page!"); + }, + error: function (result) { + alert("Reload Fails!"); + } + }).done(function(result) { + // reload page + //document.location.reload(true); - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("name", "topic"); - hiddenField.setAttribute("value", topic_id); - form.appendChild(hiddenField); - - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("name", "func"); - hiddenField.setAttribute("value", "Reload"); // reload - form.appendChild(hiddenField); - - - - _postForContineTagging(form); - - // use the current_fileId to reload the latest version of text - console.log('reloaded'); - + }); } else { alert("Just a reminder, there is a new version for this branch."); } + */ + } } return; @@ -172,6 +195,8 @@ + handleFileVersionConflict(); + /* @@ -593,10 +618,10 @@ // if this is a new branch, ask for label if (info['branch_id'] == 0) { var cnt = 0; - var label = prompt("Please enter your label for this new branch", "label for section "+info['section_id']); + var label = prompt("Please enter your label for this new branch", "section"+info['section_id']); while (label == null && cnt <= 3) { cnt ++; - label = prompt("Please enter your label for this new branch (not empty)", "label for section "+info['section_id']); + label = prompt("Please enter your label for this new branch (not empty)", "section"+info['section_id']); } }; @@ -625,6 +650,9 @@ _postForContineTagging(form); + console.log("complete saving to LGService"); + + /* if (info) { @@ -801,14 +829,12 @@ hiddenField.setAttribute("value", info['book_name']); form.appendChild(hiddenField); }; - /* if (info['current_fileId']) { var hiddenField = document.createElement("input"); hiddenField.setAttribute("name", "currentFileId"); hiddenField.setAttribute("value", info['current_fileId']); form.appendChild(hiddenField); }; - */ } if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { @@ -834,12 +860,15 @@ _postForContineTagging(form); + /* if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { document.body.appendChild(form); form.submit(); } else { form.submit(); // works under IE and Chrome, but not FF } + */ + }