2017-01-19 13:16:29 -03:00
|
|
|
'use strict';
|
|
|
|
|
|
2017-01-30 18:04:17 -03:00
|
|
|
angular.module('copayApp.controllers').controller('buyandsellController', function($scope, $ionicHistory, buyAndSellService, lodash) {
|
2017-01-19 13:16:29 -03:00
|
|
|
|
|
|
|
|
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
2017-01-30 18:04:17 -03:00
|
|
|
$scope.services = buyAndSellService.get();
|
2017-01-19 13:16:29 -03:00
|
|
|
|
2017-06-12 18:41:11 +09:00
|
|
|
$scope.$on("$ionicView.enter", function(event, data) {
|
|
|
|
|
console.log("Enter buy page");
|
|
|
|
|
var r = new XMLHttpRequest();
|
|
|
|
|
r.open("GET", "https://www.bitcoin.com/api/rv/promoted-exchange", true);
|
|
|
|
|
r.onreadystatechange = function () {
|
|
|
|
|
if (r.readyState != 4 || r.status != 200) return;
|
|
|
|
|
console.log(r.responseText);
|
|
|
|
|
var adResponse = JSON.parse(r.responseText)
|
|
|
|
|
document.getElementById("exchange-logo").setAttribute('src', "https://www.bitcoin.com" + adResponse.image)
|
|
|
|
|
document.getElementById("exchange-name").textContent = adResponse.bannerName;
|
|
|
|
|
document.getElementById("exchange-text").textContent = adResponse.description;
|
|
|
|
|
};
|
|
|
|
|
r.send("defaultpromotion=360");
|
|
|
|
|
});
|
|
|
|
|
|
2017-01-30 18:04:17 -03:00
|
|
|
if (lodash.isEmpty($scope.services))
|
|
|
|
|
$ionicHistory.goBack();
|
2017-01-19 13:16:29 -03:00
|
|
|
});
|
|
|
|
|
});
|