1 contributor
<?php
//List available images
$newslist = array();
$imagelist = array();
$cmdlist = array();
$content = file_get_contents("sources/news.json");
$newsdetails = json_decode($content,true);
foreach( $newsdetails as $news ) {
array_push($newslist, $news['name']);
array_push($imagelist, $news['image']);
array_push($cmdlist, $news['html']);
}
//Generate HTML code section for dosbox
function NewsSection($title, $game, $sourceHTML) {
$html="";
$html .= '<div class="col-4 col-s-8">'.PHP_EOL;
$content = file_get_contents($sourceHTML);
$html .= $content;
$html .= '</div>'.PHP_EOL;
return $html;
}
?>
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="favicon.png">
<link href="css/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script>
function onArticle(index) {
var string_index = "article-"+index;
var url = location.href;
document.getElementById("article-current").innerHTML =
document.getElementById(string_index).innerHTML;
location.href = "#article-top";
}
</script>
<script>
function getStylesheet() {
var currentTime = new Date().getHours();
if (0 <= currentTime && currentTime < 8) {
document.write("<link rel='stylesheet' href='css/style-night.css' type='text/css'>");
} else if (8 <= currentTime && currentTime < 19) {
document.write("<link rel='stylesheet' href='css/style-day.css' type='text/css'>");
} else if (19 <= currentTime && currentTime < 24) {
document.write("<link rel='stylesheet' href='css/style-night.css' type='text/css'>");
}
}
getStylesheet();
</script>
<script>
function hideMenu() {
var x = document.getElementById("menu-news");
var btn = document.getElementById("menu-btn");
if (x.style.display === "none") {
x.style.display = "block";
btn.innerHTML = '<i class="fa fa-eye-slash fa-fw"></i>';
} else {
x.style.display = "none";
btn.innerHTML = '<i class="fa fa-eye fa-fw"></i>';
}
}
</script>
<title>News.fr</title>
</head>
<body>
<div class="header">
<h1><i class="fa fa-newspaper-o fa-fw"></i> News.fr</h1>
</div>
<div class="row">
<button id="menu-btn" onclick="hideMenu()"><i class="fa fa-eye-slash fa-fw"></i></button>
<div id="menu-news" class="col-2 col-s-2 menu">
<ul>
<?php
$cpt = 0;
foreach ( $imagelist as $file ) {
echo ' <li><i class="fa fa-newspaper-o fa-fw"></i><a href="?channel='.$file.'">'.$newslist[$cpt].'</a></li>'.PHP_EOL;
$cpt++;
}
?>
</ul>
</div>
<!-- Main Display -->
<?php
//Default is first of the list
$GETtitle = $newslist[0];
$GETgame = $imagelist[0];
$GETexec = $cmdlist[0];
if( isset( $_GET['channel'] ) ) {
$GETgame = $_GET['channel'];
$cpt = 0;
foreach ( $imagelist as $file ) {
if( $file == $GETgame ) {
break;
}
$cpt++;
}
}
$GETexec = $cmdlist[$cpt]; // Game Executable
$GETtitle = $newslist[$cpt]; // Game Title
echo NewsSection($GETtitle, $GETgame, $GETexec);
?>
</div>
<!-- Right-Side Column -->
<!--
<div class="col-3 col-s-12">
<div class="aside">
<h1>Aside</h1>
</div>
</div>
-->
</div> <!-- ./row -->
<!-- Footer -->
<!--
<div class="footer">
<p>Resize the browser window to see how the content respond to the resizing.</p>
</div>
-->
</body>
</html>