Commit 9a380295 authored by d11e9's avatar d11e9

fix gist loading and publish text

parent 4ff4c864
......@@ -218,7 +218,7 @@ body {
#header #optionViews .pre {
word-wrap: break-word;
background-color: #efefef;
background-color: #C6CFF7;
font-family: monospace;
border-radius: 3px;
display: inline-block;
......@@ -237,7 +237,7 @@ body {
}
#header #gist {
background-color: #efefef;
background-color: #C6CFF7;
font-size: 12px;
padding: 0.25em;
color: black;
......
......@@ -49,31 +49,31 @@
syncQueryParams();
// ------------------ gist load ----------------
function getGistId(str) {
var idr = /[0-9A-Fa-f]{8,}/;
var match = idr.exec(str)[0];
return match;
}
function getGistId(str) {
var idr = /[0-9A-Fa-f]{8,}/;
var match = idr.exec(str);
return match ? match[0] : null;
}
var queryParams = getQueryParams();
var loadingFromGist = false;
if (queryParams['gist']) {
var gistId;
var loadingFromGist = false;
if (typeof queryParams['gist'] != undefined) {
var gistId;
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.");
if (str !== '') {
gistId = getGistId( str );
loadingFromGist = !!gistId;
}
} else {
gistId = queryParams['gist'];
loadingFromGist = !!gistId;
}
$.ajax({
url: 'https://api.github.com/gists/'+gistId,
jsonp: 'callback',
dataType: 'jsonp',
loadingFromGist = !!gistId;
}
if (loadingFromGist) $.ajax({
url: 'https://api.github.com/gists/'+gistId,
jsonp: 'callback',
dataType: 'jsonp',
success: function(response){
if (response.data) {
for (var f in response.data.files) {
......@@ -249,7 +249,7 @@
var files = {};
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) {
files[fileNameFromKey(filesArr[f])] = {
......@@ -734,6 +734,7 @@
var worker = null;
var loadVersion = function(version) {
$('#version').text("(loading)");
updateQueryParams({version: version});
var isFirefox = typeof InstallTrigger !== 'undefined';
if (document.location.protocol != 'file:' && Worker !== undefined && isFirefox) {
// Workers cannot load js on "file:"-URLs and we get a
......
......@@ -99,7 +99,7 @@
</div>
<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>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 id="envView">
<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