Mercurial > hg > extraction-interface
changeset 62:3fb9e3884401 extractapp
New: insert selected wordlist into textarea at cursor position when editing regex
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 31 Mar 2015 14:55:58 +0200 |
parents | c6fa7f83c5bf |
children | 3395385476d1 |
files | css/taggingtext.css data/regex_files/test_regex.txt models/extractapp.php views/Extractapp/TaggingText.php views/maintemplate.php views/maintemplate_local.php |
diffstat | 6 files changed, 52 insertions(+), 77 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/css/taggingtext.css Tue Mar 31 14:55:58 2015 +0200 @@ -0,0 +1,25 @@ +.bg-danger{ + background-color: #FFD1D1; +} + +.bg-warning{ + background-color: #FFFF99; +} + +.bg-info{ + background-color: #E7F3FF; + +} + +.bg-default{ + background-color: #F4F4F4; + +} + +.info-board{ + margin:10 30 10 30; + max-width:1270; + height:70px; + overflow:scroll; + overflow-x:hidden; +} \ No newline at end of file
--- a/data/regex_files/test_regex.txt Tue Mar 31 12:34:57 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -<span class="span_product_name" id="regex_elem_1" regextext="[^○如>〈】]{1,2}[稻|麥|豆|瓜|竹|菜|魚]" regexreplace="product_name" style="border: 1px solid black; width: 100px;">物產 test</span><span class="span_null" id="regex_elem_3" regextext="asdf" regexreplace="null" style="border: 1px solid black; width: 100px;">wdf</span><span class="span_null" id="regex_elem_5" regextext="asasasas" regexreplace="null" style="border: 1px solid black; width: 100px;">vvvv234test</span><span class="span_null" id="regex_elem_6" regextext="○" regexreplace="null" style="border: 1px solid black; width: 100px;">QQQ空白</span><span class="span_product_name" id="regex_elem_8" regextext="dddd" regexreplace="product_name" style="border: 1px solid black; width: 100px;">v222</span><span class="span_shu" id="regex_elem_9" regextext="" regexreplace="shu" style="border: 1px solid black; width: 100px;">v</span><span class="span_othername" id="regex_elem_10" regextext="○" regexreplace="othername" style="border: 1px solid black; width: 100px;">QQQ空白</span><span class="span_null" id="regex_elem_13" regextext="asdf" regexreplace="null" style="border: 1px solid black; width: 100px;">wdf</span><span class="span_othername" id="regex_elem_14" regextext="asdf" regexreplace="othername" style="border: 1px solid black; width: 100px;">w</span> \ No newline at end of file
--- a/models/extractapp.php Tue Mar 31 12:34:57 2015 +0200 +++ b/models/extractapp.php Tue Mar 31 14:55:58 2015 +0200 @@ -264,13 +264,6 @@ $this->messages['info'] .= ", file id: ".$this->file_id; $this->messages['info'] .= "<br>"; - /* - $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; - $this->messages .= ", book_id=".$this->book_id.", book_name=".$this->book_name.", section_name=".$this->section_name; - $this->messages .= ", current_fileId=".$this->current_fileId."<br>"; - */ $data['messages'] = $this->messages; @@ -303,32 +296,6 @@ } public function UpdateInfoByResponseFromLGService($response) { - - /* - $response_file = $response["file"]; - $response_branch = $response["branch"]; - - - $status = (string)$response["status"]; - - if ((string)$response["status"] == "error") { - $response_currentFile = $response["currentFile"]; - - $this->current_fileId = (string)$response_currentFile['id']; - $this->messages .= "saving does not success! ".(string)$response["message"]; - - - } else { - - $this->messages .= "saving success."; - var_dump((string)$response_file["id"]); - - $this->file_id = (string)$response_file["id"]; - $this->branch_id = (string)$response_branch["id"]; - - } - */ - $response_file = $response["file"]; $response_branch = $response["branch"]; @@ -336,7 +303,6 @@ $status = (string)$response["status"]; if ($status == "ok") { $this->messages['info'] .= "[Info] Saving success. <br>"; - //$this->messages .= "Saving success."; $this->file_id = (string)$response_file["id"]; $this->branch_id = (string)$response_branch["id"]; @@ -345,12 +311,7 @@ $this->messages['error'] .= "[Error] Saving Failed! ".(string)$response["message"]."<br>"; $this->messages['warning'] .= "[Warning] Please check branch ".$this->branch_id." in LGService, and modify from the latest version. <br>"; - /* - $this->messages .= "Saving Failed! ".(string)$response["message"]."<br>"; - $this->messages .= "Please check branch ".$this->branch_id." in LGService, and modify from the latest version. <br>"; - */ $response_currentFile = $response["currentFile"]; - //$this->current_fileId = $response["currentFileId"]; $this->current_fileId = (string)$response_currentFile["id"]; }
--- a/views/Extractapp/TaggingText.php Tue Mar 31 12:34:57 2015 +0200 +++ b/views/Extractapp/TaggingText.php Tue Mar 31 14:55:58 2015 +0200 @@ -885,20 +885,27 @@ _postForContineTagging(form); - /* - if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { - document.body.appendChild(form); - form.submit(); - } else { - form.submit(); // works under IE and Chrome, but not FF - } - */ } $(document).on("change", '#smartRegexPopUpSelectWord', function (e) { + var wordlistArray = JSON.parse('<?php echo json_encode($wordlistArray) ?>'); + for (var i = 0; i < wordlistArray.length; i++) { + var wordlistValue = wordlistArray[i]; + if ($('#smartRegexPopUpSelectWord').val() == wordlistValue[0]) { + var textarea_text = $('#smartRegexPopUpText').val(); + // insert selected wordlist into textarea at cursor position + var cursorPosition = $('#smartRegexPopUpText').prop("selectionStart"); + // cut textarea_text by cursorPosition + var text_before_cursor = textarea_text.substring(0,cursorPosition); + var text_after_cursor = textarea_text.substring(cursorPosition, textarea_text.length); + $('#smartRegexPopUpText').val( text_before_cursor+" ["+wordlistValue[2]+"] "+text_after_cursor); + } + } + +/* <?php foreach ( $wordlistArray as $wordlistValue ) { echo "if ( $('#smartRegexPopUpSelectWord').val() == \"".$wordlistValue[0]."\") {"; @@ -906,6 +913,7 @@ echo "}"; } ?> +*/ }); @@ -915,14 +923,16 @@ <div id="dialog-form" title="config tags for topic" style="position:fixed; top: 30px; "> </div> - -<div class="" style="margin:10 30 10 30;max-width:1270;height:70px;overflow:scroll;overflow-x:hidden;"> - <p class="bg-danger" style=""> <?php echo $messages['error']; ?> </p> - <p class="bg-warning" style=""> <?php echo $messages['warning']; ?> - <button id="reloadTextButton" onclick="reloadText(<?php echo $default_topic_id; ?>)" class="btn btn-xs btn-default" style="display:none;">Load Latest Version</button> +<!-- +<div class="info-board" style="margin:10 30 10 30;max-width:1270;height:70px;overflow:scroll;overflow-x:hidden;"> +--> +<div class="info-board"> + <p class="bg-danger"> <?php echo $messages['error']; ?> </p> + <p class="bg-warning"> <?php echo $messages['warning']; ?> + <button id="reloadTextButton" onclick="reloadText(<?php echo $default_topic_id; ?>)" style="display:none;">Load Latest Version</button> </p> - <p class="bg-info" style=""> <?php echo $messages['info']; ?> </p> - <p class="bg-default" style=""> <?php echo $messages['debug']; ?> </p> + <p class="bg-info"> <?php echo $messages['info']; ?> </p> + <p class="bg-default"> <?php echo $messages['debug']; ?> </p> </div> <table width="1270" border="1" style="margin:10 30 10 30;"> @@ -988,9 +998,6 @@ <button onclick="smartRegexSave(<?php echo $default_topic_id; ?>)" style="height: 35px; width: 70px">Save</button> <button onclick="smartRegexLoad(<?php echo $default_topic_id; ?>)" style="height: 35px; width: 70px">Load</button> <button onclick="smartRegexEmpty()" style="height: 35px; width: 70px">Clear</button></br> - <!-- - <button id="example" type="button" class="btn btn-sm btn-default" data-toggle="popover">Load</button> - --> </fieldset> <fieldset> @@ -1016,9 +1023,6 @@ <button onclick="editText()" id="editTextId" style="height: 35px; width: 220px">Edit the text</button></br> </br> <button onclick="window.open('./EditWordlist')" style="height: 35px; width: 220px">Manage Word List</button></br> - <!-- - <button onclick="window.open('./EditTaglist')" style="height: 30px; width: 220px">Manage Tag List</button></br> - --> <button onclick="editTaglist(<?php echo $default_topic_id; ?>)" style="height: 35px; width: 220px">Manage Tag List</button></br> </fieldset>
--- a/views/maintemplate.php Tue Mar 31 12:34:57 2015 +0200 +++ b/views/maintemplate.php Tue Mar 31 14:55:58 2015 +0200 @@ -4,15 +4,8 @@ <script src="../js/jquery-1.10.2.min.js"></script> <script src="../js/jquery-ui.js"></script> <script src="../js/taggingtext.js"></script> +<link href="../css/taggingtext.css" rel="stylesheet"> -<!-- Bootstrap --> -<!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> -<!-- -<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> -<link href="../css/bootstrap.min.css" rel="stylesheet"> -<script src="../js/bootstrap.min.js"></script> -<script src="../js/bootstrap.js"></script> ---> </head> <body>
--- a/views/maintemplate_local.php Tue Mar 31 12:34:57 2015 +0200 +++ b/views/maintemplate_local.php Tue Mar 31 14:55:58 2015 +0200 @@ -4,15 +4,8 @@ <script src="../../js/jquery-1.10.2.min.js"></script> <script src="../../js/jquery-ui.js"></script> <script src="../../js/taggingtext.js"></script> +<link href="../../css/taggingtext.css" rel="stylesheet"> -<!-- Bootstrap --> -<!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> -<!-- -<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> -<link href="../../css/bootstrap.min.css" rel="stylesheet"> -<script src="../../js/bootstrap.min.js"></script> -<script src="../../js/bootstrap.js"></script> ---> </head> <body>