|
|
@ -146,42 +146,26 @@ THE SOFTWARE. |
|
|
|
$('#gist').click(function(){ |
|
|
|
$('#gist').click(function(){ |
|
|
|
|
|
|
|
|
|
|
|
//Get Github Authorization Token with proper scope, print to console |
|
|
|
//Get Github Authorization Token with proper scope, print to console |
|
|
|
var note = ((new Date()).toString() + Math.random().toString()); |
|
|
|
|
|
|
|
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"; |
|
|
|
|
|
|
|
//Create a Gist with token from above |
|
|
|
|
|
|
|
var files = {}; |
|
|
|
|
|
|
|
var filesArr = getFiles(); |
|
|
|
|
|
|
|
files["00" + response.hashed_token] = { content: filesArr.join(".sol ") + " " + new Date() } |
|
|
|
|
|
|
|
for(var f in filesArr) { files[fileNameFromKey(filesArr[f])] = { content: localStorage[filesArr[f]] } } |
|
|
|
|
|
|
|
var data = JSON.stringify({ |
|
|
|
|
|
|
|
description: description, |
|
|
|
|
|
|
|
public: true, |
|
|
|
|
|
|
|
files: files |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
$.ajax({ |
|
|
|
$.ajax({ |
|
|
|
url: 'https://api.github.com/authorizations', |
|
|
|
url: 'https://api.github.com/gists', |
|
|
|
type: 'POST', |
|
|
|
type: 'POST', |
|
|
|
beforeSend: function(xhr) { |
|
|
|
data: data |
|
|
|
xhr.setRequestHeader("Authorization", "Basic " + "c29sZWRpdG9yOmRlY2VudHJhbGlzZWV2ZXJ5dGhpbmc="); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
data: JSON.stringify({ |
|
|
|
|
|
|
|
scopes:["gist"], |
|
|
|
|
|
|
|
note: note |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}).done(function(response) { |
|
|
|
}).done(function(response) { |
|
|
|
//Create a Gist with token from above |
|
|
|
if (response.html_url && confirm("Created a gist at " + response.html_url + " Would you like to open it in a new window?")) { |
|
|
|
var files = {}; |
|
|
|
window.open( response.html_url, '_blank' ); |
|
|
|
var filesArr = getFiles(); |
|
|
|
} |
|
|
|
files["00" + response.hashed_token] = { content: filesArr.join(".sol ") + " " + new Date() } |
|
|
|
|
|
|
|
for(var f in filesArr) { files[fileNameFromKey(filesArr[f])] = { content: localStorage[filesArr[f]] } } |
|
|
|
|
|
|
|
var data = JSON.stringify({ |
|
|
|
|
|
|
|
description: description, |
|
|
|
|
|
|
|
public: true, |
|
|
|
|
|
|
|
files: files |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$.ajax({ |
|
|
|
|
|
|
|
url: 'https://api.github.com/gists', |
|
|
|
|
|
|
|
type: 'POST', |
|
|
|
|
|
|
|
beforeSend: function(xhr) { |
|
|
|
|
|
|
|
xhr.setRequestHeader("Authorization", "token " + response.token); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
data: data |
|
|
|
|
|
|
|
}).done(function(response) { |
|
|
|
|
|
|
|
if (response.html_url && confirm("Created a gist at " + response.html_url + " Would you like to open it in a new window?")) { |
|
|
|
|
|
|
|
window.open( response.html_url ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|