Announcement

Collapse
No announcement yet.

Help with javascript on all the pages

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Help with javascript on all the pages

    Hi

    I am just completing my first site just need to tidy some code.

    When i go to the site actinic puts a lot of javascript in i want to remove this and put it in its own .js file how do i do all of this?

    #2
    What JS are we talking about here? Got an example URL?

    Comment


      #3
      <!-- Start script -----
      // Place-holder for the script to ensure that https is used for this page
      // if SSL mode is in use.



      function DWord(nHigh, nLow)
      {
      this.nLow = nLow; // Set low-order value
      this.nHigh = nHigh;
      }

      function DRotateLeft(x, nCount)
      {
      var nResult, nCarry;
      //
      // If it's more than 16 bits, we can optimise the first part
      // by simply swapping the words
      //
      if (nCount >= 16)
      {
      nResult = new DWord(x.nLow, x.nHigh);
      nCount -= 16;
      }
      else
      {
      nResult = new DWord(x.nHigh, x.nLow);
      }
      //
      // Now rotate what's left
      //
      if (nCount > 0)
      {
      nCarry = nResult.nHigh >>> (16 - nCount);
      nResult.nHigh = ((nResult.nHigh << nCount) | (nResult.nLow >>> (16 - nCount))) & 0xFFFF;
      nResult.nLow = ((nResult.nLow << nCount) | nCarry) & 0xFFFF;
      }
      return(nResult);
      }

      function DAdd(a, b)
      {
      var nLow = (a.nLow + b.nLow); // Add low-order words
      return(new DWord((a.nHigh + b.nHigh + (nLow >> 16)) & 0xFFFF, nLow & 0xFFFF));
      }

      function DAnd(a, b)
      {
      return(new DWord((a.nHigh & b.nHigh), (a.nLow & b.nLow)));
      }

      function DOr(a, b)
      {
      return(new DWord((a.nHigh | b.nHigh), (a.nLow | b.nLow)));
      }

      function DXor(a, b)
      {
      return(new DWord((a.nHigh ^ b.nHigh), (a.nLow ^ b.nLow)));
      }

      function DNot(a)
      {
      return(new DWord(a.nHigh ^ 0xFFFF, a.nLow ^ 0xFFFF));
      }

      function DF(a, b, c, d, x, s, ac)
      {
      return(DAdd(DRotateLeft(DAdd(a, DAdd(DAdd(DOr(DAnd(b, c), DAnd(DNot(b), d)), x), ac)), s), b));
      }
      function DG(a, b, c, d, x, s, ac)
      {
      return(DAdd(DRotateLeft(DAdd(a, DAdd(DAdd(DOr(DAnd(b, d), DAnd(c, DNot(d))), x), ac)), s), b));
      }
      function DH(a, b, c, d, x, s, ac)
      {
      return(DAdd(DRotateLeft(DAdd(a, DAdd(DAdd(DXor(DXor(b, c), d), x), ac)), s), b));
      }
      function DI(a, b, c, d, x, s, ac)
      {
      return(DAdd(DRotateLeft(DAdd(a, DAdd(DAdd(DXor(c, DOr(b, DNot(d))), x), ac)), s), b));
      }

      function DStringToBlocks(sInput)
      {
      var nBlockCount = ((sInput.length + 8) >> 6) + 1; // Work out what we'll need
      var Blocks = new Array(nBlockCount * 16);
      var nIndex, nByte;
      for (nIndex = 0; nIndex < nBlockCount * 16; nIndex++)
      {
      Blocks[nIndex] = new DWord(0, 0);
      }
      // Fill the blocks with the string. This gets moderately complicated

      for (nIndex = 0; nIndex < sInput.length; nIndex++)
      {
      nByte = nIndex & 0x3; // Get nybble index as 0-3
      if (nByte == 0)
      {
      Blocks[nIndex >> 2].nLow = sInput.charCodeAt(nIndex);
      }
      if (nByte == 1)
      {
      Blocks[nIndex >> 2].nLow |= sInput.charCodeAt(nIndex) << 8;

      Comment


        #4
        i need to locate where this is stored cut it and paste it in its own js file

        there is a load of javascipt missing above as i could not paste it all in

        Comment


          #5
          I've never seen that before myself and i'd be surprised (make that very surprised) if actinic was responsible for putting it there.

          Comment


            #6
            Originally posted by leehack View Post
            I've never seen that before myself and i'd be surprised (make that very surprised) if actinic was responsible for putting it there.
            With the site i have not done any javascript what so ever i dont even know where its pulling it all from as i have not put it in there lol

            I have just pm you

            Comment


              #7
              Is this something to do with customer accounts and logging in maybe?
              Reusable Snore Earplugs : Sample Earplugs - Wax Earplugs - Women's Earplugs - Children's Earplugs - Music Earplugs - Sleep Masks

              Comment


                #8
                If you have not put it there and you have created the site, then actinic must have put it there and i am obviously mistaken. It looks like it is linked to the use of SSL, which is why i have not seen it before. Actinic already uses a couple of external JS files, so perhaps this part needs to be done differently for some reason. You could always mimic what they have done with the files they do as external and see if it worked. I think the wise move would be to leave it well alone though to be honest, if you don't know how to move JS without asking, then you're in danger of screwing up what is an integral part of the site operation. Snapshot before you try, so you have a get out of jail free card if you do decide to have a go.

                Comment


                  #9
                  A search for any of the unique terms in that code on Google only throws up this page and one other site that's been compromised. There are so many warnings from Google that I haven't dared visit it to see what's going on.

                  This seems a bit suspicious to me, so I'd want to find out where that code comes from and what it does before I'd do anything with it.

                  Mike
                  -----------------------------------------

                  First Tackle - Fly Fishing and Game Angling

                  -----------------------------------------

                  Comment


                    #10
                    This code is used by Actinic to MD5 encrypt the login details when logging in via SSL.
                    If you visit any Actinic site at ~/acatalog/login.html you'll see this code is added within the login form tags.

                    The code is dynamically pulled in from the Actinic Access database.
                    It resides in the [DesignObjects] table (nID 133) and is put in at run-time when the login.html page is generated.
                    It should only be required on this page, and hence not needed to be added into the js function files (actiniccore.js), unless you are putting the login function on several other pages in which case adding in there would make sense.
                    Hope that helps
                    Fergus Weir - teclan ltd
                    Ecommerce Digital Marketing

                    SellerDeck Responsive Web Design

                    SellerDeck Hosting
                    SellerDeck Digital Marketing

                    Comment


                      #11
                      the code is pulling from this tag <actinic:variable name="JavaScriptFunctions" />

                      ?????

                      Comment


                        #12
                        As I mentioned, it's pulled in from the database and generated at "build time" when the login.html page is created. The js has a number of Actinic variables that a populated with important info (URL, Error text etc) when the page is built. Removing this "Scripts for Password Encryption" layout and placing the javascript in an included js file would mean having to hard code all the relevant variables with the correct data to ensure the scripts still run.

                        Why do you want to do this? Do you have the login on more than the login.html page?
                        Fergus Weir - teclan ltd
                        Ecommerce Digital Marketing

                        SellerDeck Responsive Web Design

                        SellerDeck Hosting
                        SellerDeck Digital Marketing

                        Comment


                          #13
                          Originally posted by fergusw View Post
                          As I mentioned, it's pulled in from the database and generated at "build time" when the login.html page is created. The js has a number of Actinic variables that a populated with important info (URL, Error text etc) when the page is built. Removing this "Scripts for Password Encryption" layout and placing the javascript in an included js file would mean having to hard code all the relevant variables with the correct data to ensure the scripts still run.

                          Why do you want to do this? Do you have the login on more than the login.html page?
                          Yes i have a mini login on almost every page

                          Comment


                            #14
                            Originally posted by fergusw View Post
                            Removing this "Scripts for Password Encryption" layout and placing the javascript in an included js file would mean having to hard code all the relevant variables with the correct data to ensure the scripts still run.
                            as mentioned, the above would be the way to go.
                            Try copying the generated JS from the login.html page and pasting into js file, then removing layout code.
                            Fergus Weir - teclan ltd
                            Ecommerce Digital Marketing

                            SellerDeck Responsive Web Design

                            SellerDeck Hosting
                            SellerDeck Digital Marketing

                            Comment


                              #15
                              Originally posted by fergusw View Post
                              as mentioned, the above would be the way to go.
                              Try copying the generated JS from the login.html page and pasting into js file, then removing layout code.
                              If i remove the login on the home page all the javascript goes but if i add this and put it in its own.js file the page has errors

                              Comment

                              Working...
                              X