Mercurial > hg > extraction-interface
changeset 9:584b1623e9ef
TOC correction list page updated
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 09 Feb 2015 18:59:24 +0100 |
parents | da10158c6d0a |
children | 54a235d43694 |
files | develop/models/extractapp.php develop/views/Extractapp/taggingtext.php interface/check_sections.php |
diffstat | 3 files changed, 116 insertions(+), 54 deletions(-) [+] |
line wrap: on
line diff
--- a/develop/models/extractapp.php Mon Feb 09 12:28:09 2015 +0100 +++ b/develop/models/extractapp.php Mon Feb 09 18:59:24 2015 +0100 @@ -25,6 +25,9 @@ $stringInput = $this->GetSectionContent(); $taglistArray = $this->GetTaglistArray(); + // test for GetTaglistByTopicID: + // $taglistArray = $this->GetTaglistByTopicID(1); + $wordlistArray = $this->GetWordlistArray(); @@ -231,6 +234,38 @@ } } + + + // TODO: get taglist by choosen topic + private function GetTaglistByTopicID($topic_id) { + $taglistArray = ""; + + $query = "SELECT * FROM topic_tag_relation WHERE topic_id=".$topic_id; + $result = mysql_query($query); + if (!$result) { + return json_encode("Failed during selecting topics table."); + } + + while ($row = mysql_fetch_assoc($result)) { + $tag_id = $row['tag_id']; + $query = "SELECT * FROM taglist WHERE id=".$tag_id; + $tag_result = mysql_query($query); + if ($tag_result) { + return json_encode("Failed during selecting taglist table."); + } + $row = mysql_fetch_assoc($tag_result)); + $taglistArray[] = array( $row['id'], $row['name'], $row['tag'], $row['color'] ); + // array_push($taglistArray, array( $row['id'], $row['name'], $row['tag'], $row['color'] )); + } + + + return $taglistArray; + + + + + + } // =========================== // === for manage wordlist ===
--- a/develop/views/Extractapp/taggingtext.php Mon Feb 09 12:28:09 2015 +0100 +++ b/develop/views/Extractapp/taggingtext.php Mon Feb 09 18:59:24 2015 +0100 @@ -5,6 +5,9 @@ $taglistArray = $viewmodel['taglistArray']; $section_id = $viewmodel['section_id']; + +var_dump($taglistArray); + ?> <html> @@ -136,6 +139,7 @@ newdiv.innerHTML += "<input id=\"RemoveTitletagName\" value=\"\"></br>"; newdiv.innerHTML += "<button onclick=\"removeTagTitle( range, container )\">Remove</button></br>"; } else { + // for pop up window on edit-area for tag list newdiv.innerHTML = "Tag: "+String(selection)+"<br>"; newdiv.innerHTML += "<button accesskey=\"2\" onclick=\"tagwithtitle( range, '"+String(selection)+"' )\">Tag As Title</button></br>"; @@ -223,6 +227,7 @@ $(document).on("change", '#smartRegexPopUpSelectWord', function (e) { + <?php foreach ( $wordlistArray as $wordlistValue ) { echo "if ( $('#smartRegexPopUpSelectWord').val() == \"".$wordlistValue[0]."\") {";
--- a/interface/check_sections.php Mon Feb 09 12:28:09 2015 +0100 +++ b/interface/check_sections.php Mon Feb 09 18:59:24 2015 +0100 @@ -22,13 +22,26 @@ case 'UpdateTOCstatus': UpdateTOCstatus($_POST['id'],$_POST['status']); break; - + case 'UpdateTOCcomments': + UpdateTOCcomments($_POST['id'],$_POST['notes']); + break; default: # code... break; } } +function UpdateTOCcomments($id, $notes) { + $query = "UPDATE books SET comments='".$notes."' WHERE id='".$id."'"; + + $result = mysql_query($query); + if (!$result){ + echo mysql_error(); + echo ("Failed during updating books table."); + } + +} + function UpdateTOCstatus($id, $status) { $query = "UPDATE books SET toc_correction='".$status."' WHERE id='".$id."'"; @@ -94,10 +107,8 @@ // sorting by the $sort_by parameter function checkSections_sort_by($sort_by){ switch ($sort_by) { - - case 'time': - $query="(SELECT name AS book_name,level1,level2,period,dynasty,start_year,id, toc_correction from books ORDER BY start_year)"; + $query="(SELECT name AS book_name,level1,level2,period,dynasty,start_year,id, toc_correction, comments from books ORDER BY start_year)"; $result = mysql_query($query); if (!$result){ echo ("Failed during selecting books table."); @@ -108,7 +119,10 @@ echo "<form autocomplete='off'>"; echo "<table>"; echo "<tr>"; - echo "<td class='bookName'>book name<td class='level1'>level1<td class='level2'>level2 <td class='period'>period<td class='dynasty'>dynasty<td class='start_year'>start_year<td class='last_editor'>last_editor<td class='edit_time'>edit_time"; + echo "<td class='bookName'>book name<td class='level1'>level1<td class='level2'>level2 + <td class='period'>period<td class='dynasty'>dynasty<td class='start_year'>start_year + <td class='last_editor'>last_editor<td class='level1'>edit_time + <td> <td> <td> Some notes for the book (optional)"; while ($row = mysql_fetch_assoc($result)) { $str="<tr>"; $str.="<td>".$row['book_name']; @@ -132,25 +146,21 @@ //$str.="<td> <input type='radio' name='books'".$row['id']." value='no'/> NotFinished"; switch ($row['toc_correction']) { case '0': - $str.="<td> <input type='radio' name='".$id."' value='0' onClick='toc_status(this)' checked/> Not Finished"; - $str.="<td> <input type='radio' name='".$id."' value='1' onClick='toc_status(this)'/> Works-in-progress"; - $str.="<td> <input type='radio' name='".$id."' value='2' onClick='toc_status(this)' /> Finished"; + $str.="<td> <input type='checkbox' name='".$id."' onchange='toc_status(this)' /> Finished"; break; case '1': - $str.="<td> <input type='radio' name='".$id."' value='0' onClick='toc_status(this)'/> Not Finished"; - $str.="<td> <input type='radio' name='".$id."' value='1' onClick='toc_status(this)' checked/> Works-in-progress"; - $str.="<td> <input type='radio' name='".$id."' value='2' onClick='toc_status(this)'/> Finished"; + $str.="<td> <input type='checkbox' name='".$id."' onchange='toc_status(this)' checked='true' /> Finished"; break; - case '2': - $str.="<td> <input type='radio' name='".$id."' value='0' onClick='toc_status(this)'/> Not Finished"; - $str.="<td> <input type='radio' name='".$id."' value='1' onClick='toc_status(this)'/> Works-in-progress"; - $str.="<td> <input type='radio' name='".$id."' value='2' onClick='toc_status(this)' checked/> Finished"; - break; - default: break; } - + // comments for book + $comments = $row['comments']; + if ($comments != "") { + $str.="<td> <textarea rows='1' cols='30' name='".$id."' maxlength='100' onchange='toc_comments(this)'>".$comments."</textarea>"; + } else { + $str.="<td> <textarea rows='1' cols='30' name='".$id."' maxlength='100' onchange='toc_comments(this)'></textarea>"; + } echo $str; } echo "</table>"; @@ -197,47 +207,59 @@ <script type="text/javascript"> - + function toc_status(t) { var id = t.name; - var val = t.value; - switch(val) { - case '0': - $.ajax({ - url : './check_sections.php', - async : false, - type : 'POST', - data : 'func=UpdateTOCstatus'+'&id='+id+'&status='+val - }).done(function(result) { - alert('You update the status of book to "Not Finished"!'); - }); + var val; + + if (t.checked) { + val = '1'; + } else { + val = '0'; + } - break; - case '1': - $.ajax({ - url : './check_sections.php', - async : false, - type : 'POST', - data : 'func=UpdateTOCstatus'+'&id='+id+'&status='+val - }).done(function(result) { - alert('You update the status of book to "Works-in-progress"!'); - }); + $.ajax({ + url : './check_sections.php', + async : false, + type : 'POST', + data : 'func=UpdateTOCstatus'+'&id='+id+'&status='+val, + complete: function(){ + switch (val){ + case '0': + alert('You update the status of book to "Not Finished"!'); + break; + case '1': + alert('You update the status of book to "Finished"!'); + break; + } + + }, + error:function() { + console.log("error to update toc status"); + alert('You have NOT updated the status of book. If this issue remains, please contact us. Thanks.'); + } + }); - break; - case '2': - $.ajax({ - url : './check_sections.php', - async : false, - type : 'POST', - data : 'func=UpdateTOCstatus'+'&id='+id+'&status='+val - }).done(function(result) { - alert('You update the status of book to "Finished"!'); - }); + } + + function toc_comments(t) { + console.log(t.value); + var text = t.value; + var id = t.name; - break; - default: - break; - } + $.ajax({ + url: './check_sections.php', + async : false, + type: 'POST', + data: 'func=UpdateTOCcomments'+'&id='+id+'¬es='+text, + complete: function(){ + console.log('You update the comments of book!'); + }, + error:function() { + console.log("error to update toc comments"); + alert('You have NOT updated the status of book. If this issue remains, please contact us. Thanks.'); + } + }); }