Is it okay to spoof navigator.product by default?

Allan Sandfeld Jensen kde at carewolf.com
Wed Sep 22 12:18:02 BST 2004


On Wednesday 22 September 2004 12:16, Leo Savernik wrote:
> Am Mittwoch, 22. September 2004 10:30 schrieb Allan Sandfeld Jensen:
> [...]
>
> > > Netscape4 ecma-code? Can you elaborate, please?
> >
> > Only related to this issue. The version of QuickMenu I was trying to fix
> > has 3 different sets of ecma/js-scripts they can issue: "ie", "ns" and
> > "ns6". Konqueror 3.3.x only works with the ie and ns6 versions, but gets
> > the ns version served by default(meant for netscape4).
> > I've checked and verified that netscape4 works with these sites, and
> > konqueror 3.1.x works about 90% correct. Konqueror 3.2.x and 3.3.x doesnt
> > work at all with this code, and just dumps all the strings at the top of
> > the page. I am guessing that Konqueror 3.2 and 3.3 are just too strict
> > and ignores the code as being wrong.
>
> Ok, so you don't know exactly what's the problem. Konqueror has never
> supported NS4 stuff (say <layer>), so it must other stuff that has been
> broken since.
>
Well, I've attached an indented version below. It does use layer a few places, 
but what I would really like to find out is why it is dumping all the strings 
in the top of the page, and then why menus doesnt expand.
Maybe the difference lies in how we ignore layer?

Anyway, I feel inspired by the old-school Microsoft philosophy of "making it 
work". Would it be acceptable to detect script-references to "dqm_ns.js" and 
rewrite them to "dqm_ns6.js" if it exists? 
(As long as we issues like these that Safari doesnt have, we will be wrongly 
percieved as more broken.)

