(function($){ $.widget('ui.scoreboard', { getScore : function(){ return this._getData('score'); }, setScore : function(newScore){ this._setData('score', parseInt(newScore)); this._refresh(); }, getTotal : function(){ return this._getData('total'); }, setTotal : function(newTotal){ this._setData('total', parseInt(newTotal)); this._refresh(); }, reset : function(){ this._setData('score', this._getData('initialScore')); this._setData('total', this._getData('initialTotal')); this._refresh(); }, inc : function(val){ var incVal = parseInt(val) || 1; this._setData('score', this._getData('score') + incVal); this._refresh(); if(this._getData('winScore') === this._getData('score')){ this.element.trigger('winGame'); } }, incTotal : function(val){ var incVal = parseInt(val) || 1; this._setData('total', this._getData('total') + incVal); this._refresh(); }, dec : function(val){ var decVal = parseInt(val) || 1; this._setData('score', this._getData('score') - decVal); this._refresh(); }, decTotal : function(val){ var decVal = parseInt(val) || 1; this._setData('total', this._getData('total') - decVal); this._refresh(); }, _init : function(){ var divDisplay = "inline"; var score = this.options.score; var total = this.options.total; var layoutId = "h"; var self = this; this._setData('initialScore', parseInt(this.options.score)); this._setData('initialTotal', parseInt(this.options.total)); this._setData('score', parseInt(this.options.score)); this._setData('total', parseInt(this.options.total)); this._setData('winScore', parseInt(this.options.winningScore) || 0); if(this.options.layout === "vertical"){ layoutId = "v"; } this.evWinGame = document.createEvent('Events'); this.element.addClass('ui-scoreboard-container-' + layoutId + ' ui-widget ui-widget-content ui-corner-all'); var clone = $('