Last active
November 8, 2019 14:04
-
-
Save GoSubRoutine/f13a55e7cfaabea6aa6bdf028c1f2f1e to your computer and use it in GitHub Desktop.
JSON Wikipedia CORS Origin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
height: 260 | |
scrolling: yes | |
border: yes | |
license: cc-by-4.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<meta charset=utf-8> | |
<meta name=viewport content=width=device-width,initial-scale=1> | |
<script async src=https://cdn.JsDelivr.net/npm/p5></script> | |
<script defer src=sketch.js></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* JSON Wikipedia CORS Origin (v1.1.2) | |
* GoToLoop (2019-Jan-21) | |
* | |
* https://Discourse.Processing.org/t/issue-with-loadjson/7682/4 | |
* https://Bl.ocks.org/GoSubRoutine/f13a55e7cfaabea6aa6bdf028c1f2f1e | |
*/ | |
"use strict"; | |
const HTTP = 'https://', SITE = 'en.Wikipedia.org', | |
FOLD = '/w/', FILE = 'api.php', | |
ASK = '?', AND = '&', | |
ORI = 'origin=*', | |
ACT = 'action=opensearch', | |
WORD = 'search=unicorn', | |
LINK = HTTP + SITE + FOLD + FILE + ASK + ORI + AND + ACT + AND + WORD, | |
LIST = 'ol', ITEM = 'li', BLANK = '_blank', COLOR = 'Red'; | |
let jsonArray; | |
function preload() { | |
print(LINK); | |
jsonArray = loadJSON(LINK, print); | |
} | |
function setup() { | |
noCanvas(), noLoop(); | |
console.table(jsonArray); | |
const list = createElement(LIST) | |
.style('color', COLOR) | |
.style('font-weight: bold') | |
.style('font-size: 1.2em'); | |
for (const url of jsonArray[3]) | |
createElement(ITEM).child(createA(url, url, BLANK)).parent(list); | |
//createElement(ITEM, url.link(url)).parent(list); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment