diff --git a/charts_api.html b/charts_api.html index bfe78902ba..b86e192809 100644 --- a/charts_api.html +++ b/charts_api.html @@ -89,8 +89,9 @@
  • "+req.name+"
  • "); + } else { + commandlist.append("
  • "+req.name+"
  • "); } - } -}); + }); +} -Request('Prepare Payment', { - method: GET, - path: '/v1/accounts/{:source_address}/payments/paths/{:destination_address}/{:amount}?{:query_params}', - description: 'Retrieve possible payment objects for a desired payment.', - link: '#prepare-payment', - params: { - "{:source_address}": DEFAULT_ADDRESS_1, - "{:destination_address}": DEFAULT_ADDRESS_2, - "{:amount}": "1+USD+rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", - "{:query_params}": "source_currencies=USD" - } -}); +function make_commands_clickable() { + commandlist.children("li").click(function() { + var cmd = slugify($(this).text().trim()); -Request('Submit Payment', { - method: POST, - path: '/v1/accounts/{:source_address}/payments?{:query_params}', - description: 'Send a prepared payment to the network.', - link: '#submit-payment', - test_only: true, - body: { - "secret": DEFAULT_SECRET, - "client_resource_id": "348170b9-16b9-4927-854d-7f9d4a2a692d", - "payment": { - "source_account": DEFAULT_ADDRESS_1, - "source_tag": "", - "source_amount": { - "value": "1", - "currency": "USD", - "issuer": "" - }, - "source_slippage": "0", - "destination_account": DEFAULT_ADDRESS_2, - "destination_tag": "", - "destination_amount": { - "value": "1", - "currency": "USD", - "issuer": DEFAULT_ADDRESS_1 - }, - "invoice_id": "", - "paths": "[]", - "partial_payment": false, - "no_direct_ripple": false - } - }, - params: { - "{:source_address}": DEFAULT_ADDRESS_1, - "{:query_params}": "validated=true" - } -}); + if (!requests[cmd]) return; -Request("Confirm Payment", { - method: GET, - path: "/v1/accounts/{:address}/payments/{:id}", - description: "Retrieve details of a payment and its status.", - link: "#confirm-payment", - params: { - "{:address}": DEFAULT_ADDRESS_1, - "{:id}": DEFAULT_HASH - } -}); + select_request(cmd, true); + window.location.hash = cmd; -Request("Get Payment History", { - method: GET, - path: "/v1/accounts/{:address}/payments?{:query_params}", - description: "Browse through the history of payments sent and received by an account.", - link: "#get-payment-history", - params: { - "{:address}": DEFAULT_ADDRESS_1, - "{:query_params}": "direction=incoming&exclude_failed=true" - } -}); - -Request("Place Order", { - method: POST, - path: "/v1/accounts/{:address}/orders?{:query_params}", - description: "Place an order on the ripple network.", - link: "#place-order", - test_only: true, - params: { - "{:address}": DEFAULT_ADDRESS_1, - "{:query_params}": "validated=true" - }, - body: { - "secret": DEFAULT_SECRET, - "order": { - "type": "sell", - "taker_pays": { - "currency": "JPY", - "value": "4000", - "counterparty": "rMAz5ZnK73nyNUL4foAvaxdreczCkG3vA6" - }, - "taker_gets": { - "currency": "USD", - "value": ".25", - "counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B" - }, - "immediate_or_cancel": true - } - } -}); - -Request("Cancel Order", { - method: DELETE, - path: "/v1/accounts/{:address}/orders/{:order}/?{:query_params}", - description: "Cancel an order on the ripple network.", - link: "#cancel-order", - test_only: true, - params: { - "{:address}": DEFAULT_ADDRESS_1, - "{:query_params}": "validated=true", - "{:order}": "23" - }, - body: { - "secret": DEFAULT_SECRET - } -}); - -Request("Get Account Orders", { - method: GET, - path: "/v1/accounts/{:address}/orders?{:query_params}", - description: "Get open currency-exchange orders associated with the Ripple address.", - link: "#get-account-orders", - params: { - "{:address}": DEFAULT_ADDRESS_3, - "{:query_params}": "ledger=10399192&limit=15" - } -}); - -Request("Get Order Transaction", { - method: GET, - path: "/v1/accounts/{:address}/orders/{:hash}", - description: "Get the details of an order transaction.", - link: "#get-order-transaction", - params: { - "{:address}": "rEQWVz1qN4DWw5J17s3DgXQzUuVYDSpK6M", - "{:hash}": "D53A3B99AC0C3CAF35D72178390ACA94CD42479A98CEA438EEAFF338E5FEB76D" - } -}); - -Request("Get Order Book", { - method: GET, - path: "/v1/accounts/{:address}/order_book/{:base}/{:counter}?{:query_params}", - description: "Get the order book for a currency pair", - link: "#get-order-book", - params: { - "{:address}": DEFAULT_ADDRESS_3, - "{:base}": "BTC+rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", - "{:counter}": "USD+rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", - "{:query_params}": "limit=10" - } -}); - -Request("Get Trustlines", { - method: GET, - path: "/v1/accounts/{:address}/trustlines?{:query_params}", - description: "Check the status of one or more trustlines attached to an account.", - link: "#get-trustlines", - params: { - "{:address}": DEFAULT_ADDRESS_1, - "{:query_params}": "currency=USD&counterparty=ra5nK24KXen9AHvsdFTKHSANinZseWnPcX" - } -}); - -Request("Grant Trustline", { - method: POST, - path: "/v1/accounts/{:address}/trustlines?{:query_params}", - description: "Add or modify a trustline from this account.", - link: "#grant-trustline", - test_only: true, - params: { - "{:address}": DEFAULT_ADDRESS_1, - "{:query_params}": "validated=true" - }, - body: { - "secret": DEFAULT_SECRET, - "trustline": { - "limit": "110", - "currency": "USD", - "counterparty": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q", - "allows_rippling": false - } - } -}); - -Request("Check Notifications", { - method: GET, - path: "/v1/accounts/{:address}/notifications/{:id}", - description: "Monitor an account for all kinds of transactions.", - link: "#check-notifications", - params: { - "{:address}": DEFAULT_ADDRESS_1, - "{:id}": DEFAULT_HASH - } -}); - -Request("Check Connection", { - method: GET, - path: "/v1/server/connected", - description: "Check whether the REST server is connected to a rippled server.", - link: "#check-connection" -}); - -Request("Get Server Status", { - method: GET, - path: "/v1/server", - description: "Retrieve information about the current status of the Ripple-REST server and the rippled server it is connected to.", - link: "#get-server-status" -}); - -Request("Retrieve Ripple Transaction", { - method: GET, - path: "/v1/transactions/{:id}", - description: "Retrieve a raw Ripple transaction", - link: "#retrieve-ripple-transaction", - params: { - "{:id}": DEFAULT_HASH - } -}); - -Request("Retrieve Transaction Fee", { - method: GET, - path: "/v1/transaction-fee", - description: "Retrieve the current transaction fee for the connected rippled server(s).", - link: "#retrieve-transaction-fee", -}); - -Request("Generate UUID", { - method: GET, - path: "/v1/uuid", - description: "Create a universally-unique identifier (UUID) to use as the client resource ID for a payment.", - link: "#create-client-resource-id" -}); - -//---------- End req. List ---------------------------// + $(this).siblings().removeClass('selected'); + $(this).addClass('selected'); + }); +} var cm_request = CodeMirror(request_body.get(0), { mode: 'javascript', @@ -410,6 +133,19 @@ function change_path(command) { } function select_request(request) { + if (request === undefined) { + var el = commandlist.children("li:not(.separator)").eq(0); + request = slugify(el.text()); + +/* var keys = Object.keys(requests); + var index = keys.indexOf(cmd); + if (index === -1) return;*/ + } else { + var el = commandlist.find("li a[href='#"+request+"']").parent(); + } + $(el).siblings().removeClass('selected'); + $(el).addClass('selected'); + command = requests[request]; if (command.test_only === true) { @@ -422,12 +158,14 @@ function select_request(request) { $(description).html(command.description); if (command.link) { - $(description).append(" Read more"); + $(description).append(" Read more"); } $(description).show(); } else if (command.link) { - $(description).html("Read more"); + $(description).html("Read more"); } else { $(description).hide(); } @@ -436,13 +174,8 @@ function select_request(request) { .attr('href', DOC_BASE+command.link) .text(command.name)); - //rest_url.val(command.path); - //rest_url.text(command.path); change_path(command); - -// rest_method.val(command.method); -// rest_method.change(); request_button.val(command.method); request_button.text(command.method+" request"); update_method(request_button); @@ -451,7 +184,6 @@ function select_request(request) { cm_request.setValue(JSON.stringify(command.body, null, 2)); } else { //No body, so wipe out the current contents. - //This prevents confusion if the user toggles the HTTP method dropdown cm_request.setValue(""); } @@ -531,6 +263,10 @@ function reset_response_area() { } $(document).ready(function() { + //wait for the Requests to be populated by another file + generate_table_of_contents(); + make_commands_clickable(); + request_button.click(send_request); //rest_method.change(update_method); @@ -547,18 +283,8 @@ $(document).ready(function() { if (window.location.hash) { var cmd = window.location.hash.slice(1).toLowerCase(); - var keys = Object.keys(requests); - var index = keys.indexOf(cmd); - - if (index === -1) return; - - var el = commands.eq(index); - select_request(cmd); - - $(el).siblings().removeClass('selected'); - $(el).addClass('selected'); } else { - select_request('generate-wallet'); + select_request(); } }); diff --git a/reliable_tx.html b/reliable_tx.html index fe58563916..4693917311 100644 --- a/reliable_tx.html +++ b/reliable_tx.html @@ -89,8 +89,9 @@