# HG changeset patch # User Zoe Hong # Date 1424698483 -3600 # Node ID 04db1dd9d10de84c7c2e6fa873fec288d03d1baf # Parent f60969462226e5832b96eefb5883c1152b5661db update topic_regex_relation table when saving (new) regex file diff -r f60969462226 -r 04db1dd9d10d develop/js/taggingtext.js --- 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!"); }); } } diff -r f60969462226 -r 04db1dd9d10d develop/models/extractapp.php --- 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"); + } + } } diff -r f60969462226 -r 04db1dd9d10d develop/views/Extractapp/configtagsintopic.php --- 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) { - }); - } @@ -108,7 +105,7 @@ ".$taglistValue['name']." (".$taglistValue['tag'].") ".""; + echo ""; } } ?> @@ -124,7 +121,7 @@ ".$taglistValue['name']." (".$taglistValue['tag'].") ".""; + echo ""; } } ?> diff -r f60969462226 -r 04db1dd9d10d develop/views/Extractapp/taggingtext.php --- 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(''); + 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 @@ +
@@ -536,7 +550,7 @@ Range: to


- +