This can simply be achieved by the github api(https://api.github.com/octocat?s={query_string_value}
),
replace the {query_string_value}
with the words you want the octocat to say.
As the browser trims empty space for display, the pattern might not render properly, i found 2 ways to preview:
- web inspector
If using Chrome, open Chrome Dev Tool and inspect the HTML elements, it's wrapped in a pair of <pre></pre>
tag.
- command prompt
using curl
command line utility:
curl -L https://api.github.com/octocat?s={query_string_value}
Result:
MMM. .MMM
MMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMM ________________________
MMMMMMMMMMMMMMMMMMMMM | |
MMMMMMMMMMMMMMMMMMMMMMM | [query_string_value] |
MMMMMMMMMMMMMMMMMMMMMMMM |_ ____________________|
MMMM::- -:::::::- -::MMMM |/
MM~:~ 00~:::::~ 00~:~MM
.. MMMMM::.00:::+:::.00::MMMMM ..
.MM::::: ._. :::::MM.
MMMM;:::::;MMMM
-MM MMMMMMM
^ M+ MMMMMMMMM
MMMMMMM MM MM MM
MM MM MM MM
MM MM MM MM
.~~MM~MM~MM~MM~~.
~~~~MM:~MM~~~MM~:MM~~~~
~~~~~~==~==~~~==~==~~~~~~
~~~~~~==~==~==~==~~~~~~
:~==~==~==~==~~
Question:
How to parse query string in JavaScript?
Answer:
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split('&');
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split('=');
if (decodeURIComponent(pair[0]) == variable) {
return decodeURIComponent(pair[1]);
}
}
console.log('Query variable %s not found', variable);
}
Now make a request to page.html?x=Hello:
console.log(getQueryVariable('x'))