`Allan
-------------- next part --------------
q39 = null;
q40 = false;
q41 = null;
q20 = new Array ();
q21 = new Array ();
q82 = null;
q93 = null;
q94 = null;
captureEvents (Event.MOUSEUP);
window.onmouseup = mclick;
if (!window.DQM_cancel_onload)
  {
    captureEvents (Event.MOUSEMOVE);
    document.captureEvents (Event.ONLOAD);
    captureEvents (Event.RESIZE);
    window.onload = DQM_handleOnload;
    window.onmousemove = DQM_mousemove;
    window.onresize = DQM_resize;
  }
document.write ("<STYLE TYPE='text/javascript'>");
q18 = q100 ();
for (var m = 0; m < q18; m++)
  if (subExists[m])
    writeStyles (m + "");
for (var j = 0; j < q19.length; j++)
  writeStyles (q19[j]);
document.write ("</style>");
for (m = 0; m < q18; m++)
  if (subExists[m])
    q0 (m + "");
for (j = 0; j < q19.length; j++)
  q0 (q19[j]);
var q34 = new Array (q18);
var q35 = new Array (q18);
var q36 = new Array (q18);
var q37 = new Array (q18);;
function
writeStyles (mindex)
{
  q130 = q15 ("DQM_text_alignment" + mindex, DQM_text_alignment);
  hltc = q15 ("DQM_hl_textcolor" + mindex, DQM_hl_textcolor);
  q144 = q15 ("DQM_textcolor" + mindex, DQM_textcolor);
  sd =
    "classes.qms" + mindex + ".layer.textalign='" + q130 + "';classes.qms" +
    mindex + ".layer.fontstyle='" + DQM_fontstyle + "';classes.qms" + mindex +
    ".layer.color='" + q144 + "';classes.qms" + mindex +
    ".layer.paddingleft=" + DQM_margin_left + ";classes.qms" + mindex +
    ".layer.paddingright=" + DQM_margin_right + ";classes.qms" + mindex +
    ".layer.paddingtop=" + DQM_margin_top + ";classes.qms" + mindex +
    ".layer.fontsize='" + DQM_fontsize + "px';classes.qms" + mindex +
    ".layer.fontweight='" + DQM_fontweight + "';classes.qms" + mindex +
    ".layer.textdecoration='" + DQM_textdecoration + "';classes.qms" +
    mindex + ".layer.fontfamily='" + DQM_fontfamily + "';";
  sd +=
    " classes.hlqm" + mindex + ".layer.textalign='" + q130 +
    "';classes.hlqm" + mindex + ".layer.fontstyle='" + DQM_fontstyle +
    "';classes.hlqm" + mindex + ".layer.color='" + hltc + "';classes.hlqm" +
    mindex + ".layer.paddingleft=" + DQM_margin_left + ";classes.hlqm" +
    mindex + ".layer.paddingright=" + DQM_margin_right + ";classes.hlqm" +
    mindex + ".layer.paddingtop=" + DQM_margin_top + ";classes.hlqm" +
    mindex + ".layer.paddingbottom=" + DQM_margin_bottom + ";classes.hlqm" +
    mindex + ".layer.fontsize='" + DQM_fontsize + "px';classes.hlqm" +
    mindex + ".layer.fontweight='" + DQM_fontweight + "';classes.hlqm" +
    mindex + ".layer.textdecoration='" + DQM_hl_textdecoration +
    "';classes.hlqm" + mindex + ".layer.fontfamily='" + DQM_fontfamily + "';";
  i = 0;
  while (eval ("window.DQM_subdesc" + mindex + "_" + i))
    {
      id = mindex + "_" + i;
      if (eval ("window.DQM_subdesc" + id + "_0"))
	q19 = q19.concat (new Array (id));
      i++;
    }
  document.write (sd);
};
function
q0 (mindex)
{
  i = 0;
  level = 1;
  while ((i = mindex.indexOf ("_", i + 1)) > -1)
    level++;
  bw = q15 ("DQM_border_width" + mindex, DQM_border_width);
  q50 = q15 ("DQM_sub_menu_width" + mindex, DQM_sub_menu_width);
  bc = q15 ("DQM_border_color" + mindex, DQM_border_color);
  dh = q15 ("DQM_divider_height" + mindex, DQM_divider_height);
  sd =
    "<layer id=qmevent" + mindex + " position=absolute z-index=900001" +
    level + " top=" + 0 + " left=" + 0 + " width=" + (q50 + 2) +
    " visibility='hide'";
  sd += "></layer>";
  sd +=
    "<layer id=qm" + mindex +
    " class='test' position=absolute z-index=900000" + level + " top=" + 0 +
    " left=" + 0 + " width=" + q50 + " visibility='hide'";
  if (bc != "transparent")
    sd += " bgcolor=" + bc;
  sd += ">";
  i = 0;
  while (eval ("window.DQM_subdesc" + mindex + "_" + i))
    {
      id = mindex + "_" + i;
      iid = -1;
      tval = eval ("window.DQM_icon_index" + mindex + "_" + i);
      if ((tval || tval == 0) && eval ("window.DQM_icon_image" + tval))
	{
	  iid = tval;
	  q52 = q33 (eval ("DQM_icon_image_wh" + iid));
	  q51 = eval ("window.DQM_icon_rollover" + iid);
	}
      q47 =
	"position='absolute' left='" + bw + "' top='" + bw + "' width='" +
	(q50 - (bw * 2)) + "'";
      q49 = "";
      if (iid > -1)
	q49 = "' border=0 width='" + q52[0] + "' height='" + q52[1] + "'>";
      tmbgc = q15 ("DQM_menu_bgcolor" + mindex, DQM_menu_bgcolor);
      sd +=
	"<layer class='qms" + mindex + "' id=qmitem" + id + " " + q47 +
	" bgcolor='" + tmbgc + "'>";
      q130 = q15 ("DQM_text_alignment" + mindex, DQM_text_alignment);
      q125 = "";
      if (iid > -1)
	q125 += "<img src='" + eval ("DQM_icon_image" + iid) + q49;
      tval = eval ("DQM_subdesc" + id);
      (q130 == "right") ? sd += tval + q125 : sd += q125 + tval;
      q131 = "";
      q132 = "";
      q129 = "";
      q134 = "";
      tval = eval ("window.DQM_2nd_icon_index" + mindex + "_" + i);
      if ((tval || tval == 0) && eval ("window.DQM_2nd_icon_image" + tval))
	{
	  q126 = tval;
	  q127 = q33 (eval ("DQM_2nd_icon_image_wh" + q126));
	  q128 = q33 (eval ("DQM_2nd_icon_image_xy" + q126));
	  q129 = eval ("DQM_2nd_icon_rollover" + q126);
	  q134 = eval ("DQM_2nd_icon_image" + q126);
	  (q130 == "left") ? tval =
	    (q50 - (bw * 2) - DQM_margin_right - q127[0] + q128[0]) : tval =
	    bw + DQM_margin_left + q128[0];
	  q131 =
	    "<layer position='absolute' top='" + q128[1] + "' left=" + tval +
	    "'><img src='";
	  q132 =
	    "' width='" + q127[0] + "' height='" + q127[1] + "'></layer>";
	}
      sd += q131 + q134 + q132 + "</layer>";
      hlbgc = q15 ("DQM_hl_bgcolor" + mindex, DQM_hl_bgcolor);
      sd +=
	"<layer class='hlqm" + mindex + "' id=qmitemhl" + id + " " + q47 +
	" visibility='hide' bgcolor=" + hlbgc + ">";
      q125 = "";
      if (iid > -1)
	q125 += "<img src='" + q51 + q49;
      tval = q15 ("DQM_hl_subdesc" + id, eval ("DQM_subdesc" + id));
      (q130 == "right") ? sd += tval + q125 : sd += q125 + tval;
      sd += q131 + q129 + q132 + "</layer>";
      i++;
    }
  document.write (sd + "</layer>");
};
function
q1 (id, main)
{
  sub = q16 ("qm" + id);
  sube = q16 ("qmevent" + id);
  dh = q15 ("DQM_divider_height" + id, DQM_divider_height);
  bw = q15 ("DQM_border_width" + id, DQM_border_width);
  sub.bw = bw;
  if (!q61)
    {
      subc = sub.layers;
      q53 = new Array (subc.length / 2);
      q54 = new Array (subc.length / 2);
      ih = bw;
      rc = 0;
      for (j = 0; j < subc.length; j = j + 2)
	{
	  subc[j].top = ih;
	  subc[j + 1].top = ih;
	  nsth = subc[j].clip.height + DQM_margin_bottom;
	  subc[j].clip.height = nsth;
	  subc[j + 1].clip.height = nsth;
	  q53[rc] = ih;
	  q54[rc] = subc[j].clip.height;
	  ih += q54[rc] + dh;
	  if (j > subc.length - 3)
	    ih = ih - dh;
	  rc++;
	}
      ih += bw;
      sub.clip.height = ih;
      sub.q55 = q53;
      sub.q56 = q54;
      sub.lasthl = null;
      sub.q60 = null;
      sube.clip.height = ih + 2;
    }
  sxy = q33 (q15 ("DQM_sub_xy" + id, DQM_sub_xy));
  if (main)
    {
      q85 = q103 (id);
      if (q85 != null)
	{
	  sub.left = q85.x + sxy[0] + q85.width;
	  sub.top = q85.y + sxy[1];
	  sube.left = q85.x + sxy[0] + q85.width - 1;
	  sube.top = q85.y + sxy[1] - 1;
	}
    }
  else
    {
      pid = id.substring (0, id.lastIndexOf ("_"));
      psub = q16 ("qm" + pid);
      pitem = id.substring (id.lastIndexOf ("_") + 1);
      sub.left = psub.left + psub.clip.width + sxy[0];
      sub.top = psub.top + psub.q55[pitem] + sxy[1];
      sube.left = psub.left + psub.clip.width + sxy[0] - 1;
      sube.top = psub.top + psub.q55[pitem] + sxy[1] - 1;
    }
};
function
q103 (id)
{
  if (!eval ("document.menu" + id))
    return null;
  q85 = q16 ("menu" + id);
  q34[id] = q85.x;
  q35[id] = q85.y;
  q36[id] = q85.width;
  q37[id] = q85.height;
  return q85;
};
function
q2 (e, id)
{
  menu = q16 ("qm" + id);
  bw = menu.bw;
  x = e.clientX;
  y = e.clientY;
  mx = menu.left;
  my = menu.top;
  mw = menu.clip.width;
  for (i = 0; i < menu.q55.length; i++)
    {
      if ((x > mx + bw) && (x < mx + mw - bw) && (y > my + menu.q55[i])
	  && (y < my + menu.q55[i] + menu.q56[i]))
	{
	  tval = id + "_" + i;
	  if (menu.lasthl != tval)
	    q5 (menu, tval);
	  else if (menu.q60 == tval)
	    q122 (false, tval);
	  return;
	}
    }
  q30 (menu);
};
function
q4 (menu)
{
  hl_obj = q42 (menu.layers, "qmitemhl" + menu.lasthl);
  hl_obj.visibility = "hide";
  q122 (true);
  q41 = null;
  menu.lasthl = null;
};
function
q5 (menu, hl_id)
{
  q111 ();
  if ((menu.lasthl != null) && (menu.lasthl != hl_id))
    q4 (menu);
  hl_obj = q42 (menu.layers, "qmitemhl" + hl_id);
  hl_obj.visibility = "show";
  q41 = hl_id;
  q122 (false, hl_id);
  if (menu.q60 != null)
    q6 (menu.q60);
  (showMenu (null, hl_id)) ? menu.q60 = hl_id : menu.q60 = null;
  menu.lasthl = hl_id;
};
function
q42 (layeq69, index)
{
  for (ii = 0; ii < layeq69.length; ii++)
    if (layeq69[ii].id == index)
      return layeq69[ii];
  return null;
};
function
DQM_mousemove (e)
{
  if ((!q61) && (!q40))
    return;
  x = e.pageX;
  y = e.pageY;
  if ((q39 != null) && (subExists[q39]))
    {
      if ((to = q45 (x, y, q44 (q39))) != null)
	{
	  q64 = new Object ();
	  q64.clientX = x;
	  q64.clientY = y;
	  q2 (q64, to);
	  q111 ();
	  return;
	}
    }
  for (i = 0; i < q18; i++)
    {
      if ((x > q34[i]) && (x < q34[i] + q36[i]) && (y > q35[i])
	  && (y < q35[i] + q37[i]))
	{
	  if ((!q61) && (q40))
	    {
	      (DQM_nn4_resize_prompt_user) ?
		alert (DQM_nn4_resize_prompt_message) : window.location.
		reload ();
	      q40 = false;
	      return;
	    }
	  if (q39 != i)
	    {
	      if (q39 != null)
		{
		  if (subExists[q39])
		    q6 (q39);
		  q111 ();
		  q27 (q39);
		  q39 = null;
		}
	      showMenu (null, i);
	      q39 = i;
	    }
	  else
	    {
	      q122 (false, i);
	      q111 ();
	    }
	  return;
	}
    }
  if (q39 != null)
    {
      if (subExists[q39])
	{
	  q30 (q16 ("qm" + q39));
	  q94 = q39;
	  q111 ();
	  q93 = setTimeout ("q96()", DQM_mouse_off_delay);
	}
      else
	{
	  q27 (q39);
	  q39 = null;
	}
      q122 (true);
    }
};
function
q111 ()
{
  if (q93 != null)
    {
      clearTimeout (q93);
      q93 = null;
    }
};
function
q96 ()
{
  q6 (q94);
  q27 (q94);
  q39 = null;
};
function
q44 (id)
{
  tm = q16 ("qm" + id);
  if (tm.q60 != null)
    return q44 (tm.q60);
  else
    return id;
};
function
q45 (x, y, id)
{
  tm = q16 ("qm" + id);
  mx = tm.left;
  my = tm.top;
  mw = tm.clip.width;
  mh = tm.clip.height;
  if ((x >= mx) && (x < mx + mw) && (y >= my) && (y < my + mh))
    return id;
  id = id + "";
  if (id.indexOf ("_") > -1)
    {
      idbase = id.substring (0, id.lastIndexOf ("_"));
      return q45 (x, y, idbase);
    }
  else
    return null;
};
function
showMenu (e, id)
{
  if (!q61)
    return false;
  if (q121[id])
    {
      timg = q16 ("menu" + id);
      timg.src = q20[id].src;
      q122 (false, id);
    }
  tval = id + "";
  (tval.indexOf ("_") > -1) ? q82 = id.substring (0, id.indexOf ("_")) : q82 =
    id;
  eval (eval ("window.DQM_showmenu_code" + q82));
  if (q15 ("DQM_subdesc" + id + "_0", null) != null)
    {
      menu = q16 ("qm" + id);
      q57 = q16 ("qmevent" + id);
      menu.visibility = "show";
      q57.visibility = "show";
      return true;
    }
  return false;
};
function
q143 ()
{
  for (i = 0; i < q18; i++)
    {
      q20 = q20.concat (new Array (new Image ()));
      if (q121[i])
	q20[i].src = eval ("DQM_rollover_image" + i);
      tval = eval ("document.menu" + i);
      if (tval)
	q21 = q21.concat (new Array (q16 ("menu" + i).src));
    }
};
function
q6 (id)
{
  tm = q16 ("qm" + id);
  tme = q16 ("qmevent" + id);
  if (tm.lasthl != null)
    q30 (tm);
  tm.visibility = "hide";
  tme.visibility = "hide";
  ts = tm.q60;
  if (ts != null)
    {
      tm.q60 = null;
      q30 (tm);
      q6 (ts);
    }
};
function
mclick (e)
{
  if (q41 != null)
    q32 (q41);
};
function
q15 (pname, rv)
{
  if (eval ("window." + pname))
    return eval (pname);
  else
    return rv;
};
function
q16 (id)
{
  return eval ("document." + id);
};
function
DQM_resize ()
{
  if (DQM_nn4_reaload_after_resize)
    {
      q61 = false;
    q40 = true}
  else
    q31 ();
}




More information about the kfm-devel mailing list