$ = jQuery context = window context.JK ||= {}; class CheckoutUtils constructor: () -> @logger = context.JK.logger @rest = new context.JK.Rest(); @cookie_name = "preserve_billing" init: () => refreshPreserveBillingInfo:() => if @shouldPreserveBillingInfo @logger.debug("refreshing preserve billing info timer") @setPreserveBillingInfo() setPreserveBillingInfo:() => date = new Date(); minutes = 10; date.setTime(date.getTime() + (minutes * 60 * 1000)) $.removeCookie(@cookie_name, { path: '/' }) $.cookie(@cookie_name, "jam", { expires: date, path: '/' }) deletePreserveBillingInfo:() => $.removeCookie(@cookie_name, { path: '/' }) @logger.debug("deleted preserve billing"); unless $.cookie(@cookie_name)? @logger.error("after deleting the preserve billing cookie, it still exists!") # existance of cookie means we should preserve billing shouldPreserveBillingInfo:() => value = $.cookie(@cookie_name) value? # global instance context.JK.CheckoutUtilsInstance = new CheckoutUtils()