video preroll vimeo in wordpress - javascript

Hello guys I would like to integrate an open source code taken from github to my wordpress theme.
link:
Vimeo Pre-roll
This is the code of my video.php, I would like to work with vimeo.
code:
<?php
get_header();
wize_set_views(get_the_ID());
echo '
<div id="wrap" class="fixed">';
if (have_posts())
while (have_posts()):
the_post();
$social = of_get_option('social_sng', '1') == '1';
$venue = get_post_meta($post->ID, 'vd_venue', true);
$youtube = get_post_meta($post->ID, 'vd_youtube', true);
$vimeo = get_post_meta($post->ID, 'vd_vimeo', true);
$date = get_post_meta($post->ID, 'vd_date', true);
$time = strtotime($date);
$year = date('Y', $time);
$month = date('F', $time);
$day = date('d', $time);
/* display */
echo '
<div id="mediasng">
<div class="mediasng-title">
<h1>' . get_the_title() . '</h1>
</div><!-- end .mediasng-title -->
<div class="mediasng-lv">
' . wize_like_info($post->ID) . '
<div class="info-view">' . wize_get_views(get_the_ID()) . '</div>
</div><!-- end .mediasng-lv -->
<div class="mediasng-info">';
if ($venue) {
echo '
<div class="mediasng-venue">' . esc_html($venue, "wizedesign") . '</div>';
}
if ($date) {
echo '
<div class="mediasng-date">' . esc_html($day, "wizedesign") . ' ' . esc_html($month, "wizedesign") . ' ' . esc_html($year, "wizedesign") . '</div>';
}
echo '
</div><!-- end .mediasng-info -->';
if ($youtube) {
echo '
<iframe src="https://www.youtube.com/embed/' . esc_attr($youtube) . '" width="1130" height="620" frameborder="0" allowfullscreen></iframe>';
} elseif ($vimeo) {
echo '
<iframe src="http://player.vimeo.com/video/' . esc_attr($vimeo) . '" width="1130" height="620" frameborder="0" allowFullScreen></iframe>';
}
if ($social) {
echo '
<div class="mediasng-social">
<span>' . esc_html__("share", "wizedesign") . '</span>
<div class="sng-facebook"></div>
<div class="sng-twitter"></div>
<div class="sng-google"></div>
<div class="sng-linkedin"></div>
</div><!-- end .mediasng-social -->';
}
echo '
</div><!-- end .mediasng -->
';
endwhile;
get_footer();
how can I make sure that the code is read by wordpress plugins github!?

Related

Stack messageboard uploads compactly in order, one under eachother in rows of 5, but dont let tall images interfere

