mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-22 12:45:50 +00:00
[FEATURE] rest tools - select custom host for rest tool using base_url query param
This commit is contained in:
@@ -186,6 +186,7 @@ function select_request(request) {
|
|||||||
//No body, so wipe out the current contents.
|
//No body, so wipe out the current contents.
|
||||||
cm_request.setValue("");
|
cm_request.setValue("");
|
||||||
}
|
}
|
||||||
|
cm_request.refresh();
|
||||||
|
|
||||||
reset_response_area();
|
reset_response_area();
|
||||||
};
|
};
|
||||||
@@ -257,18 +258,40 @@ function reset_response_area() {
|
|||||||
response_code.text("");
|
response_code.text("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function change_base_url(u) {
|
||||||
|
window.URL_BASE = u;
|
||||||
|
$("#rest_host").text(u);
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
//wait for the Requests to be populated by another file
|
//wait for the Requests to be populated by another file
|
||||||
generate_table_of_contents();
|
generate_table_of_contents();
|
||||||
make_commands_clickable();
|
make_commands_clickable();
|
||||||
|
|
||||||
request_button.click(send_request);
|
|
||||||
//rest_method.change(update_method);
|
|
||||||
|
|
||||||
if (window.location.hash) {
|
if (window.location.hash) {
|
||||||
var cmd = window.location.hash.slice(1).toLowerCase();
|
var cmd = window.location.hash.slice(1).toLowerCase();
|
||||||
select_request(cmd);
|
select_request(cmd);
|
||||||
} else {
|
} else {
|
||||||
select_request();
|
select_request();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (urlParams["base_url"]) {
|
||||||
|
change_base_url(urlParams["base_url"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
request_button.click(send_request);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var urlParams;
|
||||||
|
(window.onpopstate = function () {
|
||||||
|
var match,
|
||||||
|
pl = /\+/g, // Regex for replacing addition symbol with a space
|
||||||
|
search = /([^&=]+)=?([^&]*)/g,
|
||||||
|
decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
|
||||||
|
query = window.location.search.substring(1);
|
||||||
|
|
||||||
|
urlParams = {};
|
||||||
|
while (match = search.exec(query))
|
||||||
|
urlParams[decode(match[1])] = decode(match[2]);
|
||||||
|
})();
|
||||||
|
|||||||
Reference in New Issue
Block a user