Mercurial > hg > extraction-interface
diff develop/views/Extractapp/taggingtext.php @ 28:e6e9bdc4f256
update the saving response from LGService between different file version
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 03 Mar 2015 18:13:20 +0100 |
parents | 4a29bccb6c59 |
children | fc7342914cdf |
line wrap: on
line diff
--- a/develop/views/Extractapp/taggingtext.php Tue Mar 03 11:47:41 2015 +0100 +++ b/develop/views/Extractapp/taggingtext.php Tue Mar 03 18:13:20 2015 +0100 @@ -73,6 +73,60 @@ // ==== +handleFileVersionConflict(); +// Popup to proceeding the saving situations +function handleFileVersionConflict() { + var info = JSON.parse('<?php echo json_encode($info) ?>'); + console.log(info['current_fileId']); + + if (info['current_fileId'] != 0){ + // -- 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 ){ + // TODO: force saving with currentFileId + alert("You do the force saving!"); + //saveTextToLGService(); + + }else{ + var loadLastest = confirm("Do you want to reload for the lastest version? (Your current editing will lost.)"); + 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) ?>'); + + 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; + +} + <?php foreach ( $taglistArray as $taglistValue ) { echo '$(document).on("click", "'.$taglistValue[2].'", function (e) {'."\n"; @@ -118,29 +172,9 @@ - var info = JSON.parse('<?php echo json_encode($info) ?>'); - // Popup to proceeding the saving situations + + /* - if (info['current_fileId']) { - var retVal = confirm('There were something happened/someone editing in the between of time. - Please choose what you want to proceed the saving. - Click "OK" to force saving the current file.'); - if( retVal == true ){ - // TODO: force saving - alert("You do the force saving!"); - return true; - }else{ - // TODO: reload with the new file id (current_FileId) - - - alert("You will reload for the latest version!"); - return false; - } - - }; - - */ - // Popup choosing topic if first time to this section. without branchId if (info['file_id'] == 0) { // or info['branchId'] == 0, means new file @@ -151,7 +185,8 @@ var popup = document.getElementById('popup-window'); // alert('choose topic!'); - }; + } + */ }); $(document).on("click", "name", function (e) { @@ -359,7 +394,7 @@ form.appendChild(hiddenField); _postForContineTagging(form); - + /* var section_id = JSON.parse('<?php echo json_encode($section_id) ?>'); @@ -422,8 +457,6 @@ form.appendChild(hiddenField); _postForContineTagging(form); - - /* var section_id = JSON.parse('<?php echo json_encode($section_id) ?>'); console.log("section_id: "+section_id+", topic_id: "+topic_id); @@ -567,6 +600,7 @@ } }; + var form = document.createElement("form"); form.setAttribute("method", "post"); @@ -592,6 +626,7 @@ _postForContineTagging(form); /* + if (info) { var hiddenField = document.createElement("input"); hiddenField.setAttribute("name", "fileId"); @@ -685,8 +720,9 @@ form.appendChild(hiddenField); _postForContineTagging(form); + + }; - }; //Create and append the options for (var i = 0; i < t.length; i++) { @@ -723,39 +759,58 @@ if (info) { // TODO: different field info array based on fileId(branchId) existing or not - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("name", "fileId"); - hiddenField.setAttribute("value", info['file_id']); - form.appendChild(hiddenField); - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("name", "branchId"); - hiddenField.setAttribute("value", info['branch_id']); - form.appendChild(hiddenField); - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("name", "userId"); - hiddenField.setAttribute("value", info['user_id']); - form.appendChild(hiddenField); - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("name", "sectionId"); - hiddenField.setAttribute("value", info['section_id']); - form.appendChild(hiddenField); + if (info['file_id']) { + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("name", "fileId"); + hiddenField.setAttribute("value", info['file_id']); + form.appendChild(hiddenField); + }; + if (info['branch_id']) { + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("name", "branchId"); + hiddenField.setAttribute("value", info['branch_id']); + form.appendChild(hiddenField); + }; + if (info['user_id']) { + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("name", "userId"); + hiddenField.setAttribute("value", info['user_id']); + form.appendChild(hiddenField); + }; + if (info['section_id']) { + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("name", "sectionId"); + hiddenField.setAttribute("value", info['section_id']); + form.appendChild(hiddenField); + }; + if (info['book_id']) { + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("name", "bookId"); + hiddenField.setAttribute("value", info['book_id']); + form.appendChild(hiddenField); + }; + if (info['section_name']) { + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("name", "sectionName"); + hiddenField.setAttribute("value", info['section_name']); + form.appendChild(hiddenField); + }; + if (info['book_name']) { + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("name", "bookName"); + 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); + }; + */ - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("name", "bookId"); - hiddenField.setAttribute("value", info['book_id']); - form.appendChild(hiddenField); - - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("name", "sectionName"); - hiddenField.setAttribute("value", info['section_name']); - form.appendChild(hiddenField); - - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("name", "bookName"); - hiddenField.setAttribute("value", info['book_name']); - form.appendChild(hiddenField); } - if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { document.body.appendChild(form); form.submit(); @@ -778,7 +833,13 @@ form.appendChild(hiddenField); _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 + } }