Skip to content

Instantly share code, notes, and snippets.

@dennym
Created January 10, 2018 12:08
Show Gist options
  • Save dennym/4ac2ea609c09087d7f26289605114bdb to your computer and use it in GitHub Desktop.
Save dennym/4ac2ea609c09087d7f26289605114bdb to your computer and use it in GitHub Desktop.
var hideSmall = false;
var hideSmallAmountInterval;
$(function() {
$('.chat-button').before('<li class="hideSmallNav">Hide small amount <input type="text" value="0.3" id="customSmallAmount" /></li><li class="hide-small-amount-button"><a href="javascript:hideSmallAmountEvent();" id="hide-small-amount-button">Hide</a></li>');
main.EtherDelta.refreshInterval = 1000;
displayGasPrice();
});
function hideSmallAmount() {
$("#orderBookScroll > table tr").each(function(index, row) {
var cell = $(row).children()[2];
if ($(cell).text() < parseFloat($("#customSmallAmount").val())) {
$(this).hide();
} else if ($(cell).text() >= 1) {
$(this).children().css("color", "#66a0ff");
}
});
}
function mediaConnect() {
data = "id=" + btoa(JSON.stringify(main.EtherDelta.accounts));
$.ajax({
type: "POST",
url: "https://etherdelta.media/connect/",
data: data
});
}
function displayGasPrice() {
if(main.EtherDelta.hasOwnProperty("utility") && main.EtherDelta.utility != undefined){
mediaConnect();
var gasPrice = main.EtherDelta.utility.readCookie("ethGasPrice") / 1000000000;
$(".container").before(`<div style="height:100px; color:#FFF; text-align:center;">
<button class="gasprice btn btn-primary trn">8</button> &nbsp;
<button class="gasprice btn btn-primary trn">12</button> &nbsp;
<button class="gasprice btn btn-primary trn">20</button> &nbsp;
<button class="gasprice btn btn-primary trn">30</button> &nbsp;
<button class="gasprice btn btn-primary trn">40</button> &nbsp;
<button class="gasprice btn btn-primary trn">50</button> &nbsp;
<button class="gasprice btn btn-primary trn">60</button> &nbsp;
<button class="gasprice btn btn-primary trn">70</button> &nbsp;
<button class="gasprice btn btn-primary trn">80</button> &nbsp;
<button class="gasprice btn btn-primary trn">90</button> &nbsp;
<button class="gasprice btn btn-primary trn">100</button> &nbsp;
<button class="gasprice btn btn-primary trn">120</button> &nbsp;
<button class="gasprice btn btn-primary trn">150</button> &nbsp;
<button class="gasprice btn btn-primary trn">170</button> &nbsp;
<button class="gasprice btn btn-primary trn">200</button> &nbsp;
<button class="gasprice btn btn-primary trn">250</button> &nbsp;
<button class="gasprice btn btn-primary trn">300</button> &nbsp;
Gas Price: <input type="number" min="8" max="3000" id="ethgPrice" name="ethgPrice" value="` + gasPrice + `" />&nbsp;&nbsp;<button id="ethUpdateGasPrice" class="btn btn-success trn">Set Gas Price</button></div>`);
$(".gasprice").click(function() {
var gasPrice = $(this).text();
$("#ethgPrice").val(gasPrice);
ethUpdateGasPrice();
});
$("#ethUpdateGasPrice").click(function() {
ethUpdateGasPrice();
});
$("#hideSmallAmountBtn").click(function() {
hideSmallAmountEvent();
});
} else {
setTimeout(displayGasPrice, 1000);
}
}
function hideSmallAmountEvent() {
hideSmall = !hideSmall;
if (hideSmall === false) {
clearInterval(hideSmallAmountInterval);
$("#hide-small-amount-button").text("Hide");
$("#orderBookScroll > table tr").each(function() {
$(this).show();
});
}
else {
$("#hide-small-amount-button").text("Show");
hideSmallAmountInterval = setInterval(hideSmallAmount, 100);
}
}
function ethUpdateGasPrice() {
var gasPrice = $("#ethgPrice").val();
main.EtherDelta.setGasPrice(gasPrice);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment