| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488 |
- <?php
- /**
- * API Help view.
- *
- * Shows API documentation.
- *
- * @category View
- * @var mixed[] $API API help structure.
- */
- ?>
- <?php
- include __DIR__ . "/api.php";
- ?>
- <!DOCTYPE html>
- <html lang='en'>
- <head>
- <meta content='text/html; charset=utf-8' http-equiv='content-type'/>
- <meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1'/>
- <title>SWDB APIv3</title>
- <link rel='shortcut icon' href='<?=URL::IMG["LOGO"]?>sw.png'/>
- <!-- CSS -->
- <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>ui.css'/>
- <style>
- aside hr{
- height: 0em;
- padding: 0;
- margin: 0 1em;
- border: 0.01em solid #db490054;
- border-radius: 1em;
- }
- aside h3 {
- margin: 0.4em 0 0.2em 1em;
- border-left: 0.5em solid #db490054;
- border-radius: 0.2em;
- padding-left: 0.3em;
- background-color: #00000000;
- transition: all .3s ease-in-out;
- }
- aside h3:hover{
- background-color: #db490054;
- }
- aside h3 a{
- color: #cccccc
- }
- aside h3:hover a{
- color: #ffffff
- }
- aside ul {
- margin: 0.2em 0;
- list-style: none;
- }
- aside ul li{
- border-left: 0.5em solid #db490054;
- border-radius: 0.2em;
- padding-left: 0.3em;
- margin-bottom: 0.2em;
- background-color: #00000000;
- transition: all .3s ease-in-out;
- }
- aside ul li:hover{
- background-color: #db490054;
- }
- aside ul li a{
- color: #cccccc
- }
- aside ul li:hover a{
- color: #ffffff
- }
- aside div#copyright{
- text-align: center;
- font-size: 70%;
- position: absolute;
- bottom: 1em;
- }
- section.category article{
- margin: 1.5em;
- padding-left: 1em;
- padding-right: 1em;
- text-align: left;
- }
- section.category article h3{
- vertical-align: bottom;
- }
- section.category article h3 span.description{
- font-style: italic;
- font-size: 90%;
- }
- section.category article:not(:last-child){
- padding-bottom: 1em;
- margin-bottom: 1em;
- border-bottom: 0.1em solid #ffffff66;
- }
- section.category article div.command span{
- display: inline-block;
- border-radius: 0.6em;
- padding: 0.3em 0.5em;
- border-width: 0.15em;
- border-style: solid;
- color: #ffffff;
- font-family: monospace, monospace;
- font-weight: bold;
- }
- section.category article div.command span.url{
- background-color: #292b36;
- border-color: #4b4d57;
- }
- section.category article div.command span.type{
- text-transform: uppercase;
- }
- section.category article div.command span.type_GET {
- background-color: #008000;
- border-color: #22a222;
- }
- section.category article div.command span.type_PUT {
- background-color: #e5c500;
- border-color: #f7e722;
- }
- section.category article div.command span.type_POST {
- background-color: #4070ec;
- border-color: #6292fe;
- }
- section.category article div.command span.type_DELETE {
- background-color: #ed0039;
- border-color: #ff225b;
- }
- section.category article table{
- border-collapse: collapse;
- width: 80%;
- border-radius: 0.5em;
- margin: 0.5em auto 1em auto;
- }
- section.category article table th {
- background-color: #331100;
- text-align: left;
- font-weight: bold;
- padding: 0.5em 1em;
- border: 0.1px solid #e0e0e0;
- }
- section.category article table td {
- background-color: #352413;
- vertical-align: top;
- padding: 0.2em 0.4em;
- border: #e0e0e0 1px solid;
- }
- section.category article table td.name {
- font-family: monospace, monospace;
- font-weight: bold;
- }
- section.category article table td.name span.location{
- padding-left: 1em;
- font-size: 80%;
- font-style: italic;
- color: #ffffff77;
- }
- section.category article table td.type {
- font-family: monospace, monospace;
- font-weight: bold;
- }
- section.category article table td.status span{
- display: inline-block;
- border-radius: 0.6em;
- padding: 0.3em 0.5em;
- border-width: 0.15em;
- border-style: solid;
- color: #ffffff;
- font-family: monospace, monospace;
- font-weight: bold;
- }
- section.category article table td.status_1 span{
- border-color: #999999;
- background-color: #777777;
- }
- section.category article table td.status_2 span{
- background-color: #008000;
- border-color: #22a222;
- }
- section.category article table td.status_3 span{
- background-color: #4070ec;
- border-color: #6292fe;
- }
- section.category article table td.status_4 span{
- background-color: #e5c500;
- border-color: #f7e722;
- }
- section.category article table td.status_5 span{
- background-color: #ed0039;
- border-color: #ff225b;
- }
- section.category article table td.message{
- font-family: monospace, monospace;
- }
- section.category article table td.description span.optional {
- font-size: 90%;
- color: #bbbbbb;
- font-style: italic;
- }
- section#example{
- position: fixed;
- display: none;
- top: 15%;
- left: 20%;
- width: 60%;
- max-width: 90em;
- height: 70%;
- max-height: 30em;
- text-align: right;
- }
- section#example article{
- text-align: right;
- }
- section#example article pre#example_content{
- text-align: left;
- background-color: #292b36;
- border: 0.3em solid #4b4d57;
- border-radius: 0.8em;
- padding: 1em;
- max-height: 20em;
- overflow: scroll;
- }
- </style>
- <!-- Javascript -->
- <script>
- function showExample(command, status, example){
- document.getElementById('example_title').innerHTML = command + " HTTP status " + status + " response example";
- document.getElementById('example_content').innerHTML = JSON.stringify(JSON.parse(example), null, 4);
- document.getElementById('example').style.display = 'block';
- }
- function closeExample(command, status, example){
- document.getElementById('example').style.display = 'none';
- }
- </script>
- <!-- Meta tags -->
- <link rel='canonical' href='<?=URL::BASE?>API/v3/help/'/>
- <link rel='author' href='SWDB'/>
- <link rel='publisher' href='SWDB'/>
- <meta name='description' content='SWDB API v3 Documentation'/>
- <meta property='og:title' content='SWDB APIv3'/>
- <meta property='og:url' content='<?=URL::BASE?>API/v3/help/'/>
- <meta property='og:description' content='SWDB API v3 Documentation'/>
- <meta property='og:image' content='<?=URL::IMG["LOGO"]?>sw.png'/>
- <meta property='og:site_name' content='SWDB'/>
- <meta property='og:type' content='website'/>
- <meta property='og:locale' content='en'/>
- <meta name='twitter:card' content='summary'/>
- <meta name='twitter:title' content='SWDB APIv3'/>
- <meta name='twitter:description' content='SWDB API v3 Documentation'/>
- <meta name='twitter:image' content='<?=URL::IMG["LOGO"]?>sw.png'/>
- <meta name='twitter:url' content='<?=URL::BASE?>API/v3/help/'/>
- <meta name='robots' content='index follow'/>
- </head>
- <body>
- <header>
- <div id='logo'>
- <img id='logo_img' src='<?=URL::IMG["LOGO"]?>sw.png' alt=''/>
- <h1 id='logo_text'>
- <span class='large'>D</span>
- <span class='small'>ata</span>
- <span class='large'>B</span>
- <span class='small'>ase</span>
- </h1>
- </div>
- </header>
- <aside>
- <h2>
- API v3 endopoints:
- </h2>
- <?php
- foreach ($API["category"] as $category){
- ?>
- <h3>
- <a href='#category_<?=$category["name"]?>'>
- <?=$category["name"]?>
- </a>
- </h3>
- <ul>
- <?php
- foreach ($category["command"] as $command){
- foreach ($command["method"] as $method){
- ?>
- <li>
- <a href='#command_<?=$command["name"]?>-<?=$method["id"]?>-<?=htmlspecialchars($method["url"])?>' title='<?=$command["description"]?>'>
- <?=$method["id"]?> <?=htmlspecialchars($method["url"])?>
- </a>
- </li>
- <?php
- }
- }
- ?>
- </ul>
- <hr/>
- <?php
- }
- ?>
- </aside>
- <main>
- <?php
- foreach ($API["category"] as $category){
- foreach ($category["command"] as $command){
- ?>
- <section id='category_<?=$category["name"]?>' class='category content'>
- <h2>
- <?=$category["name"]?>
- </h2>
- <article id='command_<?=$command["name"]?>'>
- <h3>
- <?=$command["name"]?>
- </h3>
- <?php
- foreach ($command["method"] as $method){
- ?>
- <div class='command' id='command_<?=$command["name"]?>-<?=$method["id"]?>-<?=htmlspecialchars($method["url"])?>'>
- <span class='type type_<?=$method["id"]?>'>
- <?=$method["id"]?>
- </span>
- <span class='url'>
- <?=htmlspecialchars($method["url"])?>
- </span>
- <span class='description'>
- <?=$method["description"]?>
- </span>
- </div>
- <table class='params'>
- <thead>
- <tr>
- <th class='header' colspan='3'>
- Parameters
- </th>
- </tr>
- <tr>
- <th class='name'>
- Parameter
- </th>
- <th class='type'>
- Type
- </th>
- <th class='description'>
- Description
- </th>
- </tr>
- </thead>
- <tbody>
- <?php
- foreach ($method["parameters"] as $param){
- ?>
- <tr>
- <td class='name'>
- <?=$param["key"]?>
- <span class='location'>
- (<?=$param["via"]?>)
- </span>
- </td>
- <td class='type'>
- <?=$param["type"]?>
- </td>
- <td class='description'>
- <?=($param["optional"] ? "<span class='optional'>[Optional] </span>" : "")?>
- <?=$param["description"]?>
- </td>
- </tr>
- <?php
- }
- ?>
- </tbody>
- </table>
- <table class='responses'>
- <thead>
- <tr>
- <th class='header' colspan='3'>
- Responses
- </th>
- </tr>
- <tr>
- <th class='status'>
- Status
- </th>
- <th class='status'>
- Message
- </th>
- <th class='description'>
- Description
- </th>
- </tr>
- </thead>
- <tbody>
- <?php
- foreach ($method["responses"] as $response){
- ?>
- <tr>
- <td class='status status_<?=substr($response["status"], 0, 1)?>'>
- <span>
- <?=$response["status"]?>
- </span>
- </td>
- <td class='message'>
- <?=$response["message"]?>
- </td>
- <td class='description'>
- <?=$response["description"]?>
- <?php
- if ($response["example"] != null){
- ?>
- <span class='fake_a' onclick="showExample('<?=$command["name"]?>', <?=$response["status"]?>, '<?=htmlspecialchars(json_decode($response["example"]), ENT_QUOTES)?>')">
- View example.
- </span>
- <?php
- }
- ?>
- </td>
- </tr>
- <?php
- }
- ?>
- </tbody>
- </table>
- <?php
- }
- ?>
- </article>
- </section>
- <?php
- }
- ?>
- <section id='example' class='content'>
- <h2 id='example_title'>
- </h2>
- <article>
- <pre id='example_content'>
- </pre>
- <input type='button' value='Close' onClick='closeExample();'>
- </article>
- </section>
- <?php
- }
- ?>
- </main>
- <footer>
- <table id='footer_table'>
- <tr>
- <td id='footer_left'>
- Version <?=APP::VERSION?>. Developed by <a href='https://inigovalentin.com'>Iñigo Valentin</a>.
- <br/>
- <br/>
- Source code available on <a href='https://github.com'>Github</a> under the GPLv3.
- </td>
- <td id='footer_right'>
- Neither I nor this tool are affiliated with or endorsed by <a href='http://com2us.com/'>Com2uS</a> in any way. The Summoners >
- </td>
- </tr>
- </table>
- </footer>
- </body>
- </html>
|