From 261a7ac22a6027e024aa12efb35cbeaac67fad59 Mon Sep 17 00:00:00 2001 From: Maksymilian Jopek Date: Sun, 26 Mar 2023 20:32:38 +0200 Subject: Add start script --- assets/favicon.17e50649.svg | 15 +++++++++++++++ assets/index.43fa17e5.css | 1 + assets/index.f2167513.js | 1 + index.php | 3 ++- pnpm-lock.yaml | 2 +- start | 9 +++++++++ 6 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 assets/favicon.17e50649.svg create mode 100644 assets/index.43fa17e5.css create mode 100644 assets/index.f2167513.js create mode 100755 start diff --git a/assets/favicon.17e50649.svg b/assets/favicon.17e50649.svg new file mode 100644 index 0000000..de4aedd --- /dev/null +++ b/assets/favicon.17e50649.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/assets/index.43fa17e5.css b/assets/index.43fa17e5.css new file mode 100644 index 0000000..3434d45 --- /dev/null +++ b/assets/index.43fa17e5.css @@ -0,0 +1 @@ +html{font-family:Avenir,Helvetica,Arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-align:center;color:#2c3e50;margin-top:60px}td,th{border:1px solid black} diff --git a/assets/index.f2167513.js b/assets/index.f2167513.js new file mode 100644 index 0000000..7520ec7 --- /dev/null +++ b/assets/index.f2167513.js @@ -0,0 +1 @@ +const a=function(){const o=document.createElement("link").relList;if(o&&o.supports&&o.supports("modulepreload"))return;for(const e of document.querySelectorAll('link[rel="modulepreload"]'))r(e);new MutationObserver(e=>{for(const t of e)if(t.type==="childList")for(const c of t.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&r(c)}).observe(document,{childList:!0,subtree:!0});function n(e){const t={};return e.integrity&&(t.integrity=e.integrity),e.referrerpolicy&&(t.referrerPolicy=e.referrerpolicy),e.crossorigin==="use-credentials"?t.credentials="include":e.crossorigin==="anonymous"?t.credentials="omit":t.credentials="same-origin",t}function r(e){if(e.ep)return;e.ep=!0;const t=n(e);fetch(e.href,t)}};a();const d="http://localhost:8000/index.php";(async()=>{const i=await(await fetch(d)).json(),o=document.getElementById("tds-here");for(const n of i){const r=document.createElement("tr"),e=document.createElement("td");e.innerText=n,e.onclick=()=>l(n,n),r.appendChild(e),o.appendChild(r)}})();async function l(i,o){const n=await(await fetch(d,{method:"POST",body:o})).json(),r=document.getElementById("name-here"),e=document.getElementById("vtds-here");e.innerHTML="",r.innerHTML=`Miasta w ${i} (${n.length}, internet)`;for(const t of n){const c=document.createElement("tr"),s=document.createElement("td");s.innerText=t,c.appendChild(s),e.appendChild(c)}} diff --git a/index.php b/index.php index ee7431c..cb50f69 100644 --- a/index.php +++ b/index.php @@ -7,12 +7,13 @@ if ($method === "GET") { $result = $xml->xpath('//NAZWA_DOD[text()="województwo"]/ancestor::*/NAZWA/text()'); } else if ($method === "POST") { $body = file_get_contents('php://input'); - $one_xpath = true; + $one_xpath = false; if (!$one_xpath) { $id = $xml->xpath('//row/NAZWA[text()="' . $body . '"]/ancestor::*/WOJ'); $id = "{$id[0]}"; $result = $xml->xpath('//WOJ[text()=' . $id . ']/ancestor::*/NAZWA_DOD[contains(text(),"miejs")]/ancestor::*/NAZWA/text()'); } else { + set_time_limit(200); $result = $xml->xpath('//WOJ[text()=//row/NAZWA[text()="' . $body . '"]/ancestor::*/WOJ]/ancestor::*/NAZWA_DOD[contains(text(),"miejs")]/ancestor::*/NAZWA/text()'); } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 01a9f49..b6d53f0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: 5.3 +lockfileVersion: 5.4 specifiers: typescript: ^4.5.4 diff --git a/start b/start new file mode 100755 index 0000000..929beae --- /dev/null +++ b/start @@ -0,0 +1,9 @@ +#!/bin/sh +npm run dev & +npm_pid="$(echo $!)" +php -S 0.0.0.0:8000 & +php_pid="$(echo $!)" + +echo "Click anything to stop" +read t +kill $php_pid $npm_pid -- cgit v1.3.1