I have some kind of message board, users can add images, videos, markdown text.
How I want it to behave
I want items to align like in the image provided; move the blue element to the red area, as it should. the uploads (messages) are all the same width, but different heights, also, They are added by a PHP script which loops through a database and adds elements to the "message board" div, with the ".uploads" class.
if provided an image or video, theres an image or video, if not, theres only text.
home.php (shortened to the point...)
<?php
session_start();
// Check if user is logged in
if (isset($_SESSION['id']) && isset($_SESSION['user_name'])) {
?>
<!DOCTYPE html>
<body>
<div class="functions-holder">
<h1>Hello, <?php echo $_SESSION['name']; ?></h1>
<?php if (isset($_GET['msg'])) { ?>
<p class="message"><?php echo $_GET['msg']; ?></p>
<?php } ?>
Logout
<button onclick="openPopup()" class="fa-solid fa-plus" id="popUp"> Add post</button>
</div>
<div id="message-board"">
</div>
<script src="board.js"></script>
</body>
</html>
<?php
} else {
?>
<!-- ... pretty similar... -->
Sample of board.php
while ($row = $result->fetch_assoc()) {
$html .= '<div class="uploads">';
// Only display the delete button if the logged-in user is "chips"
if (isset($_SESSION['user_name']) && $_SESSION['user_name'] === "chips") {
$html .= '<button class="delete-button" data-id="' . $row['postid'] . '">Delete</button>';
}
$html .= '<h2>' . $row['author'] . ' shared</h2>';
$html .= '' . $row['markdown'] . '';
// Display the image if it exists and is not "noimg"
if ($row['img'] != '' && $row['img'] != 'noimg'){
$mimeType = mime_content_type($row['img']);
$fileType = explode('/', $mimeType)[0];
if (str_contains($fileType, 'image')){
$html .= '<img src="' . $row['img'] . '"/>';
}
else if (str_contains($fileType, 'video')){
$html .= '<video controls width="380" height="auto" src="' . $row['img'] . '"/>';
}
}
$html .= '</div>';
}
How could I do this using; HTML, CSS, and JAVASCRIPT
<html>
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.uploads {position: relative;float:left;width: 19%;border:1px dotted #000;margin:3px;height: 365px;width: 365px;background-color: #999;overflow: hidden;}
.uploads h2 {float:left;height: 30px;}
.uploads button {float:right;height: 30px;}
.uploads .markdown {float:left;clear: both;height: 20px;width: 100%;}
.uploads img {position: relative;float: none;display: block;clear: both;width:auto;height: auto;max-height: 285px; max-width: 330px;margin: 0px auto;clear: both;}
hr {width:100%;float:left;clear:both;}
</style>
</head>
<body>
<?php
$i=1;
$html = '';
while ($i<7) {
$html .= '<div class="uploads">';
// Only display the delete button if the logged-in user is "chips"
$html .= '<button class="delete-button" data-id="x' . $i . '">Delete</button>';
$html .= '<h2>xauthor shared</h2>';
$html .= '<div class="markdown">xmarkdown</div>';
// Display the image if it exists and is not "noimg"
$html .= '<img src="' . $i . '.png"/>';
// else if (str_contains($fileType, 'video')){
// $html .= '<video controls width="380" height="auto" src="' . $row['img'] . '"/>';
// }
$html .= '</div>';
if(($i%5)==0) {
$html .= '<br/><hr/><br/>';
}
$i++;
}
echo $html;
?>
</body>
</html>

Script for open image in new window not working

I'm using this code to open an image in a new window, but i can't get it to work. What is wrong?
echo "
<td align='center'>
<a href='images/spasergjengen/" . $row['Grad'] . "' target='_blank'>
<img src='images/spasergjengen/" . $row['Grad'] . "' width='125' height='150'
title='Spasergjengen' alt='Spasergjengen' />
</a>
<br>
<button onclick='myFunction" . $row['MedlemId'] . "'()'>Se Bilde</button>
<script>
function myFunction" . $row['MedlemId'] . "'() {
window.open('images/spasergjengen/" . $row['Grad'] . "', '_blank',
'toolbar=yes,scrollbars=yes,resizable=yes
,top=200,left=300,width=750,height=565'); }
</script>
</td>
";
[Tested]
<?php echo "<td align='center'><a href='images/spasergjengen/" . $row['Grad'] . "' target='_blank'><img src='images/spasergjengen/" . $row['Grad'] . "' width='125' height='150' title='Spasergjengen' alt='Spasergjengen' /></a><br><button onclick='myFunction" . $row['MedlemId'] . "()'>Se Bilde</button>
<script> function myFunction" . $row['MedlemId'] . "() { window.open('images/spasergjengen/" . $row['Grad'] . ",_blank', 'toolbar=yes,scrollbars=yes,resizable=yes,top=200,left=300,width=750,height=565'); } </script></td>";
?>

Bootstrap 3.3.7 hidden-lg-up not working

I'm trying to design a a mobile version of a game I've been working on. Apologies for the messy code, it's nothing serious. I've decided to use a hamburger-menu for the mobile version and want to hide it on desktop devices. For this I found "hidden-lg-up" in the bootstrap documentation but it doesn't seem to be working. I at least know that the bootstrap js is loaded because if I change the name I get an error in the browser console.
The element I'm trying this with is the "hamburger-menu-toggle" and "hamburger-menu".
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CEO Panel</title>
<link rel="shortcut icon" href="favicon.png?v=1"/>
<link rel="stylesheet" href="css/main.css">
<!-- JQUERY -->
<script src="js/libs/jquery-3.1.0.min.js"></script>
<script src="js/libs/jquery-ui-1.12.0/jquery-ui.min.js"></script>
<!-- LIBS AND PLUGINS -->
<script src="js/libs/jquery-mousewheel-3.1.13/jquery.mousewheel.min.js"></script>
<script src="js/libs/mapbox.js/jquery.mapbox.js"></script>
<script src="js/libs/countdown/jquery.countdown.min.js"></script>
<script src="js/libs/jquery.ui.touch-punch.min.js"></script>
<!-- GAME JS -->
<script src="js/game_logic/main.js"></script>
<script src="js/game_logic/buttons.js"></script>
<script src="js/libs/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
</head>
<body>
<main>
<div id="map-wrapper">
<img id="map" src="res/los_santos_map.png" alt="Los Santos Map">
<div id="map-content">
<!--<div class="map-marker owned" id="warehouse1"></div>
<div class="map-marker for-sale" id="warehouse2"></div>-->
<?php
$pdo = pdo();
$username = $_SESSION['username'];
foreach($pdo->query("SELECT * FROM warehouses") as $row){
$warehouse_id = $row['id'];
$statement = $pdo->prepare("SELECT * FROM warehouse_contracts WHERE warehouse_id LIKE '$warehouse_id' AND username LIKE '$username'");
$statement->execute();
$rowCount = $statement->rowCount();
//find out the size of the warehouse
if($row['slots'] < 64){
$size = "small";
}
else if($row['slots'] >= 64 && $row['slots'] < 256){
$size = "medium";
}
else{
$size = "large";
}
//find out if it's owned by the user
if($rowCount>0){
echo '<div class="map-marker owned ' . $size . '" id="warehouse' . $row['id'] . '" style="top: ' . $row['y'] . 'px; left: ' . $row['x'] . 'px;"></div>';
}
else{
echo '<div class="map-marker for-sale ' . $size . '" id="warehouse' . $row['id'] . '" style="top: ' . $row['y'] . 'px; left: ' . $row['x'] . 'px;"></div>';
}
}
?>
</div>
</div>
<div style="background-image: url('res/radar-overlay.png'); width: 100%; height: 100%; position: fixed; background-size: cover; opacity: 0.2; pointer-events: none;"></div>
<div id="HUD">
<div id="hamburger-menu-toggle" class="hidden-lg-up">
<div></div>
<div></div>
<div></div>
</div>
<div id="hamburger-menu" class="hidden-lg-up">
</div>
<div id="logout" class="button">LOGOUT</div>
<?php
if(isset($_SESSION['admin']) && $_SESSION['admin'] === "TRUE"){
echo '
<div id="admin-stats">
<h1>map.x: <span id="map_x"></span><br>map.y: <span id="map_y"></span></h1>
<h1>map.height: <span id="map_height"></span><br>map.width: <span id="map_width"></span><br>mouse.x: <span id="mouse_x"></span><br>mouse.y: <span id="mouse_y"></span></h1>
</div>
';
}
?>
<h1 id="cash">
<?php
$pdo = pdo();
$username = $_SESSION['username'];
$statement = $pdo->prepare("SELECT cash FROM users WHERE username LIKE '$username'");
$statement->execute();
$results = $statement->fetch();
echo '$' . number_format($results['cash']);
?>
</h1>
<div id="warehouse-toggle">
<div class="button toggle-selected">ALL</div>
<div class="button toggle">OWNED</div>
<div class="button toggle">SMALL</div>
<div class="button toggle">MEDIUM</div>
<div class="button toggle">LARGE</div>
</div>
<div id="stock-actions">
<?php
$pdo = pdo();
$username = $_SESSION['username'];
$statement = $pdo->prepare("SELECT * FROM shipments WHERE status LIKE 'active' AND username LIKE ?");
$statement->bindParam(1, $username);
$statement->execute();
$row_count = $statement->rowCount();
if($row_count == 0){
echo '
<div id="buy-stock-button" class="button">BUY</div>
';
$statement = $pdo->prepare("SELECT * FROM storage WHERE username LIKE ?");
$statement->bindParam(1, $username);
$statement->execute();
$row_count = $statement->rowCount();
if($row_count > 0){
echo '
<div id="sell-stock-button" class="button">SELL</div>
';
}
else{
echo '
<div id="sell-stock-button" class="button disabled">SELL</div>
';
}
}
else{
echo '
<div id="buy-stock-button" class="button disabled">BUY</div>
<div id="sell-stock-button" class="button disabled">SELL</div>
';
}
?>
<div id="upgrades-button" class="button">UPGRADES</div>
</div>
<div id="page-toggle">
<div class="button toggle">SUMMARY PAGE</div>
<div class="button toggle-selected">WAREHOUSE MAP</div>
</div>
<div class="dialog" id="owned-warehouse-dialog">
<div class="close-button">x</div>
</div>
<div class="dialog" id="buy-warehouse-dialog">
<div class="close-button">x</div>
<?php
/*
$pdo = pdo();
$warehouse_id = $_GET['warehouse_id'];
$statement = $pdo->prepare("SELECT * FROM warehouses WHERE id LIKE ?");
$statement->bindParam(1, $warehouse_id);
$statement->execute();
$warehouse = $statement->fetch();
echo '
<h1>WAREHOUSE ' . $warehouse_id . '</h1>
<p>STATUS:<span class="right-text">FOR SALE</span></p>
<p>WAREHOUSE SLOTS:<span class="right-text">' . $warehouse['slots'] . '</span></p>
<p>COST:<span class="right-text">' . $warehouse['price'] . '</span></p>
<div class="submit-button">BUY</div>
';
*/
?>
</div>
<div class="dialog" id="buy-warehouse-dialog"></div>
<div class="dialog" id="buy-stock-dialog">
<div class="close-button">x</div>
<form action="index.php?action=buy_crates" method="post">
<h1>BUY CARGO CRATES</h1>
<p>TYPE</p>
<div class="selection-list">
<?php
$pdo = pdo();
foreach($pdo->query("SELECT * FROM crate_types") as $row){
echo '<div class="button toggle">' . strtoupper($row['name']) . '</div>';
}
?>
<input class="hidden" name="type" type="text" required>
</div>
<p>QUANTITY</p>
<div class="selection-list">
<?php
$pdo = pdo();
$username = $_SESSION['username'];
$statement = $pdo->prepare("SELECT SUM(slots) FROM warehouses INNER JOIN warehouse_contracts ON warehouses.id=warehouse_contracts.warehouse_id WHERE username LIKE '$username'");
$statement->execute();
$slots = $statement->fetch();
$statement = $pdo->prepare("SELECT SUM(quantity) FROM storage WHERE username LIKE ?");
$statement->bindParam(1, $username);
$statement->execute();
$crates = $statement->fetch();
$statement = $pdo->prepare("SELECT * FROM transport_upgrades WHERE username LIKE ? AND type LIKE 'storage'");
$statement->bindParam(1, $username);
$statement->execute();
$storage_upgrades = $statement->rowCount() + 1;
$available_slots = $slots['SUM(slots)'] - $crates['SUM(quantity)'];
if($available_slots >= 1 * pow(2, $storage_upgrades)){
echo '<div class="button toggle">' . 1 * pow(2, $storage_upgrades) . '</div>';
}
else{
echo '<div class="disabled">' . 1 * pow(2, $storage_upgrades) . '</div>';
}
if($available_slots >= 2 * pow(2, $storage_upgrades)){
echo '<div class="button toggle">' . 2 * pow(2, $storage_upgrades) . '</div>';
}
else{
echo '<div class="disabled">' . 2 * pow(2, $storage_upgrades) . '</div>';
}
if($available_slots >= 4 * pow(2, $storage_upgrades)){
echo '<div class="button toggle">' . 4 * pow(2, $storage_upgrades) . '</div>';
}
else{
echo '<div class="disabled">' . 4 * pow(2, $storage_upgrades) . '</div>';
}
if($available_slots >= 8 * pow(2, $storage_upgrades)){
echo '<div class="button toggle">' . 8 * pow(2, $storage_upgrades) . '</div>';
}
else{
echo '<div class="disabled">' . 8 * pow(2, $storage_upgrades) . '</div>';
}
if($available_slots >= 16 * pow(2, $storage_upgrades)){
echo '<div class="button toggle">' . 16 * pow(2, $storage_upgrades) . '</div>';
}
else{
echo '<div class="disabled">' . 16 * pow(2, $storage_upgrades) . '</div>';
}
if($available_slots >= 32 * pow(2, $storage_upgrades)){
echo '<div class="button toggle">' . 32 * pow(2, $storage_upgrades) . '</div>';
}
else{
echo '<div class="disabled">' . 32 * pow(2, $storage_upgrades) . '</div>';
}
if($available_slots < 1 * pow(2, $storage_upgrades)){
echo '
<input class="hidden" name="quantity" type="text" required>
</div>
<p>RISK:<span class="right-text" id="delivery-risk">0%</span></p>
<p>PROFIT MARGIN:<span class="right-text" id="delivery-profit">0%</span></p>
<p>PRICE:<span class="right-text" id="delivery-price">$0</span></p>
<input class="submit-button disabled" type="submit" value="BUY">
';
}
else{
echo '
<input class="hidden" name="quantity" type="text" required>
</div>
<p>RISK:<span class="right-text" id="delivery-risk">0%</span></p>
<p>PROFIT MARGIN:<span class="right-text" id="delivery-profit">0%</span></p>
<p>PRICE:<span class="right-text" id="delivery-price">$0</span></p>
<input class="submit-button" type="submit" value="BUY">
';
}
?>
</form>
</div>
<div class="dialog" id="sell-stock-dialog">
<div class="close-button">x</div>
<?php
$pdo = pdo();
$statement = $pdo->prepare("SELECT SUM((price*((profit/100)+1))*quantity), SUM(price*quantity), SUM(quantity), AVG(profit) FROM storage INNER JOIN crate_types ON storage.crate_type_id=crate_types.id WHERE username LIKE ?");
$statement->bindParam(1, $username);
$statement->execute();
$rows = $statement->fetch();
$quantity = $rows['SUM(quantity)'];
$value = round($rows['SUM((price*((profit/100)+1))*quantity)'], 0);
$original_cost = round($rows['SUM(price*quantity)'], 0);
$profit_margin = round($rows['AVG(profit)'], 0);
echo '
<h1>SELL CARGO CRATES</h1>
<p>CRATES: <span class="right-text">' . $quantity . '</span></p>
<p>RISK: <span class="right-text"></span></p>
<p>PROFIT MARGIN: <span class="right-text">' . $profit_margin . '%</span></p>
<p>ORIGINAL COST: <span class="right-text">$' . number_format($original_cost) .'</span></p>
<p>PROFIT: <span class="right-text">$' . number_format($value - $original_cost) . '</span></p>
<p>TOTAL VALUE: <span class="right-text">$' . number_format($value) .'</span></p>
<div class="submit-button">SELL</div>
';
?>
</div>
<?php
$pdo = pdo();
$username = $_SESSION['username'];
$statement = $pdo->prepare("SELECT * FROM shipments WHERE username LIKE '$username' AND status LIKE 'active' LIMIT 1");
$statement->execute();
$row_count = $statement->rowCount();
$row1 = $statement->fetch();
$statement = $pdo->prepare("SELECT * FROM shipments INNER JOIN crate_types ON shipments.crate_type_id=crate_types.id WHERE username LIKE '$username' AND status LIKE 'active' LIMIT 1");
$statement->execute();
$row2 = $statement->fetch();
if($row_count > 0){
echo '<div id="active-shipment">';
if($row1['type'] === "purchase"){
echo '
<h1 id="countdown"></h1>
<p>Incoming shipment of ' . $row2['quantity'] . ' crates of ' . $row2['name'] . '</p>
';
}
else if($row1['type'] === "sale"){
echo '
<h1 id="countdown"></h1>
<p>Outgoing shipment of ' . $row1['quantity'] . ' crates with a value of $' . number_format($row1['value']) . '</p>
';
}
echo '
</div>
<script type="text/javascript">
$("#countdown").countdown("' . $row1['arrival'] . '", function(event) {
var arrival = {
days: event.strftime("%D"),
hours: event.strftime("%H"),
minutes: event.strftime("%M"),
seconds: event.strftime("%Ss")
};
if(arrival.days <= 0){
arrival.days = "";
}
else{
arrival.days += "d";
}
if(arrival.hours <= 0){
arrival.hours = "";
}
else{
arrival.hours += "h";
}
if(arrival.minutes <= 0){
arrival.minutes = "";
}
else{
arrival.minutes += "m";
}
$(this).text(arrival.days + " " + arrival.hours + " " + arrival.minutes + " " + arrival.seconds);
if(new Date("' . $row1['arrival'] . '") <= new Date()){
window.location.replace("index.php");
}
});
$("title").countdown("' . $row1['arrival'] . '", function(event){
var arrival = {
days: event.strftime("%D"),
hours: event.strftime("%H"),
minutes: event.strftime("%M"),
seconds: event.strftime("%Ss")
};
if(arrival.days <= 0){
arrival.days = "";
}
else{
arrival.days += "d";
}
if(arrival.hours <= 0){
arrival.hours = "";
}
else{
arrival.hours += "h";
}
if(arrival.minutes <= 0){
arrival.minutes = "";
}
else{
arrival.minutes += "m";
}
$(this).text(arrival.days + " " + arrival.hours + " " + arrival.minutes + " " + arrival.seconds + " - CEO Panel");
});
</script>
';
}
?>
<div class="dialog" id="upgrades-dialog">
<div class="close-button">x</div>
<h1>UPGRADES</h1>
<p>TRANSPORT TRUCKS</p>
<p style="font-size: 16px;">These trucks are used for <strong>purchases</strong>.</p>
<?php
$upgrade_cost = calculate_upgrade_cost("trucks", "speed");
$pdo = pdo();
$statement = $pdo->prepare("SELECT cash FROM users WHERE username LIKE ?");
$statement->bindParam(1, $_SESSION['username']);
$statement->execute();
$user = $statement->fetch();
$statement = $pdo->prepare("SELECT * FROM transport_upgrades WHERE vehicle LIKE 'trucks' AND username LIKE ? AND type LIKE 'speed'");
$statement->bindParam(1, $username);
$statement->execute();
$previous_upgrades = $statement->rowCount();
$crate_delivery_time = explode('.', 1 * (3 * (1 - ($previous_upgrades * 0.03))));
if(strpos((string)$crate_delivery_time[0], "-") !== false){
$crate_delivery_time[0] = 0;
$crate_delivery_time[1] = 0;
}
if(($crate_delivery_time[0] <= 0 && $crate_delivery_time[1] <= 0) || $crate_delivery_time[0] < 0){
echo '
<div class="upgrade">
<p>SPEED</p><div class="upgrade-button-disabled">UPGRADE</div>
<div class="upgrade-cost">Limit for upgrades reached.</div>
</div>
';
}
else if($user['cash'] < $upgrade_cost){
echo '
<div class="upgrade">
<p>SPEED</p><div class="upgrade-button-disabled">UPGRADE</div>
<div class="upgrade-cost">COST <span class="right-text red-text">$' . number_format($upgrade_cost) . '</span></div>
</div>
';
}
else if($user['cash'] >= $upgrade_cost){
echo '
<div class="upgrade">
<p>SPEED</p><div class="upgrade-button">UPGRADE</div>
<div class="upgrade-cost">COST <span class="right-text">$' . number_format($upgrade_cost) . '</span></div>
</div>
';
}
$upgrade_cost = calculate_upgrade_cost("trucks", "storage");
$statement = $pdo->prepare("SELECT cash FROM users WHERE username LIKE ?");
$statement->bindParam(1, $_SESSION['username']);
$statement->execute();
$user = $statement->fetch();
if($user['cash'] >= $upgrade_cost){
echo '
<div class="upgrade">
<p>STORAGE</p><div class="upgrade-button">UPGRADE</div>
<div class="upgrade-cost">COST <span class="right-text">$' . number_format($upgrade_cost) . '</span></div>
</div>
';
}
else{
echo '
<div class="upgrade">
<p>STORAGE</p><div class="upgrade-button-disabled">UPGRADE</div>
<div class="upgrade-cost">COST <span class="right-text red-text">$' . number_format($upgrade_cost) . '</span></div>
</div>
';
}
?>
<!--
<div class="upgrade">
<p>STORAGE</p><div class="upgrade-button">UPGRADE</div>
</div>
-->
<br>
<p>TRANSPORT PLANES</p>
<p style="font-size: 16px;">These planes are used for <strong>sales</strong>.</p>
<?php
$upgrade_cost = calculate_upgrade_cost("planes", "speed");
$pdo = pdo();
$statement = $pdo->prepare("SELECT cash FROM users WHERE username LIKE ?");
$statement->bindParam(1, $_SESSION['username']);
$statement->execute();
$user = $statement->fetch();
$statement = $pdo->prepare("SELECT * FROM transport_upgrades WHERE vehicle LIKE 'planes' AND username LIKE ? AND type LIKE 'speed'");
$statement->bindParam(1, $username);
$statement->execute();
$previous_upgrades = $statement->rowCount();
$crate_delivery_time = explode('.', 1 * (3 * (1 - ($previous_upgrades * 0.03))));
if(strpos((string)$crate_delivery_time[0], "-") !== false){
$crate_delivery_time[0] = 0;
$crate_delivery_time[1] = 0;
}
if(($crate_delivery_time[0] <= 0 && $crate_delivery_time[1] <= 0) || $crate_delivery_time[0] < 0){
echo '
<div class="upgrade">
<p>SPEED</p><div class="upgrade-button-disabled">UPGRADE</div>
<div class="upgrade-cost">Limit for upgrades reached.</div>
</div>
';
}
else if($user['cash'] < $upgrade_cost){
echo '
<div class="upgrade">
<p>SPEED</p><div class="upgrade-button-disabled">UPGRADE</div>
<div class="upgrade-cost">COST <span class="right-text red-text">$' . number_format($upgrade_cost) . '</span></div>
</div>
';
}
else if($user['cash'] >= $upgrade_cost){
echo '
<div class="upgrade">
<p>SPEED</p><div class="upgrade-button">UPGRADE</div>
<div class="upgrade-cost">COST <span class="right-text">$' . number_format($upgrade_cost) . '</span></div>
</div>
';
}
?>
</div>
<div id="warehouse-space">
<div id="used-space"></div>
<p>Used warehouse space:
<?php
$pdo = pdo();
$username = $_SESSION['username'];
$statement = $pdo->prepare("SELECT SUM(slots) FROM warehouses INNER JOIN warehouse_contracts ON warehouses.id=warehouse_contracts.warehouse_id WHERE username LIKE '$username'");
$statement->execute();
$row = $statement->fetch();
$slots = $row['SUM(slots)'];
$statement = $pdo->prepare("SELECT SUM(quantity) FROM storage WHERE username LIKE '$username'");
$statement->execute();
$row = $statement->fetch();
$crates = $row['SUM(quantity)'];
if($crates === 0 || !isset($crates)){
$crates = 0;
}
$percentage_used = round(($crates/$slots)*100, 1);
echo $crates . '/' . $slots . ' (' . $percentage_used . '%)';
?>
</p>
<?php
echo '
<script>
$("#used-space").css("width", ' . $percentage_used . ' + "%");
</script>
';
?>
</div>
</div>
<div id="summary"></div>
<?php
if(isset($_SESSION['random_event']) && $_SESSION['random_event']['recent'] === true){
$robbers = array(
"Hell's Angels",
"The Lost",
"some asian streetpunks",
"a pair of irish virgins",
"the russian mob",
"some methheads",
"a korean crew"
);
if($_SESSION['random_event']['shipment_type'] === "purchase"){
echo '
<div class="alert-background"></div>
<div class="alert">
<img class="companion-speech" src="res/companion-speeches/random-event.png">
<h1>Oh no!</h1>
<p>Boss, I\'ve got some bad news. Your recent shipment of <strong>' . $_SESSION['random_event']['ordered_quantity'] . '</strong> crates was hijacked during transport by ' . $robbers[rand(0, count($robbers) - 1)] . '. They managed to get away with <strong>' . $_SESSION['random_event']['random_event_penalty'] . '</strong> crates. Though, your crew did kill <strong>' . rand(1, 20) . '</strong> of them before they took off with the product.</p>
<div class="ok-button">OK</div>
</div>
';
}
unset($_SESSION['random_event']);
}
?>
</main>
<div id="loading">
<p>Loading, please wait..</p>
</div>
</body>
</html>
In Bootstrap 3.x, you'll want to use class = "hidden-md hidden-lg" to hide content on desktops (screen resolutions >= 992 pixels).
<div id="HUD">
<div id="hamburger-menu-toggle" class="hidden-md hidden-lg">
<div></div>
<div></div>
<div></div>
</div>
<div id="hamburger-menu" class="hidden-md hidden-lg">
</div>
Bootstrap 4 is in alpha still, so I wouldn't recommend using it yet, aside from for testing purposes.
Also, make sure you put this in your head section:
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
this feature is a new feature in the new version of bootstrap v4 but you are using bootstrap 3, you can use .hidden-md and .hidden-lg instead.
Bootstrap Doc
You can skip using bootstrap CSS, and use jQuery like this:
$(document).ready(function () {
if ($(window).width() <= 997) {
$('p').hide();
}
$(window).resize(function () {
if ($(window).width() <= 997) {
$('#hamburger-menu-toggle').hide();
} else {
$('#hamburger-menu-toggle').show();
}
});
});

making an accordion toggle that works with php

how can i make a simple accordian toggle like in https://www.wireshark.org/download.html that works like getting data from a database i have,which has questions and answers? that works simply for all the rows.
this is the current code i have and want to modify.
<?php
$connection = ($GLOBALS["___mysqli_ston"] = mysqli_connect('localhost', 'root', ''));
((bool)mysqli_query($GLOBALS["___mysqli_ston"], "USE " . 'db'));
$query = "SELECT * FROM AS_Questions";
$result = mysqli_query($GLOBALS["___mysqli_ston"], $query);
if (!$result) {
printf("Errormessage: %s\n", $mysqli->error);
}
echo "<table>";
while($row = mysqli_fetch_array($result)){
echo "<div class='span3 tiny'>
<div class='pricing-table-header-tiny'>
<h2>" . $row['Question'] . "</h2>
</div>
<a href='##' id='s'>Show answer</a>
<div class='dq'>
<div class='pricing-table-features'>
<p>" . $row['Answer'] . "</p>
</div>
<div class='Dass'>
<p id='Dassp'>Answered by:" . $row['Doctor'] . "<p>
</div>
</div>
</div>"; //$row['index'] index here is a field name
}
echo "</table>"; //Close the table in HTML
((is_null($___mysqli_res = mysqli_close($GLOBALS["___mysqli_ston"]))) ? false : $___mysqli_res);
?>

How Can I Fix Apend Designing Issues In Isotope?

I have append the ajax coding, data are coming fine, here during appending this style="position: absolute; left: 468px; top: 0px;" css is not adding to my new append data. How can I do this? Below is my ajax code. Please suggest me.
See image here
<?php
$per_page=20;
$latestImages = mysql_query("select * from ".GIFIMAGES." WHERE isActive = '1' AND not_update='1' order by modified ");
$total_record=mysql_num_rows($latestImages)/5;
$maxPage=number_format((float) $total_record, 2, '.', '');
?>
<script>
var lastX = 0;
var currentX = 0;
var page = 1;
function loadMore() {
if (page < '<?php echo $maxPage;?>') {
page++;
$('#load-more').html('Loading...');
$.post("ajax_append.php", {'ajax_append':'<?php echo $per_page;?>','page':page},function(data)
{
alert(data);
$('#homeload').append(data);
$('#load-more').html('VIEW MORE');
});
} else {
$('#load-more').hide();
}
}
</script>
Below is external(html) file append coding.(grid-splash-item)No css is calling for this same class, which I have been used in pageloading.plz check it.
<?php
$i=50;
$latestImages = mysql_query("select * from ".GIFIMAGES." WHERE isActive = '1' AND not_update='1' order by modified DESC limit $total_records,$page_records");
while($getLatestGif=mysql_fetch_array($latestImages)){
$i++;
$categoryName = mysql_fetch_array(mysql_query("select name from ".CATEGORY." where id='".$getLatestGif['cat_id']."'"));
$checkLatestUsers = mysql_num_rows(mysql_query("select * from ". YEAH." where user_id = '".$_SESSION['USER_ID']."' and gifimageid ='".$getLatestGif['id']."'"));
$yeahCount = mysql_num_rows(mysql_query("select gifimageid from ". YEAH ." where gifimageid = '".$getLatestGif['id']."'"));
$yeahCountLatest = mysql_query("update ".GIFIMAGES." set yeahCount ='$yeahCount' where id = '".$getLatestGif['id']."'");
$comment = mysql_query("select * from ".COMMENTS." where gifid='". $getLatestGif['id']."' order by id desc");
$getLatestUser=mysql_fetch_array(mysql_query("SELECT username,photo FROM ".TBL_USERS." WHERE id='".$getLatestGif['userId']."'"));
$commnetsCounts = mysql_num_rows($comment);
?>
<div class="grid-splash-item">
<!-- <img src="images/img-2.jpg" /> -->
<a href="<?php echo HTTP_ROOT.'funny-'.$categoryName['name'].'-images/'. makeSeoUrl($getLatestGif['title']).'/'.$getLatestGif['uniq_id'];?>" > <img width="198" height="169" src="<?php echo HTTP_ROOT.DIR_GIF.$getLatestGif['gifphoto'];?>" /> </a>
<div class="gif-details">
<div class="gif-details-menu">
<span>
<div class="gif-details-menu-box" <?php if(!empty($_SESSION['USER_ID']) && $checkLatestUsers){?> <?php } else {?> <?php } ?>>
//My coding present.I have removed it(too long).
</div>
</span>
<p><?php echo substr($getLatestGif['title'],0,20);?></p>
</div>
</div>
</div>
<?php } ?>
try adding the inline css in html only like,
change this
<div class="grid-splash-item">
to
<?php
$counter = 1;
while ($getLatestGif = mysql_fetch_array($latestImages)) {
$i++;
$categoryName = mysql_fetch_array(mysql_query("select name from " . CATEGORY . " where id='" . $getLatestGif['cat_id'] . "'"));
$checkLatestUsers = mysql_num_rows(mysql_query("select * from " . YEAH . " where user_id = '" . $_SESSION['USER_ID'] . "' and gifimageid ='" . $getLatestGif['id'] . "'"));
$yeahCount = mysql_num_rows(mysql_query("select gifimageid from " . YEAH . " where gifimageid = '" . $getLatestGif['id'] . "'"));
$yeahCountLatest = mysql_query("update " . GIFIMAGES . " set yeahCount ='$yeahCount' where id = '" . $getLatestGif['id'] . "'");
$comment = mysql_query("select * from " . COMMENTS . " where gifid='" . $getLatestGif['id'] . "' order by id desc");
$getLatestUser = mysql_fetch_array(mysql_query("SELECT username,photo FROM " . TBL_USERS . " WHERE id='" . $getLatestGif['userId'] . "'"));
$commnetsCounts = mysql_num_rows($comment);
if ($counter % 4 == 1) {
$style = 'style="position: absolute; left: 0px; top: 175px;"';
} else if ($counter % 4 == 2) {
$style = 'style="position: absolute; left: 234px; top: 175px;"';
} else if ($counter % 4 == 3) {
$style='style="position: absolute; left: 468px; top: 175px;"';
} else {
$style='style="position: absolute; left: 702px; top: 175px;"';
}
$counter++;
?>
<div class="grid-splash-item" <?= $style ?>>
<!-- <img src="images/img-2.jpg" /> -->
<a href="<?php echo HTTP_ROOT . 'funny-' . $categoryName['name'] . '-images/' . makeSeoUrl($getLatestGif['title']) . '/' . $getLatestGif['uniq_id']; ?>" > <img width="198" height="169" src="<?php echo HTTP_ROOT . DIR_GIF . $getLatestGif['gifphoto']; ?>" /> </a>
<div class="gif-details">
<div class="gif-details-menu">
<span>
<div class="gif-details-menu-box" <?php if (!empty($_SESSION['USER_ID']) && $checkLatestUsers) { ?> <?php } else { ?> <?php } ?>>
//My coding present.I have removed it(too long).
</div>
</span>
<p><?php echo substr($getLatestGif['title'], 0, 20); ?></p>
</div>
</div>
</div>
After researching a lot,i came to a accurate result.Here its only need to change two things.Here i have not written any inline css,after appending its coming fine,with proper css.
Below is my new code.Which is working perfectly.
This is my new script coding.I have modified a little
<?php $per_page=20; $latestImages = mysql_query("select * from ".GIFIMAGES." WHERE isActive = '1' AND not_update='1' order by modified "); $total_record=mysql_num_rows($latestImages)/5;$maxPage=number_format((float) $total_record, 2, '.', ''); ?>
<script>
$(function(){
var $container = $('#container');
var lastX = 0;
var currentX = 0;
var page = 1;
$('#append a').click(function(){
if (page < '<?php echo $maxPage;?>') {
page++;
$('.funny-gifts').html('Loading...');
$.post("ajax_append.php", {'ajax_append':'<?php echo $per_page;?>','page':page},function(data)
{
// $('#container').append(data);
var $newItems = $(data);
$('#container').isotope( 'insert', $newItems );
$('.funny-gifts').html('More Funny Gifs');
});
} else {
$('.funny-gifts').hide();
}
});
});
</script>
***var $newItems = $(data);
$('#container').isotope( 'insert', $newItems );***
This above two line coding is very important for appending.
Dont use $('#container').append(data); for appending.Result will come but,having a designing issues.Then after it replace the view more button slightly.Below is coding.
<div id="append">More Funny Gifs</div>

Categories