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

Use request module for all XHR requests
pull/3094/head
yann300 7 years ago committed by GitHub
commit b12a12b466
  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 csjs = require('csjs-inject')
var yo = require('yo-yo') var yo = require('yo-yo')
var async = require('async') var async = require('async')
var request = require('request')
var remixLib = require('remix-lib') var remixLib = require('remix-lib')
var EventManager = remixLib.EventManager var EventManager = remixLib.EventManager
@ -584,19 +585,15 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
// ------------------ gist load ---------------- // ------------------ gist load ----------------
function loadFromGist (gistId) { function loadFromGist (gistId) {
return gistHandler.handleLoad(gistId, function (gistId) { return gistHandler.handleLoad(gistId, function (gistId) {
$.ajax({ request.get({
url: 'https://api.github.com/gists/' + gistId, url: `https://api.github.com/gists/${gistId}`,
jsonp: 'callback', json: true
dataType: 'jsonp', }, (error, response, data = {}) => {
success: function (response) { if (error || !data.files) {
if (response.data) { modalDialogCustom.alert(`Gist load error: ${error || data.message}`)
if (!response.data.files) { return
modalDialogCustom.alert('Gist load error: ' + response.data.message)
return
}
loadFiles(response.data.files, 'gist')
}
} }
loadFiles(data.files, 'gist')
}) })
}) })
} }

@ -1,6 +1,7 @@
/* global Option, Worker */ /* global Option, Worker */
var $ = require('jquery') var $ = require('jquery')
var yo = require('yo-yo') var yo = require('yo-yo')
var request = require('request')
var QueryParams = require('../../lib/query-params') var QueryParams = require('../../lib/query-params')
var remixLib = require('remix-lib') var remixLib = require('remix-lib')
var Storage = remixLib.Storage var Storage = remixLib.Storage
@ -185,7 +186,19 @@ function SettingsTab (appAPI = {}, appEvents = {}, opts = {}) {
header.selected = true header.selected = true
versionSelector.appendChild(header) 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) // populate version dropdown with all available compiler versions (descending order)
$.each(data.builds.slice().reverse(), function (i, build) { $.each(data.builds.slice().reverse(), function (i, build) {
versionSelector.appendChild(new Option(build.longVersion, build.path)) versionSelector.appendChild(new Option(build.longVersion, build.path))
@ -205,12 +218,6 @@ function SettingsTab (appAPI = {}, appEvents = {}, opts = {}) {
} }
loadVersion(selectedVersion, queryParams, appAPI, el) 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 } } return { render () { return el } }

Loading…
Cancel
Save