All pastes #97409 Raw Edit

Someone

public javascript v1 · immutable
#97409 ·published 2006-07-23 18:30 UTC
rendered paste body
function TMOChatHistory() {	var stack = new TMOHistoryStack();		function add(message) {		stack.addMessage(message);	}		function get() {		stack.current();	}		function reset() {		stack.reset();	}}function TMOHistoryStack() {	var history = new Array();	var size = 50;	var index = -1;		this.function addMessage(message) {		_trim();		history.unshift(new TMOChatMessage(message));	}		this.function current() {		_next();		message = history[index].getText();	}		this.function reset() {		index = -1;	}		function _next() {		if(_hasNext()) {			index++;		} else {			index = -1;		}	}		function _hasNext() {		return index < history.length;	}		function _trim() {		if(history.length == size) {			history.pop();		}	}}function TMOChatMessage(message) {	var text = message;		this.function getText() {		return text;	}		this.function getLength() {		return text.length;	}}