<commit_before>/**
 * @depends {nrs.js}
 */
var NRS = (function(NRS, $, undefined) {
	NRS.assets = [];
	NRS.assetIds = [];
	NRS.closedGroups = [];
	NRS.assetSearch = false;
	NRS.lastIssuerCheck = false;
	NRS.viewingAsset = false; //viewing non-bookmarked asset
	NRS.currentAsset = {};
	var currentAssetID = 0;

	NRS.pages.asset_exchange = function(callback) {
		$(".content.content-stretch:visible").width($(".page:visible").width());

		if (NRS.databaseSupport) {
			NRS.assets = [];
			NRS.assetIds = [];

			NRS.database.select("assets", null, function(error, assets) {
				//select already bookmarked assets
				$.each(assets, function(index, asset) {
					NRS.cacheAsset(asset);
				});

				//check owned assets, see if any are not yet in bookmarked assets
				if (NRS.accountInfo.unconfirmedAssetBalances) {
					var newAssetIds = [];

					$.each(NRS.accountInfo.unconfirmedAssetBalances, function(key, assetBalance) {
						if (NRS.assetIds.indexOf(assetBalance.asset) == -1) {
							newAssetIds.push(assetBalance.asset);
							NRS.assetIds.push(assetBalance.asset);
						}
					});

					//add to bookmarked assets
					if (newAssetIds.length) {
						var qs = [];

						for (var i = 0; i < newAssetIds.length; i++) {
							qs.push("assets=" + encodeURIComponent(newAssetIds[i]));
						}

						qs = qs.join("&");
						//first get the assets info
						NRS.sendRequest("getAssets+", {
							//special request.. ugly hack.. also does POST due to URL max length
							"querystring": qs
						}, function(response) {
							if (response.assets && response.assets.length) {
								NRS.saveAssetBookmarks(response.assets, function() {
									NRS.loadAssetExchangeSidebar(callback);
								});
							} else {
								NRS.loadAssetExchangeSidebar(callback);
							}
						});
					} else {
						NRS.loadAssetExchangeSidebar(callback);
					}
				} else {
					NRS.loadAssetExchangeSidebar(callback);
				}
			});
		} else {
			//for users without db support, we only need to fetch owned assets
			if (NRS.accountInfo.unconfirmedAssetBalances) {
				var qs = [];

				$.each(NRS.accountInfo.unconfirmedAssetBalances, function(key, assetBalance) {
					qs.push("assets=" + encodeURIComponent(assetBalance.asset));
				});
				qs = qs.join("&");

				NRS.sendRequest("getAssets+", {
					"querystring": qs
				}, function(response) {
					if (response.assets && response.assets.length) {
						$.each(response.assets, function(key, asset) {
							NRS.cacheAsset(asset);
						});
					}
					NRS.loadAssetExchangeSidebar(callback);
				});
			} else {
				NRS.loadAssetExchangeSidebar(callback);
			}
		}
	}

	NRS.cacheAsset = function(asset) {
		NRS.assetIds.push(asset.asset);

		if (!asset.groupName) {
			asset.groupName = "";
		}

		var asset = {
			"asset": String(asset.asset),
			"name": String(asset.name).toLowerCase(),
			"description": String(asset.description),
			"groupName": String(asset.groupName).toLowerCase(),
			"account": String(asset.account),
			"accountRS": String(asset.accountRS),
			"quantityQNT": String(asset.quantityQNT),
			"decimals": parseInt(asset.decimals, 10)
		};

		NRS.assets.push(asset);

		return asset;
	}

	NRS.forms.addAssetBookmark = function($modal) {<commit_msg>Fix for when DB is not available in browser (asset exchange).<commit_after>/**
 * @depends {nrs.js}
 */
var NRS = (function(NRS, $, undefined) {
	NRS.assets = [];
	NRS.assetIds = [];
	NRS.closedGroups = [];
	NRS.assetSearch = false;
	NRS.lastIssuerCheck = false;
	NRS.viewingAsset = false; //viewing non-bookmarked asset
	NRS.currentAsset = {};
	var currentAssetID = 0;

	NRS.pages.asset_exchange = function(callback) {
		$(".content.content-stretch:visible").width($(".page:visible").width());

		if (NRS.databaseSupport) {
			NRS.assets = [];
			NRS.assetIds = [];

			NRS.database.select("assets", null, function(error, assets) {
				//select already bookmarked assets
				$.each(assets, function(index, asset) {
					NRS.cacheAsset(asset);
				});

				//check owned assets, see if any are not yet in bookmarked assets
				if (NRS.accountInfo.unconfirmedAssetBalances) {
					var newAssetIds = [];

					$.each(NRS.accountInfo.unconfirmedAssetBalances, function(key, assetBalance) {
						if (NRS.assetIds.indexOf(assetBalance.asset) == -1) {
							newAssetIds.push(assetBalance.asset);
							NRS.assetIds.push(assetBalance.asset);
						}
					});

					//add to bookmarked assets
					if (newAssetIds.length) {
						var qs = [];

						for (var i = 0; i < newAssetIds.length; i++) {
							qs.push("assets=" + encodeURIComponent(newAssetIds[i]));
						}

						qs = qs.join("&");
						//first get the assets info
						NRS.sendRequest("getAssets+", {
							//special request.. ugly hack.. also does POST due to URL max length
							"querystring": qs
						}, function(response) {
							if (response.assets && response.assets.length) {
								NRS.saveAssetBookmarks(response.assets, function() {
									NRS.loadAssetExchangeSidebar(callback);
								});
							} else {
								NRS.loadAssetExchangeSidebar(callback);
							}
						});
					} else {
						NRS.loadAssetExchangeSidebar(callback);
					}
				} else {
					NRS.loadAssetExchangeSidebar(callback);
				}
			});
		} else {
			//for users without db support, we only need to fetch owned assets
			if (NRS.accountInfo.unconfirmedAssetBalances) {
				var qs = [];

				$.each(NRS.accountInfo.unconfirmedAssetBalances, function(key, assetBalance) {
					if (NRS.assetIds.indexOf(assetBalance.asset) == -1) {
						qs.push("assets=" + encodeURIComponent(assetBalance.asset));
					}
				});

				qs = qs.join("&");

				if (qs) {
					NRS.sendRequest("getAssets+", {
						"querystring": qs
					}, function(response) {
						if (response.assets && response.assets.length) {
							$.each(response.assets, function(key, asset) {
								NRS.cacheAsset(asset);
							});
						}
						NRS.loadAssetExchangeSidebar(callback);
					});
				}
			} else {
				NRS.loadAssetExchangeSidebar(callback);
			}
		}
	}

	NRS.cacheAsset = function(asset) {
		if (NRS.assetIds.indexOf(asset.asset) != -1) {
			return;
		}

		NRS.assetIds.push(asset.asset);

		if (!asset.groupName) {
			asset.groupName = "";
		}

		var asset = {
			"asset": String(asset.asset),
			"name": String(asset.name).toLowerCase(),
			"description": String(asset.description),
			"groupName": String(asset.groupName).toLowerCase(),
			"account": String(asset.account),
			"accountRS": String(asset.accountRS),
			"quantityQNT": String(asset.quantityQNT),
			"decimals": parseInt(asset.decimals, 10)
		};

		NRS.assets.push(asset);
	}

	NRS.forms.addAssetBookmark = function($modal) {
{'fraction_non_alphanumeric': 0.1523766546329723, 'fraction_numerical': 0.0018050541516245488, 'mean_word_length': 2.98621103117506, 'pattern_counts': {'":': 20, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5372365', 'n_tokens_mistral': 2844, 'n_tokens_neox': 2177, 'n_words': 389}