diff --git a/data/web/core.telegram.org/bots/api.html b/data/web/core.telegram.org/bots/api.html
index 88c78c0dbe..89e7a95315 100644
--- a/data/web/core.telegram.org/bots/api.html
+++ b/data/web/core.telegram.org/bots/api.html
@@ -3406,22 +3406,22 @@ To learn how to create…">
can_post_messages |
Boolean |
-Optional. True, if the administrator can post messages in the channel, or access channel statistics; channels only |
+Optional. True, if the administrator can post messages in the channel, or access channel statistics; for channels only |
can_edit_messages |
Boolean |
-Optional. True, if the administrator can edit messages of other users and can pin messages; channels only |
+Optional. True, if the administrator can edit messages of other users and can pin messages; for channels only |
can_pin_messages |
Boolean |
-Optional. True, if the user is allowed to pin messages; groups and supergroups only |
+Optional. True, if the user is allowed to pin messages; for groups and supergroups only |
can_manage_topics |
Boolean |
-Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only |
+Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; for supergroups only |
@@ -3600,22 +3600,22 @@ To learn how to create…">
can_post_messages |
Boolean |
-Optional. True, if the administrator can post messages in the channel, or access channel statistics; channels only |
+Optional. True, if the administrator can post messages in the channel, or access channel statistics; for channels only |
can_edit_messages |
Boolean |
-Optional. True, if the administrator can edit messages of other users and can pin messages; channels only |
+Optional. True, if the administrator can edit messages of other users and can pin messages; for channels only |
can_pin_messages |
Boolean |
-Optional. True, if the user is allowed to pin messages; groups and supergroups only |
+Optional. True, if the user is allowed to pin messages; for groups and supergroups only |
can_manage_topics |
Boolean |
-Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only |
+Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; for supergroups only |
custom_title |
@@ -5307,7 +5307,7 @@ pre-formatted fixed-width code block written in the Python programming language
message_ids |
Array of Integer |
Yes |
-Identifiers of 1-100 messages in the chat from_chat_id to forward. The identifiers must be specified in a strictly increasing order. |
+A JSON-serialized list of 1-100 identifiers of messages in the chat from_chat_id to forward. The identifiers must be specified in a strictly increasing order. |
disable_notification |
@@ -5437,7 +5437,7 @@ pre-formatted fixed-width code block written in the Python programming language
message_ids |
Array of Integer |
Yes |
-Identifiers of 1-100 messages in the chat from_chat_id to copy. The identifiers must be specified in a strictly increasing order. |
+A JSON-serialized list of 1-100 identifiers of messages in the chat from_chat_id to copy. The identifiers must be specified in a strictly increasing order. |
disable_notification |
@@ -6604,7 +6604,7 @@ pre-formatted fixed-width code block written in the Python programming language
message_thread_id |
Integer |
Optional |
-Unique identifier for the target message thread; supergroups only |
+Unique identifier for the target message thread; for supergroups only |
action |
@@ -6642,7 +6642,7 @@ pre-formatted fixed-width code block written in the Python programming language
reaction |
Array of ReactionType |
Optional |
-New list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators. |
+A JSON-serialized list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators. |
is_big |
@@ -6913,25 +6913,25 @@ pre-formatted fixed-width code block written in the Python programming language
can_post_messages |
Boolean |
Optional |
-Pass True if the administrator can post messages in the channel, or access channel statistics; channels only |
+Pass True if the administrator can post messages in the channel, or access channel statistics; for channels only |
can_edit_messages |
Boolean |
Optional |
-Pass True if the administrator can edit messages of other users and can pin messages; channels only |
+Pass True if the administrator can edit messages of other users and can pin messages; for channels only |
can_pin_messages |
Boolean |
Optional |
-Pass True if the administrator can pin messages, supergroups only |
+Pass True if the administrator can pin messages; for supergroups only |
can_manage_topics |
Boolean |
Optional |
-Pass True if the user is allowed to create, rename, close, and reopen forum topics, supergroups only |
+Pass True if the user is allowed to create, rename, close, and reopen forum topics; for supergroups only |
@@ -8660,7 +8660,7 @@ pre-formatted fixed-width code block written in the Python programming language
message_ids |
Array of Integer |
Yes |
-Identifiers of 1-100 messages to delete. See deleteMessage for limitations on which messages can be deleted |
+A JSON-serialized list of 1-100 identifiers of messages to delete. See deleteMessage for limitations on which messages can be deleted |
@@ -8966,7 +8966,7 @@ pre-formatted fixed-width code block written in the Python programming language
custom_emoji_ids |
Array of String |
Yes |
-List of custom emoji identifiers. At most 200 custom emoji identifiers can be specified. |
+A JSON-serialized list of custom emoji identifiers. At most 200 custom emoji identifiers can be specified. |
@@ -11930,42 +11930,42 @@ pre-formatted fixed-width code block written in the Python programming language
data |
String |
-Optional. Base64-encoded encrypted Telegram Passport element data provided by the user, available for “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport” and “address” types. Can be decrypted and verified using the accompanying EncryptedCredentials. |
+Optional. Base64-encoded encrypted Telegram Passport element data provided by the user; available only for “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport” and “address” types. Can be decrypted and verified using the accompanying EncryptedCredentials. |
phone_number |
String |
-Optional. User's verified phone number, available only for “phone_number” type |
+Optional. User's verified phone number; available only for “phone_number” type |
email |
String |
-Optional. User's verified email address, available only for “email” type |
+Optional. User's verified email address; available only for “email” type |
files |
Array of PassportFile |
-Optional. Array of encrypted files with documents provided by the user, available for “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types. Files can be decrypted and verified using the accompanying EncryptedCredentials. |
+Optional. Array of encrypted files with documents provided by the user; available only for “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types. Files can be decrypted and verified using the accompanying EncryptedCredentials. |
front_side |
PassportFile |
-Optional. Encrypted file with the front side of the document, provided by the user. Available for “passport”, “driver_license”, “identity_card” and “internal_passport”. The file can be decrypted and verified using the accompanying EncryptedCredentials. |
+Optional. Encrypted file with the front side of the document, provided by the user; available only for “passport”, “driver_license”, “identity_card” and “internal_passport”. The file can be decrypted and verified using the accompanying EncryptedCredentials. |
reverse_side |
PassportFile |
-Optional. Encrypted file with the reverse side of the document, provided by the user. Available for “driver_license” and “identity_card”. The file can be decrypted and verified using the accompanying EncryptedCredentials. |
+Optional. Encrypted file with the reverse side of the document, provided by the user; available only for “driver_license” and “identity_card”. The file can be decrypted and verified using the accompanying EncryptedCredentials. |
selfie |
PassportFile |
-Optional. Encrypted file with the selfie of the user holding a document, provided by the user; available for “passport”, “driver_license”, “identity_card” and “internal_passport”. The file can be decrypted and verified using the accompanying EncryptedCredentials. |
+Optional. Encrypted file with the selfie of the user holding a document, provided by the user; available if requested for “passport”, “driver_license”, “identity_card” and “internal_passport”. The file can be decrypted and verified using the accompanying EncryptedCredentials. |
translation |
Array of PassportFile |
-Optional. Array of encrypted files with translated versions of documents provided by the user. Available if requested for “passport”, “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types. Files can be decrypted and verified using the accompanying EncryptedCredentials. |
+Optional. Array of encrypted files with translated versions of documents provided by the user; available if requested for “passport”, “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types. Files can be decrypted and verified using the accompanying EncryptedCredentials. |
hash |
diff --git a/data/web/corefork.telegram.org/bots/api.html b/data/web/corefork.telegram.org/bots/api.html
index 452915c1ef..6af9dc1b7a 100644
--- a/data/web/corefork.telegram.org/bots/api.html
+++ b/data/web/corefork.telegram.org/bots/api.html
@@ -3406,22 +3406,22 @@ To learn how to create…">
can_post_messages |
Boolean |
-Optional. True, if the administrator can post messages in the channel, or access channel statistics; channels only |
+Optional. True, if the administrator can post messages in the channel, or access channel statistics; for channels only |
can_edit_messages |
Boolean |
-Optional. True, if the administrator can edit messages of other users and can pin messages; channels only |
+Optional. True, if the administrator can edit messages of other users and can pin messages; for channels only |
can_pin_messages |
Boolean |
-Optional. True, if the user is allowed to pin messages; groups and supergroups only |
+Optional. True, if the user is allowed to pin messages; for groups and supergroups only |
can_manage_topics |
Boolean |
-Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only |
+Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; for supergroups only |
@@ -3600,22 +3600,22 @@ To learn how to create…">
can_post_messages |
Boolean |
-Optional. True, if the administrator can post messages in the channel, or access channel statistics; channels only |
+Optional. True, if the administrator can post messages in the channel, or access channel statistics; for channels only |
can_edit_messages |
Boolean |
-Optional. True, if the administrator can edit messages of other users and can pin messages; channels only |
+Optional. True, if the administrator can edit messages of other users and can pin messages; for channels only |
can_pin_messages |
Boolean |
-Optional. True, if the user is allowed to pin messages; groups and supergroups only |
+Optional. True, if the user is allowed to pin messages; for groups and supergroups only |
can_manage_topics |
Boolean |
-Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only |
+Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; for supergroups only |
custom_title |
@@ -5307,7 +5307,7 @@ pre-formatted fixed-width code block written in the Python programming language
message_ids |
Array of Integer |
Yes |
-Identifiers of 1-100 messages in the chat from_chat_id to forward. The identifiers must be specified in a strictly increasing order. |
+A JSON-serialized list of 1-100 identifiers of messages in the chat from_chat_id to forward. The identifiers must be specified in a strictly increasing order. |
disable_notification |
@@ -5437,7 +5437,7 @@ pre-formatted fixed-width code block written in the Python programming language
message_ids |
Array of Integer |
Yes |
-Identifiers of 1-100 messages in the chat from_chat_id to copy. The identifiers must be specified in a strictly increasing order. |
+A JSON-serialized list of 1-100 identifiers of messages in the chat from_chat_id to copy. The identifiers must be specified in a strictly increasing order. |
disable_notification |
@@ -6604,7 +6604,7 @@ pre-formatted fixed-width code block written in the Python programming language
message_thread_id |
Integer |
Optional |
-Unique identifier for the target message thread; supergroups only |
+Unique identifier for the target message thread; for supergroups only |
action |
@@ -6642,7 +6642,7 @@ pre-formatted fixed-width code block written in the Python programming language
reaction |
Array of ReactionType |
Optional |
-New list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators. |
+A JSON-serialized list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators. |
is_big |
@@ -6913,25 +6913,25 @@ pre-formatted fixed-width code block written in the Python programming language
can_post_messages |
Boolean |
Optional |
-Pass True if the administrator can post messages in the channel, or access channel statistics; channels only |
+Pass True if the administrator can post messages in the channel, or access channel statistics; for channels only |
can_edit_messages |
Boolean |
Optional |
-Pass True if the administrator can edit messages of other users and can pin messages; channels only |
+Pass True if the administrator can edit messages of other users and can pin messages; for channels only |
can_pin_messages |
Boolean |
Optional |
-Pass True if the administrator can pin messages, supergroups only |
+Pass True if the administrator can pin messages; for supergroups only |
can_manage_topics |
Boolean |
Optional |
-Pass True if the user is allowed to create, rename, close, and reopen forum topics, supergroups only |
+Pass True if the user is allowed to create, rename, close, and reopen forum topics; for supergroups only |
@@ -8660,7 +8660,7 @@ pre-formatted fixed-width code block written in the Python programming language
message_ids |
Array of Integer |
Yes |
-Identifiers of 1-100 messages to delete. See deleteMessage for limitations on which messages can be deleted |
+A JSON-serialized list of 1-100 identifiers of messages to delete. See deleteMessage for limitations on which messages can be deleted |
@@ -8966,7 +8966,7 @@ pre-formatted fixed-width code block written in the Python programming language
custom_emoji_ids |
Array of String |
Yes |
-List of custom emoji identifiers. At most 200 custom emoji identifiers can be specified. |
+A JSON-serialized list of custom emoji identifiers. At most 200 custom emoji identifiers can be specified. |
@@ -11930,42 +11930,42 @@ pre-formatted fixed-width code block written in the Python programming language
data |
String |
-Optional. Base64-encoded encrypted Telegram Passport element data provided by the user, available for “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport” and “address” types. Can be decrypted and verified using the accompanying EncryptedCredentials. |
+Optional. Base64-encoded encrypted Telegram Passport element data provided by the user; available only for “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport” and “address” types. Can be decrypted and verified using the accompanying EncryptedCredentials. |
phone_number |
String |
-Optional. User's verified phone number, available only for “phone_number” type |
+Optional. User's verified phone number; available only for “phone_number” type |
email |
String |
-Optional. User's verified email address, available only for “email” type |
+Optional. User's verified email address; available only for “email” type |
files |
Array of PassportFile |
-Optional. Array of encrypted files with documents provided by the user, available for “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types. Files can be decrypted and verified using the accompanying EncryptedCredentials. |
+Optional. Array of encrypted files with documents provided by the user; available only for “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types. Files can be decrypted and verified using the accompanying EncryptedCredentials. |
front_side |
PassportFile |
-Optional. Encrypted file with the front side of the document, provided by the user. Available for “passport”, “driver_license”, “identity_card” and “internal_passport”. The file can be decrypted and verified using the accompanying EncryptedCredentials. |
+Optional. Encrypted file with the front side of the document, provided by the user; available only for “passport”, “driver_license”, “identity_card” and “internal_passport”. The file can be decrypted and verified using the accompanying EncryptedCredentials. |
reverse_side |
PassportFile |
-Optional. Encrypted file with the reverse side of the document, provided by the user. Available for “driver_license” and “identity_card”. The file can be decrypted and verified using the accompanying EncryptedCredentials. |
+Optional. Encrypted file with the reverse side of the document, provided by the user; available only for “driver_license” and “identity_card”. The file can be decrypted and verified using the accompanying EncryptedCredentials. |
selfie |
PassportFile |
-Optional. Encrypted file with the selfie of the user holding a document, provided by the user; available for “passport”, “driver_license”, “identity_card” and “internal_passport”. The file can be decrypted and verified using the accompanying EncryptedCredentials. |
+Optional. Encrypted file with the selfie of the user holding a document, provided by the user; available if requested for “passport”, “driver_license”, “identity_card” and “internal_passport”. The file can be decrypted and verified using the accompanying EncryptedCredentials. |
translation |
Array of PassportFile |
-Optional. Array of encrypted files with translated versions of documents provided by the user. Available if requested for “passport”, “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types. Files can be decrypted and verified using the accompanying EncryptedCredentials. |
+Optional. Array of encrypted files with translated versions of documents provided by the user; available if requested for “passport”, “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types. Files can be decrypted and verified using the accompanying EncryptedCredentials. |
hash |
diff --git a/data/web/fragment.com/js/auction.js b/data/web/fragment.com/js/auction.js
index 0fdf6e5dfc..34fecf8742 100644
--- a/data/web/fragment.com/js/auction.js
+++ b/data/web/fragment.com/js/auction.js
@@ -18,7 +18,8 @@ var Main = {
$(cont).on('click.curPage', '.js-howofferworks', Main.eHowofferworks);
$(cont).on('click.curPage', '.js-bots-about', Main.eBotsAbout);
$(cont).on('click.curPage', '.logout-link', Login.logOut);
- $(cont).on('click.curPage', '.ton-logout-link', Login.tonLogOut);
+ $(cont).on('click.curPage', '.ton-auth-link', Wallet.eTonAuth);
+ $(cont).on('click.curPage', '.ton-logout-link', Wallet.eLogOut);
$(cont).on('click.curPage', '.js-copy-code', Main.copyCode);
$(cont).on('click.curPage', '.js-main-search-dd-item', Main.eMainSearchDDSelected);
state.$headerMenu = $('.js-header-menu');
@@ -597,14 +598,173 @@ var Login = {
location.reload();
});
return false;
+ }
+};
+
+var Wallet = {
+ init: function(options) {
+ Aj.globalState.tonConnectAuthAddress = options.address || false;
+ Aj.globalState.tonConnectProof = options.ton_proof || '';
+ Aj.globalState.tonConnectVersion = options.version || 1;
+ if (Aj.globalState.tonConnectVersion == 2) {
+ var tonConnectUI = Aj.globalState.tonConnectUI;
+ if (!tonConnectUI) {
+ tonConnectUI = Aj.globalState.tonConnectUI = new TON_CONNECT_UI.TonConnectUI({
+ manifestUrl: location.origin + '/tonconnect-manifest.json',
+ actionsConfiguration: {
+ modals: ['before'],
+ notifications: [],
+ returnStrategy: 'back'
+ },
+ uiPreferences: {
+ theme: 'DARK',
+ borderRadius: 's',
+ colorsSet: {
+ 'DARK': {
+ accent: '#4db2ff',
+ background: {
+ primary: '#1a2026',
+ qr: '#fff',
+ tint: '#242e38'
+ },
+ connectButton: {
+ background: '#248bda',
+ foreground: '#fff'
+ },
+ icon: {
+ error: '#ff5863',
+ },
+ text: {
+ primary: '#fff',
+ secondary: '#8794a1'
+ }
+ }
+ }
+ }
+ });
+ tonConnectUI.setConnectRequestParameters({
+ value: { tonProof: Aj.globalState.tonConnectProof }
+ });
+ tonConnectUI.connectionRestored.then(function() {
+ if (!Aj.globalState.tonConnectInited) {
+ Wallet.checkWallet();
+ Aj.globalState.tonConnectInited = true;
+ }
+ console.log('connected', tonConnectUI.connected);
+ });
+ tonConnectUI.onStatusChange(function(wallet) {
+ if (Aj.globalState.tonConnectInited) {
+ if (wallet &&
+ wallet.account &&
+ wallet.connectItems &&
+ wallet.connectItems.tonProof &&
+ wallet.connectItems.tonProof.proof) {
+ Aj.apiRequest('checkTonProofAuth', {
+ account: JSON.stringify(wallet.account),
+ proof: JSON.stringify(wallet.connectItems.tonProof.proof)
+ }, function(result) {
+ if (result.verified) {
+ location.reload();
+ } else {
+ Wallet.disconnect();
+ }
+ console.log('verified', result.verified);
+ });
+ } else {
+ Wallet.checkWallet();
+ }
+ }
+ });
+ } else {
+ Wallet.checkWallet();
+ }
+ }
},
- tonLogOut: function(e) {
+ sendTransaction: function(options) {
+ if (Aj.globalState.tonConnectVersion == 2) {
+ var tonConnectUI = Aj.globalState.tonConnectUI;
+ var sendTransaction = function(transaction) {
+ tonConnectUI.sendTransaction(transaction).then(function(transaction) {
+ options.onConfirm && options.onConfirm(true);
+ }).catch(function(){});
+ };
+ if (!tonConnectUI.connected) {
+ tonConnectUI.openModal();
+ } else if (options.request) {
+ var req = options.request, params = $.extend({transaction: 1}, req.params);
+ Aj.apiRequest(req.method, params, function(result) {
+ if (result.error) {
+ return showAlert(result.error);
+ }
+ sendTransaction(result.transaction);
+ });
+ } else if (options.transaction) {
+ sendTransaction(options.transaction);
+ }
+ } else {
+ QR.showPopup(options);
+ }
+ },
+ eTonAuth: function(e) {
+ e.stopImmediatePropagation();
+ e.preventDefault();
+ if (Aj.globalState.tonConnectVersion == 2) {
+ var tonConnectUI = Aj.globalState.tonConnectUI;
+ if (!tonConnectUI.connected) {
+ tonConnectUI.openModal();
+ }
+ } else {
+ QR.showPopup({
+ request: {
+ method: 'getTonAuthLink'
+ },
+ title: l('WEB_POPUP_TON_AUTH_HEADER'),
+ description: l('WEB_POPUP_TON_AUTH_TEXT'),
+ hint: l('WEB_POPUP_TON_AUTH_HINT'),
+ tk_label: l('WEB_POPUP_TON_AUTH_BUTTON'),
+ onConfirm: function() {
+ location.reload();
+ }
+ });
+ }
+ },
+ eLogOut: function(e) {
e.preventDefault();
e.stopImmediatePropagation();
+ Wallet.disconnect();
+ return false;
+ },
+ checkWallet: function() {
+ if (Aj.globalState.tonConnectVersion == 2) {
+ var authAddress = Aj.globalState.tonConnectAuthAddress,
+ wallet = Aj.globalState.tonConnectUI.wallet;
+ if (wallet && wallet.account) {
+ if (!authAddress || authAddress != wallet.account.address) {
+ Wallet.disconnect();
+ }
+ } else {
+ if (authAddress) {
+ Wallet.logOut();
+ }
+ }
+ }
+ },
+ disconnect: function() {
+ var tonConnectUI = Aj.globalState.tonConnectUI;
+ if (tonConnectUI && tonConnectUI.connected) {
+ tonConnectUI.disconnect().then(function() {
+ if (Aj.globalState.tonConnectAuthAddress) {
+ Wallet.logOut();
+ }
+ });
+ } else {
+ Wallet.logOut();
+ }
+ },
+ logOut: function() {
Aj.apiRequest('tonLogOut', {}, function(result) {
location.reload();
});
- return false;
}
};
@@ -693,7 +853,7 @@ var Auction = {
return;
}
closePopup(Aj.state.$bidPopup);
- QR.showPopup({
+ Wallet.sendTransaction({
request: {
method: 'getBidLink',
params: {
@@ -722,7 +882,7 @@ var Auction = {
var username = Aj.state.username;
var item_title = Aj.state.itemTitle;
var amount = $(this).attr('data-bid-amount');
- QR.showPopup({
+ Wallet.sendTransaction({
request: {
method: 'getBidLink',
params: {
@@ -792,7 +952,7 @@ var Auction = {
return;
}
closePopup(Aj.state.$makeOfferPopup);
- QR.showPopup({
+ Wallet.sendTransaction({
request: {
method: 'getOfferLink',
params: {
@@ -1004,7 +1164,7 @@ var Assets = {
var $form = $(this);
var req_id = $form.field('id').value();
closePopup(Aj.state.$botUsernamePopup);
- QR.showPopup({
+ Wallet.sendTransaction({
request: {
method: 'getBotUsernameLink',
params: {
@@ -1070,7 +1230,7 @@ var Assets = {
var min_amount = Main.amountFieldValue($form, 'min_bid_value');
var max_amount = Main.amountFieldValue($form, 'max_price_value');
closePopup(Aj.state.$putToAuctionPopup);
- QR.showPopup({
+ Wallet.sendTransaction({
request: {
method: 'getStartAuctionLink',
params: {
@@ -1102,7 +1262,7 @@ var Assets = {
var $actions = $(this).closest('.js-actions');
var username = $actions.attr('data-username');
var item_title = $actions.attr('data-item-title');
- QR.showPopup({
+ Wallet.sendTransaction({
request: {
method: 'getCancelAuctionLink',
params: {
@@ -1171,7 +1331,7 @@ var Assets = {
var item_title = Aj.state.$sellUsernameForm.data('item_title');
var sell_amount = Main.amountFieldValue($form, 'sell_value');
closePopup(Aj.state.$sellUsernamePopup);
- QR.showPopup({
+ Wallet.sendTransaction({
request: {
method: 'getStartAuctionLink',
params: {
@@ -1257,7 +1417,7 @@ var Random = {
e.preventDefault();
var item_title = Aj.state.itemTitle;
var amount = Aj.state.price;
- QR.showPopup({
+ Wallet.sendTransaction({
request: {
method: 'getRandomNumberLink',
params: {}
@@ -1546,7 +1706,8 @@ var Account = {
$form.data('loading', true);
Aj.apiRequest('startConverting', {
id: req_id,
- bid: amount
+ bid: amount,
+ transaction: 1
}, function(result) {
$form.data('loading', false);
Account.processConverting(result);
@@ -1663,7 +1824,7 @@ var Premium = {
Main.destroyForm(state.$giftPremiumForm);
state.$premiumSearchForm.off('submit', Premium.eSearchSubmit);
state.$premiumSearchForm.field('query').off('input', Premium.eSearchInput);
- state.$premiumSearchForm.field('query').on('change', Premium.eSearchChange);
+ state.$premiumSearchForm.field('query').off('change', Premium.eSearchChange);
$('.js-form-clear', state.$premiumSearchForm).off('click', Premium.eSearchClear);
state.$premiumSearchForm.off('change', '.js-premium-options input.radio', Premium.eRadioChanged);
state.$giftPremiumForm.off('change', 'input.checkbox', Premium.eCheckboxChanged);
@@ -1877,7 +2038,7 @@ var Premium = {
var req_id = $form.field('id').value();
var show_sender = $form.field('show_sender').prop('checked');
closePopup(Aj.state.$giftPremiumPopup);
- QR.showPopup({
+ Wallet.sendTransaction({
request: {
method: 'getGiftPremiumLink',
params: {
@@ -1945,7 +2106,7 @@ var PremiumGiveaway = {
Main.destroyForm(state.$giveawayPremiumForm);
state.$premiumSearchForm.off('submit', PremiumGiveaway.eSearchSubmit);
state.$premiumSearchForm.field('query').off('input', PremiumGiveaway.eSearchInput);
- state.$premiumSearchForm.field('query').on('change', PremiumGiveaway.eSearchChange);
+ state.$premiumSearchForm.field('query').off('change', PremiumGiveaway.eSearchChange);
$('.js-form-clear', state.$premiumSearchForm).off('click', PremiumGiveaway.eSearchClear);
state.$premiumSearchForm.field('quantity').off('change', PremiumGiveaway.eQuantityChanged);
state.$premiumSearchForm.off('change', '.js-premium-options input.radio', PremiumGiveaway.eRadioChanged);
@@ -2197,7 +2358,7 @@ var PremiumGiveaway = {
var item_title = Aj.state.itemTitle;
var req_id = $form.field('id').value();
closePopup(Aj.state.$giveawayPremiumPopup);
- QR.showPopup({
+ Wallet.sendTransaction({
request: {
method: 'getGiveawayPremiumLink',
params: {
@@ -2226,6 +2387,215 @@ var PremiumGiveaway = {
}
};
+var Ads = {
+ init: function() {
+ Aj.onLoad(function(state) {
+ var cont = Aj.ajContainer;
+ $(cont).on('click.curPage', '.js-more-funds-btn', Ads.eAddMoreFunds);
+ $(cont).on('click.curPage', '.js-recharge-btn', Ads.eRechargeAccount);
+ state.$rechargeForm = $('.js-recharge-form', cont);
+ state.$searchField = $('.js-account-search-field', cont);
+ Main.initForm(state.$rechargeForm);
+ state.$rechargeForm.on('submit', Ads.eSearchSubmit);
+ state.$rechargeForm.field('query').on('input', Ads.eSearchInput);
+ state.$rechargeForm.field('query').on('change', Ads.eSearchChange);
+ $('.js-form-clear', state.$rechargeForm).on('click', Ads.eSearchClear);
+ state.$rechargeBtn = $('.js-recharge-btn', cont);
+ state.updLastReq = +Date.now();
+ if (state.needUpdate) {
+ state.updStateTo = setTimeout(Ads.updateState, Main.UPDATE_PERIOD);
+ }
+ });
+ Aj.onUnload(function(state) {
+ clearTimeout(state.updStateTo);
+ state.needUpdate = false;
+ Main.destroyForm(state.$giftPremiumForm);
+ state.$rechargeForm.off('submit', Ads.eSearchSubmit);
+ state.$rechargeForm.field('query').off('input', Ads.eSearchInput);
+ state.$rechargeForm.field('query').off('change', Ads.eSearchChange);
+ $('.js-form-clear', state.$rechargeForm).off('click', Ads.eSearchClear);
+ });
+ },
+ updateState: function() {
+ var now = +Date.now();
+ if (document.hasFocus() ||
+ Aj.state.updLastReq && (now - Aj.state.updLastReq) > Main.FORCE_UPDATE_PERIOD) {
+ Aj.state.updLastReq = now;
+ Aj.apiRequest('updateAdsState', {
+ mode: Aj.state.mode
+ }, function(result) {
+ if (result.mode) {
+ Aj.state.mode = result.mode;
+ }
+ if (result.html) {
+ Ads.updateContent(result.html);
+ } else {
+ if (result.history_html) {
+ Ads.updateHistory(result.history_html);
+ }
+ }
+ if (result.lv) {
+ Aj.state.lastVer = result.lv;
+ if (Aj.state.$sentPopup) {
+ closePopup(Aj.state.$sentPopup);
+ }
+ }
+ if (Aj.state.needUpdate && result.need_update) {
+ Aj.state.updStateTo = setTimeout(Ads.updateState, Main.UPDATE_PERIOD);
+ }
+ });
+ } else {
+ if (Aj.state.needUpdate) {
+ Aj.state.updStateTo = setTimeout(Ads.updateState, Main.CHECK_PERIOD);
+ }
+ }
+ },
+ eSearchInput: function(e) {
+ var $field = Aj.state.$searchField;
+ $('.js-search-field-error').html('');
+ $field.removeClass('error');
+ },
+ eSearchChange: function(e) {
+ Ads.searchSubmit();
+ },
+ eSearchClear: function(e) {
+ var $form = Aj.state.$rechargeForm;
+ var $field = Aj.state.$searchField;
+ var $btn = Aj.state.$rechargeBtn;
+ $form.field('account').value('');
+ $form.field('query').value('').prop('disabled', false);
+ $btn.prop('disabled', true);
+ $field.removeClass('found');
+ $('.js-search-field-error').html('');
+ $field.removeClass('error');
+ Ads.updateUrl();
+ $form.field('query').focus();
+ },
+ eSearchSubmit: function(e) {
+ e.preventDefault();
+ Ads.searchSubmit();
+ },
+ searchSubmit: function() {
+ var $form = Aj.state.$rechargeForm;
+ var account = $form.field('account').value();
+ var query = $form.field('query').value();
+ if (!query.length) {
+ $form.field('query').focus();
+ return;
+ }
+ Aj.state.$searchField.addClass('loading').removeClass('play').redraw().addClass('play');
+ Aj.showProgress();
+ Aj.apiRequest('searchAdsAccount', {
+ query: account || query
+ }, function(result) {
+ Aj.hideProgress();
+ Ads.updateResult(result);
+ Aj.state.$searchField.removeClass('loading');
+ });
+ },
+ updateResult: function(result) {
+ var $form = Aj.state.$rechargeForm;
+ var $field = Aj.state.$searchField;
+ var $btn = Aj.state.$rechargeBtn;
+ if (result.error) {
+ $('.js-search-field-error').html(result.error);
+ $field.addClass('error').removeClass('found');
+ $form.field('query').prop('disabled', false);
+ } else {
+ $('.js-search-field-error').html('');
+ $field.removeClass('error');
+ if (result.found) {
+ if (result.found.photo) {
+ $('.js-account-search-photo', $field).html(result.found.photo);
+ }
+ if (result.found.name) {
+ var $form = Aj.state.$rechargeForm;
+ $form.field('query').value(uncleanHTML(result.found.name));
+ }
+ $form.field('account').value(result.found.account);
+ $field.addClass('found');
+ $form.field('query').prop('disabled', true);
+ $btn.prop('disabled', false);
+ } else {
+ $form.field('account').value('');
+ $field.removeClass('found');
+ $form.field('query').prop('disabled', false);
+ $btn.prop('disabled', true);
+ }
+ }
+ Ads.updateUrl();
+ },
+ updateUrl: function() {
+ var new_url = '';
+ var $form = Aj.state.$rechargeForm;
+ var account = $form.field('account').value();
+ if (account) {
+ new_url += '&account=' + encodeURIComponent(account);
+ }
+ if (new_url) {
+ new_url = '?' + new_url.substr(1);
+ }
+ var loc = Aj.location(), path = loc.pathname + loc.search;
+ if (!new_url) {
+ new_url = loc.pathname;
+ }
+ Aj.setLocation(new_url, path != '/ads');
+ },
+ updateHistory: function(html) {
+ $('.js-premium-history').replaceWith(html);
+ },
+ updateContent: function(html) {
+ $('.js-main-content').html(html).find('.js-preview-sticker').each(function() {
+ RLottie.init(this, {playUntilEnd: true});
+ });
+ },
+ eRechargeAccount: function(e) {
+ e.stopImmediatePropagation();
+ e.preventDefault();
+ var $form = Aj.state.$rechargeForm;
+ var account = $form.field('account').value();
+ var amount = Main.amountFieldValue($form, 'amount_value');
+ if (amount === false || amount <= 0) {
+ $form.field('amount_value').focus();
+ return;
+ }
+ Aj.apiRequest('initAdsRechargeRequest', {
+ account: account,
+ amount: amount
+ }, function(result) {
+ if (result.error) {
+ return showAlert(result.error);
+ }
+ Wallet.sendTransaction({
+ request: {
+ method: 'getAdsRechargeLink',
+ params: {
+ id: result.req_id
+ }
+ },
+ title: l('WEB_POPUP_QR_ADS_RECHARGE_HEADER'),
+ description: l('WEB_POPUP_QR_ADS_RECHARGE_TEXT', {
+ amount: '' + result.amount + ''
+ }),
+ qr_label: result.item_title,
+ tk_label: l('WEB_POPUP_QR_ADS_RECHARGE_TK_BUTTON'),
+ terms_label: l('WEB_POPUP_QR_PROCEED_TERMS')
+ });
+ Aj.state.needUpdate = true;
+ });
+ },
+ eAddMoreFunds: function(e) {
+ e.preventDefault();
+ e.stopImmediatePropagation();
+ Aj.apiRequest('repeatAdsAddFunds', {}, function(result) {
+ if (result.error) {
+ return showAlert(result.error);
+ }
+ Aj.location('/ads');
+ });
+ }
+};
+
var QR = {
showPopup: function(options) {
options = $.extend({