Skip to content

Commit 2d2f6b2

Browse files
committed
redirect previously versioned scratch url to new one
1 parent c6e4e69 commit 2d2f6b2

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

js/script.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,16 @@ var executeDataAndCode = function () {
511511
tracerManager.findOwner(this).mousewheel(e);
512512
});
513513

514+
var getParameterByName = function (name) {
515+
var url = window.location.href;
516+
name = name.replace(/[\[\]]/g, "\\$&");
517+
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
518+
results = regex.exec(url);
519+
if (!results) return null;
520+
if (!results[2]) return '';
521+
return decodeURIComponent(results[2].replace(/\+/g, " "));
522+
};
523+
514524
var getHashValue = function (key) {
515525
if (!key) return null;
516526
var hash = window.location.hash.substr(1);
@@ -610,4 +620,11 @@ var executeDataAndCode = function () {
610620
loadAlgorithm(category, algorithm);
611621
});
612622
};
613-
})();
623+
624+
var v1LoadedScratch = getHashValue('scratch-paper');
625+
var v2LoadedScratch = getParameterByName('scratch-paper');
626+
var vLoadedScratch = v1LoadedScratch || v2LoadedScratch;
627+
if (vLoadedScratch) {
628+
location.href = location.protocol + '//' + location.host + location.pathname + '#algorithm=scratch/' + vLoadedScratch;
629+
}
630+
})();

0 commit comments

Comments
 (0)