chndyyang / fookie Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/fookie
Automatically exported from code.google.com/p/fookie
你好,
刚用了Fookie,运行的非常好,在你的基础上对JS代码做了些改动,
代码如下,简单测试了一下,
几大浏览器跑的比较稳定.
Fookie = (function(){
var swf,
swfUrl = "",
swfId = "fookie_swf_" + Math.round(Math.random() * 100),
_self;
function _waitSwfReady(){
swf = document[ swfId ] || window[ swfId ];
if (swf) {
if (_self.onready)
_self.onready.call(_self);
}else
setTimeout( arguments.callee, 13 );
}
function _writeSwf(){
// width = height = 1px
var a = ['<object id="', swfId, '" classid="clsid:D27CDB6E-AE6D-
11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.c
ab#version=7,0,19,0" width="1" height="1">', '<param name="movie"
value="', swfUrl, '" />', '<param name="quality" value="high" />', '<param
name="allowscriptaccess" value="samedomain" />', '<embed name="',
swfId, '" src="', swfUrl, '" allowscriptaccess="samedomain" quality="high"
pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash" width="1"
height="1"></embed>', "</object>"].join(""),
ct = document.createElement("div"),
style = {
display : "block",
border : "none",
width : "1px",
height : "1px",
overflow: "hidden"
};
for (var m in style) {
ct.style[m] = style[m];
}
//wait for body tag
(function(){
if ( document.body ){
document.body.insertBefore( ct,
document.body.firstChild );
ct.innerHTML = a;
_waitSwfReady();
}else
setTimeout( arguments.callee, 13 )
})()
}
function doAction( method, config, name, value ){
if ( !swf || !swf[method] )
return;
config = config || {};
var a = config.application || _self.application,
p = config.path || _self.path,
e = config.expires || _self.expires,
s = config.secure ? true : _self.secure;
//reset arguments
var args = [];
if ( name )
args.push( name );
if( value )
args.push( value );
args.push( a, p );
//特殊处理
method == "write" ? args.push( e, s ) : args.push( s );
if ( method == "clear" ) method = "remove";
try {
return swf[ method ].apply( swf, args );
} catch (e) {
// alert( "error : " + e.toString() )
}
}
return {
application : "fookie_data",
path : "/",
expires : 1000,
secure : false,
init : function( url, config ){
_self = this;
if ( url )
swfUrl = url;
for( var c in config || {} )
this[ c ] = config[ c ];
//0,1,2表示 该方法拥有几个有效参数
var methods = {
read : 1,
write : 2,
remove: 1,
clear : 0
};
for( var m in methods )
(function(){
var name = m, num = methods[
name ];
_self[ name ] = function(){
//截取有效参数
var args =
Array.prototype.slice.call(arguments, 0, num + 1);
//在数组头添加 方法名与配置
项
args.unshift(name,
arguments[ num ] );
return doAction.apply(
null, args )
}
})();
//加载swf
_writeSwf();
return this;
}
}
})();
Original issue reported on code.google.com by [email protected]
on 15 Aug 2009 at 3:22
Attachments:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.