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

📄 ajax_base.php

📁 Simple AJAX Framework/Library. Contains numerous built-in functions, alongside speed enhancements b
💻 PHP
字号:
<?php
//  -=( NEOTELOS.COM )=-
// AJAx Framework v1.0
// (Dev Build: 0130)
// by Shawn Khameneh
// (C) 2008 NEOTELOS.COM
// 
// This script is not be used in any form
// without written permission of the original
// author.
// 

class ajax_obj {
	private $commands = array();
	
	public function __destruct() {
		// flush commands to client
		echo @implode('@',$this->commands);
	}
	
	public function encode($string) {
		$string = str_replace("\r",'',$string);
		$string = str_replace("\n",'',$string);
		$string = str_replace("\t",'',$string);
		$string = str_replace('_','_0',$string);
		$string = str_replace('@','_1',$string);
		$string = str_replace(',','_2',$string);
		$string = str_replace('\'','_3',$string);

		$string = str_replace(' id="','_5',$string);
		$string = str_replace(' style="','_6',$string);
		$string = str_replace(' class="','_7',$string);
		$string = str_replace(' src="','_8',$string);
		$string = str_replace('<img','_9',$string);
		$string = str_replace('<a href="','_a',$string);
		$string = str_replace('<br>','_b',$string);
		$string = str_replace('<br />','_c',$string);
		$string = str_replace('<br/>','_d',$string);
		$string = str_replace('</a>','_e',$string);
		$string = str_replace('</div>','_f',$string);
		$string = str_replace('<div','_g',$string);
		$string = str_replace('<b>','_h',$string);
		$string = str_replace('</b>','_i',$string);
		$string = str_replace('<i>','_j',$string);
		$string = str_replace('</i>','_k',$string);
		return $string;
	}
	
	private function add($command) {
		$i = count($this->commands)-1;
		$this->commands[$i] = $command;
		return $i; // return command index
	}
	
	public function remove($i) { // Remove command by index
		$this->commands[$i]=null;
	}
	
	public function alert($str) { // Create JS alert
		return $this->add('a,'.$this->encode($str));
	}
	
	public function execute($str) { // Execute JS
		return $this->add('j,'.$this->encode($str));
	}
	
	public function write($str) { // Write to document
		return $this->add('w,'.$this->encode($str));
	}
	
	public function removeById($id) { // Remove Element from DOM
		return $this->add('r,'.$this->encode($id));
	}
	
	public function htmlById($id,$str) { // Change Element's HTML
		return $this->add('h,'.$this->encode($id).','.$this->encode($str));
	}
	
	public function appendById($id,$str) { // Append to Element's HTML
		return $this->add('h,'.$this->encode($id).','.$this->encode($str));
	}
	
	public function attrById($id,$str) { // Change Element's Attributes
		return $this->add('d,'.$this->encode($id).','.$this->encode($str));
	}
	
	public function setvar($id,$str) { // Set global JS variable
		return $this->add('v,'.$this->encode($id).','.$this->encode($str));
	}
	
	public function appendElementById($id1,$id2,$str) { // Append Element to another
		return $this->add('d,'.$this->encode($id1).','.$this->encode($id2).','.$this->encode($str));
	}
	
	public function styleById($id,$style,$str) { // Change Element's CSS Style
		return $this->add('d,'.$this->encode($id).','.$this->encode($style).','.$this->encode($str));
	}
}
?>

⌨️ 快捷键说明

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