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