Skip to content

Commit b935a61

Browse files
committed
commenting and restructuring
1 parent 0d7719c commit b935a61

File tree

2 files changed

+273
-216
lines changed

2 files changed

+273
-216
lines changed

assets_js_bitrequest_core.js

Lines changed: 0 additions & 215 deletions
Original file line numberDiff line numberDiff line change
@@ -594,37 +594,16 @@ function finishfunctions() {
594594
//getapp
595595
close_app_panel();
596596
//platform_icon
597-
598-
// ** Query helpers **//
599-
600-
//get_setting
601-
//set_setting
602-
//get_requestli
603-
//ch_pending
604-
//get_addresslist
605-
//filter_addressli
606-
//filter_all_addressli
607-
//filter_list
608-
//get_currencyli
609-
//get_homeli
610-
//cs_node
611-
//getcoindata
612-
//activecoinsettings
613-
//getcoinsettings
614-
//getcoinconfig
615597
gk();
616598
glob_html.addClass("loaded");
617599
//is_opendialog
618600
//is_openrequest
619601

620-
// ** Check params ** //
621-
622602
check_params();
623603
//check_intents;
624604
//expand_shoturl
625605
//expand_bitly
626606
//ln_connect
627-
//click_pop
628607
//add_serviceworker
629608
}
630609

@@ -5057,153 +5036,6 @@ function platform_icon(platform) {
50575036
fetch_aws("img_button-desktop_app.png");
50585037
}
50595038

