Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-800

URL manipulation in javascript does not take into account page level links (#)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Minor
    • 3.0 Final
    • 2.1.5
    • admininterface
    • None

    Description

      This problem effects the following javascript functions:

      mgnlUpdateCK() in /admindocroot/js/general.js and
      mgnlAddParameter() and mgnlRemoveParameter() in /admindocroot/js/generic.js

      If a content editor clicks on a link that is within the current page (such as <a href="#bottom">) the url is appended with the #bottom. When clicking on the preview button after that it will not do a new request to the server because the parameters are appended AFTER the #bottom. Need to split off the page level link first. Suggest changing the methods like the following:

      function mgnlUpdateCK(href)
      {
      if (!href) href=document.location.href;
      tmp=href.split("#");
      anchor=(tmp[1]!=null ? "#"+tmp[1] : "");
      href=tmp[0];
      tmp=href.split("?");
      var href2=tmp[0]+"?mgnlCK="+new Date().getTime();
      if (tmp[1])
      {
      var qs=tmp[1].split("&");
      for (var elem=0; elem<qs.length; elem++)

      { if (qs[elem].indexOf("mgnlCK=")!=0) href2+="&"+qs[elem]; }

      }
      return href2+anchor;
      }

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

      function mgnlAddParameter(href,name,value)

      { tmp=href.split("#"); anchor=(tmp[1]!=null ? "#"+tmp[1] : ""); href=tmp[0]; var delimiter; if (href.indexOf("?")==-1) delimiter="?"; else delimiter="&"; return href+delimiter+name+"="+value + anchor; }

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

      function mgnlRemoveParameter(href,name)
      {
      //works only for a single paramter
      /*
      var nameExtended;
      var delimiter
      var tmp;
      if (href.indexOf("?"name"=")!=-1) delimiter="?";
      else delimiter="&";

      var tmp=href.split(delimiter+name+"=");
      var href2=tmp[0];
      if (tmp[1])

      { if (tmp[1].indexOf("&")!=-1) href2+=delimiter+tmp[1].substring(tmp[1].indexOf("&")+1); }

      return href2;
      */
      var tmp=href.split("#");
      anchor=(tmp[1]!=null ? "#"+tmp[1] : "");
      href=tmp[0];

      tmp=href.split("?");

      var newHref=tmp[0];
      if (tmp[1])
      {
      var paramObj=tmp[1].split("&");

      for (var i=0;i<paramObj.length;i++)
      {
      if (paramObj[i].indexOf(name+"=")!=0)

      { if (i==0) newHref+="?"; else newHref+="&"; newHref+=paramObj[i]; }

      }
      }
      return newHref + anchor;
      }

      Checklists

        Acceptance criteria

        Attachments

          Activity

            People

              chris_miner Chris Miner
              tomjnsn Tom Jensen
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Checklists

                  Bug DoR
                  Task DoD

                  Time Tracking

                    Estimated:
                    Original Estimate - 5m
                    5m
                    Remaining:
                    Remaining Estimate - 5m
                    5m
                    Logged:
                    Time Spent - Not Specified
                    Not Specified