Skip to content

Commit

Permalink
Presets
Browse files Browse the repository at this point in the history
  • Loading branch information
tmcw committed Feb 14, 2012
1 parent 5f0d6ef commit d8db6bb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ <h2>2. Write your projection</h2>
functions implementing a projection. Both functions
take x &amp; y for longitude and latitude and should
return a number.</p>
<p>presets:
<a href='#1819127'>azimuthal from the south pole</a>,
<a href='#1822426'>Tom's fun swoopy</a>
</p>
<table>
<tr>
<td>x = function(x, y)</td>
Expand Down
29 changes: 29 additions & 0 deletions site.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,32 @@ document.getElementById('netbook').onclick = function() {
skip = 5;
block = 7;
};

function loadpreset() {
if (window.location.hash) {
var id = parseInt(window.location.hash.substring(1));
if (isNaN(id)) return alert('you gave a location hash but it wasn\'t an id!');
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
head.appendChild(script);
document.getElementById('fx').value =
document.getElementById('fy').value = '... loading preset ...';
script.onload = function() {
document.getElementById('fx').value =
fx.toString()
.replace('function fx(x, y) {', '')
.replace(/\}/g, '');
document.getElementById('fy').value =
fy.toString()
.replace('function fy(x, y) {', '')
.replace(/\}/g, '');
};
script.src = 'https://raw.github.com/gist/' + id;
}
}

loadpreset();

window.onhashchange = loadpreset;

0 comments on commit d8db6bb

Please sign in to comment.