Commit 9a380295 authored by d11e9's avatar d11e9

fix gist loading and publish text

parent 4ff4c864
...@@ -218,7 +218,7 @@ body { ...@@ -218,7 +218,7 @@ body {
#header #optionViews .pre { #header #optionViews .pre {
word-wrap: break-word; word-wrap: break-word;
background-color: #efefef; background-color: #C6CFF7;
font-family: monospace; font-family: monospace;
border-radius: 3px; border-radius: 3px;
display: inline-block; display: inline-block;
...@@ -237,7 +237,7 @@ body { ...@@ -237,7 +237,7 @@ body {
} }
#header #gist { #header #gist {
background-color: #efefef; background-color: #C6CFF7;
font-size: 12px; font-size: 12px;
padding: 0.25em; padding: 0.25em;
color: black; color: black;
......
...@@ -52,13 +52,13 @@ ...@@ -52,13 +52,13 @@
function getGistId(str) { function getGistId(str) {
var idr = /[0-9A-Fa-f]{8,}/; var idr = /[0-9A-Fa-f]{8,}/;
var match = idr.exec(str)[0]; var match = idr.exec(str);
return match; return match ? match[0] : null;
} }
var queryParams = getQueryParams(); var queryParams = getQueryParams();
var loadingFromGist = false; var loadingFromGist = false;
if (queryParams['gist']) { if (typeof queryParams['gist'] != undefined) {
var gistId; var gistId;
if (queryParams['gist'] === '') { if (queryParams['gist'] === '') {
var str = prompt("Enter the URL or ID of the Gist you would like to load."); var str = prompt("Enter the URL or ID of the Gist you would like to load.");
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
gistId = queryParams['gist']; gistId = queryParams['gist'];
loadingFromGist = !!gistId; loadingFromGist = !!gistId;
} }
$.ajax({ if (loadingFromGist) $.ajax({
url: 'https://api.github.com/gists/'+gistId, url: 'https://api.github.com/gists/'+gistId,
jsonp: 'callback', jsonp: 'callback',
dataType: 'jsonp', dataType: 'jsonp',
...@@ -249,7 +249,7 @@ ...@@ -249,7 +249,7 @@
var files = {}; var files = {};
var filesArr = getFiles(); var filesArr = getFiles();
var description = "Created using soleditor: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://chriseth.github.io/browser-solidity/#gist="; var description = "Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. \n Load this file by pasting this gists URL or ID at https://chriseth.github.io/browser-solidity/#version=" + getQueryParams().version + "&optimize="+ getQueryParams().optimize +"&gist=";
for(var f in filesArr) { for(var f in filesArr) {
files[fileNameFromKey(filesArr[f])] = { files[fileNameFromKey(filesArr[f])] = {
...@@ -734,6 +734,7 @@ ...@@ -734,6 +734,7 @@
var worker = null; var worker = null;
var loadVersion = function(version) { var loadVersion = function(version) {
$('#version').text("(loading)"); $('#version').text("(loading)");
updateQueryParams({version: version});
var isFirefox = typeof InstallTrigger !== 'undefined'; var isFirefox = typeof InstallTrigger !== 'undefined';
if (document.location.protocol != 'file:' && Worker !== undefined && isFirefox) { if (document.location.protocol != 'file:' && Worker !== undefined && isFirefox) {
// Workers cannot load js on "file:"-URLs and we get a // Workers cannot load js on "file:"-URLs and we get a
......
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
</div> </div>
<div id="publishView"> <div id="publishView">
<p><button id="gist" title="Publish all files as public gist on github.com"><i class="fa fa-github"></i> Publish Gist</button> Publish all open files to an anonymous github gist.</p> <p><button id="gist" title="Publish all files as public gist on github.com"><i class="fa fa-github"></i> Publish Gist</button> Publish all open files to an anonymous github gist.</p>
<p>You can also load a gist by adding the following <span class="pre">?gist=GIST_ID</span> to your url, where GIST_ID is the id of the gist to load.</p> <p>You can also load a gist by adding the following <span class="pre">#gist=GIST_ID</span> to your url, where GIST_ID is the id of the gist to load.</p>
</div> </div>
<div id="envView"> <div id="envView">
<span id="executionContext"> <span id="executionContext">
......
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