# HG changeset patch # User Zoe Hong # Date 1426755206 -3600 # Node ID 3e42a63de0ea8c5af5b29a006637f4333d3091b9 # Parent b2c1fae5cf6a45b9a322a9615ad31d264b4d58eb bug fix: unique regex element id, edit/update/delete regex diff -r b2c1fae5cf6a -r 3e42a63de0ea config/config.php --- a/config/config.php Tue Mar 17 13:58:34 2015 +0100 +++ b/config/config.php Thu Mar 19 09:53:26 2015 +0100 @@ -1,6 +1,6 @@ 空白 某之屬 \ No newline at end of file diff -r b2c1fae5cf6a -r 3e42a63de0ea data/regex_files/Basic_Address.txt --- a/data/regex_files/Basic_Address.txt Tue Mar 17 13:58:34 2015 +0100 +++ b/data/regex_files/Basic_Address.txt Thu Mar 19 09:53:26 2015 +0100 @@ -1,1 +1,1 @@ - 籍貫 REN \ No newline at end of file +籍貫 REN \ No newline at end of file diff -r b2c1fae5cf6a -r 3e42a63de0ea data/regex_files/Zi.txt --- a/data/regex_files/Zi.txt Tue Mar 17 13:58:34 2015 +0100 +++ b/data/regex_files/Zi.txt Thu Mar 19 09:53:26 2015 +0100 @@ -1,1 +1,1 @@ - 字名 \ No newline at end of file + 字名 \ No newline at end of file diff -r b2c1fae5cf6a -r 3e42a63de0ea data/regex_files/entry_method_student.txt --- a/data/regex_files/entry_method_student.txt Tue Mar 17 13:58:34 2015 +0100 +++ b/data/regex_files/entry_method_student.txt Thu Mar 19 09:53:26 2015 +0100 @@ -1,1 +1,1 @@ - 入仕地點 干支 入仕方法 \ No newline at end of file + 入仕地點 干支 入仕方法 \ No newline at end of file diff -r b2c1fae5cf6a -r 3e42a63de0ea data/regex_files/hao.txt --- a/data/regex_files/hao.txt Tue Mar 17 13:58:34 2015 +0100 +++ b/data/regex_files/hao.txt Thu Mar 19 09:53:26 2015 +0100 @@ -1,1 +1,1 @@ - 號甚麼 \ No newline at end of file + 號甚麼 \ No newline at end of file diff -r b2c1fae5cf6a -r 3e42a63de0ea data/regex_files/kin_name_relation.txt --- a/data/regex_files/kin_name_relation.txt Tue Mar 17 13:58:34 2015 +0100 +++ b/data/regex_files/kin_name_relation.txt Thu Mar 19 09:53:26 2015 +0100 @@ -1,1 +1,1 @@ - 親屬名字 親屬關係 \ No newline at end of file + 親屬名字 親屬關係 \ No newline at end of file diff -r b2c1fae5cf6a -r 3e42a63de0ea data/regex_files/kins inherit.txt --- a/data/regex_files/kins inherit.txt Tue Mar 17 13:58:34 2015 +0100 +++ b/data/regex_files/kins inherit.txt Thu Mar 19 09:53:26 2015 +0100 @@ -1,1 +1,1 @@ - XXX \ No newline at end of file + XXX \ No newline at end of file diff -r b2c1fae5cf6a -r 3e42a63de0ea data/regex_files/post_year_month_day_former_post.txt --- a/data/regex_files/post_year_month_day_former_post.txt Tue Mar 17 13:58:34 2015 +0100 +++ b/data/regex_files/post_year_month_day_former_post.txt Thu Mar 19 09:53:26 2015 +0100 @@ -1,1 +1,1 @@ - 年號 年份 月份 前官 \ No newline at end of file + 年號 年份 月份 前官 \ No newline at end of file diff -r b2c1fae5cf6a -r 3e42a63de0ea data/regex_files/post_year_month_day_type.txt --- a/data/regex_files/post_year_month_day_type.txt Tue Mar 17 13:58:34 2015 +0100 +++ b/data/regex_files/post_year_month_day_type.txt Thu Mar 19 09:53:26 2015 +0100 @@ -1,1 +1,1 @@ - 年號 年份 月份 日子 \ No newline at end of file + 年號 年份 月份 日子 \ No newline at end of file diff -r b2c1fae5cf6a -r 3e42a63de0ea data/regex_files/post_year_month_day_with former post.txt --- a/data/regex_files/post_year_month_day_with former post.txt Tue Mar 17 13:58:34 2015 +0100 +++ b/data/regex_files/post_year_month_day_with former post.txt Thu Mar 19 09:53:26 2015 +0100 @@ -1,1 +1,1 @@ - 年號 年份 月份 叉叉叉 \ No newline at end of file + 年號 年份 月份 叉叉叉 \ No newline at end of file diff -r b2c1fae5cf6a -r 3e42a63de0ea data/regex_files/post_year_type.txt --- a/data/regex_files/post_year_type.txt Tue Mar 17 13:58:34 2015 +0100 +++ b/data/regex_files/post_year_type.txt Thu Mar 19 09:53:26 2015 +0100 @@ -1,1 +1,1 @@ - 年號 年份 \ No newline at end of file + 年號 年份 \ No newline at end of file diff -r b2c1fae5cf6a -r 3e42a63de0ea data/regex_files/product_name.txt --- a/data/regex_files/product_name.txt Tue Mar 17 13:58:34 2015 +0100 +++ b/data/regex_files/product_name.txt Thu Mar 19 09:53:26 2015 +0100 @@ -1,1 +1,1 @@ -物產 \ No newline at end of file +物產 \ No newline at end of file diff -r b2c1fae5cf6a -r 3e42a63de0ea data/regex_files/product_name_place.txt --- a/data/regex_files/product_name_place.txt Tue Mar 17 13:58:34 2015 +0100 +++ b/data/regex_files/product_name_place.txt Thu Mar 19 09:53:26 2015 +0100 @@ -1,1 +1,1 @@ - 產於 產地 \ No newline at end of file +產於產地 \ No newline at end of file diff -r b2c1fae5cf6a -r 3e42a63de0ea data/regex_files/product_name_started_with_space.txt --- a/data/regex_files/product_name_started_with_space.txt Tue Mar 17 13:58:34 2015 +0100 +++ b/data/regex_files/product_name_started_with_space.txt Thu Mar 19 09:53:26 2015 +0100 @@ -1,1 +1,1 @@ - 空白 物產名 空白 \ No newline at end of file +空白物產名空白 \ No newline at end of file diff -r b2c1fae5cf6a -r 3e42a63de0ea data/regex_files/product_name_test.txt --- a/data/regex_files/product_name_test.txt Tue Mar 17 13:58:34 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ - 物產test \ No newline at end of file diff -r b2c1fae5cf6a -r 3e42a63de0ea data/regex_files/source.txt --- a/data/regex_files/source.txt Tue Mar 17 13:58:34 2015 +0100 +++ b/data/regex_files/source.txt Thu Mar 19 09:53:26 2015 +0100 @@ -1,1 +1,1 @@ - XXX 出處 \ No newline at end of file + XXX 出處 \ No newline at end of file diff -r b2c1fae5cf6a -r 3e42a63de0ea data/regex_files/test_regex.txt --- a/data/regex_files/test_regex.txt Tue Mar 17 13:58:34 2015 +0100 +++ b/data/regex_files/test_regex.txt Thu Mar 19 09:53:26 2015 +0100 @@ -1,1 +1,1 @@ -物產 test name \ No newline at end of file +物產 testwdfvvvv234QQQ空白v222vQQQ空白wdfw \ No newline at end of file diff -r b2c1fae5cf6a -r 3e42a63de0ea data/regex_files/zhishu.txt --- a/data/regex_files/zhishu.txt Tue Mar 17 13:58:34 2015 +0100 +++ b/data/regex_files/zhishu.txt Thu Mar 19 09:53:26 2015 +0100 @@ -1,1 +1,1 @@ - 空白 某之屬 \ No newline at end of file +空白某之屬 \ No newline at end of file diff -r b2c1fae5cf6a -r 3e42a63de0ea js/taggingtext.js --- a/js/taggingtext.js Tue Mar 17 13:58:34 2015 +0100 +++ b/js/taggingtext.js Thu Mar 19 09:53:26 2015 +0100 @@ -3,6 +3,8 @@ var stringBeforeChangeStack = []; var lastAddTag=""; +var regex_element_index = 0; + window.onbeforeunload = function() { return "Are you sure?"; }; @@ -413,6 +415,7 @@ $('#smartRegexPopUpDel').attr("disabled", "disabled"); $('#smartRegexPopUpBack').attr("disabled", "disabled"); $('#smartRegexPopUpFor').attr("disabled", "disabled"); + } function replaceSmartClose() { @@ -429,11 +432,12 @@ $('#smartRegexShowDiv > #'+thisObject).attr("regexText", $("#smartRegexPopUpText").val()); $('#smartRegexShowDiv > #'+thisObject).attr("regexReplace", $("#smartRegexPopUpSelectTag").val()); $('#smartRegexShowDiv > #'+thisObject).text($("#smartRegexPopUpName").val()); // smartRgextPopUpName.val() is the name of this regex - + // id should be the same as it was } function replaceSmartDel() { thisObject = $('#smartRegexPopUpDiv').attr("editID"); + $('#smartRegexShowDiv > #'+thisObject).remove(); } @@ -457,14 +461,25 @@ function replaceSmartAdd() { var newdiv = document.createElement("span"); - newdiv.innerHTML = " "+$("#smartRegexPopUpName").val()+" "; + //newdiv.innerHTML = " "+$("#smartRegexPopUpName").val()+" "; + //newdiv.innerHTML = $("#smartRegexPopUpName").val(); + $(newdiv).text($("#smartRegexPopUpName").val()); + $(newdiv).css("border", "1px solid black"); $(newdiv).css("width", "100px"); $(newdiv).attr("class", "span_"+$("#smartRegexPopUpSelectTag").val()); - $(newdiv).attr("id", "span_"+$("#smartRegexPopUpName").val()); + + + + // id is the name from user's input, which dose not guarantee to be unique + // id should be unique + regex_element_index += 1; + $(newdiv).attr("id", "regex_elem_"+regex_element_index); + // $(newdiv).attr("id", "span_"+$("#smartRegexPopUpName").val()); $(newdiv).attr("regexText", $("#smartRegexPopUpText").val()); $(newdiv).attr("regexReplace", $("#smartRegexPopUpSelectTag").val()); + $('#smartRegexShowDiv').append(newdiv); @@ -485,15 +500,8 @@ $('#smartRegexPopUpDiv').attr("editID", $(this).attr("id")); - - var _id = $(this).attr("id"); - var aa = document.getElementById(_id); - var name = aa.textContent; - - $('#smartRegexPopUpName').val(name); + $('#smartRegexPopUpName').val($(this).text()); // $('#smartRegexPopUpName').val($(this).html()); - // why there is a inbetween? - $('#smartRegexPopUpText').val($(this).attr("regexText")); $('#smartRegexPopUpSelectTag').val($(this).attr("regexReplace")); @@ -507,6 +515,7 @@ function smartRegexEmpty() { $('#smartRegexShowDiv').html(""); + regex_element_index = 0; } function replaceSmartRunWithBr() { @@ -776,8 +785,20 @@ RegexLoadedName = $('#loadRegexSelect').val(); var divName = "#div_"+RegexLoadedName; var name = $(divName).html(); - $('#smartRegexShowDiv').html(name ); + $('#smartRegexShowDiv').html(name); $('#load_regex_div').css("display", "none"); + + // get the largest regex element index in the regex file + // for all children (span) in #smartRegexShowDiv, find MAX(id) + var regex_elem = $('#smartRegexShowDiv').children(); + var max_id = 0; + for (var i = 0; i < regex_elem.length; i++) { + var r_id = parseInt(regex_elem[i].id.slice(11)); // cut the first 11 char out: "regex_elem_" + if (r_id > max_id) { + max_id = r_id; + } + } + regex_element_index = max_id; } // ===