add: this.validProps = ['Event','Site','Date','Rount', 'White','Black'] 
context: function Pgn(pgn) {	// properties of the game eg players, ELOs etc	this.props = new Object()	// the moves, one move contains the black and white move	this.moves = new Array()	// the current move in the game	this.currentMove = 0;	// for outputting white and black moves separately	this.skip = 0	this.pgn = pgn	/* constructor */	// strip comments	this.pgn = this.pgn.replace(/\{[^}]*\}/g,'')	// the properties	var reprop = /\[([^\]]*)\]/gi	var matches = this.pgn.match(reprop)	if (matches) {		 for(var i = 0;i < matches.length; i++) {			 // lose the brackets			 tmpMatches = matches[i].substring(1, matches[i].length-1)			 // split by the first space			 var key = tmpMatches.substring(0, tmpMatches.indexOf(" "))			 var value = tmpMatches.substring(tmpMatches.indexOf(" ")+1)			 if (value.charAt(0) == '"')				 value = value.substr(1)			 if (value.charAt(value.length-1) == '"')				 value = value.substr(0, value.length-1)			 			 this.props[key] = value;			 this.pgn = this.pgn.replace(matches[i], "")		 }	}	var gameOverre = new Array(		/1\/2-1\/2/,		/0-1/,		/1-0/	)	// the moves	var re;	for(var i = 1;;i++) {		re = i+"\\.(\\n| )?([^.]*)"				var result = this.pgn.match(re)		if (result == null)			break		// newlines to spaces		result[2] = result[2].replace(/\n/g, " ")		// leave only one space in the middle		while(result[2].indexOf("  ")!=-1)			 result[2] = result[2].replace("  ", " ")		// possible first space gets removed		if (" "==result[2].charAt(0))			result[2] = result[2].substring(1)		var tmp = result[2].split(" ")		for (var j = 0;j<gameOverre.length;j++) {			if (gameOverre[j].test(tmp[1]))			tmp[1] = null		}		if (tmp[1] && 0 == tmp[1].length)				 tmp[1] = null		var move = new Move(tmp[0], tmp[1])		this.moves[this.moves.length] = move	}	// no moves	if (this.moves.length>0) {		 for(var i = 0; i < gameOverre.length; i++) {			 if (gameOverre[i].test(this.moves[this.moves.length-1][1])) {				 this.moves[this.moves.length-1][1] = null			 }		 }	}	if (/1\/2-1\/2/.test(this.pgn)) {		this.props['result'] = '1/2-1/2'	}	else if (/1-0/.test(this.pgn)) {		this.props['result'] = '1-0'   	}	else if (/0-1/.test(this.pgn)) {		this.props['result'] = '0-1'	}	else {		this.props['result'] = ''   	}	this.nextMove = function() {		var rtrn = null		try{			if (this.skip) {				this.skip = 0				rtrn = new Array(this.moves[this.currentMove].black,													'black');				this.currentMove++			}			else {				this.skip = 1				rtrn = new Array(this.moves[this.currentMove].white,											'white')			}				if (rtrn[0] == null || rtrn[0].length == 0)				rtrn = null			return rtrn			}		catch (e) {			return null		}	}}
meta: 5532	/local1/tlutelli/issta_data/temp/all_js/javascript/2007_temp/2007/5532/8dc82f970441289f8c19dae01ddbeadc156f15d6/pgn.js/clean/src/pgn.js