User:Cblair91/newchat.js

var levels = { 1: 0,	2: 83,	3: 174,	4: 276,	5: 388,	6: 512,	7: 650,	8: 801,	9: 969,	10: 1154,	11: 1358,	12: 1584,	13: 1833,	14: 2107,	15: 2411,	16: 2746,	17: 3115,	18: 3523,	19: 3973,	20: 4470,	21: 5018,	22: 5624,	23: 6291,	24: 7028,	25: 7842,	26: 8740,	27: 9730,	28: 10824,	29: 12031,	30: 13363,	31: 14833,	32: 16456,	33: 18247,	34: 20224,	35: 22406,	36: 24815,	37: 27437,	37: 30408,	39: 33648,	40: 37224,	41: 41171,	42: 45529,	43: 50339,	44: 55649,	45: 61512,	46: 67983,	47: 75127,	48: 83014,	49: 91721,	50: 101333,	51: 111945,	52: 123660,	53: 136594,	54: 150872,	55: 166636,	56: 184040,	57: 203254,	58: 224466,	59: 247886,	60: 273742,	61: 302288,	62: 333804,	63: 368599,	64: 407015,	65: 449428,	66: 496254,	67: 547953,	68: 605032,	69: 668051,	70: 737627,	71: 814445,	72: 899257,	73: 992895,	74: 1096278,	75: 1210421,	76: 1336443,	77: 1475581,	78: 1629200,	79: 1798808,	80: 1986068,	81: 2192818,	82: 2421087,	83: 2673114,	84: 2951373,	85: 3258594,	86: 3597792,	87: 3972294,	88: 4385776,	89: 4842295,	90: 5346332,	91: 5902831,	92: 6517253,	93: 7195629,	94: 7944614,	95: 8771558,	96: 9684577,	97: 10692629,	98: 11805606,	99: 13034431,	100: 14391160,	101: 15889109,	102: 17542976,	103: 19368992,	104: 21385073,	105: 23611006,	106: 26068632,	107: 28782069,	108: 31777943,	109: 35085654,	110: 38737661,	111: 42769801,	112: 47221641,	113: 52136869,	114: 57563718,	115: 63555443,	116: 70170840,	117: 77474828,	118: 85539082,	119: 94442737,	120: 104273167 }

$('[name="message"]').keypress(function(e) {	if (e.keyCode == 13 || e.which == 13) {		var cmd = this.value.toLowerCase.split(' ')		var params = this.value.replace(/^.*?\s/,)		var params2 = this.value.replace(/^.*?\s.*?\s/,)		switch (cmd[0]) {			case '/tnl': case '/quickchat': e.preventDefault; qc('tnl', params);			case '/tl': case '/privchat': e.preventDefault; qc('nl', params);		}	} })

