// global vars // holds the state of each control var state = []; // these should be moved into state eventually var search = []; search["search"] = "EC-88"; search["search prices"] = "EC-88"; search["player"] = ""; search["players"] = ""; /* for (i in search) { document.writeln(i+':'+search[i]+', '); // outputs: one:First, two:Second, three:Third }; */ // var system = 9; var systemname = 'Itan'; var sectorid = 2218; var buysector = 2218; var sellsector = 0; //var search = 'EC-88'; var map = 'sector'; var template = 'login'; var page = 'home'; var model = 'none'; //global funcs function lookup(inputString, offset) { if(!offset) offset = '0'; if(inputString.length < 2) { // Hide the suggestion box. $('#suggestions').hide(); } else { var searchtemplate = 'search prices'; if(template == 'player' || template == 'players'){ searchtemplate = 'player'; } else if(template == 'inventory'){ searchtemplate = 'inventory'; } else if(template == 'log'){ searchtemplate = 'log'; } $.post("controls/lookup.php", { template:""+searchtemplate+"", search:""+inputString+"", offset:""+offset+"" }, function(data){ if(data.length >0) { $('#suggestions').show(); $('#autoSuggestionsList').html(data); } }); } } // lookup function fill(thisValue) { search[template] = thisValue; if(template == 'players'){ search['player'] = thisValue; } else if(template == 'player'){ search['players'] = thisValue; } else if(template == 'search'){ search['search prices'] = thisValue; } else if(template == 'search prices'){ search['search'] = thisValue; } $('#inputString').val(thisValue); setTimeout("$('#suggestions').hide();", 200); } function updatemenu(leaf, depth){ $('ul.'+depth+'menu').hide(); // this is kind of a hack to close submenues... may need to redo this properly at some point, or just // not hide submenues? $('ul.'+depth+'submenu').hide(); $('ul.'+depth+'subsubmenu').hide(); $('ul.'+depth+'subsubsubmenu').hide(); $('#'+leaf.replace(' ','_')).show(); changeinputs(leaf); } function postform(form, quiet){ if(form == ''){ return false; } $('div#page_loading').fadeIn('slow'); if(quiet == null){ $.post('form.php', $('#'+form).serialize(), function(data){ $('div#data').html(''+data); $('.editor').wysiwyg({ controls : { separator04 : { visible : true }, insertOrderedList : { visible : true }, insertUnorderedList : { visible : true }, html : { visible : true } } }); $('div#page_loading').fadeOut('slow'); }); } else{ $.post('form.php', $('#'+form).serialize(), function(data){ $('div#page_loading').fadeOut('slow'); }); } } // display from where form id = id and data is matched dynamically specific to form function showForm(id, data, width, height){ // loading icon $('div#formdata').html('



