Javascript form help - function(e)?


#1

Hi guys!

I’m new to javascript and jQuery, and would like some help understanding this, and some help in the direction of creating my own mini form.

What I’m trying to do is create a mini form within a wysiwyg text editor. On click, this button will bring up the mini form which allows users to put in the information to generate a relative link.

For another button I used:

function createLink()
    {
        var link = prompt("Enter the link", "https://");
        editor.document.execCommand('createLink', false, link);

That worked because the ‘createLink’ command is able to create an absolute link.

Based off of another example I am working off of, this is what I have:

function(e) 
	{
  e = b.editor;
  var a = c(b.popup).find("#logicalId"),
    f = c(b.popup).find("#pageKey");
  if ("" == a.val() && "" == f.val()) return alert("you must enter either logicalId or pageKey"), !1;
  if ("" != a.val() && "" != f.val()) return alert("you cannot enter both logicalId and pageKey"), !1;
  var d = "\x3ca href\x3d'#' dfmltype\x3d'link' ";
  "" != a.val() && (d += "logicalid\x3d'" + a.val() + "' ");
  "" != f.val() && (d += "pagekey\x3d'" + f.val() + "' ");
  a = c(b.popup).find("#cssClass");
  "" != a.val() && (d += "class\x3d'" + a.val() + "' ");
  a = c(b.popup).find("#htmlId");
  "" != a.val() && (d += "id\x3d'" + a.val() + "' ");
  c(b.popup).find("#target").is(":checked") && (d += "target\x3d'_blank' ");
  a = c(b.popup).find("#params");
  "" != a.val() && (d += "params\x3d'" + a.val() + "' ");
  a = c(b.popup).find("#frag");
  "" != a.val() && (d += "frag\x3d'" + a.val() + "' ");
  a = c(b.popup).find("#dataOln");
  "" != a.val() && (d += "data-oln\x3d'" + a.val() + "' ");
  d += "\x3e";
  a = c(b.popup).find("#linkText");
  d = "" != a.val() ? d + a.val() : d + "[DEFAULT_TITLE]";
  (d += "\x3c/a\x3e") && e.execCommand(b.command, d, null, b.button);
  c(b.popup).find(":text").val("");
  e.hidePopups();
  e.focus()
	}

But I am confused by the use of function(e), and how to refer to that in my php file, and the variations of ‘var a’ - ‘var e’?

I understand the encoding of the ascii characters, and the logical id or page key is what I would like the users to input. The dataOln, frag, and params, and target are sections that were existing in the template I started off with, but would be okay with losing.

Any help understanding this would be much appreciated.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.