1.2.11.7 Golf stats
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Admin - User page scripts.
|
||||
*/
|
||||
|
||||
(function (win, doc, undef)
|
||||
{
|
||||
"use strict";
|
||||
let rg = sax.refGolf = sax.refGolf || { data: {}, fn: {}, $pnl: {}, $frm: {}, $dlg: {} };
|
||||
|
||||
//--------------------------------------------------------------
|
||||
/* Reference - Golf - Stats. */
|
||||
rg.fn.refreshStats = function (delay)
|
||||
{
|
||||
//sax.debug('refreshOrganisations');
|
||||
rg.ajaxGolfStats = rg.ajaxGolfStats || { url: sax.url.base + 'Reference/Golf/Ajax/GetStats', formId: rg.$frm.filter.prop('id'), callbackFn: rg.fn.doRefreshStats };
|
||||
sax.doAjaxRequest(rg.ajaxGolfStats, delay || 50);
|
||||
}
|
||||
rg.fn.doRefreshStats = function (response)
|
||||
{
|
||||
sax.debug('doRefreshStats', response);
|
||||
if (!response.success) return;
|
||||
|
||||
let $msgs = $('.sax-panel-messages', rg.$pnl.stats).empty();
|
||||
let $list = $('.sax-panel-item-list', rg.$pnl.stats).empty();
|
||||
for (let groupIdx = 0; groupIdx < (response.groups || []).length; groupIdx++)
|
||||
{
|
||||
let group = response.groups[groupIdx];
|
||||
$list.append(rg.fn.populateStatGroup(rg.fn.getStatGroupTemplate(), group.caption));
|
||||
for (let statIdx = 0; statIdx < (group.stats || []).length; statIdx++)
|
||||
{
|
||||
let stat = group.stats[statIdx];
|
||||
if (stat.value>0) $list.append(rg.fn.populateStat(rg.fn.getStatTemplate(), stat.caption, stat.value));
|
||||
}
|
||||
}
|
||||
}
|
||||
rg.fn.populateStatGroup=function($item, caption)
|
||||
{
|
||||
$('.GroupCaption', $item).text(caption);
|
||||
return $item;
|
||||
}
|
||||
rg.fn.getStatGroupTemplate = function ()
|
||||
{
|
||||
return $('.sax-panel-item-template .GolfStatGroup', rg.$pnl.stats).clone();
|
||||
}
|
||||
rg.fn.populateStat = function ($item, caption, value)
|
||||
{
|
||||
$('.StatCaption', $item).text(caption);
|
||||
$('.StatValue', $item).text(value);
|
||||
return $item;
|
||||
}
|
||||
rg.fn.getStatTemplate = function ()
|
||||
{
|
||||
return $('.sax-panel-item-template .GolfStat', rg.$pnl.stats).clone();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
$(function ()
|
||||
{
|
||||
rg.$pnl.golf = $('.sax-panel.Golf');
|
||||
rg.$pnl.filter = $('.sax-panel-filter', rg.$pnl.golf);
|
||||
$('.sax-results-refresh', rg.$pnl.filter).on('click', rg.fn.refreshStats);
|
||||
rg.$frm.filter = $('#frmRefGolfFilter', rg.$pnl.filter);
|
||||
|
||||
// Stats.
|
||||
rg.$pnl.stats = $('.sax-panel-info.GolfStats', rg.$pnl.golf);
|
||||
setTimeout(rg.fn.refreshStats, 250);
|
||||
|
||||
// Courses.
|
||||
//$('.PagingPageNo', rg.$dlg).val(1);
|
||||
//$('.PagingPageLength', rg.$dlg).val(16);
|
||||
|
||||
var opt = sax.dlgOpts();
|
||||
//opt.open = function () { rg.fn.refreshOrganisations(200); };
|
||||
//opt.buttons[sax.dlg.btn.ok] = function () { rg.fn.confirmSelection(); };
|
||||
opt.buttons[sax.dlg.btn.cancel] = function () { rg.fn.cleanUp(); $(this).dialog('close'); };
|
||||
//rg.$dlg = $('#dlgSelectOrganisation').dialog(opt);
|
||||
|
||||
});
|
||||
|
||||
//--------------------------------------------------------------
|
||||
}(window, window.document));
|
||||
|
||||
/* The End */
|
||||
Reference in New Issue
Block a user