Skip to content

Commit

Permalink
Table Search Commit
Browse files Browse the repository at this point in the history
Refer to changelog.md.
  • Loading branch information
chuushi committed Jan 27, 2016
1 parent ffa0c47 commit d739f61
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 24 deletions.
15 changes: 10 additions & 5 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
Changes:
================================================================================

v0.6.1 - January 26, 2016
v0.6.1 - January 27, 2016
-------------------------
- `conn.php`
- Searching by world alone is possible.
- Coordinate search has been fixed (if it was broken before).
- `index.php`
- Time, username, coordinate, and block terms can now be picked from the
results and placed directly into the search fields in a few clicks from the
result table!
- Table header color has been changed.
- Time, username, coordinate, and block terms can now be picked directly from
the results and placed directly into the search field in a few clicks!
- The four fields specified has a dropdown menu that allows such.
- You can now look at what was written on the sign!
- Block and user fields will get some modification.
- You can now lookup what was written on the sign!
- This feature is valid only if the blocks "minecraft:wall_sign" or
"minecraft:standing_sign" has a valid sign history. Signs generated using,
for example, worldedit might not come out correctly. (untested)
- World field has been added.


Expand Down
12 changes: 8 additions & 4 deletions conn.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
4 - Values from cachectrl Not Found
7 - No status code
*/

// TODO: Figure out why coordinate search is not working.
error_reporting(-1);
ini_set('display_errors', 'On');

