# HG changeset patch # User Zoe Hong # Date 1424790599 -3600 # Node ID c805470cefeebccd1c2f927254bd7d25ccf6c730 # Parent 04db1dd9d10de84c7c2e6fa873fec288d03d1baf Remove bootstrap.TaggingText UI layout modification diff -r 04db1dd9d10d -r c805470cefee .DS_Store Binary file .DS_Store has changed diff -r 04db1dd9d10d -r c805470cefee develop/controllers/extractapp.php --- a/develop/controllers/extractapp.php Mon Feb 23 14:34:43 2015 +0100 +++ b/develop/controllers/extractapp.php Tue Feb 24 16:09:59 2015 +0100 @@ -23,7 +23,7 @@ $this->ReturnView($viewmodel->StartTagging(), true); break; case 'SaveFullTextToLGService': - $viewmodel->messages .= "[Z] SaveFullTextToLGService! "; + $viewmodel->messages .= "SaveFullTextToLGService! "."
"; $viewmodel->GetInfoFromPreviousPage($this->postdata); $response = $viewmodel->SaveFullTextToLGService($this->postdata); @@ -40,7 +40,7 @@ break; case 'ContinueTagging': - $viewmodel->messages .= "[Z] (Countinue tagging) "; + $viewmodel->messages .= "(Countinue tagging) "."
"; if ($this->postdata['topic']) { $viewmodel->SetTopic($this->postdata['topic']); } @@ -49,7 +49,7 @@ break; default: // first time visit extraction interface from LGService - $viewmodel->messages .= "[Z] Welcome to Extraction Interface. "; + $viewmodel->messages .= "Welcome to Extraction Interface. "."
"; if ($this->postdata['fileId'] != 0) { // ($this->postdata['branchId'] != 0) { // get text from fileId, from LGService diff -r 04db1dd9d10d -r c805470cefee develop/js/taggingtext.js --- a/develop/js/taggingtext.js Mon Feb 23 14:34:43 2015 +0100 +++ b/develop/js/taggingtext.js Tue Feb 24 16:09:59 2015 +0100 @@ -619,10 +619,7 @@ } function smartRegexSave(topic_id) { - console.log(topic_id); - - var name=prompt("Please enter this Regex name",RegexLoadedName); if (name!=null){ $.ajax({ @@ -738,107 +735,6 @@ } // === -// === for exporttable.php === -function exportTable( range, container ) { - //MsgBox("enter function"); - var form = document.createElement("form"); - form.setAttribute("method", "post"); - form.setAttribute("action", "./ExportTable"); - form.setAttribute("target", "_blank"); - - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("name", "content"); - hiddenField.setAttribute("value", container.innerHTML); - form.appendChild(hiddenField); - - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("name", "sectionid"); - hiddenField.setAttribute("value", ""); - form.appendChild(hiddenField); - - var hiddenField2 = document.createElement("input"); - hiddenField2.setAttribute("name", "topic"); - hiddenField2.setAttribute("value", topic_id); - form.appendChild(hiddenField2); - - if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { - document.body.appendChild(form); - form.submit(); - } else { - form.submit(); // works under IE and Chrome, but not FF - } -} - -function exportPage() { - var startPage = $('#exportPageStart').val(); - var endPage = $('#exportPageEnd').val(); - - var el = document.getElementById("editable-area"); - var str="" + el.innerHTML; - - var regexText="【]*?)>"+startPage+"】(.*?)【]*?)>"+endPage+"】"; - - var form = document.createElement("form"); - form.setAttribute("method", "post"); - form.setAttribute("action", "./ExportTable"); - form.setAttribute("target", "_blank"); - - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("name", "content"); - hiddenField.setAttribute("value", str.match(new RegExp(regexText, "g"))); - form.appendChild(hiddenField); - - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("name", "sectionid"); - hiddenField.setAttribute("value", ""); - form.appendChild(hiddenField); - - if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { - document.body.appendChild(form); - form.submit(); - } else { - form.submit(); // works under IE and Chrome, but not FF - } -} - -function exportAll(topic_id) { - var el = document.getElementById("editable-area"); - var str= "" + el.innerHTML; - var form = document.createElement("form"); - form.setAttribute("method", "post"); - //form.setAttribute("action", "exportTable.php"); - form.setAttribute("action", "./ExportTable");//+section_id); // hand to controller - form.setAttribute("target", "_blank"); - - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("name", "content"); - hiddenField.setAttribute("value", str); - form.appendChild(hiddenField); - - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("name", "topic"); - hiddenField.setAttribute("value", topic_id); - form.appendChild(hiddenField); - - console.log(topic_id); - - /* - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("name", "sectionid"); - hiddenField.setAttribute("value", section_id); - form.appendChild(hiddenField); - */ - - if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { - document.body.appendChild(form); - form.submit(); - } else { - form.submit(); // works under IE and Chrome, but not FF - } - - -} -// =========== // === for editwordlist.php === function addNewList() { diff -r 04db1dd9d10d -r c805470cefee develop/models/extractapp.php --- a/develop/models/extractapp.php Mon Feb 23 14:34:43 2015 +0100 +++ b/develop/models/extractapp.php Tue Feb 24 16:09:59 2015 +0100 @@ -8,7 +8,7 @@ return array("Index Value 1", "Value 2", "Value 3"); } - protected $section_id = 0, $data_path, $file_id = 0, $branch_id = 0, $user_id = 0, $lg_text = ""; + protected $section_id = 0, $data_path, $file_id = 0, $branch_id = 0, $user_id = 0, $lg_text = "", $topic = 0; public $messages = ""; private function Initialize($_urlvalues) { @@ -84,7 +84,13 @@ if ($_postdata['userId']) { $this->user_id = $_postdata['userId']; } + if ($_postdata['topic_id']) { + $this->topic = $_postdata['topic_id']; + } + $this->messages .= "Info: "; + $this->messages .= "file_id=".$this->file_id.", section_id=".$this->section_id; + $this->messages .= ", user_id=".$this->user_id.", branch_id=".$this->branch_id.", topic_id=".$this->topic."
"; } public function InitData($_postdata) { @@ -365,7 +371,9 @@ $content = $postdata['content']; $topic = $postdata['topic']; - $section_id = $this->section_id; + $section_id = $postdata['sectionId']; + + //$section_id = $this->section_id; // TODO: this should be get from LGServic: sectionName, bookId, bookName @@ -487,6 +495,9 @@ // === for manage tag list === public function EditTaglist($_postdata) { + $query = "SELECT `AUTO_INCREMENT` FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'taglist'"; + $largest_id = mysql_query($query); + $topic_id = $_postdata['topic_id']; $result = $this->GetTaglistByTopicID($topic_id); @@ -508,6 +519,9 @@ $data = array(); $data['taglistArray'] = $taglistArray; $data['topic_id'] = $topic_id; + $data['largest_id'] = $largest_id; + + return $data; } @@ -599,14 +613,112 @@ $data['topic'] = $topic; $data['topic_name'] = $topic_name; + + + + // ------ + $query = "SELECT taglist.*, topic_tag_relation.topic_id FROM taglist LEFT JOIN topic_tag_relation ON taglist.id = topic_tag_relation.tag_id ORDER BY `topic_id`"; + $result = mysql_query($query); + if (!$result) { + return json_encode("Failed during selecting/joining taglist and topic_tag_relation table."); + } + + $tag_intopic = array(); + $tag_others = array(); + $tag_tmp_others = array(); + while ($row = mysql_fetch_assoc($result)) { + if ($row['topic_id'] == $topic) { + array_push($tag_intopic, array('id=>'=>$row['id'],'name'=>$row['name'], 'tag'=>$row['tag'], 'color'=>$row['color'], 'topic_id'=>$row['topic_id'])); + } else { + array_push($tag_tmp_others, array('id=>'=>$row['id'],'name'=>$row['name'], 'tag'=>$row['tag'], 'color'=>$row['color'], 'topic_id'=>$row['topic_id'])); + } + } + + + foreach ($tag_tmp_others as $tmp) { + $cnt = 0; + foreach ($tag_intopic as $intopic) { + if ($tmp['tag'] == $intopic['tag']) { + break; + } else { + $cnt ++; + } + } + if ($cnt == count($tag_intopic)) { + array_push($tag_others, $tmp); + } + } + + + $data['tag_intopic'] = $tag_intopic; + $data['tag_others'] = $tag_others; + return $data; } + + public function UpdateTagsInTopic($_postdata) { $topic_id = $_postdata['topic_id']; $tag_ids = json_decode(str_replace('\\', '', $_postdata['ids'])); // update topic_tag_relation by tags_ids array as `tag_id` and topic_id as `topic_id` - $query = "SELECT * FROM topic_tag_relation"; + // --- add new topic_tag_relation --- + foreach ($tag_ids as $tag_id) { + $query = "SELECT * FROM topic_tag_relation WHERE tag_id=".$tag_id; + $result = mysql_query($query); + if (!$result) { + echo json_encode("error when select from topic_tag_relation"); + } + $topic_tag = array(); + $flag = false; + while ($row = mysql_fetch_assoc($result)) { + if ($row['topic_id'] == $topic_id) { + $flag = true; + break; + } + } + if (!$flag) { + // insert a row into topic_tag_relation table + $queryUpdate = "INSERT INTO topic_tag_relation (topic_id, tag_id) VALUES (".$topic_id.",".$tag_id.")"; + $resultUpdate = mysql_query($queryUpdate); + if (!$resultUpdate) { + return json_encode("error when insert topic_tag_relation table"); + } + } + + } + + // --- remove tags from this topic --- + $query = "SELECT * FROM topic_tag_relation WHERE topic_id=".$topic_id; + $result = mysql_query($query); + if (!$result) { + echo json_encode("error when select from topic_tag_relation"); + } + + while ($row = mysql_fetch_assoc($result)) { + $cnt = 0; + foreach ($tag_ids as $tag_id) { + if ($row['tag_id'] == $tag_id) { + break; + } else { + $cnt ++; + } + } + $_id = $row['id']; + if ($cnt == count($tag_ids)) { + // delete row with (topic_id, tag_ids) + $queryDelete = "DELETE FROM topic_tag_relation WHERE id=".$_id; + $resultDelete = mysql_query($queryDelete); + if (!$resultDelete) { + echo json_encode("error when delete from topic_tag_relation"); + } + } + } + + + + /* +§ $query = "SELECT * FROM topic_tag_relation"; $result = mysql_query($query); if (!$result) { echo json_encode("error when select from topic_tag_relation"); @@ -616,6 +728,7 @@ array_push($topic_tag, array('tag_id'=>$row['tag_id'], 'topic_id'=>$row['topic_id'])); } + foreach ($topic_tag as $value) { $flag = false; foreach ($tag_ids as $tag_id) { @@ -639,6 +752,7 @@ } } } + */ } diff -r 04db1dd9d10d -r c805470cefee develop/views/Extractapp/configtagsintopic.php --- a/develop/views/Extractapp/configtagsintopic.php Mon Feb 23 14:34:43 2015 +0100 +++ b/develop/views/Extractapp/configtagsintopic.php Tue Feb 24 16:09:59 2015 +0100 @@ -3,6 +3,8 @@ $taglistArray = $viewmodel['taglistArray']; $topic = $viewmodel['topic']; $topic_name = $viewmodel['topic_name']; +$tag_intopic = $viewmodel['tag_intopic']; +$tag_others = $viewmodel['tag_others']; ?> diff -r 04db1dd9d10d -r c805470cefee develop/views/Extractapp/edittaglist.php --- a/develop/views/Extractapp/edittaglist.php Mon Feb 23 14:34:43 2015 +0100 +++ b/develop/views/Extractapp/edittaglist.php Tue Feb 24 16:09:59 2015 +0100 @@ -2,6 +2,8 @@ // --- initialize --- $taglistArray = $viewmodel['taglistArray']; $topic_id = $viewmodel['topic_id']; +$largestId = $viewmodel['largest_id']; +var_dump($largestId); ?> @@ -228,12 +230,10 @@ console.log("error when newTag"); }, success: function (e) { - alert("Saved!"); document.location.reload(true); } }).done(function(result) { - }); } @@ -267,7 +267,6 @@ document.location.reload(true); } }).done(function(result) { - }); } diff -r 04db1dd9d10d -r c805470cefee develop/views/Extractapp/taggingtext.php --- a/develop/views/Extractapp/taggingtext.php Mon Feb 23 14:34:43 2015 +0100 +++ b/develop/views/Extractapp/taggingtext.php Tue Feb 24 16:09:59 2015 +0100 @@ -84,22 +84,42 @@ ?> $(document).ready(function(){ + + // --- for sidebar--- //run once - /* no need, fixed sidebar var el=$('#follow-scroll'); var originalelpos=el.offset().top; // take it where it originally is on the page - */ + //run on scroll - /* $(window).scroll(function(){ var el = $('#follow-scroll'); // important! (local) var elpos = el.offset().top; // take current situation var windowpos = $(window).scrollTop(); var finaldestination = windowpos+originalelpos; - el.stop().animate({'top':finaldestination},500); + //el.stop().animate({'top':finaldestination},500); + el.stop().animate({'top':finaldestination},0); }); - */ + + //--- for popups --- + //run once + var el=$('#popups'); + var originalelpos=el.offset().top; // take it where it originally is on the page + + //run on scroll + $(window).scroll(function(){ + var el = $('#popups'); // important! (local) + var elpos = el.offset().top; // take current situation + var windowpos = $(window).scrollTop(); + var finaldestination = windowpos+originalelpos; + //el.stop().animate({'top':finaldestination},500); + el.stop().animate({'top':finaldestination},0); + }); + + + + + // Popup choosing topic if first time to this section. without branchId var info = JSON.parse(''); @@ -230,6 +250,115 @@ }); +// === for exporttable.php === +function exportTable( range, container ) { + //MsgBox("enter function"); + var form = document.createElement("form"); + form.setAttribute("method", "post"); + form.setAttribute("action", "./ExportTable"); + form.setAttribute("target", "_blank"); + + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("name", "content"); + hiddenField.setAttribute("value", container.innerHTML); + form.appendChild(hiddenField); + + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("name", "sectionid"); + hiddenField.setAttribute("value", ""); + form.appendChild(hiddenField); + + var hiddenField2 = document.createElement("input"); + hiddenField2.setAttribute("name", "topic"); + hiddenField2.setAttribute("value", topic_id); + form.appendChild(hiddenField2); + + if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { + document.body.appendChild(form); + form.submit(); + } else { + form.submit(); // works under IE and Chrome, but not FF + } +} + +function exportPage(topic_id) { + var startPage = $('#exportPageStart').val(); + var endPage = $('#exportPageEnd').val(); + + var el = document.getElementById("editable-area"); + var str="" + el.innerHTML; + + var regexText="【]*?)>"+startPage+"】(.*?)【]*?)>"+endPage+"】"; + + var form = document.createElement("form"); + form.setAttribute("method", "post"); + form.setAttribute("action", "./ExportTable"); + form.setAttribute("target", "_blank"); + + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("name", "content"); + hiddenField.setAttribute("value", str.match(new RegExp(regexText, "g"))); + form.appendChild(hiddenField); + + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("name", "topic"); + hiddenField.setAttribute("value", topic_id); + form.appendChild(hiddenField); + + var section_id = JSON.parse(''); + console.log("section_id: "+section_id+", topic_id: "+topic_id); + + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("name", "sectionId"); + hiddenField.setAttribute("value", section_id); + form.appendChild(hiddenField); + + + if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { + document.body.appendChild(form); + form.submit(); + } else { + form.submit(); // works under IE and Chrome, but not FF + } +} + +function exportAll(topic_id) { + var el = document.getElementById("editable-area"); + var str= "" + el.innerHTML; + var form = document.createElement("form"); + form.setAttribute("method", "post"); + //form.setAttribute("action", "exportTable.php"); + form.setAttribute("action", "./ExportTable");//+section_id); // hand to controller + form.setAttribute("target", "_blank"); + + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("name", "content"); + hiddenField.setAttribute("value", str); + form.appendChild(hiddenField); + + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("name", "topic"); + hiddenField.setAttribute("value", topic_id); + form.appendChild(hiddenField); + + var section_id = JSON.parse(''); + console.log("section_id: "+section_id+", topic_id: "+topic_id); + + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("name", "sectionId"); + hiddenField.setAttribute("value", section_id); + form.appendChild(hiddenField); + + if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { + document.body.appendChild(form); + form.submit(); + } else { + form.submit(); // works under IE and Chrome, but not FF + } + + +} +// =========== function replaceSmartRegex() { saveUndoText(); @@ -272,12 +401,14 @@ function saveTextToLGService() { var info = JSON.parse(''); - + var topic_id = JSON.parse(''); // if this is a new branch, ask for label if (info['branch_id'] == 0) { + var cnt = 0; var label = prompt("Please enter your label for this new branch", "label for section "+info['section_id']); - while (label == null) { + while (label == null && cnt <= 3) { + cnt ++; label = prompt("Please enter your label for this new branch (not empty)", "label for section "+info['section_id']); } }; @@ -328,6 +459,10 @@ hiddenField.setAttribute("value", text); form.appendChild(hiddenField); + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("name", "topic_id"); + hiddenField.setAttribute("value", topic_id); + form.appendChild(hiddenField); if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { document.body.appendChild(form); @@ -479,23 +614,23 @@ }); -// init for popover used in bootstrap -$(function () { - $('[data-toggle="popover"]').popover() -}) - - + -
-
-
-

