531fb282323382cbc26acaae8146c609ca803986
[stouyapi.git] / data / templates / game.tpl.php
1 <!DOCTYPE html>
2 <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
3  <head>
4   <meta charset="utf-8"/>
5   <title><?= htmlspecialchars($json->title); ?> - OUYA game</title>
6   <meta name="generator" content="stouyapi"/>
7   <meta name="author" content="<?= htmlspecialchars($json->developer->name) ?>"/>
8   <link rel="stylesheet" type="text/css" href="../ouya-game.css"/>
9   <link rel="icon" href="../favicon.ico"/>
10  </head>
11  <body class="game">
12   <header>
13    <img class="ouyalogo" src="../ouya-logo.grey.svg" alt="OUYA logo" width="50"/>
14   </header>
15   <section class="text">
16    <h1><?= htmlspecialchars($json->title); ?></h1>
17    <dl class="meta">
18     <dt>Rating</dt>
19     <dd class="rating">
20      <span class="average average-<?= round($json->rating->average) ?>" title="<?= $json->rating->average ?>"><?= $json->rating->average ?></span>
21      <span class="count">(<?= $json->rating->count ?>)</span>
22     </dd>
23
24     <dt>Developer</dt>
25     <dd class="company">
26      <?php if ($appsJson->app->website): ?>
27       <a href="<?= htmlspecialchars($appsJson->app->website) ?>"><?= htmlspecialchars($json->developer->name) ?></a>
28      <?php else: ?>
29       <?= htmlspecialchars($json->developer->name) ?>
30      <?php endif ?>
31     </dd>
32
33     <dt>Suggested age</dt>
34     <dd class="contentRating">
35      <?= htmlspecialchars($json->suggestedAge) ?>
36     </dd>
37
38     <dt>Number of players</dt>
39     <dd class="players">
40      <?= htmlspecialchars(implode(', ', $json->gamerNumbers)) ?>
41     </dd>
42
43     <dt>Download size</dt>
44     <dd class="size">
45      <?= number_format($json->apk->fileSize / 1024 / 1024, 2) ?> MiB
46     </dd>
47    </dl>
48
49    <p class="description">
50     <?= nl2br(htmlspecialchars($json->description)) ?>
51    </p>
52   </section>
53
54   <section class="media">
55    <h2>Screenshots</h2>
56    <div class="content">
57     <?php foreach ($json->mediaTiles as $tile): ?>
58      <?php if ($tile->type == 'image'): ?>
59       <img src="<?= htmlspecialchars($tile->urls->thumbnail) ?>" alt="Screenshot of <?= htmlspecialchars($json->title); ?>"/>
60      <?php elseif ($tile->type == 'video'): ?>
61       <video controls="">
62        <source src="<?= htmlspecialchars($tile->url) ?>"/>
63       </video>
64      <?php endif ?>
65     <?php endforeach ?>
66    </div>
67   </section>
68
69   <section class="buttons">
70    <h2>Links</h2>
71    <div>
72     <a href="<?= $apkDownloadUrl ?>">Download .apk</a>
73     <p>
74      Version <?= $json->version->number ?>, published
75      <?= gmdate('Y-m-d', $json->version->publishedAt) ?>
76     </p>
77    </div>
78    <div>
79     <form method="post" action="<?= htmlspecialchars($pushUrl) ?>" id="push" onsubmit="pushToMyOuya();return false;">
80      <button name="push" type="submit" class="push-to-my-ouya">
81       <img src="../push-to-my-ouya.png" width="335" height="63"
82            alt="Push to my OUYA"
83       />
84      </button>
85     </form>
86    </div>
87   </section>
88
89   <nav>
90    <?php foreach ($navLinks as $url => $title): ?>
91     <a rel="up" href="<?= htmlspecialchars($url) ?>"><?= htmlspecialchars($title) ?></a>
92    <?php endforeach ?>
93   </nav>
94
95   <div style="display: none" class="popup" id="push-success">
96    <a class="close" href="#" onclick="this.parentNode.style.display='none';return false;">⊗</a>
97    <strong><?= htmlspecialchars($json->title); ?></strong>
98    will start downloading to your OUYA within the next few minutes
99   </div>
100   <div style="display: none" class="popup" id="push-error">
101    <a class="close" href="#" onclick="this.parentNode.style.display='none';return false;">⊗</a>
102    <strong>Push error</strong>
103    <p>error message</p>
104   </div>
105
106   <script type="text/javascript">
107    function pushToMyOuya() {
108        var form = document.getElementById("push");
109        var req = new XMLHttpRequest();
110        req.addEventListener("load", pushToMyOuyaComplete);
111        req.open("POST", form.action);
112        req.send();
113    }
114    function pushToMyOuyaComplete() {
115        if (this.status / 100 == 2) {
116            document.getElementById('push-success').style.display = "";
117        } else {
118            var err = document.getElementById('push-error');
119            err.getElementsByTagName("p")[0].textContent = this.responseText;
120            err.style.display = "";
121        }
122    }
123   </script>
124  </body>
125 </html>