Mercurial > hg > extraction-interface
diff views/Extractapp/TaggingText.php @ 57:5cf9720a2e25 extractapp
New: add reloadText to load the latest version
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 30 Mar 2015 17:23:47 +0200 |
parents | f9e7119339b2 |
children | a11f9103b8db |
line wrap: on
line diff
--- a/views/Extractapp/TaggingText.php Mon Mar 30 15:54:04 2015 +0200 +++ b/views/Extractapp/TaggingText.php Mon Mar 30 17:23:47 2015 +0200 @@ -79,6 +79,34 @@ } } +function reloadText() { + // confirm to reload + var r = confirm("Your editing will be discarded. Are you sure you want to reload?"); + if (r != true) { + return; + } + + var form = document.createElement("form"); + form.setAttribute("method", "post"); + form.setAttribute("action", "./TaggingText"); // hand to controller + //form.setAttribute("target", "_self"); + form.setAttribute("target", "_blank"); + + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("name", "topic"); + var topic_id = JSON.parse('<?php echo json_encode($default_topic_id) ?>'); + hiddenField.setAttribute("value", topic_id); + form.appendChild(hiddenField); + + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("name", "func"); + hiddenField.setAttribute("value", "ReloadText"); + form.appendChild(hiddenField); + + _postForContineTagging(form); + +} + // TODO: Popup to proceeding the saving situations function handleFileVersionConflict() { var info = JSON.parse('<?php echo json_encode($info) ?>'); @@ -86,74 +114,8 @@ if (info['current_fileId'] != 0 && info['current_fileId'] != info['file_id']){ // -- there might be conflicts between different version - alert("Someone edited this file and saved before you."); + alert("Your saving failed! Someone edited this file and saved before you."); return; - - 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.)"); - - 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 - 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); - - }); - - } else { - alert("Just a reminder, there is a new version for this branch."); - } - */ - - } - } return; @@ -516,9 +478,6 @@ */ } - - - function exportAll(topic_id) { var el = document.getElementById("editable-area"); var str= "" + el.innerHTML; @@ -579,7 +538,6 @@ } // =========== - function tagwithOnlytag( range, stringSelection, tag ) { saveUndoText(); var topic_tag = JSON.parse('<?php echo json_encode($topic_tag) ?>'); @@ -625,9 +583,6 @@ $('.tagItemDivClass').remove(); } - - - function replaceSmartRegex() { saveUndoText(); var startPage = $('#regexPageStart2').val(); @@ -665,8 +620,6 @@ //document.styleSheets[0].addRule("tag001", "color:green;") } - - function saveTextToLGService() { // ------------- @@ -774,8 +727,6 @@ */ } - - function chooseTopic(default_topic_id) { var t = JSON.parse( '<?php echo json_encode($topiclistArray) ?>' ); var info = JSON.parse('<?php echo json_encode($info) ?>'); @@ -875,7 +826,6 @@ var info = JSON.parse( '<?php echo json_encode($info) ?>'); if (info) { - // TODO: different field info array based on fileId(branchId) existing or not if (info['file_id']) { var hiddenField = document.createElement("input"); hiddenField.setAttribute("name", "fileId"); @@ -961,7 +911,6 @@ } - $(document).on("change", '#smartRegexPopUpSelectWord', function (e) { <?php @@ -1028,9 +977,12 @@ <div id="follow-scroll" style="position:absolute; height:680px; overflow:scroll; margin:0 5 15 5; max-width:270px"> <form action="javascript:void(0);"> <fieldset> + <button onclick="reloadText(<?php echo $default_topic_id; ?>)">Reload</button> + </fieldset> + <fieldset> <legend><h5 class="text-success"> Config Topic: </h5></legend> <div> current topic is <?php echo $topic_name; ?> - <button onclick="chooseTopic(<?php echo $default_topic_id; ?>)" class="btn btn-xs btn-default">Change</button> + <button onclick="chooseTopic()" class="btn btn-xs btn-default">Change</button> </div> <button onclick="configTagsInTopic(<?php echo $default_topic_id;?>)" class="btn btn-sm btn-default" style="">Manage Tags in topic</button></br> </fieldset>