Commit fb3420b0 authored by d11e9's avatar d11e9

allow loading gists

parent 1438054a
...@@ -141,6 +141,27 @@ THE SOFTWARE. ...@@ -141,6 +141,27 @@ THE SOFTWARE.
compile(); compile();
} }
// ------------------ gist load ----------------
var location_hash_params = window.location.hash.substr(1).split("=");
if (location_hash_params.length == 2 && location_hash_params[0] == 'gist') {
$.ajax({
url: 'https://api.github.com/gists/'+location_hash_params[1],
jsonp: 'callback',
dataType: 'jsonp',
success: function(response){
if (response.data) {
for(var f in response.data.files) {
window.localStorage[fileKey(f)] = response.data.files[f].content;
}
updateFiles();
}
}
})
}
// ------------------ gist publish -------------- // ------------------ gist publish --------------
$('#gist').click(function(){ $('#gist').click(function(){
...@@ -148,7 +169,7 @@ THE SOFTWARE. ...@@ -148,7 +169,7 @@ THE SOFTWARE.
var files = {}; var files = {};
var filesArr = getFiles(); var filesArr = getFiles();
var description = "Ethereum Contracts Gist created using soleditor at: https://chriseth.github.io/browser-solidity"; var description = "Ethereum Contracts Gist created using soleditor at: https://chriseth.github.io/browser-solidity to load gist in soleditor append #gist=gistid to the url, where gistid is the id in this gist url.";
for(var f in filesArr) { for(var f in filesArr) {
files[fileNameFromKey(filesArr[f])] = { files[fileNameFromKey(filesArr[f])] = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment