From e575bb3a722b30d426cbdfa83b55e9ec749f362a Mon Sep 17 00:00:00 2001 From: Christian Damken Date: Fri, 12 May 2017 22:48:57 +0200 Subject: [PATCH] Implemented linecounter for cards-input, changed output formatting around a bit, moar text --- index.php | 65 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 13 deletions(-) diff --git a/index.php b/index.php index d370470..1ce87f5 100755 --- a/index.php +++ b/index.php @@ -58,6 +58,10 @@ margin-right: 0.5em; } + label small { + font-size: 0.75em; + font-weight: normal; + } textarea#query { font-family: monospace; } @@ -72,12 +76,34 @@ border-color: hsl(224, 78%, 75%); background-color: hsl(224, 78%, 90%); } + button[type=submit]:disabled { + border-color: hsl(224, 20%, 90%); + background-color: hsl(224, 20%, 75%); + } :required:invalid, :focus:invalid { /* insert your own styles for invalid form input */ background-color: #ffeeee; } +

MtG Card Data Collector

@@ -118,12 +144,15 @@ function x() { } switch ($_REQUEST['format']) { - case "set:num": + case "cardname": + $template = "{name}"; + break; + case "set:number": $template = "{set}: {number}"; break; - case "cardname": + case "setname:cardname": default: - $template = "{name}"; + $template = "{setName}: {name}"; } $lines = explode("\n", $q); @@ -139,6 +168,9 @@ function x() { $urls_only = false; foreach ($lines as $i => $line) { $parts = explode(' ', trim($line)); + if (count($parts) !== 2) + continue; + $url = "https://api.magicthegathering.io/v1/cards?set=$parts[0]&number=$parts[1]"; if (!$urls_only) { @@ -182,7 +214,8 @@ x() "cardname", - "Set: Number" => "set:num", + "Set name: Card name" => "setname:cardname", + "Set: Number" => "set:number", ] as $label => $value) { $selected = $_REQUEST["format"] === $value ? " selected" : ""; echo ""; @@ -196,24 +229,30 @@ foreach ([
- -
-
-

- Please keep in mind the data source for this service enforces a daily request limit, - so please don't waste it. If no cards are found and you are sure your set codes and - card numbers are valid, try again in a few hours or use the raw result URLs. -

+
+
+

+ Please keep in mind the data source for this service enforces a daily request limit, + so please don't waste it. If no cards are found and you are sure your set codes and + card numbers are valid, try again in a few hours or use the raw result URLs. +

+

+ Depending on how many cards you entered, loading the data will take a while. +

+
- +
+