/** * Common utility functions. */ (function (context, $) { "use strict"; context.JK = context.JK || {}; var sessionUtils = {}; var rest = new context.JK.Rest(); context.JK.SessionUtils = sessionUtils; var logger = context.JK.logger; sessionUtils.createOpenSlot = function($openSlotsTemplate, slot) { var inst = context.JK.getInstrumentIcon24(slot.instrument_id); var proficiency_desc = slot.proficiency_desc; if(!proficiency_desc) { // this is to allow unstructured RSVPs to not specify proficiency_desc proficiency_desc = "Any Skill Level"; } if(!slot.proficiency_desc) { proficiency_desc } var slot = { instrument_url: inst, instrument: slot.description, proficiency: proficiency_desc }; return context.JK.fillTemplate($openSlotsTemplate.html(), slot); } sessionUtils.defaultTimezone = function($timezoneList) { var tz = jstz.determine().name(); // first check if we have this particular timezone var found = null; if(tz) { found = $timezoneList.find('option[data-tz="' + tz +'"]') } if(found.length == 0 ) { // this is best effort path; it means some reason we couldn't match a timezone by jstz to our dropdown var offset = new Date().getTimezoneOffset() * 60; // convert to seconds to match data-utc-offset (seconds) found = $timezoneList.find('option[data-utc-offset="' + offset + '"]') } if(found.length > 0) { var defaultValue = found.attr('value'); $timezoneList.easyDropDown('select', defaultValue).val(defaultValue); } } })(window, jQuery);