diff options
author | emkael <emkael@tlen.pl> | 2016-10-24 09:53:28 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2016-10-24 09:53:28 +0200 |
commit | 516b2bde5ba9fe31b6956032d52882658cf05a2c (patch) | |
tree | 4b6995ad623bd83be3f321ff9d9ab94554295a19 /web | |
parent | 8af416efa4497cce39ef9afc9dc2ec7ad3d68e36 (diff) |
* code formatting
Diffstat (limited to 'web')
-rw-r--r-- | web/osika.js | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/web/osika.js b/web/osika.js index 5491938..810a366 100644 --- a/web/osika.js +++ b/web/osika.js @@ -4,45 +4,45 @@ var Osika = function() { that.resultTemplate = jQuery('#resultTemplate').remove().html(); that.handleData = function(data) { - jQuery('#evaluate').val('Oceń'); - jQuery('#evaluate').removeAttr('disabled'); - if (data.error) { + jQuery('#evaluate').val('Oceń'); + jQuery('#evaluate').removeAttr('disabled'); + if (data.error) { jQuery('#result').html('<div class="error">'+data.error+'</div>'); - } - else { - var html = Mustache.to_html(that.resultTemplate, data); + } + else { + var html = Mustache.to_html(that.resultTemplate, data); jQuery('#result').html(html); - } + } }; - + that.getHand = function(hand) { - jQuery('#evaluate').val('Czekaj...'); - jQuery('#evaluate').attr('disabled', 'disabled'); - jQuery.getJSON( + jQuery('#evaluate').val('Czekaj...'); + jQuery('#evaluate').attr('disabled', 'disabled'); + jQuery.getJSON( 'osika.php', { - 'h': hand, - 'f': 'json' + 'h': hand, + 'f': 'json' }, - that.handleData - ); - location.hash = hand; + that.handleData + ); + location.hash = hand; }; that.init = function() { - jQuery('#evaluate').unbind('click').click(function () { + jQuery('#evaluate').unbind('click').click(function () { var hand = jQuery('#suit0').val()+'|'+jQuery('#suit1').val()+'|'+jQuery('#suit2').val()+'|'+jQuery('#suit3').val(); that.getHand(hand); return false; - }); - if (location.hash) { + }); + if (location.hash) { var hand = location.hash.substring(1).split('|'); for (h = 0; h < hand.length; h++) { - jQuery('#suit'+h).val(hand[h]); + jQuery('#suit'+h).val(hand[h]); } that.getHand(location.hash.substring(1)); - } - jQuery(window).hashchange(that.init); + } + jQuery(window).hashchange(that.init); }; that.init(); }; @@ -50,4 +50,3 @@ var Osika = function() { jQuery(document).ready(function () { var o = new Osika(); }); - |