Expand Down Expand Up @@ -67,11 +67,15 @@ function _shutdown() {
}
else {
foreach ($q as $key => $value) {
if (in_array($key,["a","b","e","u","xyz","xyz2"],true)) {if((is_array($value)&&!in_array("",$value,true))||(is_string($value)&&($value!==""))) $$key = (is_array($value))?$value:explode(',', $value);}
if (in_array($key,["a","b","e","u","xyz"],true)) {if((is_array($value)&&!in_array("",$value,true))||(is_string($value)&&($value!==""))) $$key = (is_array($value))?$value:explode(',', $value);}
elseif (in_array($key,["r","t","keyword","wid","rollback"],true)) {if($value!=="") $$key = $value;}
elseif (in_array($key,["unixtime","asendt"],true)) {if($value!=="") $$key = true;}
elseif ($key == "xyz2") {
if((is_array($value)&&!in_array("",$value,true))||(is_string($value)&&($value!=="")))$$key = (is_array($value))?$value:explode(',', $value);
elseif(isset($value[0])&&$value[0]!=="") $r = $value[0];
}
}

if(isset($xyz2) && !isset($xyz2[2])) $r = $xyz2[0];

// Defaults if the query or parts of the query is empty:
if(empty($a)) $a = ["block"];
Expand All @@ -87,7 +91,7 @@ function _shutdown() {
$z = [$xyz[2]-$r,$xyz[2]+$r];
$coord = "(x BETWEEN ".$x[0]." AND ".$x[1].") AND (y BETWEEN ".$y[0]." AND ".$y[1].") AND (z BETWEEN ".$z[0]." AND ".$z[1].")";
}
elseif(isset($xyz) && isset($xys2)) {
elseif(isset($xyz) && isset($xyz2)) {
$x = [min($xyz[0],$xyz2[0]),max($xyz[0],$xyz2[0])];
$y = [min($xyz[1],$xyz2[1]),max($xyz[1],$xyz2[1])];
$z = [min($xyz[2],$xyz2[2]),max($xyz[2],$xyz2[2])];
Expand Down
91 changes: 76 additions & 15 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,22 +176,22 @@
*/

// Radius/Corners toggle
function radius() {
if($("#corner1").text() == "Corner 1") {
function radius(boolCorner) {
if(($("#corner1").text() == "Center")||boolCorner) {
$("#corner1").text("Corner 1");
$("#corner2").text("Corner 2");
$("#c2").addClass("input-group");
$(".c2").show();
$("#x2").attr("placeholder","x");
}
else {
$("#corner1").text("Center");
$("#corner2").text("Radius");
$("#c2").removeClass("input-group");
$(".c2").val("");
$(".c2").hide();
$("#x2").attr("placeholder","Radius");
}
else {
$("#corner1").text("Corner 1");
$("#corner2").text("Corner 2");
$("#c2").addClass("input-group");
$(".c2").show();
$("#x2").attr("placeholder","x");
}
}

// Main Submit
Expand Down Expand Up @@ -268,13 +268,74 @@ function if_exist(value,if_not) {
$("#output").on("show.bs.dropdown",".rDrop",function(){
if(!$(this).hasClass("dropdown")) {
$(this).addClass("dropdown");
($(this).hasClass("t"))?$(this).append('<div class="dropdown-menu"><span class="dropdown-header">Date/Time</span><span class="dropdown-item cPointer tAsc">Search ascending</span><span class="dropdown-item cPointer tDesc">Search descending</span></div>')
:($(this).hasClass("u"))?$(this).append('<div class="dropdown-menu"><span class="dropdown-header">User</span><span class="dropdown-item cPointer uSch">Search block</span><span class="dropdown-item cPointer uESch">Exclusive Search</span></div>')
:($(this).hasClass("c"))?$(this).append('<div class="dropdown-menu"><span class="dropdown-header">Coordinates</span><span class="dropdown-item cPointer cFl1">Center/Corner 1</span><span class="dropdown-item cPointer cFl2">Corner 2</span></div>')
:($(this).hasClass("b"))?$(this).append('<div class="dropdown-menu"><span class="dropdown-header">Block</span><span class="dropdown-item cPointer bSch">Search block</span><span class="dropdown-item cPointer bESch">Exclusive Search</span></div>')
($(this).hasClass("t"))?$(this).append('<div class="dropdown-menu"><span class="dropdown-header">Date/Time</span><span class="dropdown-item cPointer t Asc">Search ascending</span><span class="dropdown-item cPointer t Desc">Search descending</span></div>')
:($(this).hasClass("u"))?$(this).append('<div class="dropdown-menu"><span class="dropdown-header">User</span><span class="dropdown-item cPointer u Sch">Search user</span><span class="dropdown-item cPointer u ESch">Exclusive Search</span></div>')
:($(this).hasClass("c"))?$(this).append('<div class="dropdown-menu"><span class="dropdown-header">Coordinates</span><span class="dropdown-item cPointer c Fl1">Center/Corner 1</span><span class="dropdown-item cPointer c Fl2">Corner 2</span></div>')
:($(this).hasClass("b"))?$(this).append('<div class="dropdown-menu"><span class="dropdown-header">Block</span><span class="dropdown-item cPointer b Sch">Search block</span><span class="dropdown-item cPointer b ESch">Exclusive Search</span></div>')
:$(this).append('<div class="dropdown-menu"><span class="dropdown-header">wat</span></div>');
}
});
// Dropdown Menu Listener
$("#output").on("click",".rDrop .cPointer",function(){
var $par = $(this).parent();
if($(this).hasClass("t")) {
console.log($par.parent().attr("data-time"));
var value = moment($par.parent().attr("data-time"),["x"]).format("<?=$dateFormat.' '.$timeFormat?>");
if($(this).hasClass("Asc")) {
$("#trv").prop("checked",true);
$("[for=trv]").addClass("active");
$("#date").val(value);
}
else if($(this).hasClass("Desc")) {
$("#trv").prop("checked",false);
$("[for=trv]").removeClass("active");
$("#date").val(value);
}
}
if($(this).hasClass("u")) {
var value = $par.prev().text();
if($(this).hasClass("Sch")) {
$("#eus").prop("checked",false);
$("[for=eus]").removeClass("active");
$("#usr").val(value);
}
else if($(this).hasClass("ESch")) {
$("#eus").prop("checked",true);
$("[for=eus]").addClass("active");
$("#usr").val(value);
}
}
if($(this).hasClass("c")) {
var vals = $par.prev().text().split(" ");
if($(this).hasClass("Fl1")) {
$("#x1").val(vals[0]);
$("#y1").val(vals[1]);
$("#z1").val(vals[2]);
$("#wid").val(vals[3]);
}
else if($(this).hasClass("Fl2")) {
radius(true);
$("#x2").val(vals[0]);
$("#y2").val(vals[1]);
$("#z2").val(vals[2]);
$("#wid").val(vals[3]);
}
}
if($(this).hasClass("b")) {
var value = $par.parent().attr("data-block");
if($(this).hasClass("Sch")) {
$("#ebl").prop("checked",false);
$("[for=ebl]").removeClass("active");
$("#blk").val(value);
}
else if($(this).hasClass("ESch")) {
$("#ebl").prop("checked",true);
$("[for=ebl]").addClass("active");
$("#blk").val(value);
}
}
});

// Displaying sign data function
$("#output").on("click.collapse-next.data-api",".collapse-toggle",function(){$(this).next().collapse("toggle")});

Expand Down Expand Up @@ -348,7 +409,7 @@ function phraseReturn(obj,more) {
if (r[i]['rolled_back'] == '1') o += ' class="table-success"';

// Time, Username, Action
o += '><td class="rDrop t" title="'+moment(r[i]["time"]).format("<?=$dateFormat?>")+'">'+spanDToggle+moment(r[i]["time"]).format("<?=$timeFormat?>")+'</span></td><td class="rDrop u">'+spanDToggle+r[i]['user']+'</span></td><td>'+r[i]['table']+'</td><td';
o += '><td class="rDrop t" title="'+moment(r[i]["time"]).format("<?=$dateFormat?>")+'" data-time="'+r[i]["time"]+'">'+spanDToggle+moment(r[i]["time"]).format("<?=$timeFormat?>")+'</span></td><td class="rDrop u">'+spanDToggle+r[i]['user']+'</span></td><td>'+r[i]['table']+'</td><td';
$lastDataTime = r[i]["time"];
switch(r[i]["table"]) {
case "click":
Expand All @@ -365,7 +426,7 @@ function phraseReturn(obj,more) {
// Coordinates, Type:Data, Amount, Rollback
o += ' class="rDrop c">'+spanDToggle+r[i]['x']+' '+r[i]['y']+' '+r[i]['z']+' '+r[i]['wid']+"</span></td><td"+((r[i]["table"] == "session")?">"
:((r[i]["signdata"])?' class="rColl">'+spanSign
:' class="rDrop b">'+spanDToggle)+r[i]['type']+':'+r[i]['data']+"</span>"+((r[i]["signdata"])? '<div class="rDrop b collapse">'+divSignData(r[i]["signdata"])+"<br>"+spanDToggle+r[i]['type']+':'+r[i]['data']+"</span></div>"
:' class="rDrop b" data-block="'+r[i]["type"]+'">'+spanDToggle)+r[i]['type']+':'+r[i]['data']+"</span>"+((r[i]["signdata"])? '<div class="rDrop b collapse" data-block="'+r[i]["type"]+'">'+divSignData(r[i]["signdata"])+"<br>"+spanDToggle+r[i]['type']+':'+r[i]['data']+"</span></div>"
:""))+'</td><td'+((r[i]['action'] == "0")?' class="table-warning">-'
:((r[i]['action'] == "1")?' class="table-info">+'
:'>'))+((r[i]['table'] == "container") ? r[i]['amount']
Expand Down

0 comments on commit d739f61

Please sign in to comment.