Merge pull request #1164 from bitpshr/feature/ajax-requests

Use request module for all XHR requests
pull/1/head v0.6.1-alpha.2
yann300 7 years ago committed by GitHub
commit b8e119f697
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      src/app.js
  2. 21
      src/app/tabs/settings-tab.js

@ -4,6 +4,7 @@ var $ = require('jquery')
var csjs = require('csjs-inject')
var yo = require('yo-yo')
var async = require('async')
var request = require('request')
var remixLib = require('remix-lib')
var EventManager = remixLib.EventManager
@ -584,19 +585,15 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
// ------------------ gist load ----------------
function loadFromGist (gistId) {
return gistHandler.handleLoad(gistId, function (gistId) {
$.ajax({
url: 'https://api.github.com/gists/' + gistId,
jsonp: 'callback',
dataType: 'jsonp',
success: function (response) {
if (response.data) {
if (!response.data.files) {
modalDialogCustom.alert('Gist load error: ' + response.data.message)
return
}
loadFiles(response.data.files, 'gist')
}
request.get({
url: `https://api.github.com/gists/${gistId}`,
json: true
}, (error, response, data = {}) => {
if (error || !data.files) {
modalDialogCustom.alert(`Gist load error: ${error || data.message}`)
return
}
loadFiles(data.files, 'gist')
})
})
}

@ -1,6 +1,7 @@
/* global Option, Worker */
var $ = require('jquery')
var yo = require('yo-yo')
var request = require('request')
var QueryParams = require('../../lib/query-params')
var remixLib = require('remix-lib')
var Storage = remixLib.Storage
@ -185,7 +186,19 @@ function SettingsTab (appAPI = {}, appEvents = {}, opts = {}) {
header.selected = true
versionSelector.appendChild(header)
$.getJSON('https://solc-bin.ethereum.org/bin/list.json').done(function (data) {
request.get({
url: 'https://solc-bin.ethereum.org/bin/list.json',
json: true
}, (error, response, data) => {
if (error || !data) {
tooltip('Cannot load compiler version list. It might have been blocked by an advertisement blocker. Please try deactivating any of them from this page and reload.')
// loading failed for some reason, fall back to local compiler
versionSelector.append(new Option('latest local version', 'builtin'))
loadVersion('builtin', queryParams, appAPI, el)
return
}
// populate version dropdown with all available compiler versions (descending order)
$.each(data.builds.slice().reverse(), function (i, build) {
versionSelector.appendChild(new Option(build.longVersion, build.path))
@ -205,12 +218,6 @@ function SettingsTab (appAPI = {}, appEvents = {}, opts = {}) {
}
loadVersion(selectedVersion, queryParams, appAPI, el)
}).fail(function (xhr, text, err) {
tooltip('Cannot load compiler version list. It might have been blocked by an advertisement blocker. Please try deactivating any of them from this page and reload.')
// loading failed for some reason, fall back to local compiler
versionSelector.append(new Option('latest local version', 'builtin'))
loadVersion('builtin', queryParams, appAPI, el)
})
return { render () { return el } }

Loading…
Cancel
Save