|
|
|
@ -54,6 +54,7 @@ THE SOFTWARE. |
|
|
|
|
<div id="editor"> |
|
|
|
|
<div id="files"> |
|
|
|
|
<span class="newFile" title="New File">+</span> |
|
|
|
|
<span class="toggleRHP" title="Toggle right hand panel"></span> |
|
|
|
|
</div> |
|
|
|
|
<div id="input"></div> |
|
|
|
|
<div id="dragbar"></div> |
|
|
|
@ -66,6 +67,7 @@ THE SOFTWARE. |
|
|
|
|
<div class="info"> |
|
|
|
|
<p>Version: <span id="version">(loading)</span><br/> |
|
|
|
|
Change to: <select id="versionSelector"></select><br/> |
|
|
|
|
<button id="gist">Share</button> |
|
|
|
|
<code>tx.origin = <span id="txorigin"/></code></p> |
|
|
|
|
</div> |
|
|
|
|
<div id="optimizeBox"> |
|
|
|
@ -139,6 +141,50 @@ THE SOFTWARE. |
|
|
|
|
compile(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// ------------------ gist publish -------------- |
|
|
|
|
|
|
|
|
|
$('#gist').click(function(){ |
|
|
|
|
|
|
|
|
|
//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"; |
|
|
|
|
$.ajax({ |
|
|
|
|
url: 'https://api.github.com/authorizations', |
|
|
|
|
type: 'POST', |
|
|
|
|
beforeSend: function(xhr) { |
|
|
|
|
xhr.setRequestHeader("Authorization", "Basic " + "c29sZWRpdG9yOmRlY2VudHJhbGlzZWV2ZXJ5dGhpbmc="); |
|
|
|
|
}, |
|
|
|
|
data: JSON.stringify({ |
|
|
|
|
scopes:["gist"], |
|
|
|
|
note: note |
|
|
|
|
}) |
|
|
|
|
}).done(function(response) { |
|
|
|
|
//Create a Gist with token from above |
|
|
|
|
var files = {}; |
|
|
|
|
files["00" + response.hashed_token] = { content: description + " at " + new Date() } |
|
|
|
|
var filesArr = getFiles(); |
|
|
|
|
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 ); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------- file selector------------- |
|
|
|
@ -305,6 +351,10 @@ THE SOFTWARE. |
|
|
|
|
onResize(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function getEditorSize(){ |
|
|
|
|
window.localStorage[EDITOR_SIZE_CACHE_KEY] = $('#righthand-panel').width(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$(document).mouseup(function(e){ |
|
|
|
|
if (dragging) { |
|
|
|
|
var delta = $body.width() - e.pageX+2; |
|
|
|
@ -319,6 +369,17 @@ THE SOFTWARE. |
|
|
|
|
// set cached defaults |
|
|
|
|
var cachedSize = window.localStorage.getItem(EDITOR_SIZE_CACHE_KEY); |
|
|
|
|
if (cachedSize) setEditorSize(cachedSize); |
|
|
|
|
else getEditorSize(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------- toggle right hand panel |
|
|
|
|
|
|
|
|
|
var toggledRHP = false; |
|
|
|
|
$('.toggleRHP').click(function(){ |
|
|
|
|
toggledRHP = !toggledRHP; |
|
|
|
|
setEditorSize( toggledRHP ? 0 : window.localStorage[EDITOR_SIZE_CACHE_KEY] ); |
|
|
|
|
$('.toggleRHP').toggleClass('toggled', toggledRHP) |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------- editor resize --------------- |
|
|
|
|