Skip to content

Commit 1031586

Browse files
committed
AI code commenting
1 parent d24d66c commit 1031586

15 files changed

+1210
-1159
lines changed

assets_js_bitrequest_bip39.js

Lines changed: 118 additions & 118 deletions
Large diffs are not rendered by default.

assets_js_bitrequest_coin_settings.js

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ $(document).ready(function() {
5858

5959
// ** Currency Settings **
6060

61-
// Function to handle editing confirmations for cryptocurrency transactions
61+
// Handles UI interactions for editing cryptocurrency confirmation settings using emoji-based visual indicators
6262
function edit_confirmations() {
6363
$(document).on("click", ".cc_settinglist li[data-id='confirmations'] .edit_trigger", function() {
6464
const thistrigger = $(this),
@@ -139,7 +139,7 @@ function edit_confirmations() {
139139
})
140140
}
141141

142-
// Function to handle submission of confirmation settings
142+
// Processes form submission for cryptocurrency confirmation count changes with validation
143143
function submit_confirmations() {
144144
$(document).on("click", "#conf_formbox input.submit", function(e) {
145145
e.preventDefault();
@@ -156,7 +156,7 @@ function submit_confirmations() {
156156
})
157157
}
158158

159-
// Function to handle the reuse address toggle switch
159+
// Manages toggling of address reuse settings with user warnings for different cryptocurrencies
160160
function reuse_address_trigger() {
161161
$(document).on("mouseup", ".cc_settinglist li[data-id='Reuse address'] .switchpanel.custom", function() {
162162
const this_switch = $(this),
@@ -189,7 +189,7 @@ function reuse_address_trigger() {
189189
})
190190
}
191191

192-
// Function to handle generic cryptocurrency switch toggles
192+
// Controls generic boolean switch toggles for cryptocurrency settings with automatic state persistence
193193
function cc_switch() {
194194
$(document).on("mouseup", ".cc_settinglist li .switchpanel.bool", function() {
195195
const thistrigger = $(this),
@@ -202,7 +202,7 @@ function cc_switch() {
202202
})
203203
}
204204

205-
// Function to handle editing block explorer settings
205+
// Manages block explorer selection UI with dynamic option population from available explorer list
206206
function edit_blockexplorer() {
207207
$(document).on("click", ".cc_settinglist li[data-id='blockexplorers']", function() {
208208
const current_li = $(this),
@@ -268,7 +268,7 @@ function edit_blockexplorer() {
268268
})
269269
}
270270

271-
// Function to handle submission of block explorer settings
271+
// Processes block explorer selection changes and updates UI state with validation
272272
function submit_blockexplorer() {
273273
$(document).on("click", "#be_formbox input.submit", function(e) {
274274
e.preventDefault();
@@ -284,7 +284,7 @@ function submit_blockexplorer() {
284284
})
285285
}
286286

287-
// Function to handle editing RPC node settings for APIs and WebSockets
287+
// Handles RPC/API endpoint configuration UI for both HTTP and WebSocket connections with placeholder suggestions
288288
function edit_rpcnode() {
289289
$(document).on("click", ".cc_settinglist li[data-id='apis'], .cc_settinglist li[data-id='websockets']", function() {
290290
const current_li = $(this),
@@ -359,7 +359,7 @@ function edit_rpcnode() {
359359
})
360360
}
361361

362-
// Function to get RPC placeholders for different currencies and API types
362+
// Provides template URL examples for different cryptocurrency node configurations and API types
363363
function get_rpc_placeholder(currency) {
364364
return {
365365
"apisnano1": "eg: http://127.0.0.1:7076",
@@ -377,7 +377,7 @@ function get_rpc_placeholder(currency) {
377377
}
378378
}
379379

380-
// Function to test and append RPC options for different cryptocurrencies
380+
// Tests RPC endpoints for connectivity and appends validated options to the selection UI with status indicators
381381
function test_append_rpc(thiscurrency, optionlist, key, value, selected) {
382382
if (glob_let.ap_id === "apis") {
383383
if (thiscurrency === "ethereum" || glob_let.is_erc20t === true) {
@@ -504,7 +504,7 @@ function test_append_rpc(thiscurrency, optionlist, key, value, selected) {
504504
}
505505
}
506506

507-
// Function to create and append an RPC option list item
507+
// Creates and styles a UI element for RPC node options with live status indicators and deletion controls
508508
function rpc_option_li(optionlist, live, key, value, selected, checked) {
509509
const liveclass = live ? " live" : " offline",
510510
selected_class = selected ? " rpc_selected" : "",
@@ -517,7 +517,7 @@ function rpc_option_li(optionlist, live, key, value, selected, checked) {
517517
option.slideDown(500);
518518
}
519519

520-
// Function to handle RPC node selection
520+
// Handles RPC node selection in UI with offline node detection and data persistence
521521
function test_rpcnode() {
522522
$(document).on("click", "#settingsbox .selectbox .options > div", function(e) {
523523
const target = $(e.target);
@@ -539,7 +539,7 @@ function test_rpcnode() {
539539
})
540540
}
541541

542-
// Function to handle RPC node submission
542+
// Validates and processes RPC node submission with duplicate checking and connection testing
543543
function submit_rpcnode() {
544544
$(document).on("click", "#settingsbox input.submit", function(e) {
545545
e.preventDefault();
@@ -575,7 +575,7 @@ function submit_rpcnode() {
575575
})
576576
}
577577

578-
// Function to test RPC connection for various cryptocurrencies
578+
// Tests RPC/WebSocket connectivity for multiple cryptocurrency protocols with error handling
579579
function test_rpc(rpc_input_box, rpc_data, currency) {
580580
const cant_connect = translate("unabletoconnect");
581581
if (glob_let.ap_id === "apis") {
@@ -723,7 +723,7 @@ function test_rpc(rpc_input_box, rpc_data, currency) {
723723
}
724724
}
725725

726-
// Function to finalize RPC submission and update settings
726+
// Updates UI and persists RPC configuration after successful validation
727727
function pass_rpc_submit(thiscurrency, thisvalue, newnode) {
728728
const rpc_setting_li = cs_node(thiscurrency, glob_let.ap_id),
729729
options = rpc_setting_li.data("options"),
@@ -741,7 +741,7 @@ function pass_rpc_submit(thiscurrency, thisvalue, newnode) {
741741
save_cc_settings(thiscurrency, true);
742742
}
743743

744-
// Function to handle removal of RPC nodes
744+
// Manages removal of custom RPC nodes with safeguards for default nodes
745745
function remove_rpcnode() {
746746
$(document).on("click", "#settingsbox .options .opt_icon_box .icon-bin", function(e) {
747747
e.preventDefault();
@@ -782,7 +782,7 @@ function remove_rpcnode() {
782782
})
783783
}
784784

785-
// Function to construct RPC URL with optional authentication
785+
// Constructs authenticated RPC URLs with protocol and credential handling
786786
function get_rpc_url(rpc_data) {
787787
if (rpc_data === false) {
788788
return false;
@@ -796,7 +796,7 @@ function get_rpc_url(rpc_data) {
796796
return hasprefix ? urlsplit[0] + "://" + login_param + urlsplit[1] : url;
797797
}
798798

799-
// Function to handle editing of Xpub settings
799+
// Displays Xpub key information with QR code generation and deletion options
800800
function edit_xpub_trigger() {
801801
$(document).on("click", ".cc_settinglist li[data-id='Xpub'] .atext", function() {
802802
if (!glob_let.test_derive) {
@@ -833,7 +833,7 @@ function edit_xpub_trigger() {
833833
})
834834
}
835835

836-
// Function to handle deletion of Xpub
836+
// Handles Xpub deletion with user confirmation and state cleanup
837837
function delete_xpub() {
838838
$(document).on("click", "#delete_xpub", function() {
839839
const result = confirm(translate("delete") + " " + translate("bip32xpub") + "?");
@@ -856,7 +856,7 @@ function delete_xpub() {
856856
})
857857
}
858858

859-
// Function to handle callback after Xpub deletion
859+
// Updates address list UI after Xpub key deletion
860860
function delete_xpub_cb(currency, x_pubid, uncheck) {
861861
const xpublist = filter_addressli(currency, "xpubid", x_pubid);
862862
xpublist.each(function() {
@@ -868,15 +868,15 @@ function delete_xpub_cb(currency, x_pubid, uncheck) {
868868
});
869869
}
870870

871-
// Function to handle callback after adding Xpub
871+
// Updates address list UI after adding new Xpub key
872872
function add_xpub_cb(currency, x_pubid) {
873873
const xpublist = filter_addressli(currency, "xpubid", x_pubid);
874874
xpublist.each(function() {
875875
$(this).addClass("xpubv").removeClass("xpubu").attr("data-checked", "true").data("checked", true);
876876
});
877877
}
878878

879-
// Function to handle Xpub switch in currency settings
879+
// Handles enabling/disabling Xpub functionality in currency settings
880880
function xpub_cc_switch() {
881881
$(document).on("mouseup", ".cc_settinglist li[data-id='Xpub'] .switchpanel.custom", function() {
882882
if (glob_let.test_derive !== true) {
@@ -918,7 +918,7 @@ function xpub_cc_switch() {
918918
})
919919
}
920920

921-
// Function to handle editing of Xpub
921+
// Displays form for adding new Xpub key with QR scanning support
922922
function edit_xpub(ad) {
923923
const currency = ad.currency,
924924
cpid = ad.ccsymbol + "-" + currency,
@@ -949,7 +949,7 @@ function edit_xpub(ad) {
949949
}
950950
}
951951

952-
// Function to handle Xpub input changes
952+
// Validates Xpub input format and triggers address derivation on valid input
953953
function xpub_change() {
954954
$(document).on("input", "#xpub_input", function(e) {
955955
const thisnode = $(this),
@@ -965,15 +965,15 @@ function xpub_change() {
965965
})
966966
}
967967

968-
// Function to trigger Xpub submission
968+
// Triggers validation and saving of entered Xpub key
969969
function submit_xpub_trigger() {
970970
$(document).on("click", "#xpubformbox input.submit", function(e) {
971971
e.preventDefault();
972972
validate_xpub($(this).closest("#xpubformbox"));
973973
})
974974
}
975975

976-
// Function to validate Xpub
976+
// Performs comprehensive validation of Xpub key with address derivation and state updates
977977
function validate_xpub(thisnode) {
978978
const this_data = thisnode.data(),
979979
currency = this_data.currency,
@@ -1065,7 +1065,7 @@ function validate_xpub(thisnode) {
10651065
currency_check(currency);
10661066
}
10671067

1068-
// Function to handle Xpub validation failure
1068+
// Handles failed Xpub validation with error notification
10691069
function xpub_fail(currency) {
10701070
const errormessage = translate("invalidxpub", {
10711071
"currency": currency
@@ -1074,20 +1074,20 @@ function xpub_fail(currency) {
10741074
clear_xpub_inputs();
10751075
}
10761076

1077-
// Function to clear Xpub input fields
1077+
// Resets Xpub input form state
10781078
function clear_xpub_inputs() {
10791079
$("#ad_info_wrap").slideUp(200, function() {
10801080
$("#ad_info_wrap .td_box").html("");
10811081
});
10821082
clear_xpub_checkboxes();
10831083
}
10841084

1085-
// Function to clear Xpub checkboxes
1085+
// Resets Xpub confirmation checkboxes
10861086
function clear_xpub_checkboxes() {
10871087
$("#pk_confirmwrap, #matchwrap").attr("data-checked", "false").data("checked", false);
10881088
}
10891089

1090-
// Function to generate Xpub derivation list
1090+
// Generates preview of derived addresses from Xpub key
10911091
function xpub_derivelists(currency, xpub) {
10921092
try {
10931093
const coindat = getcoindata(currency),
@@ -1115,7 +1115,7 @@ function xpub_derivelists(currency, xpub) {
11151115
}
11161116
}
11171117

1118-
// Function to check if Xpub is valid
1118+
// Validates Xpub format against currency-specific patterns
11191119
function check_xpub(address, prefix, currency) {
11201120
const prefixes = {
11211121
bitcoin: "zpub|xpub",
@@ -1126,7 +1126,7 @@ function check_xpub(address, prefix, currency) {
11261126
return new RegExp(regex).test(address);
11271127
}
11281128

1129-
// Function to handle key management
1129+
// Controls UI for key derivation settings and management
11301130
function key_management() {
11311131
$(document).on("click", ".cc_settinglist li[data-id='Key derivations'] .atext", function() {
11321132
const thisnode = $(this),
@@ -1158,7 +1158,7 @@ function key_management() {
11581158
})
11591159
}
11601160

1161-
// Function to handle SegWit switch
1161+
// Manages SegWit address format switching with confirmations
11621162
function segwit_switch() {
11631163
$(document).on("mouseup", "#segw_box .toggle_segwit .switchpanel", function() {
11641164
if (is_viewonly() === true) {
@@ -1203,12 +1203,12 @@ function segwit_switch() {
12031203
})
12041204
}
12051205

1206-
// Function to trigger BIP39 settings
1206+
// Triggers BIP39 key derivation settings UI
12071207
function bip39_sc(coinsc) {
12081208
$("#" + coinsc + "_settings .cc_settinglist li[data-id='Key derivations'] .atext").trigger("click");
12091209
}
12101210

1211-
// Function to display Xpub info popup
1211+
// Displays detailed Xpub information with QR code and derived addresses
12121212
function xpub_info_pu(currency, xpub) {
12131213
const coindat = getcoindata(currency),
12141214
bip32dat = getbip32dat(currency),
@@ -1263,14 +1263,14 @@ function xpub_info_pu(currency, xpub) {
12631263
}, 550);
12641264
}
12651265

1266-
// Function to trigger API key addition
1266+
// Triggers API key input dialog
12671267
function trigger_apikey() {
12681268
$(document).on("click", "#add_api", function() {
12691269
add_apikey($(this).attr("data-api"));
12701270
})
12711271
}
12721272

1273-
// Function to add API key
1273+
// Displays form for adding new API key
12741274
function add_apikey(api) {
12751275
const get_key = $("#apikeys").data(api),
12761276
api_key = get_key || "",
@@ -1292,7 +1292,7 @@ function add_apikey(api) {
12921292
}, 800);
12931293
}
12941294

1295-
// Function to submit API key
1295+
// Validates and saves entered API key
12961296
function submit_apikey() {
12971297
$(document).on("click", "#add_apikey input.submit", function(e) {
12981298
e.preventDefault();
@@ -1317,7 +1317,7 @@ function submit_apikey() {
13171317
})
13181318
}
13191319

1320-
// Function to reset coin settings
1320+
// Triggers confirmation dialog for resetting coin settings
13211321
function reset_coinsettings_trigger() {
13221322
$(document).on("click", ".reset_cc_settings", function() {
13231323
const thistrigger = $(this),
@@ -1328,7 +1328,7 @@ function reset_coinsettings_trigger() {
13281328
})
13291329
}
13301330

1331-
// Perform coin settings reset
1331+
// Initiates coin settings reset after user confirmation
13321332
function reset_coinsettings(trigger) {
13331333
const currency = trigger.attr("data-currency"),
13341334
result = confirm(translate("resetconfirm", {
@@ -1340,7 +1340,7 @@ function reset_coinsettings(trigger) {
13401340
reset_coinsettings_function(currency);
13411341
}
13421342

1343-
// Function to perform coin settings reset
1343+
// Performs coin settings reset while preserving critical configurations
13441344
function reset_coinsettings_function(currency) {
13451345
const current_settings = br_get_local(currency + "_settings", true);
13461346
if (current_settings) {

0 commit comments

Comments
 (0)