Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Coffee Break: Join us on Wednesday, April 5th at 10am PT to chat with Ben Gaines, Director of Product Management for Adobe Analytics. Ben will be online to answer your Analytics and Adobe Summit questions.

Update inList plugin to handle serialized events


Level 2




This works as expected: = 'event1,event2'; s.inList('event1',,','); // returns true




But the plugin does not work for serialized events: = 'event1:12345,event2'; s.inList('event1',,','); // returns false



I know that it can be argued that this plugin can be used for more than just events, and ideally it should be as generic as possible, but in practice, it is almost exclusively used with the variable, so it makes sense that support for serialization be added to this plugin.  


I would suggest an optional 4th argument to specify a serialization delimiter, and have the plugin strip everything from specified delimiter to end of string in the "is this in the list?" condition.  Here is the s.inList() plugin with updated code to reflect this proposed addition:


s.inList=new Function("v","l","d","sd","" +"var s=this,ar=Array(),i=0,d=(d)?d:',',sd=(sd)?sd:'',nv=new RegExp('" +"\\\\'+sd+'.*$');if(typeof(l)=='string'){if(s.split)ar=s.split(l,d);" +"else if(l.split)ar=l.split(d);else return-1} else ar=l;while(i



This addition will now produce desired results: = 'event1:12345,event2'; s.inList('event1',,',',':'); // returns true