Skip to content

Instantly share code, notes, and snippets.

@KeithP
Last active March 18, 2019 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KeithP/6d5e086d0e4bcdda9ae30f8416f6c5cc to your computer and use it in GitHub Desktop.
Save KeithP/6d5e086d0e4bcdda9ae30f8416f6c5cc to your computer and use it in GitHub Desktop.
<!-- START-->
<hr>
<h3>Current planning applications:</h3>
<p><code><var><cite>Larger schemes currently awaiting planning decisions (updated weekly)</cite></var></code></p>
<script src="https://cdnjs.cloudflare.com/ajax/libs/json2html/1.2.0/json2html.min.js"></script><script>
function convertDate(inputFormat) {
function pad(s) { return (s < 10) ? '0' + s : s; }
var d = new Date(inputFormat);
return [pad(d.getDate()), pad(d.getMonth()+1), d.getFullYear()].join('/');
}
async function fetchBigCurrent() {
const URL = "https://www.planningapp.org/kingston-upon-thames/applications.json?utf8=✓&sort_by=decision_target_date_desc&postcode=&large_applications=on";
const transform =
{'<>':'span','html': [
{'<>':'ul','html': [
{'<>':'li', 'html': [
{'<>':'a', 'href': '${detail_page_link}', 'html': '${application_number}: ${site_address}' },
{'<>':'p', 'text': function(){return( convertDate( this.decision_target_date_iso8601 ) +
' is the target decision date (' +
convertDate( this.date_validated_iso8601 ) + ' was the validation date).'
);} },
{'<>':'em', 'text': '${documents_count} documents' }
]}
]}
]}
try {
const headers = new Headers();
headers.append('Access-Control-Allow-Origin', '*');
const request = new Request(URL, { method: 'GET', cache: 'reload', headers: headers });
const fetchResult = fetch( request );
const response = await fetchResult;
const jsonData = await response.json();
document.getElementById("planningapp").innerHTML = json2html.transform( jsonData,transform );
} catch(e){throw Error(e);}} fetchBigCurrent(); </script>
<p><div id="planningapp"></div></p>
<p><code><var><cite>Source: RBK, curated by Kingston CAACs</cite></var></code></p>
<hr>
<br>
<!-- END-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment