Add a Bitcoin Faucet to your website.


SUBMITTED BY: godsend

DATE: Dec. 23, 2020, 11:33 a.m.

UPDATED: Feb. 12, 2021, 3:53 p.m.

FORMAT: Text only

SIZE: 14.1 kB

HITS: 981

  1. https://cp.ecos.am/user/dashboard
  2. !function(a){FormValidation.AddOn.reCaptcha2={html5Attributes:{element:"element",language:"language",message:"message",sitekey:"siteKey",theme:"theme",timeout:"timeout"},CAPTCHA_FIELD:"g-recaptcha-response",CAPTCHA_TIMEOUT:120,init:function(b,c){var d=this,e="undefined"==typeof window.reCaptchaLoaded?function(){}:window.reCaptchaLoaded;window.reCaptchaLoaded=function(){e(),grecaptcha.render(c.element,{sitekey:c.siteKey,theme:c.theme||"light",callback:function(){b.updateStatus(d.CAPTCHA_FIELD,b.STATUS_VALID),setTimeout(function(){b.updateStatus(d.CAPTCHA_FIELD,b.STATUS_INVALID)},1e3*(c.timeout||d.CAPTCHA_TIMEOUT))}}),setTimeout(function(){d._addCaptcha(b,c)},3e3)};var f="//www.google.com/recaptcha/api.js?onload=reCaptchaLoaded&render=explicit"+(c.language?"&hl="+c.language:"");if(0===a("body").find('script[src="'+f+'"]').length){var g=document.createElement("script");g.type="text/javascript",g.async=!0,g.defer=!0,g.src=f,document.getElementsByTagName("body")[0].appendChild(g)}},_addCaptcha:function(a,b){var c=this;a.getForm().formValidation("addField",c.CAPTCHA_FIELD,{excluded:!1,validators:{callback:{message:b.message,callback:function(a){return""!==a}}}})}}}(jQuery);
  3. // Ion.Sound | version 2.1.3 | https://github.com/IonDen/ion.sound
  4. var ion = ion || {}; (function (e) { var l = function (a) { a && console && (console.warn && "function" === typeof console.warn ? console.warn(a) : console.log && "function" === typeof console.log && console.log(a)) }; if (e.sound) l("ion.sound already exists!"); else if ("function" !== typeof Audio && "object" !== typeof Audio) { var g = function () { l("HTML5 Audio is not supported in this browser") }; e.sound = function () { }; e.sound.play = g; e.sound.stop = g; e.sound.destroy = g; g() } else { var f, m = /iPad|iPhone/.test(navigator.appVersion), k, d = {}, b = {}, n, h, c; m ? (f = function (a) { this.name = a.name; this.paused = this.loop = !1; this.callback = this.sound = null }, f.prototype = { init: function () { this.sound = k }, play: function (a) { a || (a = {}); a.loop ? this.paused ? this._playLoop(this.loop + 1) : this._playLoop(a.loop) : (this.loop = !1, this._play()); a.onEnded && "function" === typeof a.onEnded && (this.callback = a.onEnded) }, _play: function () { if (this.paused) this.paused = !1; else try { this.sound.currentTime = 0 } catch (a) { } this.sound.removeEventListener("ended"); this.sound.addEventListener("ended", this._ended.bind(this), !1); this.sound.src = d.path + this.name + h; this.sound.load(); this.sound.play() } }) : (f = function (a) { this.name = a.name; this.volume = d.volume || .5; this.preload = d.preload ? "auto" : "none"; this.paused = this.loop = !1; this.callback = this.sound = null; "volume" in a && (this.volume = +a.volume); "preload" in a && (this.preload = a.preload ? "auto" : "none") }, f.prototype = { init: function () { this.sound = new Audio; this.sound.src = d.path + this.name + h; this.sound.load(); this.sound.preload = this.preload; this.sound.volume = this.volume; this.sound.addEventListener("ended", this._ended.bind(this), !1) }, play: function (a) { a || (a = {}); if (a.volume || 0 === a.volume) this.volume = +a.volume, this.sound.volume = this.volume; a.loop ? this.paused ? this._playLoop(this.loop + 1) : this._playLoop(a.loop) : (this.loop = !1, this._play()); a.onEnded && "function" === typeof a.onEnded && (this.callback = a.onEnded) }, _play: function () { if (this.paused) this.paused = !1; else try { this.sound.currentTime = 0 } catch (a) { } this.sound.play() } }); f.prototype._playLoop = function (a) { "boolean" === typeof a ? (this.loop = 9999999, this._play()) : "number" === typeof a && (this.loop = a - 1, this._play()) }; f.prototype._ended = function () { 0 < this.loop && (--this.loop, this._play()); this.callback && this.callback(this.name) }; f.prototype.pause = function () { this.paused = !0; this.sound.pause() }; f.prototype.stop = function () { this.loop = !1; this.sound.pause(); try { this.sound.currentTime = 0 } catch (a) { } }; f.prototype.destroy = function () { this.stop(); this.sound.removeEventListener("ended", this._ended.bind(this), !1); this.sound.src = ""; this.sound = null }; e.sound = function (a) { d = JSON.parse(JSON.stringify(a)); d.path = d.path || ""; d.volume = d.volume || .5; d.preload = d.preload || !1; d.mix = d.mix || !0; if (n = d.sounds.length) { k = new Audio; a = k.canPlayType("audio/mpeg"); var e = k.canPlayType("audio/ogg"), g = k.canPlayType('audio/mp4; codecs="mp4a.40.2"'); m ? "probably" === a ? h = ".mp3" : "probably" === g ? h = ".aac" : "maybe" === a ? h = ".mp3" : "maybe" === g && (h = ".aac") : h = "probably" === a ? ".mp3" : "probably" === e ? ".ogg" : "maybe" === a ? ".mp3" : "maybe" === e ? ".ogg" : ".wav"; for (c = 0; c < n; c++) a = d.sounds[c], b[a.name] = new f(a), b[a.name].init() } else l("No sound-files provided!") }; e.sound.version = "2.1.3"; e.sound.play = function (a, c) { b[a] && b[a].play(c) }; e.sound.pause = function (a) { if (a && b[a]) b[a].pause(); else for (c in b) b.hasOwnProperty(c) && b[c] && b[c].pause() }; e.sound.stop = function (a) { if (a && b[a]) b[a].stop(); else for (c in b) b.hasOwnProperty(c) && b[c] && b[c].stop() }; e.sound.destroy = function (a) { if (a && b[a]) b[a].destroy(), b[a] = null; else for (c in b) b.hasOwnProperty(c) && b[c] && (b[c].destroy(), b[c] = null) } } })(ion);
  5. // Faucet view model
  6. var faucetVM = new function () {
  7. var self = this;
  8. var form = $('#ClaimForm');
  9. self.interval = 60000;
  10. self.referralURL = ko.observable('');
  11. self.balance = ko.observable(0);
  12. self.referralCount = ko.observable(0);
  13. self.referralTotal = ko.observable(0);
  14. self.alert = ko.observable(true, { persistKey: 'alert' });
  15. self.alertWhenClaimReady = ko.observable(true, { persistKey: 'alertWhenClaimReady' });
  16. self.alertAtClaimThreshold = ko.observable(false, { persistKey: 'alertAtClaimThreshold' });
  17. self.alertAtClaimThresholdAmount = ko.observable(0, { persistKey: 'alertAtClaimThresholdAmount' }).extend({ crypto: null });
  18. self.alertPageTitle = ko.observable(true, { persistKey: 'alertPageTitle' });
  19. self.alertPlaySound = ko.observable(true, { persistKey: 'alertPlaySound' });
  20. self.claimAmount = ko.observable(0);
  21. self.canClaim = ko.observable(true);
  22. self.resultHtml = ko.observable('');
  23. self.captchaType = ko.observable(0, { persistKey: 'CaptchaType' });
  24. self.alerted = false;
  25. self.currentAnimate = null;
  26. self.fp = '';
  27. self.pageTitle = document.title;
  28. self.claimedAmount = ko.observable(0);
  29. self.baseClaimedAmount = ko.observable(0);
  30. self.loyaltyBonus = ko.observable(0);
  31. self.referralBonus = ko.observable(0);
  32. self.mysteryBonus = ko.observable(0);
  33. self.validate = function () {
  34. form.formValidation('validate');
  35. return form.data('formValidation').isValid();
  36. };
  37. self.load = function (skipBind) {
  38. callAPI('faucet', 'GetFaucetSummary', self, 'Get Faucet Summary', null,
  39. function (response) {
  40. if (response.result) {
  41. ko.mapping.fromJS(response, {}, self);
  42. }
  43. self.referralDetails = ko.computed(function () {
  44. return "Your referral link is...<br/><h3>" + self.referralURL() + "</h3><br/>" +
  45. "To date you have " + self.referralCount() + " referrals and have been paid <img src='coin/logo.png' style='height:16px;margin-bottom:4px'>&nbsp;" + self.referralTotal().toFixed(8) + " in referral commission (last 30 days)";
  46. }, this);
  47. // Apply bindings
  48. ko.applyBindings(self, $('#Navigation')[0]);
  49. ko.applyBindings(self, $('#Faucet')[0]);
  50. ko.applyBindings(self, $('#ClaimModal')[0]);
  51. ko.applyBindings(self, $('#FaucetClaimModal')[0]);
  52. ko.applyBindings(self, $('#AlertSettingsModal')[0]);
  53. ko.applyBindings(self, $('#ReferModal')[0]);
  54. //Start refresh cycle
  55. self.refreshClaimSummary();
  56. }, null, null);
  57. }
  58. self.refreshClaimSummary = function () {
  59. callAPI('faucet', 'GetClaimSummary', self, 'Get claim summary', null,
  60. function (response) {
  61. if (response.result) {
  62. self.canClaim(response.canClaim);
  63. // Set up form validation
  64. $('#ClaimForm').formValidation({ framework: 'bootstrap4' });
  65. self.currentAnimate = { claimAmount: response.claimAmount };
  66. $(self.currentAnimate).animate({ claimAmount: response.nextClaimAmount }, {
  67. duration: self.interval,
  68. easing: 'linear',
  69. step: function () {
  70. self.claimAmount(this.claimAmount);
  71. var seconds = Math.round(new Date().getTime() / 1000);
  72. if (self.alerted && self.alertPageTitle() && (seconds % 2 == 0))
  73. document.title = 'READY TO CLAIM - ' + self.pageTitle;
  74. else {
  75. document.title = self.claimAmount().toFixed(self.claimAmount() >= 0.001 ? 4 : 8) + ' - ' + self.pageTitle;
  76. }
  77. if (self.alert() && !self.alerted) {
  78. var alertNow = false;
  79. if (self.canClaim() && self.alertWhenClaimReady())
  80. {
  81. if (self.alertAtClaimThreshold())
  82. {
  83. if (!isNaN(self.alertAtClaimThresholdAmount()) && self.claimAmount() >= self.alertAtClaimThresholdAmount())
  84. alertNow = true;
  85. }
  86. else
  87. alertNow = true;
  88. }
  89. else if (self.alertAtClaimThreshold()) {
  90. if (!isNaN(self.alertAtClaimThresholdAmount()) && self.claimAmount() >= self.alertAtClaimThresholdAmount())
  91. alertNow = true;
  92. }
  93. if (alertNow) {
  94. if (self.alertPageTitle()) {
  95. document.title = 'READY TO CLAIM - ' + self.pageTitle;
  96. self.alerted = true;
  97. }
  98. if (self.alertPlaySound()) {
  99. self.playAlertSound();
  100. self.alerted = true;
  101. }
  102. }
  103. }
  104. },
  105. complete: function () {
  106. self.refreshClaimSummary();
  107. }
  108. });
  109. }
  110. else {
  111. setTimeout(function () { self.refreshClaimSummary(); }, self.interval);
  112. }
  113. },
  114. function (error) {
  115. if (window.console) console.log("GetClaimSummary error: ", error);
  116. setTimeout(function () { self.refreshClaimSummary(); }, self.interval);
  117. }, null);
  118. }
  119. self.instantClaim = function () {
  120. self.submitClaim(true);
  121. }
  122. self.delayedClaim = function () {
  123. self.submitClaim(false);
  124. }
  125. self.submitClaim = function (instantClaim) {
  126. if (self.captchaType() == 1 || self.validate()) {
  127. $(self.currentAnimate).stop();
  128. $('#ClaimModal').modal('hide');
  129. var captchaResponse = grecaptcha.getResponse();
  130. if (self.captchaType() == 1)
  131. captchaResponse = $('#adcopy_challenge').val() + '|' + $('#adcopy_response').val();
  132. callAPI('faucet', 'FaucetClaim', { adBlocked: (!$('#claimAd').is(":visible")), captchaResponse: captchaResponse, instantClaim: !instantClaim, fp: self.fp, version: $('#faucetVersion').val() }, 'Faucet claim', 'Processing claim',
  133. function (response) {
  134. if (response.result) {
  135. self.balance(response.newBalance);
  136. self.resultHtml(response.resultHtml);
  137. form[0].reset();
  138. form.data('formValidation').resetForm();
  139. self.baseClaimedAmount(response.baseClaimAmount);
  140. self.loyaltyBonus(response.loyaltyBonus);
  141. self.referralBonus(response.referralBonus);
  142. self.mysteryBonus(response.mysteryBonus);
  143. self.claimedAmount(response.claimAmount);
  144. $('#FaucetClaimModal').modal('show');
  145. }
  146. else {
  147. showMessageModal('Faucet claim', response.resultHtml, response.result);
  148. }
  149. }, null,
  150. function () {
  151. grecaptcha.reset();
  152. self.refreshClaimSummary();
  153. });
  154. };
  155. }
  156. self.playAlertSound = function () {
  157. ion.sound.play("alert");
  158. }
  159. };
  160. $(document).ready(function () {
  161. //Load view models
  162. faucetVM.load();
  163. //Set up alert sound
  164. ion.sound({ sounds: [{ name: "alert", volume: 0.3 }], path: "coin/", preload: true });
  165. $('#slideIn').delay(1000).animate({ 'bottom': '35px' }, 2000);
  166. });

comments powered by Disqus