[pmwiki-users] Integrating JavaScript function into Custom Markup

Hans design at softflow.co.uk
Mon Apr 10 09:56:19 CDT 2006


Monday, April 10, 2006, 3:07:08 PM, Joshua wrote:
> If I don't want to set the parameters, can I call a different function,
> like this:

> -without parameters
> (:map:)
> <a href='javascript:OpenMap();' title="Map">Map</a>

> -with parameters
> (:map map=1&2&3 title='Click here for map':)
> <a href='javascript:map("map=1&2&3");' title="Click here for map">Click
> here for map</a>

Try this:

Markup('map', 'directives', "/\\(:map (.*?)?\\s*?:\\)/e",
       "Map(PSS('$1'))");
function Map($args) {
  $arg = PSS(ParseArgs($args));
  if (isset($arg['map']) && isset($arg['title'])) {
       $map = str_replace('&amp;', '&', $arg['map']);
       $maptitle = str_replace('"', '&#022', $arg['maptitle']);
       $out = "<a href='javascript:map(\"map=$map\");' ";
       $out.= "title=\"$maptitle\">Show $maptitle</a>";
       }
  else $out = "<a href='javascript:OpenMap();' title="Map">Map</a>";
  return Keep($out);
  }


Best,
 Hans                           





More information about the pmwiki-users mailing list