Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If Statement not working with And (&&) Operator

I'm having a hard time writing up what seems should be a simple if statement! I need it to say if mod does not equal a, b, or c - then do this. Here is what I was trying but have been unsuccessful:

var mod = CURRENT_MODULE_ID;
if (mod != "5827289" && mod != "5195103" && mod != "5181422") {
   doSomething();
}

When I type this into my editor it says there is an error, specifically that "The entity name must immediately follow the '&' in the entity reference." .. and is not working when I go to test.

Any help is appreciated!!


UPDATE: The url: esber.squarespace.com

The full script:

<script type="text/javascript" src="/storage/scripts/sessvars.js"></script>
<script type="text/javascript">
<![CDATA[ 

onload=function(){
 sessvars.browserConfirmation?'none':'';
 sessvars.ageConfirmation?'none':'';
}; 

var mod = Squarespace.Constants.CURRENT_MODULE_ID;
if (mod != "5827289" && mod != "5195103" && mod != "5181422") {
   if(sessvars.ageConfirmation != "yes"){
      window.location = "/verify/";
   };
};

]]>
</script> 

I want every page in the site to automatically redirect on page load to the verify page, unless it is the verify page (/verify), the "You are not verified" page (/not-verified), or the login page (/login) -- unless the user already verified by setting the sessvars, then they can continue on to the homepage.

To test this I go to esber.squarespace.com and click on one the menu items at the right (this menu would eventually be hidden when I'm done with the page) -- when i try to go to another page without veriying my age first i should be redirected back to the /verify page but that isnt happening.

If i revise the script to:

<script type="text/javascript" src="/storage/scripts/sessvars.js"></script>
<script type="text/javascript">

onload=function(){
 sessvars.browserConfirmation?'none':'';
 sessvars.ageConfirmation?'none':'';
}; 

var mod = Squarespace.Constants.CURRENT_MODULE_ID;
if (mod != "5827289") {
   if(sessvars.ageConfirmation != "yes"){
      window.location = "/verify/";
   };
};

</script> 

then it works fine(?)

like image 664
VUELA Avatar asked Dec 13 '22 00:12

VUELA


1 Answers

Try this:

// <![CDATA[ 

onload=function(){
 sessvars.browserConfirmation?'none':'';
 sessvars.ageConfirmation?'none':'';
}; 

var mod = Squarespace.Constants.CURRENT_MODULE_ID;
if (mod != "5827289" && mod != "5195103" && mod != "5181422") {
   if(sessvars.ageConfirmation != "yes"){
      window.location = "/verify/";
   };
};

// ]]>

If this doesn't work, just leave the code there for a bit, so that we can debug it directly on your website

like image 160
Waleed Al-Balooshi Avatar answered Dec 30 '22 01:12

Waleed Al-Balooshi