-
+ +

+ + + + + + - +
+
+
+
-
- - -
-
-
-
Config Topic:
-
current topic is - -
-
-
+ +
+ +
+
Config Topic:
+
current topic is + +
+
+
-
-
Replace By Smart Regex©:
-

-
- Range: to
-
-
- - -
- -
+
+
Replace By Smart Regex©:
+

+
+ Range: to
+
+
+ + +
+ +
+ +
+
Tag by rule:
+
+
+ + + +
-
-
Tag by rule:
-
-
- - - -
- -
-
Edit:
-
- - -
-
-
-
- -
-
+
+
Edit:
+
+ + + +
+
+
+ +
+
+ +
+
Export:
+ Page: to
+
+
+
-
-
Export:
- Page: to
-
-
-
- -
-
Replace By Regex:
- Range: to
- Regex:
- Replace:
- -
- -
-
- -
-
- -
-
+
+
Replace By Regex:
+ Range: to
+ Regex:
+ Replace:
+ +
+ + +
+ + diff -r 04db1dd9d10d -r c805470cefee develop/views/maintemplate.php --- a/develop/views/maintemplate.php Mon Feb 23 14:34:43 2015 +0100 +++ b/develop/views/maintemplate.php Tue Feb 24 16:09:59 2015 +0100 @@ -12,12 +12,13 @@ +