source: Dev/trunk/src/client/dojox/mobile/_ExecScriptMixin.js @ 532

Last change on this file since 532 was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 1.1 KB
Line 
1define([
2        "dojo/_base/kernel",
3        "dojo/_base/declare",
4        "dojo/_base/window",
5        "dojo/dom-construct"
6], function(kernel, declare, win, domConstruct){
7        // module:
8        //              dojox/mobile/_ExecScriptMixin
9
10        return declare("dojox.mobile._ExecScriptMixin", null, {
11                // summary:
12                //              Mixin for providing script execution capability to content handlers.
13                // description:
14                //              This module defines the execScript method, which is called
15                //              from an HTML content handler.
16
17                execScript: function(/*String*/ html){
18                        // summary:
19                        //              Finds script tags and executes the script.
20                        // html: String
21                        //              The HTML input.
22                        // returns: String
23                        //              The given HTML text from which <script> blocks are removed.
24                        var s = html.replace(/\f/g, " ").replace(/<\/script>/g, "\f");
25                        s = s.replace(/<script [^>]*src=['"]([^'"]+)['"][^>]*>([^\f]*)\f/ig, function(ignore, path){
26                                domConstruct.create("script", {
27                                        type: "text/javascript",
28                                        src: path}, win.doc.getElementsByTagName("head")[0]);
29                                return "";
30                        });
31
32                        s = s.replace(/<script>([^\f]*)\f/ig, function(ignore, code){
33                                kernel.eval(code);
34                                return "";
35                        });
36
37                        return s;
38                }
39        });
40});
Note: See TracBrowser for help on using the repository browser.