var hstype = ''; function toSkillName(skill, rs07) { skill = skill.toLowerCase switch (skill) { case 'agility': case 'agil': skill = 'Agility';break; case 'attack': case 'att': case 'atk': skill = 'Attack';break; case 'combat': case 'cb': case 'cmb': skill = 'Combat';break; case 'construction': case 'con': case 'cons': case 'const': case 'construct': skill = 'Construction';break; case 'constitution': case 'hp': case 'hitpoints': case 'hits': case 'lifepoints': case 'lp': case 'health': skill = rs07?'Hitpoints':'Constitution'; break; case 'cooking': case 'cook': skill = 'Cooking';break; case 'crafting': case 'craft': skill = 'Crafting';break; case 'defence': case 'def': case 'defense': skill = 'Defence';break case 'dungeoneering': case 'dg': case 'dung': case 'dungeon': skill = 'Dungeoneering';break; case 'farming': case 'farm': skill = 'Farming';break; case 'firemaking': case 'fm': case 'firemake': case 'fire': skill = 'Firemaking';break; case 'fishing': case 'fish': skill = 'Fishing';break; case 'fletching': case 'fletch': skill = 'Fletching';break; case 'herblore': case 'herb': case 'herblaw': skill = 'Herblore';break; case 'hunter': case 'hunt': case 'hunting': skill = 'Hunter';break; case 'magic': case 'mage': skill = 'Magic';break; case 'mining': case 'mine': skill = 'Mining';break; case 'overall': case 'total': case 'tot': case 'combined': skill = 'Overall';break; case 'prayer': case 'pray': skill = 'Prayer';break; case 'ranged': case 'arching': case 'range': case 'ranger': skill = 'Ranged';break; case 'runecrafting': case 'rc': case 'runecraft': skill = 'Runecrafting';break; case 'slayer': case 'slay': case 'slaying': skill = 'Slayer';break; case 'smithing': case 'smith': skill = 'Smithing';break; case 'strength': case 'str': case 'strenght': skill = 'Strength';break; case 'summoning': case 'summ': case 'summon': skill = 'Summoning';break; case 'thieving': case 'thief': case 'thieve': skill = 'Thieving';break; case 'woodcutting': case 'wc': case 'woodcut': skill = 'Woodcutting';break; case 'duel': case 'duelling': case 'tournament': skill = 'Duelling Tournament'; hstype = 'score';break; case 'bounty': case 'bh': case 'bhunt': skill = 'Bounty Hunter'; hstype = 'score';break; case 'rogue': case 'bhrouge': case 'bhr': skill = 'Bounty Hunter Rogue'; hstype = 'score';break; case 'fog': case 'fist': case 'guthix': skill = 'Fist of Guthix'; hstype = 'score';break; case 'ma': case 'armies': case 'mobilising': skill = 'Mobilising Armies'; hstype = 'score';break; case 'baa': case 'baattack': case 'baattacker': case 'attacker': skill = 'Barbarian Assault Attacker'; hstype = 'score';break; case 'bad': case 'badef': case 'badefender': case 'defender': skill = 'Barbarian Assault Defender'; hstype = 'score';break; case 'bac': case 'collector': case 'bacollecter': case 'collecter': case 'bacollect': skill = 'Barbarian Assault Collector'; hstype = 'score';break; case 'bah': case 'bahealer': case 'baheal': case 'healer': skill = 'Barbarian Assault Healer'; hstype = 'score';break; case 'cw': case 'castle': case 'cwars': case 'castlewars': skill = 'Castle Wars'; hstype = 'score';break; case 'conq': case 'conquest': skill = 'Conquest'; hstype = 'score';break; case 'dom': case 'dominion': case 'dt': skill = 'Dominion Tower'; hstype = 'score';break; case 'cru': case 'crucible': case 'cruc': skill = 'Crucible'; hstype = 'rank';break; default: skill = false; }	return skill; }

function hs(player,skill,run,rs07) { var skillData; $.ajax({		url:'http://'+CORSSite+'/get?url=http%3A//services.runescape.com/m%3Dhiscore'+(rs07?'_oldschool':)+'/index_lite.ws%3Fplayer%3D'+player+'&callback=?',		dataType:'json',		success: function(data) {			var stats = data.contents;			skill = toSkillName(skill, rs07);			if (skill) {				if (skill == 'Combat') {					var template = '["","","","","","","",""'+(rs07?:',""')+',]';				} else {					var template = '["","",""]';				}				parse(template, function(response) { run(eval(response.replace(/\n?<\/?p>/g,'')), rs07) });			} else {				run(false)			}		},		error: function(xhr, error) {			if (error == 'timeout') {				inlineAlert('The request took too long to finish and has been cancelled.');			} else {				inlineAlert('AJAX error: ' + error);			}		},		timeout: 7500	}); }

function getCookie( c_name ) { if ( document.cookie.length > 0 ) { var c_start = document.cookie.indexOf( c_name + "=" ) if ( c_start !== -1 ) { c_start = c_start + c_name.length + 1; var c_end = document.cookie.indexOf( ";", c_start ); if ( c_end === -1 ) { c_end = document.cookie.length; }			return unescape( document.cookie.substring( c_start, c_end ) ); } 	}	return ""; }

function xptl(curxp, lvl) { return levels[lvl] - curxp }

function sendQCMessage(msg) { mainRoom.sendMessage({which: 13, shiftKey: false, preventDefault: function {}, target: $(' (qc) '+msg+' ') }) $('[name="message"]').removeAttr('disabled').focus; }

function qc(cmd,pms,priv) { $('[name="message"]').attr('disabled','disabled').val('').blur; setTimeout("$('[name=\"message\"]').removeAttr('disabled').focus", 7500) var params = pms.split(' '); var rs07 = params[2]?(params[2]=='@07'?true:false):(params[1]=='@07'?true:false); var user = params[1]&&params[1]!='@07'?pms.replace(/^.*? /,).replace('@07',):getCookie('ign'); if (cmd == 'tnl') { hs(user,params[0], function(stats, rs07) {			sendQCMessage(xptl(stats[0], stats[1] + 1));		}, rs07); } else if (cmd == 'tl') { hs(user,params[0], function(stats, rs07) {			sendQCMessage(xptl(stats[0], stats[3]));		}, rs07); }	return true; }