//
// Copyright (C) 2004 - 2006 by Pragmatic Solutions, Inc. This document is the
// intellectual property of Pragmatic Solutions, Inc. All rights reserved.
//
/* credit: Special thanks to Ryan Lewis and AACM for many of the screenshots */
/*	EventCache Version 1.0
Copyright 2005 Mark Wubben
Provides a way for automagically removing events from nodes and thus preventing memory leakage.
See <http://novemberborn.net/javascript/event-cache> for more information.
This software is licensed under the CC-GNU LGPL <http://creativecommons.org/licenses/LGPL/2.1/>
*/
if(Array.prototype.push == null){
Array.prototype.push = function(){
for(var i = 0; i < arguments.length; i++){
this[this.length] = arguments[i];
};
return this.length;
};
};
var EventCache = function(){
var listEvents = [];
return {
listEvents : listEvents,
add : function(node, sEventName, fHandler, bCapture){
listEvents.push(arguments);
},
flush : function(){
var i, item;
for(i = listEvents.length - 1; i >= 0; i = i - 1){
item = listEvents[i];
if(item[0].removeEventListener){
item[0].removeEventListener(item[1], item[2], item[3]);
};
if(item[1].substring(0, 2) != "on"){
item[1] = "on" + item[1];
};
if(item[0].detachEvent){
item[0].detachEvent(item[1], item[2]);
};
item[0][item[1]] = null;
};
}
};
}();
// credit: Peter Paul-Kloch www.quirksmode.org
if(document.all && !document.getElementById)
{
document.getElementById = function(id)
{
return document.all[id];
}
}
var core=
{
image_preloads:null,
init:function()
{
if(0) setInterval('core.force_reflow();',5000);
if(0) core.addEvent(window,'resize',core.force_reflow,false);
tpl.init();
sprite.init();
core.image_preloads={};
core.dbug=function(){};
},
addEvent:function(elm,evType,fn,useCapture)
{
if(elm)
{
if(typeof(MetaWrap)!=='undefined' && 1)
{
MetaWrap.Page.Element.addEventListener(elm,evType,fn,useCapture);
}
else
{
// credit: cross-browser event handling for IE5+, NS6, and Mozilla
// credit: by Scott Andrew
if(elm.addEventListener)
{
elm.addEventListener(evType,fn,useCapture);
return true;
}
else
{
if(elm.attachEvent)
{
var r=elm.attachEvent('on'+evType,fn);
if(typeof(EventCache)!='undefined')
{
EventCache.add(elm,evType,fn);
}
return r;
}
else
{
elm['on'+evType]=fn;
return true;
}
}
}
}
else
{
alert('cannot find event target');
}
return false;
},
removeEvent:function(element,event,func,capture)
{
if(element.removeEventListener)
{
element.removeEventListener(event,func,capture);
}
else
{
if(element.detachEvent)
{
element.detachEvent(event,func);
}
else
{
element['on'+event]=null;
}
}
},
startup_fn:[],
addStartup:function(callback)
{
core.startup_fn.push(callback);
},
startup:function()
{
var cs=core.startup_fn;
var n=cs.length;
for(var i=0;i<n;++i)
{
(cs[i])();
}
core.startup_fn=[];
},
shutdown:function()
{
if(typeof(EventCache)!=='undefined')
{
EventCache.flush();
}
if(typeof(MetaWrap)!=='undefined')
{
MetaWrap.Page.deleteListeners();
}
},
show:function(el)
{
if(el.oldDisplay)
{
el.style.display=el.oldDisplay;
}
else
{
el.style.display='block';
}
},
hide:function(el)
{
if(el.style.display)
{
el.oldDisplay=el.style.display;
}
else
{
el.style.display='none';
}
},
toggle_block_display_el:function(el)
{
if(el.style.display=='none')
{
el.style.display='block';
}
else
{
el.style.display='none';
}
},
toggle_block_display:function(id)
{
var el=document.getElementById(id);
if(el)
{
core.toggle_block_display_el(el);
core.force_reflow();
}
else
{
alert('cannot find element');
}
},
toggle_inline_display:function(id)
{
var el=document.getElementById(id);
if(el)
{
if(el.style.display=='none')
{
el.style.display='inline';
}
else
{
el.style.display='none';
}
}
},
force_reflow:function()
{
if(0)
{
document.body.resizeBy(1,0);
}
if(0)
{
window.resizeBy(1,0);
window.resizeBy(-1,0);
}
if(0)
{
window.blur();
}
if(1)
{
document.body.style.width='auto';
document.body.style.width='100%';
}
}
,dbug:function()
{
}
,pixelsplit:function(target_id,direction,separation)
{
// credit: IE workaround
if(document.all)
{
var obl=document.all[target_id];
if(obl)
{
obl.style.styleFloat=direction;
if(direction=='left')
{
obl.style.margin='0 0 0 '+separation;
}
else
{
if(direction=='right')
{
obl.style.margin='0 '+separation+' 0 0';
}
}
}
else
{
}
}
else
{
}
}
,has_class:function(classes,oneclass)
{
return classes.match(RegExp('\\b'+oneclass+'\\b'));
}
,sub_class:function(classes,oneclass)
{
return classes.replace(RegExp('\\s*\\b'+oneclass+'\\b\\s*'),'');
}
,add_class:function(classes,oneclass)
{
return classes.replace(RegExp('\\s*\\b'+oneclass+'\\b\\s*'),'')+' '+oneclass;
}
,preload:function(image_src)
{
if(typeof(core.image_preloads[image_src])=='undefined')
{
var i=new Image();
i.src=image_src;
core.image_preloads[image_src]=i;
}
return core.image_preloads[image_src];
}
,delete_hover_states:function(controller)
{
controller.onmouseup=null;
controller.onmouseover=null;
controller.onmouseout=null;
controller.onmousedown=null;
controller.hover_src=null;
controller.normal_src=null;
controller.click_src=null;
}
,make_hover_states:function(controller,normal_src,hover_src,click_src)
{
var setup_exported_bindings=false;
if(normal_src)
{
core.preload(normal_src);
}
if(hover_src)
{
core.preload(hover_src);
}
if(click_src)
{
core.preload(click_src);
}
var is_hover=false;
var is_click=false;
var uhf=function()
{
controller.src=normal_src;
is_hover=false;
}
var hf=function()
{
controller.src=hover_src;
is_hover=true;
}
var cf=function()
{
controller.src=click_src;
is_click=true;
}
var ucf=function()
{
if(is_hover)
{
hf();
}
else
{
uhf();
}
is_click=false;
}
uhf();
if(1)
{
if(hover_src)
{
controller.onmouseover=hf;
controller.onmouseout=uhf;
}
if(click_src)
{
controller.onmousedown=cf;
controller.onmouseup=ucf;
}
if(setup_exported_bindings)
{
controller.hover_src=hf;
controller.normal_src=uhf;
controller.click_src=cf;
}
}
if(0)
{
if(normal_src)
{
core.preload(normal_src);
}
if(hover_src)
{
core.preload(hover_src);
}
if(click_src)
{
core.preload(click_src);
}
}
controller.className="A8d0a4";
}
,make_button_states:function(operation,
controller_id,
normal_callback,
hover_callback,
click_callback,
setup_exported_bindings)
{
var controller=document.getElementById(controller_id);
if(controller)
{
if(operation=='add')
{
var is_hover=false;
var is_click=false;
var uhf=function()
{
normal_callback();
is_hover=false;
}
var hf=function()
{
hover_callback();
is_hover=true;
}
var cf=function()
{
click_callback();
is_click=true;
}
var ucf=function()
{
if(is_hover)
{
hf();
}
else
{
uhf();
}
is_click=false;
}
uhf();
if(1)
{
if(hover_callback)
{
controller.onmouseover=hf;
controller.onmouseout=uhf;
}
if(click_callback)
{
controller.onmousedown=cf;
controller.onmouseup=ucf;
controller.style.cursor='pointer';
}
if(setup_exported_bindings)
{
controller.normal_callback=normal_callback;
controller.hover_callback=hover_callback;
controller.click_callback=click_callback;
}
}
}
if(operation=='delete')
{
controller.onmouseup=null;
controller.onmouseover=null;
controller.onmouseout=null;
controller.onmousedown=null;
controller.hover_callback=null;
controller.normal_callback=null;
controller.click_callback=null;
}
}
else
{
core.dbug('invalid controller id:'+controller_id);
}
}
,delete_controller_icon:function(controller_id)
{
var controller=document.getElementById(controller_id);
if(controller)
{
core.delete_hover_states(controller);
}
}
,make_controller_icon:function(controller_id,icon_prefix,module_name)
{
var controller=document.getElementById(controller_id);
if(controller)
{
var normal_src='./module//AAMBS/controller_icons/PREFIX.png';
var hover_src='./module//AAMBS/controller_icons/PREFIX_h.png';
normal_src=normal_src.replace(/PREFIX/,icon_prefix);
hover_src=hover_src.replace(/PREFIX/,icon_prefix);
if(module_name)
{
normal_src=normal_src.replace(/AAMBS/,module_name);
hover_src=hover_src.replace(/AAMBS/,module_name);
}
core.make_hover_states(controller,normal_src,hover_src);
}
}
,make_sprite_controller_icon:function(controller_id,
sprite_code_prefix_normal,
sprite_code_prefix_hover,
sprite_code_prefix_click,
module_name,
normal_callback,
hover_callback,
click_callback)
{
var sprite_tile_name='';
if(module_name)
{
sprite_tile_name=module_name+'_';
}
sprite_tile_name+='controller_icons';
sprite.make_sprite_element(controller_id,sprite_tile_name);
if(sprite_code_prefix_normal)
{
sprite.define_sprite_mode(controller_id,'normal',sprite_code_prefix_normal);
}
if(sprite_code_prefix_hover)
{
sprite.define_sprite_mode(controller_id,'hover',sprite_code_prefix_hover);
}
if(sprite_code_prefix_click)
{
sprite.define_sprite_mode(controller_id,'click',sprite_code_prefix_click);
}
var normal_fn=function()
{
if(sprite_code_prefix_normal)
{
sprite.set_sprite_mode(controller_id,'normal');
}
if(normal_callback)
{
normal_callback(controller_id,sprite_code_prefix_normal,module_name);
}
}
var hover_fn=function()
{
if(sprite_code_prefix_hover)
{
sprite.set_sprite_mode(controller_id,'hover');
}
if(hover_callback)
{
hover_callback(controller_id,sprite_code_prefix_hover,module_name);
}
}
var click_fn=function()
{
if(sprite_code_prefix_click)
{
sprite.set_sprite_mode(controller_id,'click');
}
if(click_callback)
{
click_callback(controller_id,sprite_code_prefix_click,module_name);
}
}
core.make_button_states('add',controller_id,normal_fn,hover_fn,click_fn);
}
,delete_sprite_controller_icon:function(controller_id)
{
var controller=document.getElementById(controller_id);
if(controller)
{
core.make_button_states('delete',controller_id);
}
}
,make_controller_icon_s:function(controller_id,normal_src,hover_src,click_src)
{
var controller=document.getElementById(controller_id);
if(controller)
{
core.make_hover_states(controller,normal_src,hover_src,click_src);
}
else
{
core.dbug('cannot find controller:'+controller_id);
}
}
,profile_time:function()
{
var date=new Date();
var time0=date.getTime();
return time0;
}
};
var o;
var mymbs=
{
favorite_player_control:null,
favorite_server_control:null,
init:function()
{
}
,register_mymbs_favorite_player_control:function(target_id)
{
mymbs.favorite_player_control=target_id;
}
,register_mymbs_favorite_server_control:function(target_id)
{
mymbs.favorite_server_control=target_id;
}
,make_controller_icon_e:function(row,controller_id,controller_size)
{
var controller=document.getElementById(controller_id);
if(controller)
{
var normal_src='./module//AAMBS/controller_icons/PREFIX.png';
var hover_src='./module//AAMBS/controller_icons/PREFIX_h.png';
var icon_prefix;
var title;
if(row.is_favorite)
{
icon_prefix='remove';
title='Remove '+row.data_type+' from My MBS';
}
else
{
icon_prefix='add';
title='Add '+row.data_type+' to My MBS';
}
if(controller_size!=='medium')
{
icon_prefix+='_'+controller_size;
}
normal_src=normal_src.replace(/PREFIX/,icon_prefix);
hover_src=hover_src.replace(/PREFIX/,icon_prefix);
core.make_hover_states(controller,normal_src,hover_src);
controller.title=title;
}
}
,delete_controller_icon:function(row)
{
var controller_id=row.controller_id;
var controller=document.getElementById(controller_id);
if(controller)
{
core.delete_hover_states(controller);
controller.title=null;
}
}
,make_controller_icon:function(row)
{
var controller_id=row.controller_id;
var controller=document.getElementById(controller_id);
if(controller)
{
var normal_src='./module//AAMBS/controller_icons/PREFIX.png';
var hover_src='./module//AAMBS/controller_icons/PREFIX_h.png';
var icon_prefix;
var title;
if(row.is_favorite)
{
icon_prefix='remove';
title='Remove '+row.data_type+' from My MBS';
}
else
{
icon_prefix='add';
title='Add '+row.data_type+' to My MBS';
}
if(row.controller_size!=='medium')
{
icon_prefix+='_'+row.controller_size;
}
normal_src=normal_src.replace(/PREFIX/,icon_prefix);
hover_src=hover_src.replace(/PREFIX/,icon_prefix);
core.make_hover_states(controller,normal_src,hover_src);
controller.title=title;
}
}
,make_sprite_controller_icon:function(operation,row)
{
var controller_id=row.controller_id;
var controller=document.getElementById(controller_id);
if(controller)
{
if(operation=='add')
{
var icon_prefix;
var title;
if(row.is_favorite)
{
icon_prefix='remove';
title='Remove '+row.data_type+' from My MBS';
}
else
{
icon_prefix='add';
title='Add '+row.data_type+' to My MBS';
}
if(row.controller_size!=='medium')
{
icon_prefix+='_'+row.controller_size;
}
core.make_sprite_controller_icon(controller_id,icon_prefix,icon_prefix+'_h',null,'AAMBS');
controller.title=title;
}
if(operation=='delete')
{
core.delete_sprite_controller_icon(controller_id);
controller.title=null;
}
}
}
,toggle_favorite_callback:function(row,del_cmd,add_cmd,e,f)
{
var controller_id=null;
var controller=null;
if(row.controller_id)
{
controller_id=row.controller_id;
controller=document.getElementById(controller_id);
}
var favorite_img_id=null;
var favorite_img=null;
if(row.favorite_img_id)
{
favorite_img_id=row.favorite_img_id;
favorite_img=document.getElementById(favorite_img_id);
}
var parts=f.split('\n');
var code=parts[0];
var cmd=parts[1];
var id=parts[2];
var name=parts[3];
var response=parts[4];
if(code=='OK')
{
if(cmd==del_cmd)
{
row.is_favorite=0;
}
else
{
if(cmd==add_cmd)
{
row.is_favorite=1;
}
}
if(controller)
{
mymbs.make_controller_icon(row);
}
if(favorite_img)
{
if(row.is_favorite)
{
favorite_img.style.display='inline';
}
else
{
favorite_img.style.display='none';
}
}
if(0)
{
if(row.data_type=='player')
{
if(mymbs.favorite_player_control)
{
modclient.refresh(mymbs.favorite_player_control);
}
}
else
{
if(mymbs.favorite_server_control)
{
if(row.data_type=='server')
{
modclient.refresh(mymbs.favorite_server_control);
}
}
}
}
}
else
{
alert(response);
}
}
,toggle_favorite:function(row)
{
var del_cmd='del_'+row.data_type;
var add_cmd='add_'+row.data_type;
var cb=function(e,f)
{
mymbs.toggle_favorite_callback(row,del_cmd,add_cmd,e,f);
}
var cmd='';
if(row.is_favorite)
{
cmd=del_cmd;
}
else
{
cmd=add_cmd;
}
modclient.send_modulemessage('MyMBS','cmd='+cmd+'&id='+row.enc_id+'&name='+row.enc_name,null,cb);
}
};
var tpl=
{
key_begin:'tpl\\\('
,key_end:'\\\)'
,key_flags:'ig'
,section_key:/%%begin_section\[([^\]]+?)\]%%(\r?\n)?((.|\r?\n)*?)%%end_section\[(\1)\]%%(\r?\n)?/i
,feature_delimiter:/\|/
,regex_keys:{}
,template_key:/tpl\(([^\)]*?)\)/ig
,argument_key:/^([^\[]+)(\[([^\]]*?)\])?/i
,global_keys:{}
,init:function()
{
tpl.add_key_regex('row');
tpl.add_key_regex('row_index');
tpl.add_key_regex('index');
}
,make_key_regex:function(key)
{
var pattern=tpl.key_begin+key+tpl.key_end;
return new RegExp(pattern,tpl.key_flags);
}
,add_key_regex:function(key)
{
tpl.regex_keys[key]=tpl.make_key_regex(key);
}
,get_key_regex:function(key)
{
if(typeof(tpl.regex_keys[key])=='undefined')
{
tpl.add_key_regex(key);
}
return tpl.regex_keys[key];
}
,make_regex_keys:function(data_row)
{
for(var key in data_row)
{
tpl.add_key_regex(key);
}
}
,replace:function(str,key,value)
{
var key_regex=tpl.get_key_regex(key);
return str.replace(key_regex,value);
}
,select_section:function(str,features)
{
while(true)
{
var matches=str.match(tpl.section_key);
if(matches)
{
var feature_list=matches[1];
var split_features=feature_list.split(tpl.feature_delimiter);
var pass=false;
for(var f in split_features)
{
var feature=split_features[f];
if(typeof(features[feature])!=='undefined')
{
pass=features[feature];
}
}
if(pass)
{
str=str.replace(tpl.section_key,'$3');
}
else
{
str=str.replace(tpl.section_key,'');
}
if(0)
{
}
}
else
{
break;
}
}
return str;
}
,replace_attribute:function(key,arg,match,data)
{
if(typeof(data)=='object')
{
if(typeof(data[key])!=='undefined')
{
return data[key];
}
}
return match;
}
,check_callback:function(key,arg,match,data)
{
core.dbug('remnant match:'+match);
return 'LALA';
}
,run_template:function(template,
global_record,
constant_record,
row_records,
start,
length,
callback,
thisobj)
{
var key=null;
var html=[];
if(typeof(callback)=='undefined')
{
callback=tpl.replace_attribute;
}
if(template.begin)
{
html.push(template.begin);
}
if(row_records)
{
if(template.middle)
{
if(typeof(start)=='undefined')
{
start=0;
}
else
{
if(start>=row_records.length)
{
start=row_records.length-1;
}
if(start<0)
{
start=0;
}
}
var maxlength=row_records.length-start;
if(typeof(length)=='undefined')
{
length=maxlength;
}
else
{
if(length>maxlength)
{
length=maxlength;
}
if(length<0)
{
length=0;
}
}
var n=length;
var index=start;
while(n--)
{
var row=row_records[index];
var result=template.middle;
result=tpl.replace_callback(result,callback,row,thisobj);
html.push(result);
++index;
}
}
}
else
{
length=0;
start=0;
}
if(template.end)
{
html.push(template.end);
}
html=html.join('');
if(html)
{
if(global_record)
{
html=tpl.replace_callback(html,callback,global_record,thisobj);
}
if(constant_record)
{
html=tpl.replace_callback(html,callback,constant_record,thisobj);
}
}
return html;
}
,replace_template:function(template,
global_record,
constant_record,
callback,
thisobj)
{
var complex_template=
{
begin:template
,middle:null
,end:null
};
var result=tpl.run_template(complex_template,
global_record,
constant_record,
null,
0,0,
callback,
thisobj);
return result;
}
,parse_key_argument:function(rawkey)
{
var key='';
var arg='';
var matches=rawkey.match(tpl.argument_key);
var n=matches.length;
if(0)
{
var i=0;
while(i<matches.length)
{
core.dbug('match:'+i+':'+matches[i]);
++i;
}
}
if(matches.length==2)
{
key=matches[2];
}
else
{
if(matches.length==4)
{
key=matches[1];
arg=matches[3];
}
else
{
core.dbug('key argument error');
}
}
return {key:key,arg:arg};
}
,dispatch_key_argument:function(callback,data,thisobj)
{
return function()
{
var keyarg=tpl.parse_key_argument(arguments[1]);
var key=keyarg.key;
var arg=keyarg.arg;
var match=arguments[0];
var result;
if(thisobj)
{
result=callback.call(thisobj,key,arg,match,data);
}
else
{
result=callback(key,arg,match,data);
}
return result;
}
}
,replace_callback:function(string,callback,data,thisobj)
{
var dispatch_function=tpl.dispatch_key_argument(callback,data,thisobj);
var result=string.replace(tpl.template_key,dispatch_function);
dispatch_function=null;
return result;
}
,test_parse_section:function()
{
var input=
'first\n'+
'%%BEGIN_SECTION[lala]%%\n'+
'inner\r\n'+
'%%bEgIn_sEcTiOn[foofoo]%%\n'+
'nested\n'+
'%%END_SECTION[foofoo]%%\n'+
'%%begin_section[tootoo|lala]%%\n'+
'compound\n'+
'%%END_section[tootoo|lala]%%\n'+
'%%bEgIn_sEcTiOn[barbar]%%inline%%END_SECTION[barbar]%%\n'+
'%%END_SECTION[lala]%%\r\n'+
'outer\n'+
'';
var testmatrix=
[
{
features:{lala:1,foofoo:0,barbar:0,tootoo:0},
expected:
'first\n'+
'inner\r\n'+
'compound\n'+
'outer\n'
},
{
features:{lala:1,foofoo:0,barbar:1,tootoo:0},
expected:
'first\n'+
'inner\r\n'+
'compound\n'+
'inline'+
'outer\n'
},
{
features:{lala:1,foofoo:1,barbar:0,tootoo:0},
expected:
'first\n'+
'inner\r\n'+
'nested\n'+
'compound\n'+
'outer\n'
},
{
features:{lala:1,foofoo:1,barbar:1,tootoo:0},
expected:
'first\n'+
'inner\r\n'+
'nested\n'+
'compound\n'+
'inline'+
'outer\n'
},
{
features:{lala:0,foofoo:0,barbar:0,tootoo:0},
expected:
'first\n'+
'outer\n'
},
{
features:{lala:0,foofoo:0,barbar:1,tootoo:0},
expected:
'first\n'+
'outer\n'
},
{
features:{lala:0,foofoo:1,barbar:0,tootoo:0},
expected:
'first\n'+
'outer\n'
},
{
features:{lala:0,foofoo:1,barbar:1,tootoo:0},
expected:
'first\n'+
'outer\n'
},
{
features:{lala:1,foofoo:0,barbar:0,tootoo:1},
expected:
'first\n'+
'inner\r\n'+
'compound\n'+
'outer\n'
},
{
features:{lala:1,foofoo:0,barbar:1,tootoo:1},
expected:
'first\n'+
'inner\r\n'+
'compound\n'+
'inline'+
'outer\n'
},
{
features:{lala:1,foofoo:1,barbar:0,tootoo:1},
expected:
'first\n'+
'inner\r\n'+
'nested\n'+
'compound\n'+
'outer\n'
},
{
features:{lala:1,foofoo:1,barbar:1,tootoo:1},
expected:
'first\n'+
'inner\r\n'+
'nested\n'+
'compound\n'+
'inline'+
'outer\n'
},
{
features:{lala:0,foofoo:0,barbar:0,tootoo:1},
expected:
'first\n'+
'outer\n'
},
{
features:{lala:0,foofoo:0,barbar:1,tootoo:1},
expected:
'first\n'+
'outer\n'
},
{
features:{lala:0,foofoo:1,barbar:0,tootoo:1},
expected:
'first\n'+
'outer\n'
},
{
features:{lala:0,foofoo:1,barbar:1,tootoo:1},
expected:
'first\n'+
'outer\n'
}
];
var n=testmatrix.length;
var i=0;
var failures=0;
while(n--)
{
var tmi=testmatrix[i];
var features=tmi.features;
var expected=tmi.expected;
var result=tpl.select_section(input,features);
if(result!=expected)
{
core.dbug('expected:\n'+expected);
core.dbug('got:\n'+result);
++failures;
}
++i;
}
if(failures)
{
core.dbug('parse_section unit test failed '+failures+' times');
return false;
}
return true;
}
,test_replace_callback:function()
{
var fn=function(key,arg,match,data)
{
var result='';
switch(key)
{
case 'testme':
result+=arg;
break;
case 'testyou':
result+='-'+arg+'-';
break;
case 'de':
result+=key+arg;
break;
case 'dat':
result+=data.odd;
break;
case 'match':
result+=match;
break;
case 'recursive':
var subkey='testyou';
var subarg='subarg';
result+=fn(subkey,subarg,match,data);
break;
default:
var subresult=tpl.replace_attribute(key,arg,null,data);
if(subresult!==null)
{
result+=subresult;
}
else
{
result+=match;
}
break;
}
return result;
}
var input='this tpl(testme[thearg]) that tpl(testyou[anarg]) those\ntpl(semi) hemi tpl(de[mi])\ntpl(dat)\r\ntpl(random)\r\ntpl(recursive)';
var data={odd:'true',random:parseInt(Math.random()*10)};
var anarg='-anarg-';
var subarg='-subarg-';
var expected='this thearg that '+anarg+' those\ntpl(semi) hemi demi\n'+data.odd+'\r\n'+data.random+'\r\n'+subarg;
var result=tpl.replace_callback(input,fn,data);
if(result!==expected)
{
core.dbug('expected ('+expected.length+' bytes):\n'+expected);
core.dbug('got ('+result.length+' bytes):\n'+result);
return false;
}
return true;
}
,test_replace_callback_oo:function()
{
function Lala()
{
this.lala='yeah';
}
Lala.prototype.fn=function(key,arg,match,data)
{
var result='';
switch(key)
{
case 'testme':
result+=arg;
break;
case 'testyou':
result+='-'+arg+'-';
break;
case 'de':
result+=key+arg;
break;
case 'dat':
result+=data.odd;
break;
case 'match':
result+=match;
break;
case 'recursive':
var subkey='testyou';
var subarg='subarg';
result+=this.fn(subkey,subarg,match,data);
break;
default:
var subresult=tpl.replace_attribute(key,arg,null,data);
if(subresult!==null)
{
result+=subresult;
}
else
{
result+=match;
}
break;
}
return result;
}
var input='this tpl(testme[thearg]) that tpl(testyou[anarg]) those\ntpl(semi) hemi tpl(de[mi])\ntpl(dat)\r\ntpl(random)\r\ntpl(recursive)';
var data={odd:'true',random:parseInt(Math.random()*10)};
var anarg='-anarg-';
var subarg='-subarg-';
var expected='this thearg that '+anarg+' those\ntpl(semi) hemi demi\n'+data.odd+'\r\n'+data.random+'\r\n'+subarg;
var lala=new Lala();
var result=tpl.replace_callback(input,lala.fn,data,lala);
if(result!==expected)
{
core.dbug('expected ('+expected.length+' bytes):\n'+expected);
core.dbug('got ('+result.length+' bytes):\n'+result);
return false;
}
return true;
}
,test_run_template:function()
{
var datarow={};
datarow.lala='hello';
datarow.foo=5;
datarow.bar=2.5;
datarow.array=[];
var data_array=[8,6,7,'-',5,3,0,9];
var n=data_array.length;
var i=0;
while(n--)
{
var dob={};
dob.value=data_array[i];
dob.row_index=i;
dob.index=i;
dob.row=i;
datarow.array.push(dob);
++i;
}
var template={};
template.begin='lala pi=tpl(pi)\ntpl(foo)-tpl(bar)\n';
template.middle ='foo tpl(row_index)/tpl(index)/tpl(row) lala\n';
template.middle+='two value=tpl(value)\n';
template.end='foobar last length=tpl(length)\n';
var constant_keys={};
constant_keys.pi='3.14159';
var template_keys={};
datarow.length='52 meters';
var result=tpl.run_template(template,datarow,constant_keys,datarow.array,1,datarow.array.length-2);
var expected=
'lala pi=3.14159\n'+
'5-2.5\n'+
'foo 1/1/1 lala\n'+
'two value=6\n'+
'foo 2/2/2 lala\n'+
'two value=7\n'+
'foo 3/3/3 lala\n'+
'two value=-\n'+
'foo 4/4/4 lala\n'+
'two value=5\n'+
'foo 5/5/5 lala\n'+
'two value=3\n'+
'foo 6/6/6 lala\n'+
'two value=0\n'+
'foobar last length=52 meters\n'+
'';
if(result!==expected)
{
document.write('<pre>');
document.write('expected:\n');
document.write(expected);
document.write('got:\n');
document.write(result);
document.write('</pre>');
return false;
}
return true;
}
,test:function()
{
if(!tpl.test_parse_section())
{
core.dbug('test_parse_section failed');
return false;
}
if(!tpl.test_replace_callback())
{
core.dbug('test_replace_callback failed');
return false;
}
if(!tpl.test_run_template())
{
core.dbug('test_run_template failed');
return false;
}
if(!tpl.test_replace_callback_oo())
{
core.dbug('test_replace_callback_oo failed');
return false;
}
return true;
}
};
var sprite=
{
sprite:null
,icon_class_table:null
,transparent_src:'images/transparent.gif'
,init:function()
{
sprite.icon_class_table={};
}
,make_icon:function(icon_class,
sprite_class_prefix,
sprite_code,
attributes)
{
var icon='<img src="images/transparent.gif" class="'+icon_class+' '+sprite_class_prefix+sprite_code+'"';
if(typeof(attributes)=='object')
{
for(var a in attributes)
{
icon+=' '+a+'="'+attributes[a]+'"';
}
}
else
{
icon+=' '+attributes;
}
icon+='>';
return icon;
}
,make_sprite:function(tile_name,
sprite_code,
attributes)
{
var tiledef=sprite.sprite_class_table[tile_name];
var icon='';
if(tiledef)
{
icon+='<img src="'+sprite.transparent_src+'"';
icon+=' class="';
if(sprite_code!=='world_custom')
{
icon+=tiledef.aux_class+' ';
}
icon+=tiledef.prefix+' '+tiledef.prefix+'_'+sprite_code+'"';
if(typeof(attributes)=='object')
{
for(var a in attributes)
{
var html_a=core.htmlentities(attributes[a]);
icon+=' '+a+'="'+html_a+'"';
}
}
else
{
if(attributes)
{
icon+=' '+attributes;
}
}
icon+='>';
}
return icon;
}
,get_sprite_class:function(tile_name,sprite_code)
{
var tiledef=sprite.sprite_class_table[tile_name];
var result='';
if(tiledef)
{
result+=tiledef.aux_class+' '+tiledef.prefix+' '+tiledef.prefix+'_'+sprite_code;
}
return result;
}
,define_sprite_mode:function(element_id,mode,sprite_code)
{
var element=document.getElementById(element_id);
if(element)
{
if(typeof(element.sprite_codes)=='undefined')
{
element.sprite_codes={};
}
element.sprite_codes[mode]=sprite_code;
}
else
{
core.dbug('invalid element:'+element_id);
}
}
,set_sprite_mode:function(element_id,mode)
{
var element=document.getElementById(element_id);
if(element)
{
if(typeof(element.old_class)=='undefined')
{
element.old_class=element.className;
}
if(typeof(element.tiledef)!=='undefined')
{
var tiledef=element.tiledef;
if(typeof(element.sprite_codes)!=='undefined')
{
if(typeof(element.sprite_codes[mode])!=='undefined')
{
var sprite_code=element.sprite_codes[mode];
var element_class=element.old_class;
if(element_class)
{
element_class+=' ';
}
if(sprite_code!=='world_custom')
{
element_class+=tiledef.aux_class+' ';
}
element_class+=tiledef.prefix+' '+tiledef.prefix+'_'+sprite_code;
element.className=element_class;
}
else
{
core.dbug('invalid sprite mode:'+mode);
}
}
else
{
core.dbug('missing sprite_codes object');
}
}
else
{
core.dbug('no tiledef');
}
}
else
{
core.dbug('invalid element:'+element_id);
}
}
,make_sprite_element:function(element_id,tile_name,sprite_code)
{
var tiledef=sprite.sprite_class_table[tile_name];
var icon='';
if(tiledef)
{
var element=document.getElementById(element_id);
if(element)
{
element.tiledef=tiledef;
element.src=sprite.transparent_src;
if(typeof(sprite_code)!=='undefined')
{
sprite.define_sprite_mode(element_id,'normal',sprite_code);
sprite.set_sprite_mode(element_id,'normal');
}
}
else
{
core.dbug('cannot find element:'+element_id);
}
}
else
{
core.dbug('invalid sprite tile name:'+tile_name);
}
}
};
function Module(class_name)
{
this.parent_target_id=null;
}
Module.prototype=
{
class_name:''
,id_name:''
,module_register:function(module_registry0)
{
module_registry0(this);
this.register();
}
,register:function()
{
}
,module_execute:function()
{
return this.execute();
}
,execute:function()
{
}
,module_deregister:function()
{
this.deregister();
}
,deregister:function()
{
}
};
function Affb78()
{
}
Affb78.prototype=new Module(Affb78);
Affb78.prototype.make_split=function(width,unit,separation,left_code,right_code)
{
var template='<table cellspacing=0 cellpadding="0" border=0 width="100%" style="width:100%;"><tr valign=top><td style="width:LEFT_WIDTH;"><div>LEFT_CODE</div></td><td style="width:SEPARATION;"><div style="width:0px;height:0;overflow:hidden;">&nbsp;</div></td><td style="width:RIGHT_WIDTH;"><div>RIGHT_CODE</div></td></tr></table>';
var scale=100.0;
var separation_over_2=separation/2;
var lwidth=width-separation_over_2;
var rwidth=scale-separation_over_2-width;
lwidth+=unit;
rwidth+=unit;
separation+=unit;
var result=template;
result=result.replace(/\bLEFT_WIDTH\b/,lwidth);
result=result.replace(/\bRIGHT_WIDTH\b/,rwidth);
result=result.replace(/\bSEPARATION\b/,separation);
result=result.replace(/\bLEFT_CODE\b/,left_code);
result=result.replace(/\bRIGHT_CODE\b/,right_code);
return result;
}
var registry_unloads=[];
var module_registry=function(module_ref)
{
module_ref.parent_target_id=null;
registry_unloads.push(module_ref);
};
var IE_BUGGY=true;
var MOZ_BUGGY=true;
var server_type=
{
select_mode:function(htmldoc)
{
var select_field = htmldoc.getElementById("server_mode");
var official_element = htmldoc.getElementById("official_flag");
var leased_element = htmldoc.getElementById("leased_flag");
var eta_element = htmldoc.getElementById("eta_flag");
switch(select_field.value)
{
case "0":
official_element.setAttribute("value", "0");
leased_element.setAttribute("value", "0");
eta_element.setAttribute("value", "");
break
case "1":
official_element.setAttribute("value", "1");
leased_element.setAttribute("value", "");
eta_element.setAttribute("value", "");
break
case "3":
official_element.setAttribute("value", "1");
leased_element.setAttribute("value", "0");
eta_element.setAttribute("value", "0");
break
case "4":
official_element.setAttribute("value", "");
leased_element.setAttribute("value", "1");
eta_element.setAttribute("value", "");
break
case "103":
official_element.setAttribute("value", "");
leased_element.setAttribute("value", "");
eta_element.setAttribute("value", "1");
break
default:
official_element.setAttribute("value", "");
leased_element.setAttribute("value", "");
eta_element.setAttribute("value", "");
break
}
}
}
var modclient=
{
targets:null
,dispatch_table:null
,deregister:function()
{
if(1)
{
var nu=registry_unloads.length;
while(nu--)
{
registry_unloads[nu].module_deregister();
}
registry_unloads=[];
}
for(var b in modclient.targets)
{
modclient.delete_periodic_refresh(b);
}
}
,init:function()
{
modclient.targets={};
modclient.init_dispatch_table();
core.addEvent(window,'unload',modclient.deregister,false);
}
,construct_url:function(script,client,clientargs)
{
if(clientargs)
{
clientargs='&'+clientargs;
}
else
{
clientargs='';
}
var url=script+'?client='+client+clientargs;
if(0)
{
url+='&module_index=1000';
}
return url;
},
refresh_client:function(target_id)
{
var target=modclient.targets[target_id];
if(target)
{
modclient.send_client_request(target_id);
}
},
send_client_request:function(target_id)
{
var target=modclient.targets[target_id];
if(target)
{
var url=modclient.construct_url('/moduleserver.php',target.client,target.clientargs);
var callback=function(target_id,responseText)
{
modclient.receive_client(target_id,responseText);
delete(callback);
};
modclient.send_xmlhttprequest_ext(target.xmlhttp,url,target_id,callback);
}
},
send_xmlhttprequest_ext:function(xmlhttp,url,context,callback)
{
if(1)
{
var date=new Date();
url+='&time='+date.getTime();
}
(function(){
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4)
{
if(xmlhttp.status==200)
{
if(callback)
{
var text;
if(0)
{
text=new String(xmlhttp.responseText);
callback(context,text);
}
else
{
callback(context,xmlhttp.responseText);
}
}
// credit: IE memory leak workaround: mishoo
(function(){
setTimeout(function(){
xmlhttp.onreadystatechange=function(){};
xmlhttp.abort();
delete(date);
},1);
})();
}
else
{
if(0)
{
core.dbug('failed..resending');
setTimeout(xmlhttp.send,10000);
}
}
}
};
})();
var async=true;
xmlhttp.open('GET',url,async);
xmlhttp.send(null);
},
send_xmlhttprequest:function(url,context,callback)
{
if(1)
{
var date=new Date();
url+='&time='+date.getTime();
}
var xmlhttp=new XMLHttpRequest();
xmlhttp.open('GET',url,true);
if(0)
{
var test=[];
alert(xmlhttp);
alert(xmlhttp.onload);
for(var i in xmlhttp)
{
test.push(i);
}
alert(test.join(','));
lkajsdf();
}
(function(){
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4)
{
if(xmlhttp.status==200)
{
if(callback)
{
var text;
if(0)
{
text=new String(xmlhttp.responseText);
callback(context,text);
}
else
{
callback(context,xmlhttp.responseText);
}
}
// credit: IE memory leak workaround
xmlhttp.onreadystatechange=function(){};
xmlhttp.abort();
xmlhttp=null;
}
else
{
if(0)
{
core.dbug('failed..resending');
setTimeout(xmlhttp.send,10000);
}
}
}
};
})();
xmlhttp.send(null);
},
init_dispatch_table:function()
{
var table=[];
table['html.core']=function(section,target_id)
{
var target=modclient.targets[target_id];
if(target)
{
var element=document.getElementById(target.target_id);
if(element)
{
element.innerHTML=section.data;
delete(section.data);
}
}
};
table['html.title']=function(section,target_id)
{
var target=modclient.targets[target_id];
if(target)
{
if(target.title_container_id)
{
var container=document.getElementById(target.title_container_id);
if(container)
{
container.innerHTML=section.data;
delete(section.data);
}
}
}
};
table['html.controller']=function(section,target_id)
{
var target=modclient.targets[target_id];
if(target)
{
if(target.controller_container_id)
{
var container=document.getElementById(target.controller_container_id);
if(container)
{
container.innerHTML=section.data;
delete(section.data);
}
}
}
};
modclient.dispatch_table=table;
}
,print_target_node:function(target_id)
{
var q='';
var target=modclient.targets[target_id];
if(target)
{
q='target node:'+target_id+':\n';
for(var b in target.subtargets)
{
var s=modclient.print_target_node(b);
}
q+=s;
}
else
{
core.dbug('invalid target:'+target_id);
}
return q;
}
,print_target_tree:function()
{
for(target_id in modclient.targets)
{
var q=modclient.print_target_node(target_id);
}
}
,stop_subtarget_refresh:function(is_top,target_id)
{
var target=modclient.targets[target_id];
if(target)
{
for(var b in target.subtargets)
{
var subtarget=modclient.targets[b];
if(subtarget)
{
modclient.stop_subtarget_refresh(0,b);
}
else
{
}
}
if(0)
{
if(is_top)
{
target.subtargets={};
}
else
{
modclient.stop_periodic_refresh(target_id);
if(0)
{
if(1)
{
modclient.delete_periodic_refresh(target_id);
}
else
{
delete(modclient.targets[target_id]);
}
}
}
}
else
{
modclient.stop_periodic_refresh(target_id);
}
}
}
,enable_loading_prompt:function(target_id)
{
var target=modclient.targets[target_id];
if(target)
{
if(target.loading_prompt)
{
var loading_prompt=target.loading_prompt;
if(target.loading_prompt_target_id)
{
var prompt_target_id=target.loading_prompt_target_id;
var prompt_target=document.getElementById(prompt_target_id);
if(prompt_target)
{
prompt_target.innerHTML=loading_prompt;
}
else
{
core.dbug('cannot find prompt target:'+prompt_target_id);
}
}
else
{
var element=document.getElementById(target.target_id);
if(element)
{
element.innerHTML=loading_prompt;
}
}
}
}
}
,disable_loading_prompt:function(target_id)
{
var target=modclient.targets[target_id];
if(target)
{
if(target.loading_prompt_target_id)
{
var prompt_target_id=target.loading_prompt_target_id;
var prompt_target=document.getElementById(prompt_target_id);
if(prompt_target)
{
prompt_target.innerHTML='';
}
else
{
core.dbug('cannot find prompt target:'+prompt_target_id);
}
}
}
}
,receive_client_dt:function(target_id,documentText,dispatch_table)
{
var target=modclient.targets[target_id];
if(target)
{
if(1)
{
function module_registry(module_ref)
{
target.registered_object=module_ref;
module_ref.parent_target_id=target_id;
return target_id;
}
}
if(1)
{
var module_register=function(module_id,deregister_callback,module_ref)
{
target.deregister_callback=deregister_callback;
target.module_ref=module_ref;
return target_id;
}
}
if(1)
{
modclient.deregister_client(target_id);
}
if(0)
{
modclient.stop_subtarget_refresh(1,target_id);
}
if(1)
{
modclient.delete_subtargets(target_id);
}
if(1)
{
modclient.flush_events(target_id);
}
if(1)
{
var section={};
section.iterator=0;
while(section.iterator<documentText.length)
{
section=modclient.parse_section(section,documentText);
if(dispatch_table[section.name])
{
dispatch_table[section.name](section,target_id);
}
else
{
switch(section.name)
{
case 'javascript.core':
eval(section.data);
break;
case 'javascript.foot':
eval(section.data);
break;
case 'javascript.lib':
break;
}
}
}
delete(section.data);
delete(section);
}
if(1)
{
modclient.disable_loading_prompt(target_id);
}
if(MOZ_BUGGY)
{
core.force_reflow();
}
if(1)
{
modclient.schedule_refresh(target_id);
}
target.num_refreshes++;
}
},
receive_client:function(target_id,documentText)
{
if(1)
{
var time0=core.profile_time();
}
modclient.receive_client_dt(target_id,documentText,modclient.dispatch_table);
if(1)
{
var time1=core.profile_time();
var dtime=time1-time0;
var target=modclient.targets[target_id];
if(target)
{
var target_name=target.client;
}
}
}
,parse_section:function(section,text)
{
if(section.iterator<text.length)
{
var i=section.iterator;
++i;
while(text.charAt(i)!=='\n')
{
++i;
}
section.name=text.substring(section.iterator+1,i);
if(0) core.dbug('section name:'+section.name);
++i;
var j=i;
while(text.charAt(j)!=='\n')
{
++j;
}
section.length=text.substring(i,j);
section.length=parseInt(section.length);
if(0) core.dbug('section length(number):'+section.length);
++j;
var k=j+section.length;
section.data=text.substring(j,k);
section.iterator=k;
}
return section;
}
,setup_refresh_controller:function(operation,target_id)
{
var target=modclient.targets[target_id];
if(target)
{
var controller_id=target.controller_id;
var cn=document.getElementById(controller_id);
if(cn)
{
if(operation=='add')
{
var fn=function()
{
modclient.refresh(target_id);
}
if(0)
{
if(1)
{
core.addEvent(cn,'click',fn,false);
}
else
{
modclient.addEvent(cn,'click',fn,false,target_id);
}
}
else
{
cn.onclick=fn;
}
}
if(operation=='delete')
{
cn.onclick=null;
}
}
else
{
if(0) core.dbug('controller not found: '+controller_id);
}
}
else
{
core.dbug('target not found: '+target_id);
}
}
,add_binding:function(parent_id,child_id)
{
var parent=modclient.targets[parent_id];
var child=modclient.targets[child_id];
if(child)
{
if(parent)
{
parent.subtargets[child_id]=1;
child.parent_target_id=parent_id;
}
else
{
child.parent_target_id=null;
}
}
}
,delete_binding:function(parent_id,child_id)
{
var parent=modclient.targets[parent_id];
if(parent)
{
if(typeof(parent.subtargets[child])!=='undefined')
{
delete(parent.subtargets[child]);
}
}
var child=modclient.targets[child_id];
if(child)
{
child.parent_target_id=null;
}
}
,add_periodic_refresh:function(client,
clientargs,
target_id,
controller_id,
is_static,
interval,
limit,
controller_container_id,
title_container_id,
parent_target_id,
loading_prompt,
loading_prompt_target_id)
{
if(0)
{
var old_target=modclient.targets[target_id];
if(old_target)
{
core.dbug('old target exists');
}
}
var el=document.getElementById(target_id);
if(el)
{
var target={};
target.client=client;
target.clientargs=clientargs;
target.timer_cancelled=false;
target.target_id=target_id;
target.controller_id=controller_id;
target.is_static=is_static;
if(1)
{
target.interval=interval;
}
else
{
if(interval)
{
target.interval=2000;
}
else
{
target.interval=0;
}
}
target.limit=limit;
target.timer0=null;
target.started=false;
target.paused=false;
target.controller_container_id=controller_container_id;
target.title_container_id=title_container_id;
target.subtargets={};
target.num_refreshes=0;
if(0)
{
loading_prompt='Loading...';
}
target.loading_prompt=loading_prompt;
target.loading_prompt_target_id=loading_prompt_target_id;
target.module_ref=null;
target.event_cache=[];
target.xmlhttp=new XMLHttpRequest();
modclient.targets[target_id]=target;
modclient.add_binding(parent_target_id,target_id);
}
else
{
core.dbug('cannot find target');
}
}
,add_container:function(target_id,
controller_id,
controller_container_id,
title_container_id,
parent_target_id,
loading_prompt,
loading_prompt_target_id)
{
modclient.add_periodic_refresh(null,
null,
target_id,
controller_id,
true,
0,
0,
controller_container_id,
title_container_id,
parent_target_id,
loading_prompt,
loading_prompt_target_id);
}
,delete_container:function(target_id)
{
modclient.delete_periodic_refresh(target_id);
}
,delete_periodic_refresh:function(target_id)
{
var target=modclient.targets[target_id];
if(target)
{
for(var st in target.subtargets)
{
modclient.delete_periodic_refresh(st);
}
modclient.deregister_client(target_id);
if(0)
{
target.xmlhttp.abort();
delete(target.xmlhttp);
}
modclient.delete_foldout_closer(target_id);
modclient.delete_foldout(target_id);
modclient.stop_subtarget_refresh(target_id);
modclient.flush_events(target_id);
modclient.delete_binding(target_id);
delete(modclient.targets[target_id]);
}
}
,delete_subtargets:function(target_id)
{
var target=modclient.targets[target_id];
if(target)
{
for(var st in target.subtargets)
{
modclient.delete_periodic_refresh(st);
}
}
}
,deregister_client:function(target_id)
{
var target=modclient.targets[target_id];
if(target)
{
if(typeof(target.deregister_callback)!=='undefined')
{
target.deregister_callback(target_id);
delete(target.deregister_callback);
target.module_ref=null;
}
if(typeof(target.registered_object)!=='undefined')
{
target.registered_object.module_deregister();
target.registered_object=null;
delete(target.registered_object);
}
}
}
,start_periodic_refresh:function(target_id)
{
var target=modclient.targets[target_id];
if(target)
{
target.paused=false;
var force_restart=false;
if(force_restart)
{
if(target.started)
{
modclient.stop_periodic_refresh(target_id);
}
}
if(!target.started)
{
if(target.limit)
{
var fn=function()
{
modclient.canceltimer(target_id);
delete(fn);
}
setTimeout(fn,target.limit);
}
if(target.is_static)
{
modclient.schedule_refresh(target_id);
}
else
{
modclient.refresh(target_id);
}
target.started=true;
}
else
{
if(0) core.dbug('target already started.');
if(0) alert('target already started');
}
}
else
{
core.dbug('cannot find target:'+target_id);
}
}
,stop_periodic_refresh:function(target_id)
{
var target=modclient.targets[target_id];
if(target)
{
modclient.canceltimer(target_id);
}
}
,pause_periodic_refresh:function(target_id)
{
var target=modclient.targets[target_id];
if(target)
{
if(!target.paused)
{
target.paused=true;
}
else
{
if(0) core.dbug('target not paused: '+target_id);
}
}
}
,get_target:function(target_id)
{
if(modclient.targets)
{
if(modclient.targets[target_id])
{
return modclient.targets[target_id];
}
}
return null;
},
cleartimer:function(target_id)
{
var target=modclient.targets[target_id];
if(target)
{
if(target.timer0!=null)
{
clearTimeout(target.timer0);
target.timer0=null;
}
}
},
canceltimer:function(target_id)
{
var target=modclient.targets[target_id];
if(target)
{
if(target.timer0!=null)
{
modclient.cleartimer(target_id);
target.timer_cancelled=true;
if(0) core.dbug('limit reached; stopping period refresh.');
}
else
{
if(0) core.dbug('invalid timer');
}
target.started=false;
}
},
refresh:function(target_id)
{
var target=modclient.targets[target_id];
if(target)
{
if(target.controller_id)
{
modclient.setup_refresh_controller('delete',target_id);
}
if(0) core.dbug('refresh');
if(0) core.dbug('interval:'+target.interval);
if(!core.production && 0)
{
var time0=core.profile_time();
}
if(1)
{
modclient.cleartimer(target_id);
}
if(!target.paused)
{
modclient.enable_loading_prompt(target_id);
modclient.refresh_client(target_id);
}
else
{
modclient.schedule_refresh(target_id);
}
if(!core.production && 0)
{
var time1=core.profile_time();
var dtime=time1-time0;
core.dbug('dt:'+dtime);
}
if(target.controller_id)
{
modclient.setup_refresh_controller('add',target_id);
}
}
},
schedule_refresh:function(target_id)
{
var target=modclient.targets[target_id];
if(target)
{
if(target.timer0!=null)
{
modclient.cleartimer(target_id);
}
if(!target.timer_cancelled)
{
if(target.interval)
{
if(target.timer0===null)
{
var interval=target.interval;
interval+=interval*0.1*Math.random();
var fn=function()
{
modclient.refresh(target_id);
delete(fn);
}
target.timer0=setTimeout(fn,interval);
if(0) core.dbug('setting interval');
}
else
{
if(1) core.dbug('timer overlap');
}
}
else
{
if(0) core.dbug(target.interval);
if(0) core.dbug('no interval');
}
}
else
{
if(0) core.dbug('timer was cancelled');
}
}
}
,send_modulemessage:function(client,message,target,callback)
{
var url='modulemessage.php?module='+client+'&'+message;
if(1)
{
var xmlhttp=new XMLHttpRequest();
modclient.send_xmlhttprequest_ext(xmlhttp,url,target,callback);
}
else
{
modclient.send_xmlhttprequest(url,target,callback);
}
}
,add_foldout:function(container_id,
target_id,
foldout_controller_id,
show_foldout_callback,
hide_foldout_callback)
{
var container=document.getElementById(container_id);
if(container)
{
var target=modclient.targets[target_id];
if(target)
{
if(typeof(container.subtargets)!=='undefined')
{
modclient.add_binding(container_id,target_id);
}
if(0)
{
if(typeof(target.parent_container_id)!='undefined')
{
var parent=document.getElementById(target.parent_container_id);
if(parent)
{
target.container_id=target.parent_container_id;
target.container=parent;
}
}
}
{
target.container_id=container_id;
target.container=container;
}
target.show_foldout_callback=show_foldout_callback;
target.hide_foldout_callback=hide_foldout_callback;
var cn=document.getElementById(foldout_controller_id);
if(cn)
{
target.foldout_controller_id=foldout_controller_id;
target.foldout_controller=cn;
target.is_folded_out=false;
if(typeof(container.bindings)=='undefined')
{
container.bindings=[];
}
var binding={};
binding.target_id=target_id;
binding.controller_id=foldout_controller_id;
container.bindings.push(binding);
if(0) core.dbug('id:'+container.bindings[0].target_id);
var element=document.getElementById(target.target_id);
if(0)
{
if(element)
{
element.style.display='none';
}
}
modclient.add_foldout_controller(container,target);
}
else
{
core.dbug('cannot find controller:'+foldout_controller_id);
}
}
else
{
dbug.write('add_foldout: invalid target:'+target_id);
}
}
else
{
dbug.write('add_foldout: cannot find container:'+container_id);
}
}
,delete_foldout:function(target_id)
{
var target=modclient.targets[target_id];
if(target)
{
var container_id=target.container_id;
var container=document.getElementById(container_id);
if(container)
{
var foldout_controller_id=target.foldout_controller_id;
var cn=document.getElementById(foldout_controller_id);
if(cn)
{
modclient.delete_foldout_controller(target);
var element=document.getElementById(target.target_id);
if(element)
{
element.style.display='none';
}
if(1)
{
if(0)
{
delete(container.bindings);
}
else
{
container.bindings=null;
// credit: IE has a problem with deleting this property
}
delete(target.foldout_controller_id);
delete(target.foldout_controller);
target.is_folded_out=false;
}
else
{
container.bindings=null;
target.foldout_controller_id=null;
target.foldout_controller=null;
target.is_folded_out=false;
}
}
else
{
dbug.write('delete_foldout: cannot find controller:'+foldout_controller_id);
}
if(1)
{
delete(target.show_foldout_callback);
delete(target.hide_foldout_callback);
delete(target.container_id);
delete(target.container);
}
if(typeof(container.subtargets)!=='undefined')
{
modclient.delete_binding(container_id,target_id);
}
}
else
{
}
}
else
{
}
}
,add_foldout_closer:function(row_id,foldout_closer_id)
{
var target=modclient.targets[row_id];
if(target)
{
var foldout_closer=document.getElementById(foldout_closer_id);
if(foldout_closer)
{
target.foldout_closer_id=foldout_closer_id;
if(foldout_closer.style.display)
{
foldout_closer.old_display=foldout_closer.style.display;
foldout_closer.style.display='none';
}
else
{
core.dbug('foldout closer inline style display must be set');
lkajsdf();
}
var fn=function()
{
modclient.hide_foldout(row_id);
if(foldout_closer.onmouseout)
{
foldout_closer.onmouseout();
}
}
if(0)
{
core.addEvent(foldout_closer,'click',fn,false);
}
else
{
foldout_closer.onclick=fn;
}
}
else
{
dbug.write('cannot find closer:'+foldout_closer_id);
}
}
else
{
dbug.write('cannot find target:'+row_id);
}
}
,delete_foldout_closer:function(row_id)
{
var target=modclient.targets[row_id];
if(target)
{
var foldout_closer_id=target.foldout_closer_id;
var foldout_closer=document.getElementById(foldout_closer_id);
if(foldout_closer)
{
foldout_closer.onclick=null;
foldout_closer.style.display='none';
delete(target.foldout_closer_id);
}
else
{
}
}
else
{
dbug.write('delete_foldout_closer: cannot find target:'+row_id);
}
}
,add_foldout_controller:function(container,target)
{
var fn=function()
{
modclient.toggle_foldout(target.target_id);
}
if(1)
{
if(0)
{
core.addEvent(target.foldout_controller,'click',fn,false);
}
else
{
target.foldout_controller.onclick=fn;
}
}
else
{
modclient.addEvent(target.foldout_controller,'click',fn,false,target.target_id);
}
}
,delete_foldout_controller:function(target)
{
target.foldout_controller.onclick=null;
}
,hide_all_foldouts:function()
{
}
,hide_foldout:function(target_id)
{
var target=modclient.targets[target_id];
if(target)
{
if(target.is_folded_out)
{
for(var b in target.subtargets)
{
modclient.hide_foldout(b);
}
var controller=target.foldout_controller;
if(target.foldout_closer_id)
{
var foldout_closer=document.getElementById(target.foldout_closer_id);
if(foldout_closer)
{
foldout_closer.style.display='none';
}
}
var element=document.getElementById(target.target_id);
if(element)
{
element.style.display='none';
}
if(target.title_container_id)
{
var title_container=document.getElementById(target.title_container_id);
if(title_container)
{
title_container.style.display='none';
}
}
if(target.controller_container_id)
{
var controller_container=document.getElementById(target.controller_container_id);
if(controller_container)
{
controller_container.style.display='none';
}
}
if(target.hide_foldout_callback)
{
target.hide_foldout_callback(target_id);
}
target.is_folded_out=false;
if(MOZ_BUGGY && 0)
{
core.force_reflow();
}
}
modclient.pause_periodic_refresh(target_id);
}
}
,hide_container_foldouts:function(container_id)
{
var container=document.getElementById(container_id);
if(container)
{
for(var i in container.bindings)
{
modclient.hide_foldout(container.bindings[i].target_id);
}
}
}
,show_foldout:function(target_id)
{
var target=modclient.targets[target_id];
if(target)
{
if(!target.is_folded_out)
{
var container=target.container;
var element=document.getElementById(target.target_id);
if(element)
{
element.style.display='block';
}
if(target.foldout_closer_id)
{
var foldout_closer=document.getElementById(target.foldout_closer_id);
if(foldout_closer)
{
if(foldout_closer.old_display)
{
foldout_closer.style.display=foldout_closer.old_display;
}
}
}
if(target.title_container_id)
{
var title_container=document.getElementById(target.title_container_id);
if(title_container)
{
title_container.style.display='inline';
}
}
if(target.controller_container_id)
{
var controller_container=document.getElementById(target.controller_container_id);
if(controller_container)
{
controller_container.style.display='block';
}
}
if(1)
{
modclient.start_periodic_refresh(target_id);
}
if(target.show_foldout_callback)
{
target.show_foldout_callback(target_id);
}
target.is_folded_out=true;
if(MOZ_BUGGY && 0)
{
core.force_reflow();
}
}
}
}
,toggle_foldout:function(target_id)
{
var target=modclient.targets[target_id];
if(target)
{
var bindings=target.container.bindings;
var n=bindings.length;
while(n--)
{
if(bindings[n].target_id!=target_id)
{
modclient.hide_foldout(bindings[n].target_id);
}
}
if(target.is_folded_out)
{
modclient.hide_foldout(target_id);
}
else
{
modclient.show_foldout(target_id);
}
}
else
{
core.dbug('target not found:'+target_id);
}
}
,hide_foldout_controllers:function()
{
}
,get_foldout_state:function()
{
}
,flush_events:function(target_id)
{
var target=modclient.targets[target_id];
if(target)
{
var event_cache=target.event_cache;
var n=event_cache.length;
while(n--)
{
var ec=event_cache[n];
var element=ec.element;
var event=ec.event;
var func=ec.func;
var capture=ec.capture;
core.removeEvent(element,event,func,capture);
for(var p in element)
{
if(p.substr(0,2)=='on')
{
delete(element[p]);
}
}
delete(ec.element);
delete(ec.func);
}
target.event_cache=[];
}
}
,addEvent:function(el,event,fn,capture,target_id)
{
if(target_id)
{
var target=modclient.targets[target_id];
if(target)
{
var ec={};
ec.element=el;
ec.event=event;
ec.func=fn;
ec.capture=capture;
target.event_cache.push(ec);
core.addEvent(el,event,fn,capture);
}
}
else
{
core.addEvent(el,event,fn,capture);
}
}
}
var dbug=
{
write:function(text)
{
var element=document.getElementById('dbugout0');
if(element)
{
text='<pre>'+core.htmlentities(text)+'</pre>';
element.innerHTML=text+element.innerHTML;
}
}
}
function A7ca28()
{
this.rows=null;
this.row_index=null;
this.template=null;
this.template_keys=null;
this.template_run=null;
this.features=null;
this.sort_handler=null;
this.sort_feature=null;
}
A7ca28.prototype=new Module(A7ca28);
A7ca28.prototype.deregister=function()
{
var o=this;
o.deinit();
}
A7ca28.prototype.init=function()
{
this.rows={};
this.row_index=[];
this.template={};
this.template_features={};
this.template_keys={};
this.features={};
this.sort_handler=null;
this.sort_feature=null;
if(this.features.pager)
{
this.init_pager();
}
this.template_run=true;
if(0)
{
if(Math.random()>0.5)
{
o.template_keys.num_columns=2;
}
else
{
o.template_keys.num_columns=1;
}
}
}
A7ca28.prototype.deinit=function()
{
this.setup_controller_features('delete');
this.init();
}
A7ca28.prototype.hide_datarow=function(row)
{
var delete_index=0;
var n=this.row_index.length;
var on=n;
while(n--)
{
if(this.row_index[delete_index]==row)
{
break;
}
++delete_index;
}
this.row_index.splice(delete_index,1);
if(this.row_index.length!==on-1)
{
dbug.write('problem in delete');
}
this.run();
}
A7ca28.prototype.setup_mymbs_controller=function
(
operation
,row_id
,controller_id
,hide_after_mymbs_remove
,controller_size
,data_type
)
{
var o=this;
var row=o.rows[row_id];
if(row)
{
var controller=document.getElementById(controller_id);
if(controller)
{
var newrow={};
newrow.controller_id=controller_id;
newrow.favorite_img_id=row[data_type+'_favorite_img_id'];
newrow.data_type=data_type;
newrow.is_favorite=row[data_type+'_is_favorite'];
newrow.enc_id=row[data_type+'_enc_id'];
newrow.enc_name=row[data_type+'_enc_name'];
if(operation=='add')
{
if(typeof(controller_size)=='undefined')
{
controller_size='medium';
}
newrow.controller_size=controller_size;
var fn=function()
{
mymbs.toggle_favorite(newrow);
if(hide_after_mymbs_remove && 1)
{
if(newrow.is_favorite)
{
o.hide_datarow(row);
}
}
}
if(1)
{
controller.onclick=fn;
}
mymbs.make_sprite_controller_icon('add',newrow);
}
if(operation=='delete')
{
controller.onclick=null;
mymbs.make_sprite_controller_icon('delete',newrow);
}
}
else
{
if(operation=='add')
{
dbug.write('setup_mymbs_controller: cannot find controller:'+controller_id);
}
}
}
else
{
if(operation=='add')
{
dbug.write('setup_mymbs_controller: cannot find row:'+row_id);
}
}
}
A7ca28.prototype.make_row_id=function(index)
{
return this.template_keys.row_prefix+index;
}
A7ca28.prototype.add_datarow=function
(
data_type
,blocks
)
{
var o=this;
var rows=o.rows;
var row={};
var i;
var aux;
if(1)
{
row.row_index=o.row_index.length;
row.data_type=data_type;
row.row_color=blocks.color;
if(typeof(blocks.player)!=='undefined')
{
i=0;
aux=blocks.player;
row.player_name=aux[i++];
row.player_is_favorite=aux[i++];
row.player_is_online=aux[i++];
row.player_search_match=aux[i++];
row.player_ping=aux[i++];
row.player_locale_code=aux[i++];
row.player_locale=aux[i++];
row.player_honor=aux[i++];
row.player_enc_id=encodeURIComponent(row.player_name);
row.player_enc_name=row.player_enc_id;
}
if(typeof(blocks.server)!=='undefined')
{
i=0;
aux=blocks.server;
row.server_ip=aux[i++];
row.server_locale_code=aux[i++];
row.server_locale=aux[i++];
row.server_is_favorite=aux[i++];
row.server_name=aux[i++];
row.server_is_online=aux[i++];
row.server_honor=aux[i++];
row.server_ping=aux[i++];
row.server_players=aux[i++];
row.server_max_players=aux[i++];
row.server_map_name=aux[i++];
row.server_official_status=aux[i++];
row.server_leased_status=aux[i++];
row.server_eta_status=aux[i++];
row.server_enc_id=encodeURIComponent(row.server_ip);
row.server_enc_name=encodeURIComponent(row.server_name);
if(1)
{
if(typeof(core.map_icon_table[row.server_map_name])!=='undefined')
{
row.server_map_icon_code=core.map_icon_table[row.server_map_name];
}
else
{
row.server_map_icon_code='';
}
}
}
if(typeof(blocks.player_aux_attributes)!=='undefined')
{
i=0;
aux=blocks.player_aux_attributes;
++i;
row.player_score_deaths=aux[i++];
row.player_score_kills=aux[i++];
row.player_score_leadership=aux[i++];
row.player_score_objectives=aux[i++];
row.player_score_roe=aux[i++];
row.player_score_wins=aux[i++];
row.player_shots_fired=aux[i++];
row.player_shots_hit=aux[i++];
row.player_spectator=aux[i++];
row.player_team=aux[i++];
row.player_time_played=aux[i++];
row.player_class=aux[i++];
row.player_current_weapon=aux[i++];
row.player_role=aux[i++];
row.player_total_score=aux[i++];
row.player_accuracy=aux[i++];
row.player_kill_die_ratio=aux[i++];
}
if(typeof(blocks.player_detail)!=='undefined')
{
i=0;
aux=blocks.player_detail;
row.player_group_icon_img=aux[i++];
row.player_since_date=aux[i++];
row.player_tour_img_list=aux[i++];
row.player_version=aux[i++];
}
}
row.row_id=o.make_row_id(row.row_index);
rows[row.row_id]=row;
o.row_index.push(row);
}
A7ca28.prototype.add_datarows=function(datarows)
{
var o=this;
var data_type;
this.data_type=datarows[0];
for(var r in datarows)
{
switch(typeof(datarows[r]))
{
case 'object':
o.add_datarow(data_type,datarows[r]);
break;
case 'string':
data_type=datarows[r];
break;
}
}
}
A7ca28.prototype.add_player_favorite_status=function(row_id,favorite_status_id)
{
var row=this.rows[row_id];
if(row)
{
row.player_favorite_img_id=favorite_status_id;
var favorite_img=document.getElementById(row.player_favorite_img_id);
if(favorite_img)
{
if(row.player_is_favorite)
{
favorite_img.style.display='inline';
}
else
{
favorite_img.style.display='none';
}
}
else
{
dbug.write('cannot find status id:'+favorite_status_id);
}
}
}
A7ca28.prototype.add_server_favorite_status=function(row_id,favorite_status_id)
{
var row=this.rows[row_id];
if(row)
{
row.server_favorite_img_id=favorite_status_id;
var favorite_img=document.getElementById(row.server_favorite_img_id);
if(favorite_img)
{
if(row.server_is_favorite)
{
favorite_img.style.display='inline';
}
else
{
favorite_img.style.display='none';
}
}
else
{
dbug.write('cannot find status id:'+favorite_status_id);
}
}
}
A7ca28.prototype.setup_foldout=function(operation,row_id,target_id,foldout_controller_id,client,interval,cue,foldout_closer_id)
{
if(0)
{
core.dbug('row_id:'+row_id);
core.dbug('target_id:'+target_id);
core.dbug('foldout_controller_id:'+foldout_controller_id);
core.dbug('client:'+client);
core.dbug('interval:'+interval);
core.dbug('cue:'+cue);
core.dbug('foldout_closer_id:'+foldout_closer_id);
}
var row=this.rows[row_id];
if(row)
{
if(operation=='add')
{
var clientargs='';
switch(cue)
{
case 'player_server':
clientargs='ip='+row.server_enc_id;
break;
case 'player_player':
clientargs='username='+row.player_enc_name;
break;
case 'server_server':
clientargs='ip='+row.server_enc_id;
break;
case 'server_player':
clientargs='ip='+row.server_enc_id;
break;
}
modclient.add_periodic_refresh
(
client,
clientargs,
target_id,
null,
false,
interval,
0,
null,
null,
this.parent_target_id,
null,
null
);
modclient.add_foldout(row_id,target_id,foldout_controller_id);
if(foldout_closer_id)
{
modclient.add_foldout_closer(target_id,foldout_closer_id);
}
}
if(operation=='delete')
{
modclient.delete_periodic_refresh(target_id);
}
}
else
{
if(operation=='add')
{
dbug.write('setup_foldout: cannot find row:'+row_id);
}
}
}
A7ca28.prototype.setup_controller_features=function(operation)
{
if(this.features.player_name)
{
if(this.features.player_favorite_status)
{
this.add_player_favorite_status_targets(operation);
}
}
if(this.features.server_name)
{
if(this.features.server_favorite_status)
{
this.add_server_favorite_status_targets(operation);
}
}
if(this.features.player_controllers)
{
if(this.features.player_mymbs_controller)
{
this.setup_mymbs_controllers(operation,this.template_keys.player_mymbs_controller_id,'medium','player');
}
if(this.features.player_player_controller)
{
this.setup_foldouts(operation,'player_player');
}
if(this.features.player_server_controller)
{
this.setup_foldouts(operation,'player_server');
}
if(this.features.row_colors)
{
if(this.features.player_color_controller)
{
this.setup_row_color_controllers(operation,this.template_keys.player_color_controller_id,'player');
}
}
}
if(this.features.server_controllers)
{
if(this.features.server_mymbs_controller)
{
this.setup_mymbs_controllers(operation,this.template_keys.server_mymbs_controller_id,'medium','server');
}
if(this.features.server_player_controller)
{
this.setup_foldouts(operation,'server_player');
}
if(this.features.server_server_controller)
{
this.setup_foldouts(operation,'server_server');
}
if(this.features.row_colors)
{
if(this.features.server_color_controller)
{
this.setup_row_color_controllers(operation,this.template_keys.server_color_controller_id,'server');
}
}
}
if(this.features.small_controllers)
{
if(this.features.small_mymbs_controller)
{
this.setup_mymbs_controllers(operation,this.template_keys.small_mymbs_controller_id,'small','player');
}
}
if(this.features.javascript_templating)
{
if(operation=='add')
{
this.setup_sort_controllers('title');
}
if(this.row_index.length>1)
{
this.setup_sort_controllers(operation);
}
}
if(this.features.pager)
{
this.setup_pager_controllers(operation);
}
}
A7ca28.prototype.init_pager=function()
{
this.pager={};
this.pager.start=0;
this.pager.current_page=0;
this.pager.last_page=0;
this.pager.total_pages=0;
this.pager.enabled=false;
}
A7ca28.prototype.calculate_pager=function()
{
var v;
if(this.features.pager)
{
var row_index=this.row_index;
var num_rows=row_index.length;
if(num_rows)
{
var total_pages;
total_pages=num_rows/this.pager.stride;
total_pages=Math.floor(total_pages);
total_pages=parseInt(total_pages);
var row_stride_modulus=num_rows%this.pager.stride;
if(row_stride_modulus)
{
total_pages++;
}
if(total_pages==0)
{
}
this.pager.total_pages=total_pages;
var last_page=total_pages-1;
this.pager.last_page=last_page;
var current_page=this.pager.current_page;
if(current_page<0)
{
current_page=0;
}
else
{
if(current_page>last_page)
{
current_page=last_page;
}
}
this.pager.current_page=current_page;
if(this.pager.current_page>0)
{
this.pager.enabled_buttons['first']=true;
this.pager.enabled_buttons['prev']=true;
}
else
{
this.pager.enabled_buttons['first']=false;
this.pager.enabled_buttons['prev']=false;
}
this.pager.start=this.pager.current_page*this.pager.stride;
if(this.pager.current_page==this.pager.last_page)
{
this.pager.enabled_buttons['last']=false;
this.pager.enabled_buttons['next']=false;
if(row_stride_modulus)
{
this.pager.length=row_stride_modulus;
}
else
{
this.pager.length=this.pager.stride;
}
}
else
{
this.pager.enabled_buttons['last']=true;
this.pager.enabled_buttons['next']=true;
this.pager.length=this.pager.stride;
}
this.pager.enabled=true;
}
else
{
this.pager.start=0;
this.pager.length=0;
this.pager.current_page=0;
this.pager.last_page=0;
this.pager.enabled=false;
for(v in this.pager.enabled_buttons)
{
this.pager.enabled_buttons[v]=false;
}
}
}
else
{
this.pager.start=0;
this.pager.length=this.row_index.length;
this.pager.current_page=1;
this.pager.last_page=1;
this.pager.enabled=false;
for(v in this.pager.enabled_buttons)
{
this.pager.enabled_buttons[v]=false;
}
}
}
A7ca28.prototype.run=function()
{
this.setup_controller_features('delete');
if(this.features.javascript_templating)
{
if(this.row_index.length>1)
{
if(!this.sort_handler)
{
if(this.sort_feature)
{
this.sort_handler=this.template_keys.sort[this.sort_feature].sort_handler;
}
}
if(this.sort_handler)
{
if(this.last_sort!==this.sort_handler)
{
this.row_index.sort(this.sort_handler);
this.last_sort=this.sort_handler;
if(this.features.pager)
{
this.pager.current_page=0;
}
}
}
}
if(this.features.pager)
{
this.calculate_pager();
}
this.run_template();
}
this.setup_controller_features('add');
}
A7ca28.prototype.select_sections=function()
{
var o=this;
for(var seq in o.template_features)
{
o.template[seq]=tpl.select_section(o.template_features[seq],o.features);
}
}
A7ca28.prototype.prepare_templates=function()
{
if(!this.pre_select_sections)
{
dbug.write('prepare_templates: running section parse');
this.select_sections();
}
}
A7ca28.prototype.show_no_data=function()
{
var o=this;
var column_index=o.template_keys.column_index;
var data_id=o.template_keys.data_id+column_index;
var data=document.getElementById(data_id);
if(data)
{
data.style.display='none';
}
else
{		
core.dbug('cannot find id:'+data_id);
}
var no_data_id=o.template_keys.no_data_id+column_index;
var no_data=document.getElementById(no_data_id);
if(no_data)
{
no_data.style.display='block';
}
}
A7ca28.prototype.get_target_element=function(target_name)
{
var o=this;
if(!target_name)
{
target_name='target_id';
}
var target_id=o.template_keys[target_name];
var target=document.getElementById(target_id);
return target;
}
A7ca28.prototype.either_template_key=function(bit,a,b)
{
if(bit)
{
return this.template_keys[a];
}
else
{
return this.template_keys[b];
}
}
A7ca28.prototype.wbr_filter=function(string)
{
string=string.replace(/([^A-Za-z0-9 ])/g,'$1((bb))');
string=core.htmlentities(string);
string=string.replace(/\(\(bb\)\)/g,'<wbr>');
return string;
}
A7ca28.prototype.make_map_name_search_link=function(map_name,inner_code)
{
var link=tpl.global_keys.mapname_refine_search_link_template;
link=link.replace(/SEARCH_VALUE/g,map_name);
link=link.replace(/INNER_CODE/,inner_code);
return link;
}
A7ca28.prototype.make_map_icon=function(map_name,map_icon_code)
{
var o=this;
var result=sprite.make_sprite(o.template_keys.map_icon_sprite_tile_name,map_icon_code,'');
return result;
}
A7ca28.prototype.make_detail_link=function(ip_address,title,inner_code)
{
var link=tpl.global_keys.detail_link_template;
link=link.replace(/IP_ADDRESS/g,ip_address);
link=link.replace(/TITLE/,title);
link=link.replace(/INNER_CODE/,inner_code);
return link;
}
A7ca28.prototype.make_locale_search_link=function(locale,icon)
{
var link=tpl.global_keys.locale_refine_search_link_template;
link=link.replace(/SEARCH_VALUE/g,locale);
link=link.replace(/INNER_CODE/,icon);
return link;
}
A7ca28.prototype.make_locale_icon=function(locale,locale_code)
{
var o=this;
var result=sprite.make_sprite(o.template_keys.locale_icon_sprite_tile_name,locale_code,'');
result=o.make_locale_search_link(locale,result);
return result;
}
A7ca28.prototype.make_status_icon=function(type,official,leased,eta)
{
var result='';
var search_url_template;
if(type=='official')
{
if(official)
{
if (eta)
result=this.template_keys.server_army_eta_icon;
else
{
if(leased)
{
result=this.template_keys.server_leased_official_icon;
}
else
{
result=this.template_keys.server_army_official_icon;
}
}
}
else
{
result=this.template_keys.server_army_authorized_icon;
}
search_url_template=this.template_keys.server_official_status_search_url_template;
}
if(type=='honor')
{
if (eta)
{
result=' ';
}
else
{
if(official)
{
result=this.template_keys.server_honor_server_icon;
}
else
{
result=' ';
}
}
search_url_template=this.template_keys.server_honor_status_search_url_template;
}
search_url_template=search_url_template.replace(/LEASED_VALUE/,leased);
search_url_template=search_url_template.replace(/OFFICIAL_VALUE/,official);
result='<a href="'+search_url_template+'">'+result+'</a>';
return result;
}
A7ca28.prototype.key_cache=function(key,arg,match,data)
{
}
A7ca28.prototype.tpl_replace_key=function(key,arg,match,data)
{
var o=this;
var result='';
switch(key)
{
case 'page_display_current':
result=this.pager.current_page+1;
break;
case 'page_display_last':
result=this.pager.last_page+1;
break;
case 'row_class':
result+=o.row_colors[data.row_color%o.row_colors.length];
break;
default:
if(typeof(data[key])!=='undefined')
{
result=data[key];
if(result===null)
{
result='&nbsp;';
}
}
else
{
switch(key)
{
case 'player_accuracy_pct':
if(data.player_accuracy)
{
result=data.player_accuracy+'%';
}
break;
case 'player_kill_die_ratio_pct':
if(data.player_kill_die_ratio)
{
result=data.player_kill_die_ratio+'%';
}
break;
case 'player_name_wbr':
result=o.wbr_filter(data.player_name);
break;
case 'server_name_detail_link':
var server_name_wbr=o.wbr_filter(data.server_name);
result=o.make_detail_link(data.server_enc_id,data.server_name,server_name_wbr);
break;
case 'server_name_wbr':
result=o.wbr_filter(data.server_name);
break;
case 'server_official_icon':
result=o.make_status_icon('official',
data.server_official_status,
data.server_leased_status,
data.server_eta_status);
break;
case 'server_honor_icon':
result=o.make_status_icon('honor',
data.server_official_status,
data.server_leased_status,
data.server_eta_status);
break;
case 'server_map_name_search_link':
result+=o.make_map_name_search_link(data.server_map_name,data.server_map_name);
break;
case 'server_map_icon':
if(data.server_map_name)
{
result+=o.make_map_icon(data.server_map_name,
data.server_map_icon_code);
}
break;
case 'server_locale_icon':
if(data.server_locale)
{
result+=o.make_locale_icon(data.server_locale,
data.server_locale_code);
}
break;
case 'player_locale_icon':
result+=o.make_locale_icon(data.player_locale,data.player_locale_code);
break;
case 'hi_class':
if(data.player_search_match)
{
result=o.either_template_key(data.player_search_match,
'hi_class_tpl',
'lo_class_tpl');
}
break;
case 'player_online_status_led_src':
result+=o.either_template_key(data.player_is_online,
'online_status_led_src_tpl',
'offline_status_led_src_tpl');
break;
case 'player_online_class':
result+=o.either_template_key(data.player_is_online,
'online_class_tpl',
'offline_class_tpl');
break;
case 'player_online_status':
result+=o.either_template_key(data.player_is_online,
'online_status_tpl',
'offline_status_tpl');
break;
case 'server_online_status_led_src':
result+=o.either_template_key(data.server_is_online,
'online_status_led_src_tpl',
'offline_status_led_src_tpl');
break;
case 'server_online_class':
result+=o.either_template_key(data.server_is_online,
'online_class_tpl',
'offline_class_tpl');
break;
case 'server_online_status':
result+=o.either_template_key(data.server_is_online,
'online_status_tpl',
'offline_status_tpl');
break;
case 'player_name_attributes':
if(this.features.server_name)
{
}
break;
case 'server_name_attributes':
result='';
if(this.features.player_name)
{
if(this.features.server_name)
{
result+='style="width:32%;"';
}
}
break;
default:
var subresult=tpl.replace_attribute(key,arg,null,data);
if(subresult!==null)
{
result+=subresult;
}
else
{
if(0)
{
result+=match;
}
else
{
result='';
}
}
break;
}
data[key]=result;
}
break;
}
return result;
}
A7ca28.prototype.run_template=function()
{
var o=this;
var row_index=o.row_index;
if(1)
{
o.prepare_templates();
var target=o.get_target_element();
if(target)
{
var result='';
var controller_code='';
if(o.features.pager)
{
if(o.pager.enabled)
{
if(0)
{
controller_code=tpl.replace_template
(
o.controller_template.middle
,this.pager
);
}
else
{
controller_code=tpl.replace_template
(
o.controller_template.middle
,this.pager
,null
,o.tpl_replace_key
,this
);
}
}
}
var controller=this.get_target_element('controller_target_id');
if(controller)
{
controller.innerHTML=controller_code;
}
var slice_start;
var slice_length;
if(o.features.pager)
{
o.template_keys.column_index=0;
slice_start=this.pager.start;
slice_length=this.pager.length;
}
else
{
slice_start=0;
slice_length=o.row_index.length;
}
if(slice_length>0)
{
if(o.template_keys.num_columns==1)
{
o.template_keys.column_index=0;
result=tpl.run_template
(
o.template,
o.template_keys,
null,
row_index,
slice_start,
slice_length,
o.tpl_replace_key,
this
);
}
else
{
var code={};
code['left']='&nbsp;';
code['right']='&nbsp;';
var team_display=false;
if(1)
{
var sample_row=row_index[0];
if(typeof(sample_row.player_team)!=='undefined')
{
team_display=true;
}
}
if(team_display)
{
var i;
var t;
var teams=
{
'Red':'left'
,'Blue':'right'
};
var team_row_index={};
for(t in teams)
{
team_row_index[t]=[];
}
for(i in row_index)
{
var player_team=row_index[i].player_team;
team_row_index[player_team].push(row_index[i]);
}
o.template_keys.column_index=0;
for(t in teams)
{
code[teams[t]]=tpl.run_template
(
o.template,
o.template_keys,
null,
team_row_index[t],
0,
team_row_index[t].length,
o.tpl_replace_key,
this
);
o.template_keys.column_index++;
}
o.template_keys.column_index=0;
}
else
{
var left_start=slice_start;
var left_length=slice_length/2;
left_length=Math.ceil(left_length);
left_length=parseInt(left_length);
var right_start=left_start+left_length;
var right_length=slice_length-left_length;
o.template_keys.column_index=0;
code['left']=tpl.run_template
(
o.template,
o.template_keys,
null,
row_index,
left_start,
left_length,
o.tpl_replace_key,
this
);
o.template_keys.column_index=1;
code['right']=tpl.run_template
(
o.template,
o.template_keys,
null,
row_index,
right_start,
right_length,
o.tpl_replace_key,
this
);
}
result=Affb78.prototype.make_split(50,'%',1.5,code['left'],code['right']);
}
}
if(slice_length==0)
{
result=o.template_keys.no_data_message;
}
target.innerHTML=result;
}
else
{
dbug.write('cannot find target:');
o.template_run=false;
}
}
}
A7ca28.prototype.get_row_slice=function()
{
var result;
if(this.features.pager)
{
if(typeof(this.pager.start)!=='undefined')
{
var start=this.pager.start;
var end=this.pager.start+this.pager.length;
result=this.row_index.slice(start,end);
}
}
else
{
result=this.row_index;
}
return result;
}
A7ca28.prototype.add_player_favorite_status_targets=function(operation)
{
if(operation=='add')
{
var o=this;
var row_slice=this.get_row_slice();
if(row_slice)
{
for(var slice_index in row_slice)
{
var row=row_slice[slice_index];
this.add_player_favorite_status(row.row_id,
o.template_keys.player_favorite_img_id+row.row_index);
}
}
}
}
A7ca28.prototype.add_server_favorite_status_targets=function(operation)
{
if(operation=='add')
{
var o=this;
var row_slice=this.get_row_slice();
if(row_slice)
{
for(var slice_index in row_slice)
{
var row=row_slice[slice_index];
this.add_server_favorite_status
(
row.row_id,
o.template_keys.server_favorite_img_id+row.row_index
);
}
}
}
}
A7ca28.prototype.setup_mymbs_controllers=function(operation,controller_id_prefix,controller_size,data_type)
{
var o=this;
var row_slice=this.get_row_slice();
if(row_slice)
{
for(var slice_index in row_slice)
{
var row=row_slice[slice_index];
var row_id=row.row_id;
var controller_id=controller_id_prefix+row.row_index;
var hide_after_mymbs_remove=o.template_keys.hide_after_mymbs_remove;
this.setup_mymbs_controller(operation,row_id,controller_id,hide_after_mymbs_remove,controller_size,data_type);
}
}
}
A7ca28.prototype.setup_foldouts=function(operation,cue)
{
var o=this;
var row_slice=this.get_row_slice();
if(row_slice)
{
var foldout=o.template_keys.foldouts[cue];
for(var slice_index in row_slice)
{
var row=row_slice[slice_index];
this.setup_foldout
(
operation
,row.row_id
,foldout.target+row.row_index
,foldout.controller+row.row_index
,foldout.client
,foldout.interval
,foldout.cue
,foldout.closer+row.row_index
);
if(operation=='add')
{
core.make_sprite_controller_icon(foldout.controller+row.row_index,
foldout.icon,
foldout.icon+'_h',
null,
'AAMBS');
core.make_sprite_controller_icon(foldout.closer+row.row_index,
foldout.close,
foldout.close+'_h',
null,
'AAMBS');
}
if(operation=='delete')
{
core.delete_sprite_controller_icon(foldout.controller+row.row_index);
core.delete_sprite_controller_icon(foldout.closer+row.row_index);
}
}
}
}
A7ca28.prototype.sort_column_dispatch=function(sort_info)
{
this.sort_handler=sort_info.sort_handler;
this.run();
}
A7ca28.prototype.sort_handler_callback=function(sort_info)
{
var o=this;
return function()
{
o.sort_column_dispatch(sort_info);
}
}
A7ca28.prototype.setup_sort_controllers=function(operation)
{
var sort_handlers=this.template_keys.sort;
var num_columns=this.template_keys.num_columns;
var column_index=0;
while(num_columns--)
{
for(var sh_id in sort_handlers)
{
var sh=sort_handlers[sh_id];
if(sh)
{
var controller_id=sh.controller_id+column_index;
var controller=document.getElementById(controller_id);
if(controller)
{
if(operation=='title')
{
controller.title=sh.title;
}
if(operation=='add')
{
controller.title="Sort by "+controller.title;
controller.style.cursor='pointer';
if(this.sort_handler==sh.sort_handler)
{
controller.style.color='#a98a2f';
}
if(1)
{
controller.onclick=this.sort_handler_callback(sh);
}
}
if(operation=='delete')
{
controller.onclick=null;
}
}
else
{
}
}
}
column_index++;
}
}
A7ca28.prototype.update_row_stride=function()
{
var cmd='row_stride';
var id=this.pager.row_stride_client;
var name=this.pager.stride;
var message='cmd='+cmd+'&id='+id+'&name='+name;
modclient.send_modulemessage('MyMBS',message,null,null);
}
A7ca28.prototype.create_pager_handler_callback=function(direction)
{
var o=this;
var result;
if(direction=='next')
{
result=function()
{
o.pager.current_page++;
o.run();
}
}
if(direction=='prev')
{
result=function()
{
o.pager.current_page--;
if(o.pager.current_page<0)
{
o.pager.current_page=0;
}
o.run();
}
}
if(direction=='last')
{
result=function()
{
o.pager.current_page=o.pager.last_page;
o.run();
}
}
if(direction=='first')
{
result=function()
{
o.pager.current_page=0;
o.run();
}
}
if(direction=='inc_stride')
{
result=function()
{
o.pager.stride++;
o.pager.current_page=0;
o.update_row_stride();
o.run();
}
}
if(direction=='dec_stride')
{
result=function()
{
if(0)
{
o.pager.stride--;
o.pager.current_page=0;
if(o.pager.stride<1)
{
o.pager.stride=1;
}
o.update_row_stride();
o.run();
}
else
{
if(o.pager.stride>1)
{
o.pager.stride--;
o.pager.current_page=0;
o.update_row_stride();
o.run();
}
}
}
}
return result;
}
A7ca28.prototype.setup_pager_controller=function(operation,controller_id,direction)
{
var o=this;
var controller=document.getElementById(controller_id);
if(controller)
{
if(operation=='add')
{
var sprite_codes=this.pager.controller_sprite_codes;
if(typeof(sprite_codes[direction])!=='undefined')
{
sprite_codes=sprite_codes[direction];
var sprite_code_normal=sprite_codes.normal;
var sprite_code_hover=sprite_codes.hover;
var click_fn=o.create_pager_handler_callback(direction);
if(typeof(this.pager.enabled_buttons[direction])!=='undefined')
{
if(!this.pager.enabled_buttons[direction])
{
sprite_code_normal=sprite_codes.disabled;
sprite_code_hover=null;
click_fn=null;
}
}
core.make_sprite_controller_icon(controller_id,
sprite_code_normal,
sprite_code_hover,
null,
'AAMBS',
null,
null,
click_fn);
}
}
else
{
if(operation=='delete')
{
core.delete_sprite_controller_icon(controller_id);
}
}
}
}
A7ca28.prototype.setup_pager_controllers=function(operation)
{
for(var dir in this.pager.controller_ids)
{
var controller_id=this.pager.controller_ids[dir];
this.setup_pager_controller(operation,controller_id,dir);
}
}
A7ca28.prototype.register_row_color=function(row_id,color_index)
{
var row=this.rows[row_id];
if(row)
{
var message='cmd='+row.data_type+'_color&id='+row[row.data_type+'_enc_id']+'&name='+color_index;
modclient.send_modulemessage('MyMBS',message,null,null);
}
else
{
core.dbug('cannot find row data:'+row_id);
}
}
A7ca28.prototype.change_row_color=function(row_id)
{
var row=this.rows[row_id];
if(row)
{
var target=document.getElementById(row_id);
if(target)
{
var i=row.row_color;
var old_class=this.row_colors[i];
++i;
i=i%this.row_colors.length;
var new_class=this.row_colors[i];
row.row_color=i;
var target_class=target.className;
target_class=core.sub_class(target_class,old_class);
target_class=core.add_class(target_class,new_class);
target.className=target_class;
this.register_row_color(row_id,i);
}
else
{
core.dbug('cannot find target: '+row_id);
}
}
}
A7ca28.prototype.setup_row_color_controller=function(operation,row_id,controller_id)
{
var controller=document.getElementById(controller_id);
if(controller)
{
if(operation=='add')
{
var o=this;
var fn=function()
{
o.change_row_color(row_id);
}
core.make_sprite_controller_icon(controller_id,
'c',
'c_h',
null,
'AAMBS',
null,
null,
fn);
}
if(operation=='delete')
{
core.delete_sprite_controller_icon(controller_id);
}
}
else
{
dbug.write('setup_row_color_controller: cannot find controller:'+controller_id);
}
}
A7ca28.prototype.setup_row_color_controllers=function(operation,controller_id_prefix,data_type)
{
var o=this;
var row_slice=this.get_row_slice();
if(row_slice)
{
for(var slice_index in row_slice)
{
var row=row_slice[slice_index];
var row_id=row.row_id;
var controller_id=controller_id_prefix+row.row_index;
this.setup_row_color_controller(operation,row_id,controller_id);
}
}
}
A7ca28.prototype.set_row_colors=function()
{
for(var r in this.rows)
{
var row=this.rows[r];
var row_id=row.row_id;
var target=document.getElementById(row_id);
if(target)
{
target.className=core.add_class(target.className,this.row_colors[row.row_color]);
}
}
}
A7ca28.sort_by_row_color=function(a,b)
{
return b.row_color-a.row_color;
}
A7ca28.sort_by_server_official_status=function(a,b)
{
var a_l=a.server_leased_status;
var a_o=a.server_official_status;
var b_l=b.server_leased_status;
var b_o=b.server_official_status;
var a_v;
var b_v;
if(a_o)
{
if(a_l)
{
a_v=1;
}
else
{
a_v=2;
}
}
else
{
a_v=0;
}
if(b_o)
{
if(b_l)
{
b_v=1;
}
else
{
b_v=2;
}
}
else
{
b_v=0;
}
return b_v-a_v;
}
A7ca28.sort_by_server_map_name=function(a,b)
{
return a.server_map_name.localeCompare(b.server_map_name);
}
A7ca28.sort_by_server_players=function(a,b)
{
return b.server_players-a.server_players;
}
A7ca28.sort_by_player_online_status=function(a,b)
{
return b.player_is_online-a.player_is_online;
}
A7ca28.sort_by_server_online_status=function(a,b)
{
return b.server_is_online-a.server_is_online;
}
A7ca28.sort_by_player_name=function(a,b)
{
return a.player_name.replace(/[^A-Za-z]/g,'').localeCompare(b.player_name.replace(/[^A-Za-z]/g,''));
}
A7ca28.sort_by_player_name_alpha=function(a,b)
{
if(typeof(a.player_name_alpha)=='undefined')
{
a.player_name_alpha=a.player_name.replace(/[^A-Za-z0-9]/g,'');
}
if(typeof(b.player_name_alpha)=='undefined')
{
b.player_name_alpha=b.player_name.replace(/[^A-Za-z0-9]/g,'');
}
var result=a.player_name_alpha.localeCompare(b.player_name_alpha);
return result;
}
A7ca28.sort_by_server_name=function(a,b)
{
if(!a.server_name)
{
return 1;
}
if(!b.server_name)
{
return -1;
}
return a.server_name.replace(/[^A-Za-z]/g,'').localeCompare(b.server_name.replace(/[^A-Za-z]/g,''));
}
A7ca28.sort_by_player_ping=function(a,b)
{
return a.player_ping-b.player_ping;
}
function null_numeric_sort(a,b,attribute)
{
if(b[attribute]===null)
{
return 1;
}
if(a[attribute]===null)
{
return -1;
}
return a[attribute]-b[attribute];
}
function null_string_sort(a,b,attribute)
{
if(a[attribute]===null)
{
return 1;
}
if(b[attribute]===null)
{
return -1;
}
return a[attribute].localeCompare(b[attribute]);
}
A7ca28.sort_by_player_class=function(a,b)
{
return null_string_sort(a,b,'player_class');
}
A7ca28.sort_by_player_current_weapon=function(a,b)
{
return null_string_sort(a,b,'player_current_weapon');
}
A7ca28.sort_by_player_role=function(a,b)
{
return null_string_sort(a,b,'player_role');
}
A7ca28.sort_by_player_score_deaths=function(a,b)
{
return null_numeric_sort(b,a,'player_score_deaths');
}
A7ca28.sort_by_player_score_kills=function(a,b)
{
return null_numeric_sort(b,a,'player_score_kills');
}
A7ca28.sort_by_player_score_leadership=function(a,b)
{
return null_numeric_sort(b,a,'player_score_leadership');
}
A7ca28.sort_by_player_score_objectives=function(a,b)
{
return null_numeric_sort(b,a,'player_score_objectives');
}
A7ca28.sort_by_player_total_score=function(a,b)
{
return null_numeric_sort(b,a,'player_total_score');
}
A7ca28.sort_by_player_accuracy=function(a,b)
{
return null_numeric_sort(b,a,'player_accuracy');
}
A7ca28.sort_by_player_kill_die_ratio=function(a,b)
{
return null_numeric_sort(b,a,'player_kill_die_ratio');
}
A7ca28.sort_by_player_score_roe=function(a,b)
{
return null_numeric_sort(b,a,'player_score_roe');
}
A7ca28.sort_by_player_score_wins=function(a,b)
{
return null_numeric_sort(b,a,'player_score_wins');
}
A7ca28.sort_by_player_shots_fired=function(a,b)
{
return null_numeric_sort(b,a,'player_shots_fired');
}
A7ca28.sort_by_player_shots_hit=function(a,b)
{
return null_numeric_sort(b,a,'player_shots_hit');
}
A7ca28.sort_by_player_spectator=function(a,b)
{
return null_string_sort(a,b,'player_spectator');
}
A7ca28.sort_by_player_team=function(a,b)
{
return null_string_sort(a,b,'player_team');
}
A7ca28.sort_by_player_time_played=function(a,b)
{
return null_string_sort(b,a,'player_time_played');
}
A7ca28.sort_by_player_version=function(a,b)
{
return null_string_sort(a,b,'player_version');
}
A7ca28.sort_by_server_ping=function(a,b)
{
return a.server_ping-b.server_ping;
}
A7ca28.sort_by_server_honor=function(a,b)
{
return b.server_honor-a.server_honor;
}
A7ca28.sort_by_player_honor=function(a,b)
{
return b.player_honor-a.player_honor;
}
A7ca28.sort_by_player_since=function(a,b)
{
var a_parts=a.player_since_date.split(/\//);
var b_parts=b.player_since_date.split(/\//);
var a_month=a_parts[0];
var a_year=a_parts[1];
var b_month=b_parts[0];
var b_year=b_parts[1];
var year_result;
var month_result;
var result;
year_result=b_year.localeCompare(a_year);
month_result=b_month.localeCompare(a_month);
if(year_result>0)
{
result=1;
}
else
{
if(year_result<0)
{
result=-1;
}
else
{
if(month_result>0)
{
result=1;
}
else
{
if(month_result<0)
{
result=-1;
}
else
{
result=0;
}
}
}
}
return result;
}
A7ca28.sort_by_player_tours=function(a,b)
{
return b.player_tour_img_list.length-a.player_tour_img_list.length;
}
A7ca28.sort_by_player_locale=function(a,b)
{
var top_country='United States';
var result;
if(a.player_locale==top_country)
{
if(b.player_locale==top_country)
{
result=0;
}
else
{
result=-1;
}
}
else
{
if(b.player_locale==top_country)
{
result=1;
}
else
{
result=a.player_locale.localeCompare(b.player_locale);
}
}
return result;
}
A7ca28.sort_by_server_locale=function(a,b)
{
var top_country='United States';
var result;
if(a.server_locale==top_country)
{
if(b.server_locale==top_country)
{
result=0;
}
else
{
result=-1;
}
}
else
{
if(b.server_locale==top_country)
{
result=1;
}
else
{
result=a.server_locale.localeCompare(b.server_locale);
}
}
return result;
}
A7ca28.sort_by_server_ip=function(a,b)
{
if(1)
{
var split_a=a.server_ip.split(/[.:]/);
var split_b=b.server_ip.split(/[.:]/);
var result=0;
var i=0;
while(result==0)
{
result=split_a[i]-split_b[i];
if(i==4)
{
break;
}
++i;
}
}
return result;
}
A7ca28.hover_header=function()
{
}
core.entity_table=
{
	 '\u00a0':'&nbsp;'
	,'\u00a1':'&iexcl;'
	,'\u00a2':'&cent;'
	,'\u00a3':'&pound;'
	,'\u00a4':'&curren;'
	,'\u00a5':'&yen;'
	,'\u00a6':'&brvbar;'
	,'\u00a7':'&sect;'
	,'\u00a8':'&uml;'
	,'\u00a9':'&copy;'
	,'\u00aa':'&ordf;'
	,'\u00ab':'&laquo;'
	,'\u00ac':'&not;'
	,'\u00ad':'&shy;'
	,'\u00ae':'&reg;'
	,'\u00af':'&macr;'
	,'\u00b0':'&deg;'
	,'\u00b1':'&plusmn;'
	,'\u00b2':'&sup2;'
	,'\u00b3':'&sup3;'
	,'\u00b4':'&acute;'
	,'\u00b5':'&micro;'
	,'\u00b6':'&para;'
	,'\u00b7':'&middot;'
	,'\u00b8':'&cedil;'
	,'\u00b9':'&sup1;'
	,'\u00ba':'&ordm;'
	,'\u00bb':'&raquo;'
	,'\u00bc':'&frac14;'
	,'\u00bd':'&frac12;'
	,'\u00be':'&frac34;'
	,'\u00bf':'&iquest;'
	,'\u00c0':'&Agrave;'
	,'\u00c1':'&Aacute;'
	,'\u00c2':'&Acirc;'
	,'\u00c3':'&Atilde;'
	,'\u00c4':'&Auml;'
	,'\u00c5':'&Aring;'
	,'\u00c6':'&AElig;'
	,'\u00c7':'&Ccedil;'
	,'\u00c8':'&Egrave;'
	,'\u00c9':'&Eacute;'
	,'\u00ca':'&Ecirc;'
	,'\u00cb':'&Euml;'
	,'\u00cc':'&Igrave;'
	,'\u00cd':'&Iacute;'
	,'\u00ce':'&Icirc;'
	,'\u00cf':'&Iuml;'
	,'\u00d0':'&ETH;'
	,'\u00d1':'&Ntilde;'
	,'\u00d2':'&Ograve;'
	,'\u00d3':'&Oacute;'
	,'\u00d4':'&Ocirc;'
	,'\u00d5':'&Otilde;'
	,'\u00d6':'&Ouml;'
	,'\u00d7':'&times;'
	,'\u00d8':'&Oslash;'
	,'\u00d9':'&Ugrave;'
	,'\u00da':'&Uacute;'
	,'\u00db':'&Ucirc;'
	,'\u00dc':'&Uuml;'
	,'\u00dd':'&Yacute;'
	,'\u00de':'&THORN;'
	,'\u00df':'&szlig;'
	,'\u00e0':'&agrave;'
	,'\u00e1':'&aacute;'
	,'\u00e2':'&acirc;'
	,'\u00e3':'&atilde;'
	,'\u00e4':'&auml;'
	,'\u00e5':'&aring;'
	,'\u00e6':'&aelig;'
	,'\u00e7':'&ccedil;'
	,'\u00e8':'&egrave;'
	,'\u00e9':'&eacute;'
	,'\u00ea':'&ecirc;'
	,'\u00eb':'&euml;'
	,'\u00ec':'&igrave;'
	,'\u00ed':'&iacute;'
	,'\u00ee':'&icirc;'
	,'\u00ef':'&iuml;'
	,'\u00f0':'&eth;'
	,'\u00f1':'&ntilde;'
	,'\u00f2':'&ograve;'
	,'\u00f3':'&oacute;'
	,'\u00f4':'&ocirc;'
	,'\u00f5':'&otilde;'
	,'\u00f6':'&ouml;'
	,'\u00f7':'&divide;'
	,'\u00f8':'&oslash;'
	,'\u00f9':'&ugrave;'
	,'\u00fa':'&uacute;'
	,'\u00fb':'&ucirc;'
	,'\u00fc':'&uuml;'
	,'\u00fd':'&yacute;'
	,'\u00fe':'&thorn;'
	,'\u00ff':'&yuml;'
	,'\u0022':'&quot;'
	,'\u003c':'&lt;'
	,'\u003e':'&gt;'
	,'\u0026':'&amp;'
};
core.htmlentities=function(string)
{
var arr=[];
var len=string.length;
var i=0;
var etab=core.entity_table;
while(len--)
{
var cha=string.charAt(i);
if(etab[cha])
{
arr.push(etab[cha]);
}
else
{
arr.push(cha);
}
++i;
}
return arr.join('');
}
core.test_htmlentities=function()
{
var input='<the>" without bla&\näüöéèß';
var result=core.htmlentities(input);
var expected='&lt;the&gt;&quot; without bla&amp;\n&auml;&uuml;&ouml;&eacute;&egrave;&szlig;';
for(var q in core.entity_table)
{
if(!core.entity_table[q])
{
alert('table null entry');
lkjsdf();
}
}
if(expected===result)
{
}
else
{
alert('html character entity translation failed');
}
}
tpl.global_keys=
{
new_search_url_template:'/search.php?search_init=default&attr=SEARCH_ATTR&value=SEARCH_VALUE&type=SEARCH_TYPE'
,search_url_template:'/search.php?search_init=refine&attr=SEARCH_ATTR&value=SEARCH_VALUE&type=SEARCH_TYPE'
,locale_new_search_link_template:'<a href="/search.php?search_init=default&attr=locale&value=SEARCH_VALUE&type=default" title="Server Search: Country SEARCH_VALUE">INNER_CODE</a>'
,locale_refine_search_link_template:'<a href="/search.php?search_init=refine&attr=locale&value=SEARCH_VALUE&type=default" title="Server Search: Country SEARCH_VALUE">INNER_CODE</a>'
,mapname_new_search_link_template:'<a href="/search.php?search_init=default&attr=mapName&value=SEARCH_VALUE&type=default" title="Server Search: Mapname SEARCH_VALUE">INNER_CODE</a>'
,mapname_refine_search_link_template:'<a href="/search.php?search_init=refine&attr=mapName&value=SEARCH_VALUE&type=default" title="Server Search: Mapname SEARCH_VALUE">INNER_CODE</a>'
,detail_link_template:'<a href="/serverlookup.php?ip=IP_ADDRESS" title="TITLE">INNER_CODE</a>'
};
core.map_icon_table=
{
	 'Border':'icn_172inf_patch'
	,'Bridge Crossing':'icn_172inf_patch'
	,'Bridge SE':'icn_172inf_patch'
	,'Collapsed Tunnel':'icn_10mountain_patch'
	,'Dusk':'icn_75ranger'
	,'FLS Assault':'icn_82nd_patchfull'
	,'Headquarters Raid':'icn_10mountain_patch'
	,'Insurgent Camp':'icn_10mountain_patch'
	,'Interdiction':'icn_75ranger'
	,'JRTC Farm Raid':'icn_82nd_patchfull'
	,'Mountain Ambush':'icn_75ranger'
	,'Mountain Pass':'icn_172inf_patch'
	,'Mountain Pass SE':'icn_172inf_patch'
	,'MOUT McKenna':'training'
	,'Mout McKenna':'training'
	,'Pipeline':'icn_172inf_patch'
	,'Radio Tower':'icn_75ranger'
	,'River Basin':'icn_10mountain_patch'
	,'SF Arctic':'icn_sf_patchfull'
	,'SF Blizzard':'icn_sf_patchfull'
	,'SF Courtyard':'icn_sf_patchfull'
	,'SF CSAR':'icn_sf_patchfull'
	,'SF Dockside':'icn_sf_patchfull'
	,'SF Extraction':'icn_sf_patchfull'
	,'SF Hospital':'icn_sf_patchfull'
	,'SF Oasis':'icn_sf_patchfull'
	,'SF PCR':'icn_sf_patchfull'
	,'Pipeline SF':'icn_sf_patchfull'
	,'SF Pipeline':'icn_sf_patchfull'
	,'SF Recon':'icn_sf_patchfull'
	,'SF SandStorm':'icn_sf_patchfull'
	,'SF Sandstorm':'icn_sf_patchfull'
	,'SF Taiga':'icn_sf_patchfull'
	,'SF Village':'icn_sf_patchfull'
	,'SF Water Treatment':'icn_sf_patchfull'
	,'Swamp Raid':'icn_75ranger'
	,'Untitled':'transparent'
	,'Urban Assault':'icn_172inf_patch'
	,'Weapons Cache':'icn_75ranger'
	,'Weapons Cache SE':'icn_75ranger'
	,'Woodland Outpost':'icn_75ranger'
	,'SF SnakePlain':'icn_sf_patchfull'
	,'Steamroller':'icn_75ranger'
	,'ES2Border':'icn_sf_patchfull'
	,'SMU GH RiverVillage':''
	,'SMU GH SFFloodgate':''
	,'SMU GH SFOldTown':''
	,'SMU GH SFRefinery':''
	,'Rummage':'icn_75ranger'
	,'SF Hospital SE':'icn_sf_patchfull'
};
core.production_mode=1;
sprite.sprite_class_table=
{
	 large:	
	{
		 srcdir:'images/flags_thumb'
		,name:'large'
		,prefix:'fcifl'
		,aux_class:'flag_icon_image'
	}
	,medium:	
	{
		 srcdir:'images/flag_icons_medium'
		,name:'medium'
		,prefix:'fcifm'
		,aux_class:'flag_icon_image'
	}
	,small:	
	{
		 srcdir:'images/flag_icons_small'
		,name:'small'
		,prefix:'fcifs'
		,aux_class:'flag_icon_image'
	}
	,map_small:	
	{
		 srcdir:'images/map_icons_small'
		,name:'map_small'
		,prefix:'fcims'
		,aux_class:'map_icon'
	}
	,map_medium:	
	{
		 srcdir:'images/map_icons_medium'
		,name:'map_medium'
		,prefix:'fcimm'
		,aux_class:'map_icon'
	}
	,AAMBS_controller_icons:	
	{
		 srcdir:'module/AAMBS/controller_icons'
		,name:'AAMBS_controller_icons'
		,prefix:'fcici'
		,aux_class:'controller_icon'
	}
};