5060-
// ** Query helpers ** //
5061-
5062-
// Retrieves a setting value
5063-
function get_setting(setting, dat) {
5064-
return $("#" + setting).data(dat);
5065-
}
5066-
5067-
// Sets a setting value and optionally updates its title
5068-
function set_setting(setting, keypairs, title) {
5069-
const set_node = $("#" + setting);
5070-
set_node.data(keypairs);
5071-
if (title) {
5072-
set_node.find("p").text(title);
5073-
}
5074-
}
5075-
5076-
// Finds a request list item based on data attributes
5077-
function get_requestli(datakey, dataval) {
5078-
return $("#requestlist li.rqli").filter(function() {
5079-
return $(this).data(datakey) == dataval;
5080-
})
5081-
}
5082-
5083-
// Checks if a pending request exists for the given data
5084-
function ch_pending(dat) {
5085-
return ($("#requestlist li.rqli[data-address='" + dat.address + "'][data-pending='scanning'][data-cmcid='" + dat.cmcid + "']").length > 0) ? true : false;
5086-
}
5087-
5088-
// Retrieves the address list for a given currency
5089-
function get_addresslist(currency) {
5090-
return $("main #" + currency + " .content ul.pobox[data-currency='" + currency + "']");
5091-
}
5092-
5093-
// Filters address list items based on data attributes
5094-
function filter_addressli(currency, datakey, dataval) {
5095-
const addressli = get_addresslist(currency).children("li");
5096-
return filter_list(addressli, datakey, dataval);
5097-
}
5098-
5099-
// Filters all address list items based on data attributes
5100-
function filter_all_addressli(datakey, dataval) {
5101-
return filter_list($(".adli"), datakey, dataval);
5102-
}
5103-
5104-
// Filters a list based on data attributes
5105-
function filter_list(list, datakey, dataval) {
5106-
return list.filter(function() {
5107-
return $(this).data(datakey) == dataval;
5108-
})
5109-
}
5110-
5111-
// Retrieves the currency list item for a given currency
5112-
function get_currencyli(currency) {
5113-
return $("#usedcurrencies > li[data-currency='" + currency + "']");
5114-
}
5115-
5116-
// Retrieves the home list item for a given currency
5117-
function get_homeli(currency) {
5118-
return $("#currencylist > li[data-currency='" + currency + "']");
5119-
}
5120-
5121-
// Retrieves coin settings node or data
5122-
function cs_node(currency, id, data) {
5123-
const coinnode = $("#" + currency + "_settings .cc_settinglist li[data-id='" + id + "']");
5124-
if (coinnode.length) {
5125-
if (data) {
5126-
const coindat = coinnode.data();
5127-
if (coindat) {
5128-
return coindat;
5129-
}
5130-
}
5131-
return coinnode;
5132-
}
5133-
const coindata = getcoinsettings(currency);
5134-
if (coindata) {
5135-
const apis = coindata.apis;
5136-
if (apis) {
5137-
return apis;
5138-
}
5139-
}
5140-
return false
5141-
}
5142-
5143-
// Retrieves coin data for a given currency
5144-
function getcoindata(currency) {
5145-
const coindata_object = getcoinconfig(currency);
5146-
if (coindata_object) {
5147-
const coindata = coindata_object.data,
5148-
settings = coindata_object.settings,
5149-
has_settings = (settings) ? true : false,
5150-
is_monitored = (settings) ? (settings.apis) ? true : false : false,
5151-
cd_object = {
5152-
"currency": coindata.currency,
5153-
"ccsymbol": coindata.ccsymbol,
5154-
"cmcid": coindata.cmcid,
5155-
"monitored": is_monitored,
5156-
"urlscheme": coindata.urlscheme,
5157-
"settings": has_settings,
5158-
"regex": coindata.address_regex,
5159-
"erc20": false
5160-
};
5161-
return cd_object;
5162-
} // if not it's probably erc20 token
5163-
const currencyref = get_currencyli(currency); // check if erc20 token is added
5164-
if (currencyref.length > 0) {
5165-
return $.extend(currencyref.data(), glob_br_config.erc20_dat.data);
5166-
} // else lookup erc20 data
5167-
const tokenobject = br_get_local("erc20tokens", true);
5168-
if (tokenobject) {
5169-
const erc20data = $.grep(tokenobject, function(filter) {
5170-
return filter.name == currency;
5171-
})[0];
5172-
if (erc20data) {
5173-
const fetched_data = {
5174-
"currency": erc20data.name,
5175-
"ccsymbol": erc20data.symbol,
5176-
"cmcid": erc20data.cmcid.toString(),
5177-
"contract": erc20data.contract
5178-
}
5179-
return $.extend(fetched_data, glob_br_config.erc20_dat.data);
5180-
}
5181-
}
5182-
return false;
5183-
}
5184-
5185-
// Retrieves active coin settings for a given currency
5186-
function activecoinsettings(currency) {
5187-
const saved_coinsettings = br_get_local(currency + "_settings", true);
5188-
return (saved_coinsettings) ? saved_coinsettings : getcoinsettings(currency);
5189-
}
5190-
5191-
// Retrieves coin settings for a given currency
5192-
function getcoinsettings(currency) {
5193-
const coindata = getcoinconfig(currency);
5194-
if (coindata) {
5195-
return coindata.settings;
5196-
} // return erc20 settings
5197-
return glob_br_config.erc20_dat.settings;
5198-
}
5199-
5200-
// Retrieves coin configuration for a given currency
5201-
function getcoinconfig(currency) {
5202-
return $.grep(glob_br_config.bitrequest_coin_data, function(filter) {
5203-
return filter.currency == currency;
5204-
})[0];
5205-
}
5206-
52075039
// Checks if a dialog is currently open
52085040
function is_opendialog() {
52095041
return ($("#dialogbody > div.formbox").length) ? true : false;
@@ -5214,44 +5046,6 @@ function is_openrequest() {
52145046
return ($("#request_front").length) ? true : false;
52155047
}
52165048

5217-
// ** Check params ** //
5218-
5219-
// Checks and processes URL parameters
5220-
function check_params(gets) {
5221-
const lgets = (gets) ? gets : geturlparameters();
5222-
if (lgets.xss) {
5223-
return
5224-
}
5225-
if (lgets.i) {
5226-
expand_shoturl(lgets.i);
5227-
return
5228-
}
5229-
if (lgets.cl) {
5230-
click_pop(lgets.cl);
5231-
}
5232-
const page = lgets.p;
5233-
if (page == "settings") {
5234-
if (lgets.ro) {
5235-
check_teaminvite(lgets.ro);
5236-
} else if (lgets.sbu) {
5237-
check_systembu(lgets.sbu);
5238-
} else if (lgets.csv) {
5239-
check_csvexport(lgets.csv);
5240-
} else if (lgets.code) {
5241-
init_access(lgets.code);
5242-
}
5243-
return
5244-
}
5245-
if (lgets.scheme) {
5246-
check_intents(lgets.scheme);
5247-
return
5248-
}
5249-
if (lgets.lnconnect) {
5250-
lm_function();
5251-
ln_connect();
5252-
}
5253-
}
5254-
52555049
// Checks and processes URL scheme intents
52565050
function check_intents(scheme) {
52575051
if (scheme == "false") {
@@ -5431,15 +5225,6 @@ function ln_connect(gets) {
54315225
notify(translate("invalidformat"));
54325226
}
54335227

5434-
// Triggers a click event after a delay
5435-
function click_pop(fn) {
5436-
const timeout = setTimeout(function() {
5437-
$("#" + fn).trigger("click");
5438-
}, 1200, function() {
5439-
clearTimeout(timeout);
5440-
});
5441-
}
5442-
54435228
// Adds a service worker to the application
54445229
function add_serviceworker() {
54455230
if ("serviceWorker" in navigator) {

0 commit comments

Comments
 (0)