newsFR / index.php /
Yanik Cawidrone Added CSS & Sources
5c3c367 6 years ago
1 contributor
114 lines | 3.299kb
<?php
//List available images
$newslist = array();
$imagelist = array();
$cmdlist = array();
$content = file_get_contents("sources/news.json");
$games = json_decode($content,true);
foreach( $games as $game ) {
  array_push($newslist, $game['name']);
  array_push($imagelist, $game['image']);
  array_push($cmdlist, $game['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">
    <!-- <script type="text/javascript" src="jquery.min.js"></script> -->
    <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>
    <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">
    <div 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>