From 2788147fae9f60b5a8d0c65b01d312b7146e39da Mon Sep 17 00:00:00 2001
From: Coleman Watts <coleman@civicrm.org>
Date: Wed, 10 Jul 2013 07:17:39 -0700
Subject: [PATCH] Cleanup js

---
 js/Common.js                           | 8 +++++---
 templates/CRM/Profile/Form/Dynamic.tpl | 2 +-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/js/Common.js b/js/Common.js
index 294f76b98b..8b92642307 100644
--- a/js/Common.js
+++ b/js/Common.js
@@ -44,10 +44,12 @@ var cj = jQuery;
 function ts(text, params) {
   "use strict";
   text = CRM.strings[text] || text;
-  if (params && typeof(params) === 'object') {
+  if (typeof(params) === 'object') {
     for (var i in params) {
-      // sprintf emulation: escape % characters in the replacements to avoid conflicts
-      text = text.replace(new RegExp('%' + i, 'g'), params[i].replace(/%/g, '%-crmescaped-'));
+      if (typeof(params[i]) === 'string') {
+        // sprintf emulation: escape % characters in the replacements to avoid conflicts
+        text = text.replace(new RegExp('%' + i, 'g'), params[i].replace(/%/g, '%-crmescaped-'));
+      }
     }
     return text.replace(/%-crmescaped-/g, '%');
   }
diff --git a/templates/CRM/Profile/Form/Dynamic.tpl b/templates/CRM/Profile/Form/Dynamic.tpl
index 389f91f0c1..971b8e2d06 100644
--- a/templates/CRM/Profile/Form/Dynamic.tpl
+++ b/templates/CRM/Profile/Form/Dynamic.tpl
@@ -341,7 +341,7 @@ cj(document).ready(function(){
     var queryString = cj.param(formData);
     queryString = queryString + '&snippet=5&gid=' + {/literal}"{$profileID}"{literal};
     var postUrl = {/literal}"{crmURL p='civicrm/profile/create' h=0 }"{literal};
-    var blockNo = {/literal}{$blockNo}{literal};
+    var blockNo = {/literal}{if $blockNo}{$blockNo}{else}null{/if}{literal};
     var prefix  = {/literal}"{$prefix}"{literal};
     var response = cj.ajax({
       type: "POST",
-- 
GitLab