annotate lisp/w3/w3-script.el @ 108:360340f9fd5f r20-1b6

Import from CVS: tag r20-1b6
author cvs
date Mon, 13 Aug 2007 09:18:39 +0200
parents ec9a17fef872
children e04119814345
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
1 ;;; w3-script.el --- Scripting support
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
2 ;; Author: wmperry
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
3 ;; Created: 1997/03/07 14:13:39
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
4 ;; Version: 1.5
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
5 ;; Keywords: hypermedia, scripting
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
6
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
8 ;;; Copyright (c) 1997 Free Software Foundation, Inc.
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
9 ;;;
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
10 ;;; This file is part of GNU Emacs.
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
11 ;;;
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
12 ;;; GNU Emacs is free software; you can redistribute it and/or modify
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
13 ;;; it under the terms of the GNU General Public License as published by
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
14 ;;; the Free Software Foundation; either version 2, or (at your option)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
15 ;;; any later version.
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
16 ;;;
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
17 ;;; GNU Emacs is distributed in the hope that it will be useful,
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
18 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
20 ;;; GNU General Public License for more details.
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
21 ;;;
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
22 ;;; You should have received a copy of the GNU General Public License
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
23 ;;; along with GNU Emacs; see the file COPYING. If not, write to the
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
24 ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
25 ;;; Boston, MA 02111-1307, USA.
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
26 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
27
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
28 (require 'cl)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
29 (require 'w3-elisp)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
30 (require 'w3-jscript)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
31
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
32 ;; Event Handlers
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
33 ;; onclick ; It was clicked on
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
34 ;; onchange ; Text area was changed
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
35 ;; onselect ; Menu choice changed
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
36 ;; onmouseover ; Mouse is over us
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
37 ;; onmouseout ; Mouse left us
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
38 ;; onblur ; We lost focus
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
39 ;; onfocus ; We gained focus
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
40 ;; onload ; We got loaded
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
41 ;; onunload ; We got unloaded
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
42 ;; onreset ; Form got reset
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
43 ;; onsubmit ; From is about to be submitted
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
44 ;; onabort ; User cancelled loading an image
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
45 ;; onerror ; Error occurred loading an image
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
46
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
47 (defvar w3-do-scripting t
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
48 "*Whether to handle client-side scripting or not.
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
49 If you are ultra-paranoid, set this to `nil'")
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
50
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
51 (defvar w3-current-scripting-language 'elisp)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
52 (make-variable-buffer-local 'w3-current-scripting-language)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
53
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
54 (put 'form 'w3-event-handlers
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
55 '(onclick onchange onselect onblur onfocus onreset onsubmit))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
56
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
57 (put 'mouse 'w3-event-handlers '(onmouseover onmouseout))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
58
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
59 (put 'misc 'w3-event-handlers '(onload onunload))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
60
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
61 (put 'all 'w3-event-handlers (append (get 'form 'w3-event-handlers)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
62 (get 'mouse 'w3-event-handlers)))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
63
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
64 (defun w3-script-find-event-handlers (pt type)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
65 (if w3-do-scripting
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
66 (let* ((html-stack (get-text-property pt 'html-stack))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
67 (args nil)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
68 (rval nil)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
69 (cur nil))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
70 (while html-stack
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
71 (setq args (cdr (pop html-stack)))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
72 (while (setq cur (pop args))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
73 (if (memq (car cur) (get type 'w3-event-handlers))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
74 (setq rval (cons cur rval)))))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
75 (nreverse rval))))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
76
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
77 (defun w3-script-evaluate-form (f)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
78 (if w3-do-scripting
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
79 (case w3-current-scripting-language
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
80 (elisp
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
81 (let ((st 0)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
82 (form nil)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
83 (max (length f)))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
84 (while (and (< st max) (setq form (read-from-string f st)))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
85 (setq st (cdr form)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
86 form (car form))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
87 (w3-elisp-safe-eval form))))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
88 (otherwise
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
89 (message "Unimplemented scripting language: %S"
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
90 w3-current-scripting-language)))))
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
91
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
92 (provide 'w3-script)