From 7cc12cc3befee79a566feca4a955d86502842b61 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 2 Mar 2022 20:13:30 -0500 Subject: [PATCH] Fix undefined javascript variables These variables need to be declared with the `var` keyword, or it crashes some browsers. --- ang/crmMailing/RadioDate.js | 23 ++++++++++++----------- ang/crmMailing/Recipients.js | 4 ++-- ang/crmMailing/Templates.js | 4 ++-- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/ang/crmMailing/RadioDate.js b/ang/crmMailing/RadioDate.js index 037b6e22ba..0f9128d69c 100644 --- a/ang/crmMailing/RadioDate.js +++ b/ang/crmMailing/RadioDate.js @@ -62,22 +62,23 @@ if (context === 'userInput' && $(this).val() === '' && $(this).siblings('.crm-form-date').val().length) { schedule.mode = 'at'; schedule.datetime = '?'; - } else { + } else { var d = new Date(), - month = '' + (d.getMonth() + 1), - day = '' + d.getDate(), - year = d.getFullYear(), - hours = '' + d.getHours(), - minutes = '' + d.getMinutes(); - var submittedDate = $(this).val(); + month = '' + (d.getMonth() + 1), + day = '' + d.getDate(), + year = d.getFullYear(), + hours = '' + d.getHours(), + minutes = '' + d.getMinutes(), + submittedDate = $(this).val(); if (month.length < 2) month = '0' + month; if (day.length < 2) day = '0' + day; if (hours.length < 2) hours = '0' + hours; if (minutes.length < 2) minutes = '0' + minutes; - date = [year, month, day].join('-'); - time = [hours, minutes, "00"].join(':'); - currentDate = date + ' ' + time; - var isInPast = (submittedDate.length && submittedDate.match(/^[0-9\-]+ [0-9\:]+$/) && isDateBefore(submittedDate, currentDate, 4*60*60*1000)); + var + date = [year, month, day].join('-'), + time = [hours, minutes, "00"].join(':'), + currentDate = date + ' ' + time, + isInPast = (submittedDate.length && submittedDate.match(/^[0-9\-]+ [0-9\:]+$/) && isDateBefore(submittedDate, currentDate, 4*60*60*1000)); ngModel.$setValidity('dateTimeInThePast', !isInPast); if (lastAlert && lastAlert.isOpen) { lastAlert.close(); diff --git a/ang/crmMailing/Recipients.js b/ang/crmMailing/Recipients.js index 1867e9582f..518f6075cb 100644 --- a/ang/crmMailing/Recipients.js +++ b/ang/crmMailing/Recipients.js @@ -253,7 +253,7 @@ } }, results: function(data) { - results = { + var results = { children: $.map(data.values, function(obj) { if('civicrm_mailing' === rcpAjaxState.entity) { return obj["api.MailingRecipients.getcount"] > 0 ? { id: obj.id + ' ' + rcpAjaxState.entity + ' ' + rcpAjaxState.type, @@ -271,7 +271,7 @@ (rcpAjaxState.entity == 'civicrm_group'? 'Group' : 'Mailing')); } - more = data.more_results || !(rcpAjaxState.entity == 'civicrm_mailing' && rcpAjaxState.type == 'exclude'); + var more = data.more_results || !(rcpAjaxState.entity == 'civicrm_mailing' && rcpAjaxState.type == 'exclude'); if (more && !data.more_results) { if (rcpAjaxState.type == 'include') { diff --git a/ang/crmMailing/Templates.js b/ang/crmMailing/Templates.js index 301b565f23..b67e7b1162 100644 --- a/ang/crmMailing/Templates.js +++ b/ang/crmMailing/Templates.js @@ -88,7 +88,7 @@ }, results: function(data) { - results = { + var results = { children: $.map(data.values, function(obj) { return { id: obj.id, text: obj.label }; }) @@ -98,7 +98,7 @@ results.text = ts('Message Templates'); } - more = data.more_results; + var more = data.more_results; if (more && !data.more_results) { rcpAjaxState.page_n += rcpAjaxState.page_i; -- 2.25.1