'); // set the width and height, use defaults if none provided if(typeof width == 'number'){ $('div#formdiv').css({'width' : width}); $('div#formdiv').css({'margin-left' : -width/2}); } else{ $('div#formdiv').css({'width' : 700}); $('div#formdiv').css({'margin-left' : -350}); } if(typeof height == 'number'){ $('div#formdiv').css({'height' : height}); } else{ $('div#formdiv').css({'height' : 600}); } // show the form page $('div#formdiv').show(); $('div#formdiv').css({'z-index' : '9999'}); var vars = 'form='+id; if(data != null){ Object.keys(data).forEach(function (key) { vars = vars + '&' + key + '=' + data[key]; }); } // load formdata $.post('form.php',vars, function(data){ $('div#formdata').html(''+data); }); } function closeForm(){ $('div#formdiv').hide(); $('div#formdiv').css({'z-index' : '-9999'}); } function updatetemplate(tmpl){ $('div#page_loading').fadeIn('slow'); template = tmpl; templatetype = template; if(template == 'buysector'){ buysector = sectorid; templatetype = 'station compare'; } else if(template == 'sellsector'){ sellsector = sectorid; templatetype = 'station compare'; } $.post('template.php',{ system:''+system, sectorid:''+sectorid, buysector:''+buysector, sellsector:''+sellsector, search:''+search[templatetype], template:''+templatetype, page:''+page, model:''+model }, function(data){ $('div#data').html(''+data); $('.editor').wysiwyg({ controls : { separator04 : { visible : true }, insertOrderedList : { visible : true }, insertUnorderedList : { visible : true }, html : { visible : true } } }); $('div#page_loading').fadeOut('slow'); }); } function changeinputs(type){ if(type == 'station compare'){ $('div.search').slideUp('slow', function() { $('input.sector').slideUp('slow', function() { $('input.station').slideDown('slow'); }); }); } else if(type == 'sector' || type == 'system'){ $('div.search').slideUp('slow', function() { $('input.station').slideUp('slow', function() { $('input.sector').slideDown('slow'); }); }); if(type == 'sector'){ $.post('controls/map.php', {systemid:system}, function(data){ $('div#system').html(''+data); }); } else if(type == 'system'){ $.post('controls/map.php', function(data){ $('div#system').html(''+data); }); } } else if(type == 'search' || type == 'search prices' || type == 'player' || type == 'players' || type == 'inventory' || type == 'log'){ search['inventory'] = ''; $('#inputString').val(search[type]); $('input.sector').slideUp('slow', function() { $('input.station').slideUp('slow', function() { $('div.search').slideDown('slow'); }); }); } else $('input.map').slideUp('slow', function() { $('div.search').slideUp('slow', function() { $('#map').slideUp('slow') }) }); } function changemenu(id, inputtype){ if(id == '#oremenu'){ $('#adminmenu').hide('slow'); $('#trademenu').hide('slow', function(){ $('#stuffmenu').hide('slow', function(){ $('#oremenu').show('slow', function(){ changeinputs(inputtype); }); }); }); } else if(id == '#trademenu'){ $('#adminmenu').hide('slow'); $('#oremenu').hide('slow', function(){ $('#stuffmenu').hide('slow', function(){ $('#trademenu').show('slow', function(){ changeinputs(inputtype); }); }); }); } else if(id == '#stuffmenu'){ $('#adminmenu').hide('slow'); $('#oremenu').hide('slow', function(){ $('#trademenu').hide('slow', function(){ $('#stuffmenu').show('slow', function(){ changeinputs(inputtype); }); }); }); } else if(id == '#adminmenu'){ $('#oremenu').hide('slow', function(){ $('#trademenu').hide('slow', function(){ $('#stuffmenu').hide('slow', function(){ $('#adminmenu').show('slow', function(){ changeinputs(inputtype); }); }); }); }); } else $('ul.submenu').hide('slow'); } function ajaxAvatarUpload(element) { $.ajaxFileUpload ({ url:'forms/doavatarupload.php?element='+element, secureuri:false, fileElementId:''+element, dataType: 'json', success: function (data, status){ if(typeof(data.error) != 'undefined'){ if(data.error != ''){ alert(data.error); }else{ if(data.msg == 'true'){ updatetemplate('characters'); } else{ alert(data.msg); } } } }, error: function (data, status, e){ alert(e); } } ) return false; } // do some stuff to start $(document).ready(function(){ $("input.map").click(function(event){ var id = $(this).attr('id'); var display = $('div#map').css('display'); $('input#sector').removeClass('map_active'); $('input#buysector').removeClass('map_active'); $('input#sellsector').removeClass('map_active'); if(display == 'none'){ $(this).addClass('map_active'); $('div#map').slideDown('slow'); } else{ if(map == id){ $('div#map').slideUp('slow'); } else{ $(this).addClass('map_active'); } } map = id; }); $.post('controls/map.php',{systemid:''+system}, function(data){ $('div#system').html(''+data); }); updatemenu(template, 'sub'); updatetemplate(template); });