Sixtest Wiki:API3/Item

TWAPI.addExt("Item"); /* temporary */ TWAPI.Item.addFunc({	"unparsedData": function {		return [];	},	"parser": function(data) {		var itemIndex, editGrouped = false, a = 0, z = data.length, c, setup = {			editparam: ,			edit: ,			param: ,			name: ,			value: ,			trim: false,			array: {				value: ,				array: []			}		}, tokens = {			"{": function  {				editGrouped = true;			},			"=": function  {				setup.name = setup.edit;				setup.editparam = 'value';				setup.edit = ;			},			".": function  {				if (setup.editparam !== 'param') {					setup.edit += c;				} else {					if (setup.edit !== ) {						setup[setup.editparam] = setup.edit;						setup.edit = ;						setup.editparam = 'name';					}				}			},			"|": function  {				if (setup.edit !== ) {					setup[setup.editparam] = setup.edit;					setup.edit = '';				}				setup.editparam = 'param';			},			array: {				"}": function  {					editGrouped = false;					if (setup.array.value !== undefined) { setup.array.array[setup.array.array.length] = setup.array.value; setup.value = setup.array.array; setup.array.value = ''; setup.array.array = []; }				},				",": function { setup.array.array[setup.array.array.length] = setup.array.value; setup.array.value = ''; setup.trim = true; }			}		}, out = TWAPI.Item.Data || {}; if (TWAPI === undefined) { alert('TWAPI is not defined. Use the TWAPI_Init function.'); return false; }		function allNonEmpty(a, b, c) { return (a !== undefined && a !==  && b !== undefined && b !==  && c !== undefined && c !== ''); }		function toDataObj(name, param, value) { if (allNonEmpty(name, param, value)) { if (out[name] === undefined) { out[name] = {}; }				out[name][param] = value; return true; }			return false; }		while (a < z) { c = data.charAt(a); if (editGrouped) { if (tokens.array[c] !== undefined) { tokens.array[c]; } else { if (c !== ' ' || !setup.trim) { setup.array.value += c;						if (setup.trim) { setup.trim = false; }					}				}			} else { if (tokens[c] !== undefined) { tokens[c]; } else { if (c !== ' ' || !setup.trim) { setup.edit += c;						if (setup.trim) { setup.trim = false; }					}				}			}			if (toDataObj(setup.name, setup.param, setup.value)) { setup.name = setup.param = setup.value = ''; }			a += 1; }		itemIndex = (function(data) {			var rtn = [], i = 0, item;			for (item in data) {				if (data.hasOwnProperty(item)) {					rtn[i] = data[item];					i += 1;				}			}			return rtn;		}(out)); TWAPI.Item.Data = itemIndex; },	"Get": function (get) { return TWAPI.Item.Data[get]; },	"Refresh": function (id) { if (id === undefined) { TWAPI.Item.RefreshAll; } else { $.ajax({				url: 'http://sixtest.wikia.com/wiki/Sixtest_Wiki:API/Item/Data'+ id + '?action=raw',				dataType: 'text',				async: false,				success: function(text) {					TWAPI.Item.unparsedData[id-1] = text;					TWAPI.Item.parser(text);				}			}); }	},	"RefreshAll": function { var i = 1; for (i; i <= 3; i += 1) { TWAPI.Item.Refresh(i); }	},	"Interface": function { var t = TWAPI.Interface.Container, ein = document.createElement('input'), eout = document.createElement('div'); ein.setAttribute('type', 'text'); t.appendChild(ein); t.appendChild(eout); var out = { Input: ein, Output: eout }	} }); TWAPI.Item.Refresh;