doubleclick.pl 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Copyright (C) 2004 Alex Schroeder <alex@emacswiki.org>
  2. # 2004 Niklas Volbers <mithrandir42@web.de>
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the
  16. # Free Software Foundation, Inc.
  17. # 59 Temple Place, Suite 330
  18. # Boston, MA 02111-1307 USA
  19. # This module offers the user the additional possibility to
  20. # edit a page by double-clicking on it. The user must have
  21. # JavaScript enabled for this to work.
  22. use strict;
  23. use v5.10;
  24. AddModuleDescription('doubleclick.pl', 'Doubleclick Extension');
  25. our ($ScriptName);
  26. *OldDoubleclickGetHeader = \&GetHeader;
  27. *GetHeader = \&NewDoubleclickGetHeader;
  28. sub NewDoubleclickGetHeader {
  29. my $id = shift;
  30. my $html = OldDoubleclickGetHeader($id, @_);
  31. my $action = lc(GetParam('action', 'browse'));
  32. if (($action eq 'browse') and $id) {
  33. my $ondblclick="ondblclick=\"location.href='"
  34. . $ScriptName . "?action=edit;id=" . $id . "'\"";
  35. $html =~ s/\<body /\<body $ondblclick /;
  36. }
  37. return $html;
  38. }