mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-20 11:49:56 +09:00
17223554 : xquared upgrade to 0.7
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@4968 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
5956e254e7
commit
7c3b336e41
59 changed files with 34562 additions and 8454 deletions
|
|
@ -0,0 +1,42 @@
|
|||
/**
|
||||
* @requires macro/Base.js
|
||||
*/
|
||||
xq.macro.JavascriptMacro = xq.Class(xq.macro.Base,
|
||||
/**
|
||||
* Javascript macro
|
||||
*
|
||||
* @name xq.macro.JavascriptMacro
|
||||
* @lends xq.macro.JavascriptMacro.prototype
|
||||
* @extends xq.macro.Base
|
||||
* @constructor
|
||||
*/
|
||||
{
|
||||
initFromHtml: function() {
|
||||
var p = xq.compilePattern("src=[\"'](.+?)[\"']", "img");
|
||||
this.params.url = p.exec(this.html)[1];
|
||||
},
|
||||
initFromParams: function() {
|
||||
if(!xq.macro.JavascriptMacro.isSafeScript(this.params.url)) throw "Unknown src";
|
||||
},
|
||||
createHtml: function() {return '<script type="text/javascript" src="' + this.params.url + '"></script>'},
|
||||
|
||||
onLayerInitialzied: function(layer) {
|
||||
layer.getDoc().write(this.createHtml());
|
||||
}
|
||||
});
|
||||
|
||||
xq.macro.JavascriptMacro.recognize = function(html) {
|
||||
var p = xq.compilePattern("<SCRIPT\\s+[^>]*src=[\"']([^\"']+)[\"'][^>]*(?:/>|>.*?</(?:SCRIPT)>)", "img");
|
||||
var m = p.exec(html);
|
||||
if(!m || !m[1]) return false;
|
||||
return this.isSafeScript(m[1]);
|
||||
}
|
||||
xq.macro.JavascriptMacro.isSafeScript = function(url) {
|
||||
var safeSrcs = {
|
||||
googleGadget: /http:\/\/gmodules\.com\/ig\/ifr\?/img
|
||||
};
|
||||
for(var id in safeSrcs) {
|
||||
if(url.match(safeSrcs[id])) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue