Skip to content

Instantly share code, notes, and snippets.

@kentaromiura
kentaromiura / kenta.AOP.js
Created October 11, 2011 16:50
AOP for Mootools
/*
---
name: kenta.AOP
description: AOP for MooTools 1.3
version: 1.1
license: MIT-style license.
@kentaromiura
kentaromiura / kenta.AOP.Profile.js
Created October 10, 2011 16:27
Class Profiler for Mootools 1.3.x
/*
---
name: kenta.AOP.Profile.js
description: Profiling for MooTools 1.3
version: 1.0
license: MIT-style license.
@kentaromiura
kentaromiura / kenta.Private.js
Created March 4, 2011 18:26
private pattern mutator for Mootools 1.3.x
/*
---
name: kenta.Private
description: Private mootator for MooTools 1.3.x
license: MIT-style license.
copyright: Carlesso Cristian http://mykenta.blogspot.com
Class.Mutators.Profile = function(uniqueID){
var imp = this.implement;
this.implement = function(key, value){
if($type(key) =='string' && $type(value) == 'function'){
var me = this;
var profile = function(){
var start = $time();
@kentaromiura
kentaromiura / Class.Mutators.Private.js
Created August 6, 2010 09:04
Private mootator for mooTools 1.2.4
Class.Mutators.Private = function(private) {
var Private = {};
var me = this;
var imp = me.implement;
imp.apply(me, ['~', function() {
var uid = $uid(this);
private = null;
delete Private[uid];
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<style>
*{
margin:0;padding:0;border:0;
}
body {
font-size:1em;
}
var require =(function(){
var imports = new Hash();
var path = "libs"
return function(lib){
if(!imports.has(lib)){
var req = new Request({
url:[path,lib].join('/') + ".js",
async:false
});
Events.implement('oneShot', function(evt, fx) {
function once() {
fx.run(arguments);
this.removeEvent(evt, once);
}
this.addEvent(evt, once);
});
/*
This is a fix for $type function to make it work with ActiveXObject too :) - optimized for size
*/
function $type(obj) {
if (obj == undefined) return false;
if (obj.$family) return (obj.$family.name == 'number' && !isFinite(obj)) ? false : obj.$family.name;
if (obj.nodeName) {
switch (obj.nodeType) {
case 1: return 'element';
case 3: return (/\S/).test(obj.nodeValue) ? 'textnode' : 'whitespace';
<html>
<head>
<title>Mootools $type and ActiveXObject</title>
<script type="text/javascript" src="mootools-1.2.4-core-nc.js"></script>
<script type="text/javascript">
addEvent('domready',function(){
var doc = new ActiveXObject("Msxml2.DOMDocument.4.0");
var source = '<root><burp decibel="too much" direction="front of you" save="none"></burp></root>';
doc.async = false;
doc.loadXML(source);