提交 1acc5ef5 编写于 作者: J Jason Park

Merge branch 'gh-pages' of https://github.com/parkjs814/AlgorithmVisualizer into gh-pages

...@@ -351,4 +351,53 @@ $(document).mouseup(function (e) { ...@@ -351,4 +351,53 @@ $(document).mouseup(function (e) {
}); });
$module_container.on('DOMMouseScroll mousewheel', '.module_wrapper', function (e) { $module_container.on('DOMMouseScroll mousewheel', '.module_wrapper', function (e) {
tm.findOwner(this).mousewheel(e); tm.findOwner(this).mousewheel(e);
}); });
\ No newline at end of file
// Share scratch paper
var getParameterByName = function(name) {
url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
};
$(document).ready(function() {
if(/[?&]scratch-paper=/.test(location.search)){
var gistID = getParameterByName('scratch-paper');
console.log(gistID);
loadScratchPaper(gistID);
}
});
var shareScratchPaper = function(){
var json = {
"data": dataEditor.getValue(),
"code": codeEditor.getValue()
};
var gist = {
"description": "Shared scratch paper",
"public": true,
"files": {
"scratch-paper.json": {
"content": JSON.stringify(json)
}
}
};
$.post("https://api.github.com/gists", JSON.stringify(gist), function(res) {
var data = JSON.parse(res);
console.log(window.location.origin + "\/?scratch-paper=" + data.id);
});
};
var loadScratchPaper = function (gistID) {
$.get("https://api.github.com/gists/" + gistID, function(res) {
var data = JSON.parse(res);
var content = data.files["scratch-paper.json"].content;
console.log(content);
});
};
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册