From 7d72c7c5936a94576f79657d7845a61042022ee9 Mon Sep 17 00:00:00 2001 From: Sebastien Plante Date: Thu, 12 Sep 2019 17:15:11 -0400 Subject: [PATCH] Prettier Formatting --- class.php | 394 +++++++++++++++++++++++++-------------------- index.php | 4 +- page.php | 179 ++++++++++++-------- post.php | 14 +- style.css | 181 ++++++++++----------- updatethumbnail.js | 66 ++++---- 6 files changed, 451 insertions(+), 387 deletions(-) diff --git a/class.php b/class.php index 1586bab..8846d1b 100644 --- a/class.php +++ b/class.php @@ -1,206 +1,242 @@ dbconf(); + // Create connection + $conn = new mysqli($db["servername"], $db["username"], $db["password"], $db["dbname"]); + $conn->set_charset("utf8"); + // Check connection + if ($conn->connect_error) { + die("Connection failed: " . $conn->connect_error); } - function mysql_conn($sql=null) { + if ($sql == null) { + echo "Error: No SQL Request?"; + $conn->close(); + return null; + } else { + $return = $conn->query($sql); + $conn->close(); + return $return; + } + } - $db = $this->dbconf(); + function gameTimeDetails($gameid) + { + $result = $this->mysql_conn("SELECT * FROM game_time WHERE game_id = '" . $gameid . "' ORDER BY game_start DESC;"); + if ($result->num_rows > 0) { + $i = 0; + echo '
'; + echo '
Start
End
Time Played
'; + while ($row = $result->fetch_assoc()) { + echo '
'; + $i++; + echo '
' . $this->secondsToDate($row["game_start"]) . '
'; - // Create connection - $conn = new mysqli($db["servername"], $db["username"], $db["password"], $db["dbname"]); - $conn->set_charset("utf8"); - // Check connection - if ($conn->connect_error) { - die("Connection failed: " . $conn->connect_error); - } + echo '
'; + if ($row["game_end"] == "") { + echo "now playing"; + } else { + echo $this->secondsToDate($row["game_end"]); + } + echo '
'; - if ($sql == null) { - echo "Error: No SQL Request?"; - $conn->close(); - return null; - } else { - $return = $conn->query($sql); - $conn->close(); - return $return; - } - } + echo '
'; + if ($row["game_end"] == "") { + echo $this->playtime((round(microtime(true) * 1000) - $row["game_start"]) / 1000, true); + } else { + echo $this->playtime(($row["game_end"] - $row["game_start"]) / 1000, true); + } + echo '
'; - function gameTimeDetails($gameid) { - $result = $this->mysql_conn("SELECT * FROM game_time WHERE game_id = '". $gameid ."' ORDER BY game_start DESC;"); - if ($result->num_rows > 0) { - $i=0; - echo '
'; - echo '
Start
End
Time Played
'; - while ($row = $result->fetch_assoc()) { - echo '
'; - $i++; - echo '
'. $this->secondsToDate($row["game_start"]) .'
'; + echo '
'; + } + echo '
' . + $i . + ' sessions
'; + echo '
'; + echo '
'; + } + } - echo '
'; - if ($row["game_end"] == "") { - echo "now playing"; - } else { - echo $this->secondsToDate($row["game_end"]); - } - echo '
'; + function playtime($seconds, $text = false) + { + $playtime = null; + $label = null; - echo '
'; - if ($row["game_end"] == "") { - echo $this->playtime(((round(microtime(true) * 1000)-$row["game_start"])/1000),true); - } else { - echo $this->playtime((($row["game_end"]-$row["game_start"])/1000),true); - } - echo '
'; + if ($seconds < 60) { + if ($text == true) { + $label = "second"; + } + if ($seconds > 1) { + $label .= "s"; + } + $playtime = $seconds; + } elseif ($seconds / 60 < 60) { + if ($text == true) { + $label = "minute"; + } + if ($seconds / 60 > 1) { + $label .= "s"; + } + $playtime = round($seconds / 60, 2); + } else { + if ($text == true) { + $label = "hour"; + } + if ($seconds / 60 / 60 > 1) { + $label .= "s"; + } + $playtime = round($seconds / 60 / 60, 2); + } - echo '
'; - } - echo '
'. $i .' sessions
'; - echo '
'; - echo '
'; - } - } + $return = $playtime; + if ($text == true) { + $return = $return . " " . $label; + } + return $return; + } - function playtime($seconds, $text=false) { - $playtime = null; - $label = null; + function secondsToDate($seconds) + { + return date("d M Y H:i:s", $seconds / 1000); + } - if ($seconds < 60) { - if ($text == true) { - $label = "second"; - } - if ($seconds > 1) { $label .= "s"; } - $playtime = $seconds; - } else - if ($seconds/60 < 60) { - if ($text == true) { - $label = "minute"; - } - if ($seconds/60 > 1) { $label .= "s"; } - $playtime = round($seconds/60,2); - } else { - if ($text == true) { - $label = "hour"; - } - if ($seconds/60/60 > 1) { $label .= "s"; } - $playtime = round($seconds/60/60,2); - } + function thumbnailurl($game_id) + { + $result = $this->mysql_conn("SELECT thumbnail_url FROM game_thumbnail WHERE game_id = '" . $game_id . "' limit 1;"); + if ($result->num_rows > 0) { + while ($row = $result->fetch_assoc()) { + $url = $row["thumbnail_url"]; + } + } else { + $url = "images/no-thumbnail.png"; + } + return $url; + } - $return = $playtime; - if ($text == true) { $return = $return ." ". $label; } - return $return; - } + function thumbnailupdateurl($gameid, $gamename, $url) + { + $actualurl = $this->thumbnailurl($gameid); + if ($actualurl == "images/no-thumbnail.png") { + $sql = "INSERT INTO game_thumbnail (game_id, thumbnail_url) VALUES ('" . $gameid . "', '" . $url . "');"; + } else { + $sql = "UPDATE game_thumbnail SET thumbnail_url = '" . $url . "' WHERE game_id = '" . $gameid . "';"; + } - function secondsToDate($seconds) { - return date("d M Y H:i:s", $seconds/1000); - } + if ($url == "" or $url == "null") { + echo "
ERROR
No URL specified.
"; + } else { + if ($this->isImage($url)) { + $result = $this->mysql_conn($sql); + if ($result == 1) { + echo "
SUCCESS
Updated image URL for " . + $gamename . + " (" . + $gameid . + ")
"; + } else { + echo "
ERROR
Can't update image URL for " . + $gamename . + " (" . + $gameid . + ")
"; + } + } else { + echo "
ERROR
Not an image.
"; + } + } + } - function thumbnailurl($game_id) { - $result = $this->mysql_conn("SELECT thumbnail_url FROM game_thumbnail WHERE game_id = '". $game_id ."' limit 1;"); - if ($result->num_rows > 0) { - while ($row = $result->fetch_assoc()) { - $url = $row["thumbnail_url"]; - } - } else { - $url = "images/no-thumbnail.png"; - } - return $url; - } + function isImage($url) + { + $params = array( + 'http' => array( + 'method' => 'HEAD' + ) + ); + $ctx = stream_context_create($params); + $fp = @fopen($url, 'rb', false, $ctx); + if (!$fp) { + return false; + } // Problem with url - function thumbnailupdateurl($gameid,$gamename,$url) { - $actualurl = $this->thumbnailurl($gameid); - if ($actualurl == "images/no-thumbnail.png") { - $sql = "INSERT INTO game_thumbnail (game_id, thumbnail_url) VALUES ('".$gameid."', '".$url."');"; - } else { - $sql = "UPDATE game_thumbnail SET thumbnail_url = '".$url."' WHERE game_id = '".$gameid."';"; - } + $meta = stream_get_meta_data($fp); + if ($meta === false) { + fclose($fp); + return false; // Problem reading data from url + } - if (($url == "") or ($url == "null")) { - echo "
ERROR
No URL specified.
"; - } else { - if ($this->isImage($url)) { - $result = $this->mysql_conn($sql); - if ($result == 1) { - echo "
SUCCESS
Updated image URL for ". $gamename ." (". $gameid .")
"; - } else { - echo "
ERROR
Can't update image URL for ". $gamename ." (". $gameid .")
"; - } - } else { - echo "
ERROR
Not an image.
"; - } - } + $wrapper_data = $meta["wrapper_data"]; + if (is_array($wrapper_data)) { + foreach (array_keys($wrapper_data) as $hh) { + if (substr($wrapper_data[$hh], 0, 19) == "Content-Type: image") { + // strlen("Content-Type: image") == 19 + fclose($fp); + return true; + } + } + } - } + fclose($fp); + return false; + } - function isImage($url) - { - $params = array('http' => array( - 'method' => 'HEAD' - )); - $ctx = stream_context_create($params); - $fp = @fopen($url, 'rb', false, $ctx); - if (!$fp) - return false; // Problem with url + function games_reorder($games, $orderby = "last_played_desc") + { + function totaltime_asc($a, $b) + { + return $a["game_total_time"] <= $b["game_total_time"] ? -1 : 1; + } + function totaltime_desc($a, $b) + { + return $a["game_total_time"] >= $b["game_total_time"] ? -1 : 1; + } - $meta = stream_get_meta_data($fp); - if ($meta === false) - { - fclose($fp); - return false; // Problem reading data from url - } + function firstplayed_asc($a, $b) + { + return $a["game_played_first"] <= $b["game_played_first"] ? -1 : 1; + } + function firstplayed_desc($a, $b) + { + return $a["game_played_first"] >= $b["game_played_first"] ? -1 : 1; + } - $wrapper_data = $meta["wrapper_data"]; - if(is_array($wrapper_data)){ - foreach(array_keys($wrapper_data) as $hh){ - if (substr($wrapper_data[$hh], 0, 19) == "Content-Type: image") // strlen("Content-Type: image") == 19 - { - fclose($fp); - return true; - } - } - } - - fclose($fp); - return false; - } - - function games_reorder($games,$orderby="last_played_desc") { - function totaltime_asc($a,$b) { - return ($a["game_total_time"] <= $b["game_total_time"]) ? -1 : 1; - } - function totaltime_desc($a,$b) { - return ($a["game_total_time"] >= $b["game_total_time"]) ? -1 : 1; - } - - - function firstplayed_asc($a,$b) { - return ($a["game_played_first"] <= $b["game_played_first"]) ? -1 : 1; - } - function firstplayed_desc($a,$b) { - return ($a["game_played_first"] >= $b["game_played_first"]) ? -1 : 1; - } - - function lastplayed_asc($a,$b) { - if ($a["game_played_last"] == -1) { $a["game_played_last"] = (round(microtime(true) * 1000)); } - if ($b["game_played_last"] == -1) { $b["game_played_last"] = (round(microtime(true) * 1000)); } - return ($a["game_played_last"] <= $b["game_played_last"]) ? -1 : 1; - } - function lastplayed_desc($a,$b) { - if ($a["game_played_last"] == -1) { $a["game_played_last"] = (round(microtime(true) * 1000)); } - if ($b["game_played_last"] == -1) { $b["game_played_last"] = (round(microtime(true) * 1000)); } - return ($a["game_played_last"] >= $b["game_played_last"]) ? -1 : 1; - } - - usort($games, $orderby); - return $games; - } + function lastplayed_asc($a, $b) + { + if ($a["game_played_last"] == -1) { + $a["game_played_last"] = round(microtime(true) * 1000); + } + if ($b["game_played_last"] == -1) { + $b["game_played_last"] = round(microtime(true) * 1000); + } + return $a["game_played_last"] <= $b["game_played_last"] ? -1 : 1; + } + function lastplayed_desc($a, $b) + { + if ($a["game_played_last"] == -1) { + $a["game_played_last"] = round(microtime(true) * 1000); + } + if ($b["game_played_last"] == -1) { + $b["game_played_last"] = round(microtime(true) * 1000); + } + return $a["game_played_last"] >= $b["game_played_last"] ? -1 : 1; + } + usort($games, $orderby); + return $games; + } } -?> \ No newline at end of file +?> diff --git a/index.php b/index.php index 1593059..b869ed5 100644 --- a/index.php +++ b/index.php @@ -7,8 +7,6 @@ error_reporting(E_ALL); $rootpage = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : "index.php"; $orderby = isset($_GET['orderby']) ? $_GET['orderby'] : "lastplayed_desc"; $details = isset($_GET['details']) ? $_GET['details'] : ""; - - ?> @@ -26,7 +24,7 @@ $details = isset($_GET['details']) ? $_GET['details'] : ""; update(); }); function update() { - $.get('page.php?rootpage=&orderby=&details=', function(data) { + $.get('page.php?rootpage=&orderby=&details=', function(data) { $("#page").html(data); window.setTimeout(update, 10000); // 10 secondes }); diff --git a/page.php b/page.php index a2eed2f..541fd14 100644 --- a/page.php +++ b/page.php @@ -1,5 +1,5 @@ mysql_conn($sql); $rootpage = $_GET['rootpage']; $orderby = isset($_GET['orderby']) ? $_GET['orderby'] : "lastplayed_desc"; $details = isset($_GET['details']) ? $_GET['details'] : ""; - ?>
- Last refresh : + Last refresh :
-num_rows > 0) { - // output data of each row +num_rows > 0) { + // output data of each row - while ($row = $result->fetch_assoc()) { + while ($row = $result->fetch_assoc()) { + $games[$row["game_id"]]["game_id"] = $row["game_id"]; + $games[$row["game_id"]]["game_name"] = $row["game_name"]; + isset($games[$row["game_id"]]["game_total_time"]) ?: ($games[$row["game_id"]]["game_total_time"] = 0); - $games[$row["game_id"]]["game_id"] = $row["game_id"]; - $games[$row["game_id"]]["game_name"] = $row["game_name"]; - isset($games[$row["game_id"]]["game_total_time"]) ?: $games[$row["game_id"]]["game_total_time"] = 0; + isset($games[$row["game_id"]]["game_played_first"]) ?: ($games[$row["game_id"]]["game_played_first"] = $row["game_start"]); + isset($games[$row["game_id"]]["game_played_last"]) ?: ($games[$row["game_id"]]["game_played_last"] = $row["game_end"]); + if ($row["game_start"] < $games[$row["game_id"]]["game_played_first"]) { + $games[$row["game_id"]]["game_played_first"] = $row["game_start"]; + } - isset($games[$row["game_id"]]["game_played_first"]) ?: $games[$row["game_id"]]["game_played_first"] = $row["game_start"]; - isset($games[$row["game_id"]]["game_played_last"]) ?: $games[$row["game_id"]]["game_played_last"] = $row["game_end"]; - if ($row["game_start"] < $games[$row["game_id"]]["game_played_first"]) { - $games[$row["game_id"]]["game_played_first"] = $row["game_start"]; - } + if ($row["game_end"] == "") { + $games[$row["game_id"]]["game_time"][$row["id"]] = -1; + $games[$row["game_id"]]["game_played_last"] = -1; + $games[$row["game_id"]]["game_total_time"] += (round(microtime(true) * 1000) - $row["game_start"]) / 1000; + } else { + $games[$row["game_id"]]["game_time"][$row["id"]] = ($row["game_end"] - $row["game_start"]) / 1000; + $games[$row["game_id"]]["game_total_time"] += ($row["game_end"] - $row["game_start"]) / 1000; + if ( + $row["game_end"] > $games[$row["game_id"]]["game_played_last"] and + $games[$row["game_id"]]["game_played_last"] != -1 + ) { + $games[$row["game_id"]]["game_played_last"] = $row["game_end"]; + } + } + } - if ($row["game_end"] == "") { - $games[$row["game_id"]]["game_time"][$row["id"]] = -1; - $games[$row["game_id"]]["game_played_last"] = -1; - $games[$row["game_id"]]["game_total_time"] += ((round(microtime(true) * 1000)-$row["game_start"])/1000); - } else { - $games[$row["game_id"]]["game_time"][$row["id"]] = (($row["game_end"]-$row["game_start"])/1000); - $games[$row["game_id"]]["game_total_time"] += (($row["game_end"]-$row["game_start"])/1000); - if (($row["game_end"] > $games[$row["game_id"]]["game_played_last"]) AND ($games[$row["game_id"]]["game_played_last"] != -1)) { - $games[$row["game_id"]]["game_played_last"] = $row["game_end"]; - } - } - } + // reorder + sort($games); + $games = $ps4->games_reorder($games, $orderby); -// reorder -sort($games); -$games = $ps4->games_reorder($games, $orderby); + foreach ($games as $key => $value) { + echo "
"; + echo "
"; + echo "thumbnailurl($games[$key]["game_id"]) . + "\" border=0 weight=\"80px\" height=\"80px\" onclick=\"thumbnailupdateurl('" . + $games[$key]["game_id"] . + "', '" . + str_replace("'", "", $games[$key]["game_name"]) . + "', '" . + $rootpage . + "', '" . + $orderby . + "', '" . + $details . + "');\">"; + echo "
"; + echo "
"; + echo "" . $games[$key]["game_name"] . ""; + echo "
"; + echo ""; + echo "
First Played
" . + $ps4->secondsToDate($games[$key]["game_played_first"]) . + "
"; + echo "
Last Played
"; -foreach ($games as $key => $value) { - echo "
"; - echo "
"; - echo "thumbnailurl($games[$key]["game_id"])."\" border=0 weight=\"80px\" height=\"80px\" onclick=\"thumbnailupdateurl('". $games[$key]["game_id"] ."', '". str_replace("'", "", $games[$key]["game_name"]) ."', '". $rootpage ."', '". $orderby ."', '". $details ."');\">"; - echo "
"; - echo "
"; - echo "". $games[$key]["game_name"] .""; - echo "
"; - echo ""; - echo "
First Played
". $ps4->secondsToDate($games[$key]["game_played_first"]) ."
"; - echo "
Last Played
"; + if ($games[$key]["game_played_last"] == -1) { + echo "now playing"; + } else { + echo $ps4->secondsToDate($games[$key]["game_played_last"]); + } + echo "
"; - if ($games[$key]["game_played_last"] == -1) { - echo "now playing"; - } else { - echo $ps4->secondsToDate($games[$key]["game_played_last"]); - } - echo "
"; + echo "
"; // info - echo "
"; // info + if ($details == $games[$key]["game_id"]) { + $ps4->gameTimeDetails($games[$key]["game_id"]); + } - if ($details == $games[$key]["game_id"]) { - $ps4->gameTimeDetails($games[$key]["game_id"]); - } + echo "
"; // game + } - echo "
"; // game -} - -/* + /* echo "
";
 print_r($games);
 echo "
"; */ - } else { - echo "0 results"; -} - -?> + echo "0 results"; +} ?> diff --git a/post.php b/post.php index 6bdde2f..c33257e 100644 --- a/post.php +++ b/post.php @@ -1,12 +1,12 @@ thumbnailupdateurl($_POST['gameid'],$_POST['gamename'],$_POST['url']); - } - } -?> \ No newline at end of file +if ($_SERVER["REQUEST_METHOD"] == "POST") { + if ($_POST['what'] == 'thumbnail') { + $ps4->thumbnailupdateurl($_POST['gameid'], $_POST['gamename'], $_POST['url']); + } +} +?> diff --git a/style.css b/style.css index 547627b..7114fe0 100644 --- a/style.css +++ b/style.css @@ -1,6 +1,7 @@ -body{ - background-color: #1C406A; - font-family: 'Barlow';font-size: 16px; +body { + background-color: #1c406a; + font-family: "Barlow"; + font-size: 16px; } body:before { @@ -20,180 +21,180 @@ body:before { } a { - color: #000; - text-decoration: none; - font-weight: bold; + color: #000; + text-decoration: none; + font-weight: bold; } -.refresh{ - background: #cadbeb; - border: 1px solid #5f94c2; - border-radius: 4px; - display: block; - padding-bottom: 3px; - margin-bottom: 10px; +.refresh { + background: #cadbeb; + border: 1px solid #5f94c2; + border-radius: 4px; + display: block; + padding-bottom: 3px; + margin-bottom: 10px; } .thumbnail { - float: left; - width: 95px; - height: 90px; - padding-top: 10px; - padding-left: 10px; + float: left; + width: 95px; + height: 90px; + padding-top: 10px; + padding-left: 10px; } .thumbnail img { - border: 1px solid #3b6f9d; - border-radius: 4px; + border: 1px solid #3b6f9d; + border-radius: 4px; } .info { - float: left; - width: auto; - padding-top: 10px; - padding-bottom: 10px; + float: left; + width: auto; + padding-top: 10px; + padding-bottom: 10px; } /* Clear floats after the columns */ .game:after { - content: ""; - display: table; - clear: both; + content: ""; + display: table; + clear: both; } -.game{ - width: 500px; - background: #cadbeb; - border: 1px solid #3b6f9d; - border-radius: 4px; - margin-top: 10px; - display: block; - overflow: auto; - opacity: 0.95; +.game { + width: 500px; + background: #cadbeb; + border: 1px solid #3b6f9d; + border-radius: 4px; + margin-top: 10px; + display: block; + overflow: auto; + opacity: 0.95; } #message { - width: 100%; - height: 100%; - margin-bottom: 5px; - padding-bottom: 5px; + width: 100%; + height: 100%; + margin-bottom: 5px; + padding-bottom: 5px; } .message-error { - background: #fca4a4; - border: 1px solid #8e0000; - border-radius: 4px; + background: #fca4a4; + border: 1px solid #8e0000; + border-radius: 4px; } - .message-success { - background: #a7d6ad; - border: 1px solid #034c00; - border-radius: 4px; + background: #a7d6ad; + border: 1px solid #034c00; + border-radius: 4px; } .message-head { - display: block; - text-align: center; - font-weight: bold; + display: block; + text-align: center; + font-weight: bold; } .message-details { - display: block; - text-align: center; + display: block; + text-align: center; } .center500 { - width: 500px; - text-align: center; + width: 500px; + text-align: center; } .orderby { - color: #1f3b53; - font-weight: bold; - align-content: center; - display: inline-block; - background-color: #95b8d7; - border: 1px solid #274a68; - border-radius: 4px; + color: #1f3b53; + font-weight: bold; + align-content: center; + display: inline-block; + background-color: #95b8d7; + border: 1px solid #274a68; + border-radius: 4px; } .material-icons.md-arrow { - color: #5f94c2; + color: #5f94c2; +} +.material-icons.md-arrow.md-active { + color: #274a68; } -.material-icons.md-arrow.md-active { color: #274a68; } .vertical-align-middle { - vertical-align: middle; + vertical-align: middle; } .padding-bottom-3 { - padding-bottom: 3px; + padding-bottom: 3px; } .padding-bottom-10 { - padding-bottom: 10px; + padding-bottom: 10px; } .gameinfoline { - } .gameinfohead { - display: inline-block; - width: 150px; - text-align: left; + display: inline-block; + width: 150px; + text-align: left; } .gameinfoseparator:before { - content: ""; + content: ""; } .gameinfoseparator { - display: inline; + display: inline; } .gameinfodetails { - padding-left: 3px; - display: inline; + padding-left: 3px; + display: inline; } .PlaytimeDetails { - display: table; - padding: 5px; - margin-right: 10px; - border-radius: 4px; - border: 1px solid #274a68; + display: table; + padding: 5px; + margin-right: 10px; + border-radius: 4px; + border: 1px solid #274a68; } .PlaytimeStart { - width: 140px; - display: table-cell; + width: 140px; + display: table-cell; } .PlaytimeEnd { - width: 140px; - display: table-cell; + width: 140px; + display: table-cell; } .PlaytimeTotal { - width: 100px; - display: table-cell; + width: 100px; + display: table-cell; } .head { - font-weight: bold; + font-weight: bold; } .row { - display: table-row; + display: table-row; } .row:nth-child(even) { - background:#95b8d7; + background: #95b8d7; } .cell { - display: table-cell; + display: table-cell; } .FontSmaller { - font-size: 14px; + font-size: 14px; } diff --git a/updatethumbnail.js b/updatethumbnail.js index 8ad908b..73902b0 100644 --- a/updatethumbnail.js +++ b/updatethumbnail.js @@ -1,41 +1,31 @@ function thumbnailupdateurl(gameid, gamename, rootpage, orderby, details) { + var url = prompt("Enter Image URL for " + gamename + " (" + gameid + ")", ""); - var url = prompt("Enter Image URL for " + gamename + " (" + gameid + ")", ""); + if (url === "") { + alert("Enter something !"); + } else { + var data = { + what: "thumbnail", + gameid: gameid, + gamename: gamename, + url: url + }; - if (url === "") { - - alert ("Enter something !"); - - } else { - - var data = { - 'what': 'thumbnail', - 'gameid': gameid, - 'gamename': gamename, - 'url': url - }; - - - - $.ajax( - { - type: "POST", - url: "post.php", - data: data, - success: function(data, textStatus, jqXHR) - { - - $( document ).ready(function(){ - $('#message').html(data); - $('#message').fadeIn('slow', function(){ - $('#message').delay(3000).fadeOut(); - }); - $("#page").load('page.php?rootpage=' + rootpage + '&orderby=' + orderby + '&details=' + details); - }); - - } - }); - - } - -} \ No newline at end of file + $.ajax({ + type: "POST", + url: "post.php", + data: data, + success: function(data, textStatus, jqXHR) { + $(document).ready(function() { + $("#message").html(data); + $("#message").fadeIn("slow", function() { + $("#message") + .delay(3000) + .fadeOut(); + }); + $("#page").load("page.php?rootpage=" + rootpage + "&orderby=" + orderby + "&details=" + details); + }); + } + }); + } +}