Allow Javascript Variables
cyberswat - October 29, 2008 - 18:25
| Project: | Omniture Integration |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Description
The current implementation of the module places double quotes around all variable names. This creates a problem when the variable name itself is additional javascript that needs to be processed as in the following from a SiteCatalyst code version: H.15.1 sample:
s.prop15=s.prop9+'-'+s.prop12+'-'+s.prop13+'-'+s.prop8+'-'+s.prop14;
This patch removes the quotes from both the administrative interface input and the api input so that they must be explicitly written for strings.

#1
#2
and p.s. ... this patch isn't really that large but my editor stripped all the trailing whitespace off the lines.
#3
Since this breaks functionality it seems like we should document it.
On the other hand, there's really not anybody using this version -- http://drupal.org/project/usage/omniture -- so what the heck, let's do it.
#4
would it be better to perform the writing out of the javascript via the drupal_add_js() function, then we could push out the omniture variables in a safe way.
for example
$settings = array('omniture' => array('page' => 'node'));
drupal_add_js('setting', $settings);
Drupal.omniture.page
#5
I'm not much of a js person so I can't agree/disagree with the approach. If it works it seems like a much more "Drupal way" approach.
#6
I re-rolled the previous patch without all the extra garbage in it because it hurt my head when I looked at it.
I also think it might be more drupalish to use drupal_add_js (which is a seperate issue) ... It's been a while since I've worked with omniture so I would suggest care be taken that the formatting they require is preserved.