Mercurial > hg > LGToc
changeset 18:a15320882b30
modified version list area, make it more neat.
author | Calvin Yeh <cyeh@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 25 Sep 2017 14:23:20 +0200 |
parents | 2e6bf16b0be3 |
children | c0eccf597fcc |
files | check_sections_details.php css/check_sections.css |
diffstat | 2 files changed, 118 insertions(+), 92 deletions(-) [+] |
line wrap: on
line diff
--- a/check_sections_details.php Tue Mar 21 18:05:52 2017 +0100 +++ b/check_sections_details.php Mon Sep 25 14:23:20 2017 +0200 @@ -13,39 +13,46 @@ } $db_selected = mysql_select_db($mysql_database, $link_mysql); + if (!$db_selected) { die ('Can\'t use foo : ' . mysql_error()); } + function getBookInfo($bookId){ $query="SELECT * FROM books WHERE id=".$bookId; $result=mysql_query($query); $bookInfo=mysql_fetch_assoc($result); return $bookInfo; } + function printBookInfo($bookInfo){ - $str="<table>"; - $str.="<tr><td class='bookId'>book id - <td class='bookName'>book name - <td class='level1'>level1 - <td class='level2'>level2 - <td class='period'>period - <td class='bookId'>pages - <td class='bookId'>version - <td class='bookName'>editor - <td class='bookName'>date"; + + $str="<table class='bookInfo'><tr> + <th class='bookId'>book id</th> + <th class='bookName'>book name</th> + <th class='level1'>level1</th> + <th class='level2'>level2</th> + <th class='period'>period</th> + <th class='bookId'>pages</th> + <th class='bookId'>version</th> + <th class='bookName'>editor</th> + <th class='bookName'>date</th></tr>"; + $str.="<tr>"; $str.="<td>".$bookInfo['id']; - $str.="<td>".$bookInfo['name']; - $str.="<td>".$bookInfo['level1']; - $str.="<td>".$bookInfo['level2']; - $str.="<td>".$bookInfo['period']; - $str.="<td>".$bookInfo['line']; - $str.="<td>".$bookInfo['version']; - $str.="<td>".$bookInfo['editor']; - $str.="<td>".$bookInfo['date']; - $str.="</table>"; + $str.="</td><td>".$bookInfo['name']; + $str.="</td><td>".$bookInfo['level1']; + $str.="</td><td>".$bookInfo['level2']; + $str.="</td><td>".$bookInfo['period']; + $str.="</td><td>".$bookInfo['line']; + $str.="</td><td>".$bookInfo['version']; + $str.="</td><td>".$bookInfo['editor']; + $str.="</td><td>".$bookInfo['date']; + $str.="</td></tr></table>"; + echo $str; } + function printSectionArray($sectionArray,$missingPageArray){ $str="<div id='bookContainer'>"; echo $str; @@ -67,7 +74,7 @@ $i++; echo $str; } - + $str="<div class='entry level".$row['level']." ".$row['flag']." ".$row['deleted']."'>"; $str.="<div class='hiddenInfo'>"; $str.="<div class='id'>".$row['id']."</div>"; @@ -84,7 +91,7 @@ $str.="</div>";//end of page $str.="</div>"; //end of class entry echo $str; - + } if($i<sizeof($missingPageArray)){ $str="<div class='missingPage'>Missing pages: ".$missingPageArray[$i]['start_page']." - ".$missingPageArray[$i]['end_page']."</div>"; @@ -101,20 +108,34 @@ global $lgserver_url; $lg_url = $lgserver_url."rest/utils/getUser?sessionId=".$session_id; // url to get username from LGService //$lg_url = "http://localgazetteers-dev/LGServices/rest/utils/getUser?sessionId=".$session_id; // url to get username from LGService - $output = file_get_contents($lg_url); - $user_info = json_decode($output, true); - $current_editor = (string)$user_info['userName']; - - if ($current_editor == null || $current_editor == "" || strcmp($current_editor, "") === 0 || strcmp($user_info['status'], "ok") !== 0) { - // redirect to LGServices homepage - header("Location: "+$lgserver_url+"LGServices"); - //header('Location: http://localgazetteers/LGServices'); - } + $output = file_get_contents($lg_url); + $user_info = json_decode($output, true); + + if(strcmp($user_info['status'], "ok") === 0 && isset($user_info['userName'])){ + + $current_editor = (string)$user_info['userName']; + + if($current_editor == "" || strcmp($current_editor, "") === 0){ + + // redirect to LGServices homepage + header("Location: ".$lgserver_url); + + exit; + + } + } else { + + // redirect to LGServices homepage + header("Location: ".$lgserver_url); + + exit; + } } else { // test locally // redirect to LGServices homepage - header("Location: "+$lgserver_url+"LGServices"); + header("Location: ".$lgserver_url); + exit; } @@ -128,16 +149,9 @@ <link href="css/jquery-ui/jquery-ui.css" type="text/css" rel="stylesheet"/> <script src="js/jquery/1.6.2/jquery.min.js" type="text/javascript"></script> <script src="js/jquery/jquery-ui.js" type="text/javascript"></script> - - <link href="css/check_sections.css" type="text/css" rel="stylesheet"/> - <script src="js/check_sections_details.js" type="text/javascript"></script> - - <!-- - <link href="https://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" type="text/css" rel="stylesheet"/> - <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script> - <script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js" type="text/javascript"></script> - --> - <!--<script src="js/check_sections.js" charset="utf-8"></script>!--> + + <link href="css/check_sections.css?v=18" type="text/css" rel="stylesheet"/> + <script src="js/check_sections_details.js?v=18" type="text/javascript"></script> </head> <body> @@ -161,23 +175,15 @@ $missingPageArray=checkMissingPage($bookInfo,$info); ?> - <table> - <thead>Show editing records: - <button id="show_all">Show all</button> - <button id="close">Close</button> + <table id="history_table"> + <thead> + <button id="show_all" style="display:block;">Show history</button> + <button id="close" style="display:none;margin-bottom:10px;">Close</button> </thead> - <tbody> - <tr> - <td id="editor_th"></td> - <td id="date_th"></td> - </tr> - <tr> - <td><div id="editor"></div></td> - <td><div id="date"></div></td> - </tr> + <tbody id="history_body"> + </tbody> </table> - <div id="searchResults"> <?php $sectionArray=getSectionArray($bookId,$count,$info); @@ -192,9 +198,7 @@ <script> var version=<?php echo $version;?>; var session_id = "<?php echo $_GET['sessionId'];?>"; - </script> - <script type="text/javascript"> function setCurrentEditor() { // current_editor is gotten from LGService var current_editor = <?php echo json_encode($current_editor) ?>; @@ -206,74 +210,78 @@ } } - document.getElementById("show_all").onclick = function(){showAll()}; - function showAll() { - closeAll(); - document.getElementById("editor_th").innerHTML = "Editor(version)"; - document.getElementById("date_th").innerHTML = "Date/Time"; <?php - $editors = ""; - $editing_time = ""; $query_editor = "(SELECT editor, date, version from sections_versions WHERE books_id='".$bookId."' ORDER BY version DESC)"; $result = mysql_query($query_editor); - - while ($row = mysql_fetch_assoc($result)) { - $editor = $row['editor']; - $edit_time = $row['date']; - $version = $row['version']; - ?> - document.getElementById("editor").innerHTML += '<?php echo $editor; ?>' +'('+'<?php echo $version;?>' +')<br>'; - document.getElementById("date").innerHTML += '<?php echo $edit_time; ?>' + '<br>'; - <?php - - } + + while ($row = mysql_fetch_assoc($result)) { + $history[] = $row; + } + + $struct = array("data" => $history); + print "var histories=".json_encode($struct) .";"; + ?> + var tableData = '<tr><td>Editor</td><td>Version</td><td>Saved Time</td></tr>'; + + $.each(histories.data, function(index, data) { + tableData += '<tr><td>'+data.editor+'</td><td>'+data.version+'</td><td>'+data.date+'</td><</tr>'; + }); + + $('#history_body').html(tableData); + + document.getElementById("show_all").style.display = "none"; + document.getElementById("close").style.display = "block"; + } - document.getElementById("close").onclick = function(){closeAll()}; + document.getElementById("show_all").onclick = showAll; function closeAll() { - document.getElementById("editor_th").innerHTML = ""; - document.getElementById("date_th").innerHTML = ""; - document.getElementById("editor").innerHTML = ""; - document.getElementById("date").innerHTML = ""; + + $('#history_body').html(""); + + document.getElementById("show_all").style.display = "block"; + document.getElementById("close").style.display = "none"; } - + + document.getElementById("close").onclick = closeAll; + // --- timeout reminder --- var timeoutID; delayedAlert(); function delayedAlert() { - timeoutID = window.setTimeout(slowAlert, 3600*1000); + timeoutID = window.setTimeout(slowAlert, 1200*1000); } function slowAlert() { - if (confirm("Reminder: It's been 1 hour. Remember saving your work to prevent data lost. \n\nKeep working? \n(Press Cancel will turn off this reminder.)")) { - + if (confirm("Reminder: It's been 20 mins. Remember saving your work to prevent data lost. \n\nKeep working? \n(Press Cancel will turn off this reminder.)")) { + var lg_url = "<?php echo $lgserver_url?>" + "rest/utils/getUser?sessionId=" + session_id; $.post(lg_url, function(data) { console.log("renew session."); - + }).done(function(data){ console.log(data); console.log("login as: " + data['userName']); if (data['userName'] == "") { - alert("Error!! You have to login from LGService!"); + alert("Error!! You have to re-login from LGService!"); $("#loading").show(); } else { - timeoutID = window.setTimeout(slowAlert, 3600*1000); + timeoutID = window.setTimeout(slowAlert, 1200*1000); } }).fail(function(){ console.log("fail to renew session."); }); } - + } @@ -284,4 +292,3 @@ </body> </html> -
--- a/css/check_sections.css Tue Mar 21 18:05:52 2017 +0100 +++ b/css/check_sections.css Mon Sep 25 14:23:20 2017 +0200 @@ -42,6 +42,25 @@ #bookContainer td{ padding:10px; } + +table.bookInfo, +table.bookInfo tr, +table.bookInfo th, +table.bookInfo td, +table#history_table, +#history_body tr, +#history_body td { + border: 1px solid black; + border-collapse: collapse; +} + +table.bookInfo th, +table.bookInfo td, +#history_body td { + text-align: center; + padding: 5px; +} + table{ margin-bottom:20px; } @@ -85,7 +104,7 @@ } div.entry .page{ display:inline-block; - padding:0px; + padding:0px; } div.startPage{ display:inline-block; @@ -193,7 +212,7 @@ vertical-align:middle; } #configure{ - + } #configure input[type="checkbox"]{ margin-right:5px; @@ -217,7 +236,7 @@ #saveBook .editor{ display:block; margin:4px 0; -} +} #saveBook .save{ } .hovered{