You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.1 KiB
40 lines
1.1 KiB
define([ |
|
"dojo/_base/kernel", |
|
"dojo/_base/declare", |
|
"dojo/_base/window", |
|
"dojo/dom-construct" |
|
], function(kernel, declare, win, domConstruct){ |
|
// module: |
|
// dojox/mobile/_ExecScriptMixin |
|
|
|
return declare("dojox.mobile._ExecScriptMixin", null, { |
|
// summary: |
|
// Mixin for providing script execution capability to content handlers. |
|
// description: |
|
// This module defines the execScript method, which is called |
|
// from an HTML content handler. |
|
|
|
execScript: function(/*String*/ html){ |
|
// summary: |
|
// Finds script tags and executes the script. |
|
// html: String |
|
// The HTML input. |
|
// returns: String |
|
// The given HTML text from which <script> blocks are removed. |
|
var s = html.replace(/\f/g, " ").replace(/<\/script>/g, "\f"); |
|
s = s.replace(/<script [^>]*src=['"]([^'"]+)['"][^>]*>([^\f]*)\f/ig, function(ignore, path){ |
|
domConstruct.create("script", { |
|
type: "text/javascript", |
|
src: path}, win.doc.getElementsByTagName("head")[0]); |
|
return ""; |
|
}); |
|
|
|
s = s.replace(/<script>([^\f]*)\f/ig, function(ignore, code){ |
|
kernel.eval(code); |
|
return ""; |
|
}); |
|
|
|
return s; |
|
} |
|
}); |
|
});
|
|
|