annotate lisp/w3/w3-script.el @ 62:28a7c63c7e1e r19-16-pre6

Import from CVS: tag r19-16-pre6
author cvs
date Mon, 13 Aug 2007 08:59:13 +0200
parents 1a767b41a199
children
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
38
1a767b41a199 Import from CVS: tag r19-15b102
cvs
parents: 32
diff changeset
3 ;; Created: 1997/03/20 14:22:28
1a767b41a199 Import from CVS: tag r19-15b102
cvs
parents: 32
diff changeset
4 ;; Version: 1.7
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
38
1a767b41a199 Import from CVS: tag r19-15b102
cvs
parents: 32
diff changeset
47 (defgroup w3-scripting nil
1a767b41a199 Import from CVS: tag r19-15b102
cvs
parents: 32
diff changeset
48 "When, where, how, and why to enable client-side scripting."
1a767b41a199 Import from CVS: tag r19-15b102
cvs
parents: 32
diff changeset
49 :group 'w3)
1a767b41a199 Import from CVS: tag r19-15b102
cvs
parents: 32
diff changeset
50
1a767b41a199 Import from CVS: tag r19-15b102
cvs
parents: 32
diff changeset
51 (defcustom w3-do-scripting nil
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
52 "*Whether to handle client-side scripting or not.
38
1a767b41a199 Import from CVS: tag r19-15b102
cvs
parents: 32
diff changeset
53 If you are adventurous, set this to `t'"
1a767b41a199 Import from CVS: tag r19-15b102
cvs
parents: 32
diff changeset
54 :group 'w3-scripting
1a767b41a199 Import from CVS: tag r19-15b102
cvs
parents: 32
diff changeset
55 :type 'boolean)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
56
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
57 (defvar w3-current-scripting-language 'elisp)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
58 (make-variable-buffer-local 'w3-current-scripting-language)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
59
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
60 (put 'form 'w3-event-handlers
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
61 '(onclick onchange onselect onblur onfocus onreset onsubmit))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
62
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
63 (put 'mouse 'w3-event-handlers '(onmouseover onmouseout))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
64
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
65 (put 'misc 'w3-event-handlers '(onload onunload))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
66
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
67 (put 'all 'w3-event-handlers (append (get 'form 'w3-event-handlers)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
68 (get 'mouse 'w3-event-handlers)))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
69
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
70 (defun w3-script-find-event-handlers (pt type)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
71 (if w3-do-scripting
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
72 (let* ((html-stack (get-text-property pt 'html-stack))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
73 (args nil)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
74 (rval nil)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
75 (cur nil))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
76 (while html-stack
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
77 (setq args (cdr (pop html-stack)))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
78 (while (setq cur (pop args))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
79 (if (memq (car cur) (get type 'w3-event-handlers))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
80 (setq rval (cons cur rval)))))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
81 (nreverse rval))))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
82
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
83 (defun w3-script-evaluate-form (f)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
84 (if w3-do-scripting
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
85 (case w3-current-scripting-language
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
86 (elisp
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
87 (let ((st 0)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
88 (form nil)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
89 (max (length f)))
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
90 (condition-case ()
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
91 (while (and (< st max) (setq form (read-from-string f st)))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
92 (setq st (cdr form)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
93 form (car form))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
94 (w3-elisp-safe-eval form))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
95 (error nil))))
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
96 (otherwise
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
97 (message "Unimplemented scripting language: %S"
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
98 w3-current-scripting-language)))))
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
99
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents:
diff changeset
100 (provide 'w3-script)