Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function(property) {
- for (var index = 0; index < dataLayer.length; index++) {
- if (dataLayer[index].ajaxLists != undefined) {
- console.log("It's dataLayer[" + index + "]");
- var theList = dataLayer[index].ajaxLists.vehicles;
- for (var i = 0; i < theList.length; i++) {
- var theVehicle = theList[i];
- // console.log( "Make: " + theVehicle.make );
- console.log(theVehicle[property]); // …print out the values
- }
- }
- }
- })("condition");
- // Two properties:
- (function(property1,property2) {
- for (var index = 0; index < dataLayer.length; index++) {
- if (dataLayer[index].ajaxLists != undefined) {
- console.log("In dataLayer[" + index + "] we have the following:");
- var theList = dataLayer[index].ajaxLists.vehicles;
- for (var i = 0; i < theList.length; i++) {
- var theVehicle = theList[i];
- // console.log( "Make: " + theVehicle.make );
- console.log(property1 + ": " + theVehicle[property1] + ", " + property2 + ": " + theVehicle[property2] ); // …print out the values
- }
- }
- }
- })("upgradeMobileBoost","listingPosition");
- // v4: Use any number of arguments:
- (function() {
- for (var index = 0; index < dataLayer.length; index++) {
- if (dataLayer[index].ajaxLists != undefined) {
- var theList = dataLayer[index].ajaxLists.vehicles;
- for (var i = 0; i < theList.length; i++) {
- var theVehicle = theList[i];
- console.log("==== ");
- console.log(theVehicle.make + " " + theVehicle.model);
- for (a = 0; a < arguments.length; a++) {
- console.log(arguments[a] + " = " + theVehicle[arguments[a]]);
- }
- }
- }
- }
- })("adType", "condition", "province", "financingPrice", "transmission");
- // v5: Add the entry number for visual ease:
- (function() {
- for (var index = 0; index < dataLayer.length; index++) {
- if (dataLayer[index].ajaxLists != undefined) {
- var theList = dataLayer[index].ajaxLists.vehicles;
- for (var i = 0; i < theList.length; i++) {
- var theVehicle = theList[i];
- console.log(i + " ==== ");
- console.log(theVehicle.make + " " + theVehicle.model);
- for (a = 0; a < arguments.length; a++) {
- console.log(arguments[a] + " = " + theVehicle[arguments[a]]);
- }
- }
- }
- }
- })("adType", "condition", "province", "financingPrice", "upgradeMobileBoost");
- // v6: restore indication of where in the datalayer we are
- (function() {
- for (var index = 0; index < dataLayer.length; index++) {
- if (dataLayer[index].ajaxLists != undefined){
- console.log("We're in dataLayer[" + index + "]"); // ← this line
- var theList = dataLayer[index].ajaxLists.vehicles;
- for (var i = 0; i < theList.length; i++) {
- var theVehicle = theList[i];
- console.log(i + " ==== ");
- console.log(theVehicle.make + " " + theVehicle.model);
- for (a = 0; a < arguments.length; a++) {
- console.log(arguments[a] + " = " + theVehicle[arguments[a]]);
- }
- }
- }
- }
- })("adType", "condition", "province", "financingPrice", "upgradeMobileBoost");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement