UNPKG

mubot-server

Version:
104 lines (99 loc) 4.71 kB
(function(){ var api; $(function() { api = window.location.pathname.match(/\/([^/]*)/)[1]; if(api === "api" || api === "crypto" || !api) { api = "crypto"; loadCryptoApi() } else loadGamblingApi(); $('#api_change').click(function() { if($('#api_change').text() === "Mubot Crypto API") { history.pushState({}, "", "/api/crypto"); api = "crypto"; loadCryptoApi() } else { api = "gambling"; history.pushState({}, "", "/api/gambling"); loadGamblingApi() } }) }); function loadCryptoApi() { $('#api').text('Mubot Crypto API'); $('#api_change').text('Mubot Gambling API'); $('.nav li > a').eq(0).text('View'); $('.nav li > a').eq(1).text('Swap'); $('.nav li > a').eq(2).text('Amount'); $('.nav li > a').eq(3).text('Depth'); if($('.nav li > a').length > 4) $('.nav li').eq(4).remove(); loadApiQuery(1) } function loadGamblingApi() { $('#api').text('Mubot Gambling API'); $('#api_change').text('Mubot Crypto API'); $('.nav li > a').eq(0).text('View'); $('.nav li > a').eq(1).text('Bet'); $('.nav li > a').eq(2).text('Check'); $('.nav li > a').eq(3).text('Balance'); $('.nav li').eq(3).clone().children().eq(0).text('Cancel').click(()=>loadApiQuery(4)).parent().appendTo($('.nav li').parent()) loadApiQuery(1) } function loadApiQuery(mode) { for(let i = 0 ; i < 4+(api === "gambling"); i++) $('.nav li').eq(i).removeClass('active') $('.nav li').eq(mode).addClass('active') if(mode === 0) { if (api === "crypto") { $('#title').text( "Coin view" ) $('#description').text( "Returns price and total depth information about the specified ticker." ) $('#link').text("https://leathan.xyz/api/?ticker=BTM") $('#example').text('{\n price": "0.00033483",\n "asks": \n {\n "BTM": "626840.68313214",\n "BTC": "3590.52919464"\n },\n "bids":\n {\n "BTM": "730721.17738970",\n "BTC": "32.26468347"\n }\n}') } else { $('#title').text( "View bets" ) $('#description').text( "Returns the entire betting que, make sure to loop through the entire array." ) $('#link').text("https://leathan.xyz/api/?bets=true") $('#example').text('[\n {\n "id": "762",\n "bet": "250",\n "cashout": "1.12"\n },\n {\n "id": "763",\n "bet": "150",\n "cashout": "2.5"\n }\n]') } } else if(mode === 1) { if(api === "crypto") { $('#title').text( "Swap coins" ) $('#description').text( "Returns the quantity of ticker2 coins that ticker amount yeilds." ) $('#link').text("https://leathan.xyz/api/?ticker=BTM&amount=250&ticker2=BTS") $('#example').text('{\n "BTS": "4756.74914465"\n}') } else { $('#title').text( "Create bet" ) $('#description').text( "Creates a bet and adds it to the betting que, to see if you won use the check api." ) $('#link').text("https://leathan.xyz/api/?bet=100&cashout=1.5") $('#example').text('{\n "id": "763",\n "position_in_que": "7"\n}') } } else if(mode === 2) { if(api === "crypto") { $('#title').text( "Coin amount" ) $('#description').text( "Returns price and total depth information about the specified ticker." ) $('#link').text("https://leathan.xyz/api/?ticker=BTM&amount=1000") $('#example').text('{\n "asks":\n {\n "BTM": "1000",\n "BTC": "0.33893767"\n },\n "bids":\n {\n "BTM":"1000",\n "BTC": "0.33166584"\n }\n}') } else { $('#title').text( "Check bet" ) $('#description').text( "Checks the specified bet and returns the profit, returns 0 if the bet is still in the que." ) $('#link').text("https://leathan.xyz/api/?check=763") $('#example').text('{\n "profit": "-100"\n}') } } else if(mode === 3) { if(api === "crypto") { $('#title').text( "Coin depth" ) $('#description').text( "Returns information for ticker up to specified order book depth." ) $('#link').text("https://leathan.xyz/api/?ticker=BTM&depth=50") $('#example').text('{\n "asks":\n {\n "BTM": "5740.82567081",\n "BTC": "1.97553107"\n },\n "bids":\n {\n "BTM": "38362.08399499",\n "BTC": "12.15147874"\n }\n}') } else { $('#title').text( "Get balance" ) $('#description').text( "Returns the balance available to all users." ) $('#link').text("https://leathan.xyz/api/?balance=true") $('#example').text('{\n "balance": "17230"\n}') } } else if(mode === 4) { $('#title').text( "Cancel bet" ); $('#description').text( "Cancels the bet with the specified id if it is in the que." ) $('#link').text("https://leathan.xyz/api/?cancel=763") $('#example').text('{\n "canceled": "763"\n}') } } }).call(this);