Mercurial > hg > extraction-interface
changeset 20:04db1dd9d10d
update topic_regex_relation table when saving (new) regex file
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 23 Feb 2015 14:34:43 +0100 |
parents | f60969462226 |
children | c805470cefee |
files | develop/js/taggingtext.js develop/models/extractapp.php develop/views/Extractapp/configtagsintopic.php develop/views/Extractapp/taggingtext.php |
diffstat | 4 files changed, 41 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/develop/js/taggingtext.js Mon Feb 23 12:46:03 2015 +0100 +++ b/develop/js/taggingtext.js Mon Feb 23 14:34:43 2015 +0100 @@ -618,20 +618,30 @@ //el.innerHTML = str.replace(new RegExp(replaceSmartRegexString, "g"), replaceSmartReplaceString); } -function smartRegexSave() { - var x; +function smartRegexSave(topic_id) { + + console.log(topic_id); + + var name=prompt("Please enter this Regex name",RegexLoadedName); if (name!=null){ $.ajax({ type : 'POST', url : './TaggingText', async : false, - data : 'func=SmartRegexSave'+'&text='+encodeURIComponent($('#smartRegexShowDiv').html())+'&filename='+name, + data : 'func=SmartRegexSave'+'&text='+encodeURIComponent($('#smartRegexShowDiv').html())+'&filename='+name+'&topic_id='+topic_id, error: function (e) { alert("Error when saving"); + }, + success: function (e) { + if (e == "error") { + alert("Error when saving!!"); + + } else { + alert("Saved!"); + } } }).done(function(result) { - alert("Saved!"); }); } }
--- a/develop/models/extractapp.php Mon Feb 23 12:46:03 2015 +0100 +++ b/develop/models/extractapp.php Mon Feb 23 14:34:43 2015 +0100 @@ -345,6 +345,16 @@ } file_put_contents( $data_path."regex_files/".$_postdata['filename'].".txt", $require); + + // update topic_regex_relation table + $topic_id = $_postdata['topic_id']; + $filename = $_postdata['filename'].'.txt'; + $query = "INSERT INTO topic_regex_relation (topic_id, regex_filename) VALUES (".$topic_id.",'".$filename."')"; + $result = mysql_query($query); + if (!$result) { + echo json_encode("error"); + } + } }
--- a/develop/views/Extractapp/configtagsintopic.php Mon Feb 23 12:46:03 2015 +0100 +++ b/develop/views/Extractapp/configtagsintopic.php Mon Feb 23 14:34:43 2015 +0100 @@ -54,7 +54,6 @@ } function checkTopic(t) { - // TODO: save the modification into topic_tag_relation var ids = []; for (var i = 0; i < t.options.length; i++) { @@ -78,10 +77,8 @@ alert("Updated!"); } }).done(function(result) { - }); - } </script> @@ -108,7 +105,7 @@ <?php foreach ($taglistArray as $taglistValue) { if ($taglistValue['topic_id'] == $topic) { - echo "<option value='".$taglistValue['id']."' class='text-primary'>".$taglistValue['name']." (".$taglistValue['tag'].") "."</option>"; + echo "<option value='".$taglistValue['id']."'>".$taglistValue['name']." (".$taglistValue['tag'].") "."</option>"; } } ?> @@ -124,7 +121,7 @@ <?php foreach ($taglistArray as $taglistValue) { if ($taglistValue['topic_id'] != $topic) { - echo "<option value='".$taglistValue['id']."' class='text-muted'>".$taglistValue['name']." (".$taglistValue['tag'].") "."</option>"; + echo "<option value='".$taglistValue['id']."'>".$taglistValue['name']." (".$taglistValue['tag'].") "."</option>"; } } ?>
--- a/develop/views/Extractapp/taggingtext.php Mon Feb 23 12:46:03 2015 +0100 +++ b/develop/views/Extractapp/taggingtext.php Mon Feb 23 14:34:43 2015 +0100 @@ -101,6 +101,18 @@ }); */ + // Popup choosing topic if first time to this section. without branchId + var info = JSON.parse('<?php echo json_encode($info) ?>'); + if (info['file_id'] == 0) { // or info['branchId'] == 0, means new file + // ask to choose topic + $.ajax({ + + }); + var popup = document.getElementById('popup-window'); + + // alert('choose topic!'); + }; + }); $(document).on("click", "name", function (e) { @@ -476,6 +488,8 @@ </script> +<div id="popup-window" style="display: none; background-color:white; height:300px; width:300px; margin:200 0 0 200;position:fixed; z-index:2"> +</div> <div class="container-fluid"> <div class="row"> @@ -536,7 +550,7 @@ Range: <input type="text" size="5" id="regexPageStart">to<input type="text" size="5" id="regexPageEnd"><br> <button onclick="replaceSmartRun()" style="height: 30px; width: 220px">Run</button></br> <button onclick="replaceSmartRunSpace()" style="height: 30px; width: 220px">Run(Allow space between Group)</button></br> - <button onclick="smartRegexSave()" style="height: 30px; width: 70px">Save</button> + <button onclick="smartRegexSave(<?php echo $default_topic_id; ?>)" style="height: 30px; width: 70px">Save</button> <button onclick="smartRegexLoad(<?php echo $default_topic_id; ?>)" style="height: 30px; width: 70px">Load</button> <button onclick="smartRegexEmpty()" style="height: 30px; width: 70px">Clear</button></br> <!--