withdraw.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /**
  2. * Copyright (c) UNA, Inc - https://una.io
  3. * MIT License - https://opensource.org/licenses/MIT
  4. *
  5. * @defgroup Credits Credits
  6. * @ingroup UnaModules
  7. *
  8. * @{
  9. */
  10. function BxCreditsWithdraw(oOptions) {
  11. this._sActionsUri = oOptions.sActionUri;
  12. this._sActionsUrl = oOptions.sActionUrl;
  13. this._sObjName = oOptions.sObjName == undefined ? 'oBxCreditsWithdraw' : oOptions.sObjName;
  14. this._sAnimationEffect = oOptions.sAnimationEffect == undefined ? 'slide' : oOptions.sAnimationEffect;
  15. this._iAnimationSpeed = oOptions.iAnimationSpeed == undefined ? 'slow' : oOptions.iAnimationSpeed;
  16. this._aHtmlIds = oOptions.aHtmlIds == undefined ? {} : oOptions.aHtmlIds;
  17. }
  18. BxCreditsWithdraw.prototype.getResult = function(oElement) {
  19. var fRate = parseFloat($('#' + this._aHtmlIds['withdraw_field_rate']).val());
  20. var fAmount = parseFloat($(oElement).val())
  21. $('#' + this._aHtmlIds['withdraw_field_result']).val(this._round(fRate * fAmount, 2));
  22. };
  23. BxCreditsWithdraw.prototype.loadingInButton = function(e, bShow) {
  24. if($(e).length)
  25. bx_loading_btn($(e), bShow);
  26. else
  27. bx_loading($('body'), bShow);
  28. };
  29. BxCreditsWithdraw.prototype.loadingInBox = function(e, bShow) {
  30. var oParent = $(e).length ? $(e).parents('.bx-base-text-poll:first') : $('body');
  31. bx_loading(oParent, bShow);
  32. };
  33. BxCreditsWithdraw.prototype.loadingInBlock = function(e, bShow) {
  34. var oParent = $(e).length ? $(e).parents('.bx-db-container:first') : $('body');
  35. bx_loading(oParent, bShow);
  36. };
  37. BxCreditsWithdraw.prototype._getDefaultData = function() {
  38. var oDate = new Date();
  39. return jQuery.extend({}, this._oRequestParams, {_t:oDate.getTime()});
  40. };
  41. BxCreditsWithdraw.prototype._round = function(fNum, iPrecision = 0) {
  42. var iMux = Math.pow(10, iPrecision);
  43. var iNum = (fNum * iMux) * (1 + Number.EPSILON);
  44. return Math.round(iNum) / iMux;
  45. }
  46. /** @} */