code
stringlengths
1
2.08M
language
stringclasses
1 value
var xmlHttpallskill function Showallskill() { xmlHttpallskill=GetXmlHttpObject() if (xmlHttpallskill==null) { alert ("Browser does not support HTTP Request") return } var url="Ajax/GetAllSkill.php" url=url+"?sid="+Math.random() //document.write(url); xmlHttpallskill.onreadystatechange=stateChangedallskill xmlHttpallskill.open("GET",url,true) xmlHttpallskill.send(null) } function stateChangedallskill() { //document.write(xmlHttp.readyState); //document.write(xmlHttp.readyState); if (xmlHttpallskill.readyState==4 || xmlHttpallskill.readyState=="complete") { document.getElementById("SkilltreeInterface").innerHTML=xmlHttpallskill.responseText } }
JavaScript
var xmlHttprole var nam function Showroleinfo(name) { xmlHttprole=GetXmlHttpObject() if (xmlHttprole==null) { alert ("Browser does not support HTTP Request") return } var url="Ajax/Getroleinfo.php" url=url+"?name="+name url=url+"&sid="+Math.random() //document.write(url); xmlHttprole.onreadystatechange=stateChangedrole xmlHttprole.open("GET",url,true) xmlHttprole.send(null) nam=name } function stateChangedrole() { //document.write(xmlHttp.readyState); //document.write(xmlHttp.readyState); if (xmlHttprole.readyState==4 || xmlHttprole.readyState=="complete") { document.getElementById("Roledata").innerHTML=xmlHttprole.responseText } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; }
JavaScript
var xmlHttpsyn; var xmlHttpsynsubmit; var nam; var syn=''; var flag1=0; var flag2=0; var flag3=0; var flag4=0; var flag5=0; function SynAdd1() { if(document.getElementById("Bag1syid").textContent!='0'&&flag1==0) { add=document.getElementById("Bag1syid").textContent; add+=','; syn+=add; document.getElementById("chain1").style.display='inline'; flag1=1; } } function SynAdd2() { if(document.getElementById("Bag2syid").textContent!='0'&&flag2==0) { add=document.getElementById("Bag2syid").textContent; add+=','; syn+=add; document.getElementById("chain2").style.display='inline'; flag2=1; } } function SynAdd3() { if(document.getElementById("Bag3syid").textContent!='0'&&flag3==0) { add=document.getElementById("Bag3syid").textContent add+=',' syn+=add; document.getElementById("chain3").style.display='inline'; flag3=1; } } function SynAdd4() { if(document.getElementById("Bag4syid").textContent!='0'&&flag4==0) { add=document.getElementById("Bag4syid").textContent add+=',' syn+=add; document.getElementById("chain4").style.display='inline'; flag4=1; } } function SynAdd5() { if(document.getElementById("Bag5syid").textContent!='0'&&flag5==0) { add=document.getElementById("Bag5syid").textContent add+=',' syn+=add; document.getElementById("chain5").style.display='inline'; flag5=1; } } function SynClean() { syn=''; flag1=0; flag2=0; flag3=0; flag4=0; flag5=0; } function SynSubmit() { xmlHttpsynsubmit=GetXmlHttpObject() if (xmlHttpsynsubmit==null) { alert ("Browser does not support HTTP Request") return } async: false; var url="Ajax/SynthesisSubmit.php" url=url+"?m="+syn; url=url+"&sid="+Math.random() //document.write(url); xmlHttpsynsubmit.onreadystatechange=stateChangedsynsubmit xmlHttpsynsubmit.open("GET",url,true) xmlHttpsynsubmit.send(null) } function stateChangedsynsubmit() { //document.write(xmlHttp.readyState); //document.write(xmlHttp.readyState); if (xmlHttpsynsubmit.readyState==4 || xmlHttpsynsubmit.readyState=="complete") { document.getElementById("SynthesisInterface").innerHTML=xmlHttpsynsubmit.responseText; SynClean(); Showresinfo(nam); Showbag(); } } function Showsyn(name) { xmlHttpsyn=GetXmlHttpObject() if (xmlHttpsyn==null) { alert ("Browser does not support HTTP Request") return } var url="Ajax/Synthesis.php" url=url+"?name="+name url=url+"&sid="+Math.random() //document.write(url); xmlHttpsyn.onreadystatechange=stateChangedsyn xmlHttpsyn.open("GET",url,true) xmlHttpsyn.send(null) nam=name } function stateChangedsyn() { //document.write(xmlHttp.readyState); //document.write(xmlHttp.readyState); if (xmlHttpsyn.readyState==4 || xmlHttpsyn.readyState=="complete") { document.getElementById("SynthesisInterface").innerHTML=xmlHttpsyn.responseText; } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } function allowDrop(ev) { ev.preventDefault(); } function drag(ev) { ev.dataTransfer.setData("Text",ev.target.id); } function drop(ev) { ev.preventDefault(); var data=ev.dataTransfer.getData("Text"); if(data=='Bag1Sy') {SynAdd1();} if(data=='Bag2Sy') {SynAdd2();} if(data=='Bag3Sy') {SynAdd3();} if(data=='Bag4Sy') {SynAdd4();} if(data=='Bag5Sy') {SynAdd5();} document.getElementById(data).style.display='none'; }
JavaScript
var reg1 var att function Showplayer(atti) { reg1=GetXmlHttpObject1() if (reg1==null) { alert ("Browser does not support HTTP Request") return } att=atti var url1="Ajax/PlayerAttend.php" url1=url1+"?att="+atti url1=url1+"&sid="+Math.random() //document.write(url); reg1.onreadystatechange=stateChanged1 reg1.open("GET",url1,true) reg1.send(null) } function stateChanged1() { //document.write(xmlHttp2.readyState); if (reg1.readyState==4 || reg1.readyState=="complete") { //document.write(xmlHttp2.responseText) document.getElementById("Playerattend").innerHTML=reg1.responseText setTimeout("Showplayer(att)",3000); } } function GetXmlHttpObject1() { var reg=null; try { // Firefox, Opera 8.0+, Safari reg=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { reg=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { reg=new ActiveXObject("Microsoft.XMLHTTP"); } } return reg; }
JavaScript
var xmlHttpres var nam function Showresinfo(name) { xmlHttpres=GetXmlHttpObject() if (xmlHttpres==null) { alert ("Browser does not support HTTP Request") return } var url="Ajax/Getresinfo.php" url=url+"?name="+name url=url+"&sid="+Math.random() //document.write(url); xmlHttpres.onreadystatechange=stateChangedres xmlHttpres.open("GET",url,true) xmlHttpres.send(null) nam=name } function stateChangedres() { //document.write(xmlHttp.readyState); //document.write(xmlHttp.readyState); if (xmlHttpres.readyState==4 || xmlHttpres.readyState=="complete") { document.getElementById("Resdata").innerHTML=xmlHttpres.responseText; DeHeHH(); DeArHH(); DeShHH(); TranHH(); TrHH(); AHH(); WHH(); Bag1H(); Bag2H(); Bag3H(); Bag4H(); Bag5H(); Bag1HH(); Bag2HH(); Bag3HH(); Bag4HH(); Bag5HH(); } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; }
JavaScript
var xmlHttpsearch var nam function Showsearch(name) { xmlHttpsearch=GetXmlHttpObject() if (xmlHttpsearch==null) { alert ("Browser does not support HTTP Request") return } var url="Ajax/Search.php" url=url+"?name="+name url=url+"&sid="+Math.random() //document.write(url); xmlHttpsearch.onreadystatechange=stateChangedsearch xmlHttpsearch.open("GET",url,true) xmlHttpsearch.send(null) nam=name } function stateChangedsearch() { //document.write(xmlHttp.readyState); //document.write(xmlHttp.readyState); if (xmlHttpsearch.readyState==4 || xmlHttpsearch.readyState=="complete") { document.getElementById("SearchInterface").innerHTML=xmlHttpsearch.responseText; } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; }
JavaScript
var xmlHttpinfo var at function Showinfo(atti) { xmlHttpinfo=GetXmlHttpObject() if (xmlHttpinfo==null) { alert ("Browser does not support HTTP Request") return } var url="Ajax/Getinformation.php" url=url+"?a="+atti url=url+"&sid="+Math.random() //document.write(url); xmlHttpinfo.onreadystatechange=stateChangedinfo xmlHttpinfo.open("GET",url,true) xmlHttpinfo.send(null) at=atti } function stateChangedinfo() { //document.write(xmlHttp.readyState); //document.write(xmlHttp.readyState); if (xmlHttpinfo.readyState==4 || xmlHttpinfo.readyState=="complete") { document.getElementById("Status").innerHTML=xmlHttpinfo.responseText setTimeout("Showinfo(at)",2000); } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; }
JavaScript
$(document).ready(function(){ $(".flip").click(function(){ $(".panel").slideToggle("slow"); }); }); $(document).ready(function(){ $("p.box2").hide(); }); $(document).ready(function(){ $("#box").mouseenter(function(){ $("p.box2").show("slow"); }); }); $(document).ready(function(){ $("#box").mouseleave(function(){ $("p.box2").hide("slow"); }); });
JavaScript
$(document).ready(function(){ $("img.small").mouseover(function(){ $("img.small").css("height","80px"); }); }); $(document).ready(function(){ $("img.small").mouseout(function(){ $("img.small").css("height","50px"); }); });
JavaScript
/*! * jQuery blockUI plugin * Version 2.53 (01-NOV-2012) * @requires jQuery v1.3 or later * * Examples at: http://malsup.com/jquery/block/ * Copyright (c) 2007-2012 M. Alsup * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * * Thanks to Amir-Hossein Sobhi for some excellent contributions! */ ;(function() { "use strict"; function setup($) { if (/^1\.(0|1|2)/.test($.fn.jquery)) { /*global alert:true */ alert('blockUI requires jQuery v1.3 or later! You are using v' + $.fn.jquery); return; } $.fn._fadeIn = $.fn.fadeIn; var noOp = $.noop || function() {}; // this bit is to ensure we don't call setExpression when we shouldn't (with extra muscle to handle // retarded userAgent strings on Vista) var msie = /MSIE/.test(navigator.userAgent); var ie6 = /MSIE 6.0/.test(navigator.userAgent); var mode = document.documentMode || 0; // var setExpr = msie && (($.browser.version < 8 && !mode) || mode < 8); var setExpr = $.isFunction( document.createElement('div').style.setExpression ); // global $ methods for blocking/unblocking the entire page $.blockUI = function(opts) { install(window, opts); }; $.unblockUI = function(opts) { remove(window, opts); }; // convenience method for quick growl-like notifications (http://www.google.com/search?q=growl) $.growlUI = function(title, message, timeout, onClose) { var $m = $('<div class="growlUI"></div>'); if (title) $m.append('<h1>'+title+'</h1>'); if (message) $m.append('<h2>'+message+'</h2>'); if (timeout === undefined) timeout = 3000; $.blockUI({ message: $m, fadeIn: 700, fadeOut: 1000, centerY: false, timeout: timeout, showOverlay: false, onUnblock: onClose, css: $.blockUI.defaults.growlCSS }); }; // plugin method for blocking element content $.fn.block = function(opts) { var fullOpts = $.extend({}, $.blockUI.defaults, opts || {}); this.each(function() { var $el = $(this); if (fullOpts.ignoreIfBlocked && $el.data('blockUI.isBlocked')) return; $el.unblock({ fadeOut: 0 }); }); return this.each(function() { if ($.css(this,'position') == 'static') this.style.position = 'relative'; this.style.zoom = 1; // force 'hasLayout' in ie install(this, opts); }); }; // plugin method for unblocking element content $.fn.unblock = function(opts) { return this.each(function() { remove(this, opts); }); }; $.blockUI.version = 2.53; // 2nd generation blocking at no extra cost! // override these in your code to change the default behavior and style $.blockUI.defaults = { // message displayed when blocking (use null for no message) message: '<h1>Please wait...</h1>', title: null, // title string; only used when theme == true draggable: true, // only used when theme == true (requires jquery-ui.js to be loaded) theme: false, // set to true to use with jQuery UI themes // styles for the message when blocking; if you wish to disable // these and use an external stylesheet then do this in your code: // $.blockUI.defaults.css = {}; css: { padding: 0, margin: 0, width: '30%', top: '40%', left: '35%', textAlign: 'center', color: '#000', border: '3px solid #aaa', backgroundColor:'#fff', cursor: 'wait' }, // minimal style set used when themes are used themedCSS: { width: '30%', top: '40%', left: '35%' }, // styles for the overlay overlayCSS: { backgroundColor: '#000', opacity: 0.6, cursor: 'wait' }, // style to replace wait cursor before unblocking to correct issue // of lingering wait cursor cursorReset: 'default', // styles applied when using $.growlUI growlCSS: { width: '350px', top: '10px', left: '', right: '10px', border: 'none', padding: '5px', opacity: 0.6, cursor: 'default', color: '#fff', backgroundColor: '#000', '-webkit-border-radius':'10px', '-moz-border-radius': '10px', 'border-radius': '10px' }, // IE issues: 'about:blank' fails on HTTPS and javascript:false is s-l-o-w // (hat tip to Jorge H. N. de Vasconcelos) /*jshint scripturl:true */ iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank', // force usage of iframe in non-IE browsers (handy for blocking applets) forceIframe: false, // z-index for the blocking overlay baseZ: 1000, // set these to true to have the message automatically centered centerX: true, // <-- only effects element blocking (page block controlled via css above) centerY: true, // allow body element to be stetched in ie6; this makes blocking look better // on "short" pages. disable if you wish to prevent changes to the body height allowBodyStretch: true, // enable if you want key and mouse events to be disabled for content that is blocked bindEvents: true, // be default blockUI will supress tab navigation from leaving blocking content // (if bindEvents is true) constrainTabKey: true, // fadeIn time in millis; set to 0 to disable fadeIn on block fadeIn: 200, // fadeOut time in millis; set to 0 to disable fadeOut on unblock fadeOut: 400, // time in millis to wait before auto-unblocking; set to 0 to disable auto-unblock timeout: 0, // disable if you don't want to show the overlay showOverlay: true, // if true, focus will be placed in the first available input field when // page blocking focusInput: true, // suppresses the use of overlay styles on FF/Linux (due to performance issues with opacity) // no longer needed in 2012 // applyPlatformOpacityRules: true, // callback method invoked when fadeIn has completed and blocking message is visible onBlock: null, // callback method invoked when unblocking has completed; the callback is // passed the element that has been unblocked (which is the window object for page // blocks) and the options that were passed to the unblock call: // onUnblock(element, options) onUnblock: null, // callback method invoked when the overlay area is clicked. // setting this will turn the cursor to a pointer, otherwise cursor defined in overlayCss will be used. onOverlayClick: null, // don't ask; if you really must know: http://groups.google.com/group/jquery-en/browse_thread/thread/36640a8730503595/2f6a79a77a78e493#2f6a79a77a78e493 quirksmodeOffsetHack: 4, // class name of the message block blockMsgClass: 'blockMsg', // if it is already blocked, then ignore it (don't unblock and reblock) ignoreIfBlocked: false }; // private data and functions follow... var pageBlock = null; var pageBlockEls = []; function install(el, opts) { var css, themedCSS; var full = (el == window); var msg = (opts && opts.message !== undefined ? opts.message : undefined); opts = $.extend({}, $.blockUI.defaults, opts || {}); if (opts.ignoreIfBlocked && $(el).data('blockUI.isBlocked')) return; opts.overlayCSS = $.extend({}, $.blockUI.defaults.overlayCSS, opts.overlayCSS || {}); css = $.extend({}, $.blockUI.defaults.css, opts.css || {}); if (opts.onOverlayClick) opts.overlayCSS.cursor = 'pointer'; themedCSS = $.extend({}, $.blockUI.defaults.themedCSS, opts.themedCSS || {}); msg = msg === undefined ? opts.message : msg; // remove the current block (if there is one) if (full && pageBlock) remove(window, {fadeOut:0}); // if an existing element is being used as the blocking content then we capture // its current place in the DOM (and current display style) so we can restore // it when we unblock if (msg && typeof msg != 'string' && (msg.parentNode || msg.jquery)) { var node = msg.jquery ? msg[0] : msg; var data = {}; $(el).data('blockUI.history', data); data.el = node; data.parent = node.parentNode; data.display = node.style.display; data.position = node.style.position; if (data.parent) data.parent.removeChild(node); } $(el).data('blockUI.onUnblock', opts.onUnblock); var z = opts.baseZ; // blockUI uses 3 layers for blocking, for simplicity they are all used on every platform; // layer1 is the iframe layer which is used to supress bleed through of underlying content // layer2 is the overlay layer which has opacity and a wait cursor (by default) // layer3 is the message content that is displayed while blocking var lyr1, lyr2, lyr3, s; if (msie || opts.forceIframe) lyr1 = $('<iframe class="blockUI" style="z-index:'+ (z++) +';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="'+opts.iframeSrc+'"></iframe>'); else lyr1 = $('<div class="blockUI" style="display:none"></div>'); if (opts.theme) lyr2 = $('<div class="blockUI blockOverlay ui-widget-overlay" style="z-index:'+ (z++) +';display:none"></div>'); else lyr2 = $('<div class="blockUI blockOverlay" style="z-index:'+ (z++) +';display:none;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>'); if (opts.theme && full) { s = '<div class="blockUI ' + opts.blockMsgClass + ' blockPage ui-dialog ui-widget ui-corner-all" style="z-index:'+(z+10)+';display:none;position:fixed">'; if ( opts.title ) { s += '<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(opts.title || '&nbsp;')+'</div>'; } s += '<div class="ui-widget-content ui-dialog-content"></div>'; s += '</div>'; } else if (opts.theme) { s = '<div class="blockUI ' + opts.blockMsgClass + ' blockElement ui-dialog ui-widget ui-corner-all" style="z-index:'+(z+10)+';display:none;position:absolute">'; if ( opts.title ) { s += '<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(opts.title || '&nbsp;')+'</div>'; } s += '<div class="ui-widget-content ui-dialog-content"></div>'; s += '</div>'; } else if (full) { s = '<div class="blockUI ' + opts.blockMsgClass + ' blockPage" style="z-index:'+(z+10)+';display:none;position:fixed"></div>'; } else { s = '<div class="blockUI ' + opts.blockMsgClass + ' blockElement" style="z-index:'+(z+10)+';display:none;position:absolute"></div>'; } lyr3 = $(s); // if we have a message, style it if (msg) { if (opts.theme) { lyr3.css(themedCSS); lyr3.addClass('ui-widget-content'); } else lyr3.css(css); } // style the overlay if (!opts.theme /*&& (!opts.applyPlatformOpacityRules)*/) lyr2.css(opts.overlayCSS); lyr2.css('position', full ? 'fixed' : 'absolute'); // make iframe layer transparent in IE if (msie || opts.forceIframe) lyr1.css('opacity',0.0); //$([lyr1[0],lyr2[0],lyr3[0]]).appendTo(full ? 'body' : el); var layers = [lyr1,lyr2,lyr3], $par = full ? $('body') : $(el); $.each(layers, function() { this.appendTo($par); }); if (opts.theme && opts.draggable && $.fn.draggable) { lyr3.draggable({ handle: '.ui-dialog-titlebar', cancel: 'li' }); } // ie7 must use absolute positioning in quirks mode and to account for activex issues (when scrolling) var expr = setExpr && (!$.support.boxModel || $('object,embed', full ? null : el).length > 0); if (ie6 || expr) { // give body 100% height if (full && opts.allowBodyStretch && $.support.boxModel) $('html,body').css('height','100%'); // fix ie6 issue when blocked element has a border width if ((ie6 || !$.support.boxModel) && !full) { var t = sz(el,'borderTopWidth'), l = sz(el,'borderLeftWidth'); var fixT = t ? '(0 - '+t+')' : 0; var fixL = l ? '(0 - '+l+')' : 0; } // simulate fixed position $.each(layers, function(i,o) { var s = o[0].style; s.position = 'absolute'; if (i < 2) { if (full) s.setExpression('height','Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.support.boxModel?0:'+opts.quirksmodeOffsetHack+') + "px"'); else s.setExpression('height','this.parentNode.offsetHeight + "px"'); if (full) s.setExpression('width','jQuery.support.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"'); else s.setExpression('width','this.parentNode.offsetWidth + "px"'); if (fixL) s.setExpression('left', fixL); if (fixT) s.setExpression('top', fixT); } else if (opts.centerY) { if (full) s.setExpression('top','(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"'); s.marginTop = 0; } else if (!opts.centerY && full) { var top = (opts.css && opts.css.top) ? parseInt(opts.css.top, 10) : 0; var expression = '((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + '+top+') + "px"'; s.setExpression('top',expression); } }); } // show the message if (msg) { if (opts.theme) lyr3.find('.ui-widget-content').append(msg); else lyr3.append(msg); if (msg.jquery || msg.nodeType) $(msg).show(); } if ((msie || opts.forceIframe) && opts.showOverlay) lyr1.show(); // opacity is zero if (opts.fadeIn) { var cb = opts.onBlock ? opts.onBlock : noOp; var cb1 = (opts.showOverlay && !msg) ? cb : noOp; var cb2 = msg ? cb : noOp; if (opts.showOverlay) lyr2._fadeIn(opts.fadeIn, cb1); if (msg) lyr3._fadeIn(opts.fadeIn, cb2); } else { if (opts.showOverlay) lyr2.show(); if (msg) lyr3.show(); if (opts.onBlock) opts.onBlock(); } // bind key and mouse events bind(1, el, opts); if (full) { pageBlock = lyr3[0]; pageBlockEls = $(':input:enabled:visible',pageBlock); if (opts.focusInput) setTimeout(focus, 20); } else center(lyr3[0], opts.centerX, opts.centerY); if (opts.timeout) { // auto-unblock var to = setTimeout(function() { if (full) $.unblockUI(opts); else $(el).unblock(opts); }, opts.timeout); $(el).data('blockUI.timeout', to); } } // remove the block function remove(el, opts) { var full = (el == window); var $el = $(el); var data = $el.data('blockUI.history'); var to = $el.data('blockUI.timeout'); if (to) { clearTimeout(to); $el.removeData('blockUI.timeout'); } opts = $.extend({}, $.blockUI.defaults, opts || {}); bind(0, el, opts); // unbind events if (opts.onUnblock === null) { opts.onUnblock = $el.data('blockUI.onUnblock'); $el.removeData('blockUI.onUnblock'); } var els; if (full) // crazy selector to handle odd field errors in ie6/7 els = $('body').children().filter('.blockUI').add('body > .blockUI'); else els = $el.find('>.blockUI'); // fix cursor issue if ( opts.cursorReset ) { if ( els.length > 1 ) els[1].style.cursor = opts.cursorReset; if ( els.length > 2 ) els[2].style.cursor = opts.cursorReset; } if (full) pageBlock = pageBlockEls = null; if (opts.fadeOut) { els.fadeOut(opts.fadeOut); setTimeout(function() { reset(els,data,opts,el); }, opts.fadeOut); } else reset(els, data, opts, el); } // move blocking element back into the DOM where it started function reset(els,data,opts,el) { els.each(function(i,o) { // remove via DOM calls so we don't lose event handlers if (this.parentNode) this.parentNode.removeChild(this); }); if (data && data.el) { data.el.style.display = data.display; data.el.style.position = data.position; if (data.parent) data.parent.appendChild(data.el); $(el).removeData('blockUI.history'); } if (typeof opts.onUnblock == 'function') opts.onUnblock(el,opts); // fix issue in Safari 6 where block artifacts remain until reflow var body = $(document.body), w = body.width(), cssW = body[0].style.width; body.width(w-1).width(w); body[0].style.width = cssW; } // bind/unbind the handler function bind(b, el, opts) { var full = el == window, $el = $(el); // don't bother unbinding if there is nothing to unbind if (!b && (full && !pageBlock || !full && !$el.data('blockUI.isBlocked'))) return; $el.data('blockUI.isBlocked', b); // don't bind events when overlay is not in use or if bindEvents is false if (!opts.bindEvents || (b && !opts.showOverlay)) return; // bind anchors and inputs for mouse and key events var events = 'mousedown mouseup keydown keypress touchstart touchend touchmove'; if (b) $(document).bind(events, opts, handler); else $(document).unbind(events, handler); // former impl... // var $e = $('a,:input'); // b ? $e.bind(events, opts, handler) : $e.unbind(events, handler); } // event handler to suppress keyboard/mouse events when blocking function handler(e) { // allow tab navigation (conditionally) if (e.keyCode && e.keyCode == 9) { if (pageBlock && e.data.constrainTabKey) { var els = pageBlockEls; var fwd = !e.shiftKey && e.target === els[els.length-1]; var back = e.shiftKey && e.target === els[0]; if (fwd || back) { setTimeout(function(){focus(back);},10); return false; } } } var opts = e.data; var target = $(e.target); if (target.hasClass('blockOverlay') && opts.onOverlayClick) opts.onOverlayClick(); // allow events within the message content if (target.parents('div.' + opts.blockMsgClass).length > 0) return true; // allow events for content that is not being blocked return target.parents().children().filter('div.blockUI').length === 0; } function focus(back) { if (!pageBlockEls) return; var e = pageBlockEls[back===true ? pageBlockEls.length-1 : 0]; if (e) e.focus(); } function center(el, x, y) { var p = el.parentNode, s = el.style; var l = ((p.offsetWidth - el.offsetWidth)/2) - sz(p,'borderLeftWidth'); var t = ((p.offsetHeight - el.offsetHeight)/2) - sz(p,'borderTopWidth'); if (x) s.left = l > 0 ? (l+'px') : '0'; if (y) s.top = t > 0 ? (t+'px') : '0'; } function sz(el, p) { return parseInt($.css(el,p),10)||0; } } /*global define:true */ if (typeof define === 'function' && define.amd && define.amd.jQuery) { define(['jquery'], setup); } else { setup(jQuery); } })();
JavaScript
/** * impress.js * * impress.js is a presentation tool based on the power of CSS3 transforms and transitions * in modern browsers and inspired by the idea behind prezi.com. * * * Copyright 2011-2012 Bartek Szopka (@bartaz) * * Released under the MIT and GPL Licenses. * * ------------------------------------------------ * author: Bartek Szopka * version: 0.5.1 * url: http://bartaz.github.com/impress.js/ * source: http://github.com/bartaz/impress.js/ */ /*jshint bitwise:true, curly:true, eqeqeq:true, forin:true, latedef:true, newcap:true, noarg:true, noempty:true, undef:true, strict:true, browser:true */ (function ( document, window ) { 'use strict'; // HELPER FUNCTIONS var pfx = (function () { var style = document.createElement('dummy').style, prefixes = 'Webkit Moz O ms Khtml'.split(' '), memory = {}; return function ( prop ) { if ( typeof memory[ prop ] === "undefined" ) { var ucProp = prop.charAt(0).toUpperCase() + prop.substr(1), props = (prop + ' ' + prefixes.join(ucProp + ' ') + ucProp).split(' '); memory[ prop ] = null; for ( var i in props ) { if ( style[ props[i] ] !== undefined ) { memory[ prop ] = props[i]; break; } } } return memory[ prop ]; }; })(); var arrayify = function ( a ) { return [].slice.call( a ); }; var css = function ( el, props ) { var key, pkey; for ( key in props ) { if ( props.hasOwnProperty(key) ) { pkey = pfx(key); if ( pkey !== null ) { el.style[pkey] = props[key]; } } } return el; }; var toNumber = function (numeric, fallback) { return isNaN(numeric) ? (fallback || 0) : Number(numeric); }; var byId = function ( id ) { return document.getElementById(id); }; var $ = function ( selector, context ) { context = context || document; return context.querySelector(selector); }; var $$ = function ( selector, context ) { context = context || document; return arrayify( context.querySelectorAll(selector) ); }; var triggerEvent = function (el, eventName, detail) { var event = document.createEvent("CustomEvent"); event.initCustomEvent(eventName, true, true, detail); el.dispatchEvent(event); }; var translate = function ( t ) { return " translate3d(" + t.x + "px," + t.y + "px," + t.z + "px) "; }; var rotate = function ( r, revert ) { var rX = " rotateX(" + r.x + "deg) ", rY = " rotateY(" + r.y + "deg) ", rZ = " rotateZ(" + r.z + "deg) "; return revert ? rZ+rY+rX : rX+rY+rZ; }; var scale = function ( s ) { return " scale(" + s + ") "; }; var perspective = function ( p ) { return " perspective(" + p + "px) "; }; var getElementFromUrl = function () { // get id from url # by removing `#` or `#/` from the beginning, // so both "fallback" `#slide-id` and "enhanced" `#/slide-id` will work return byId( window.location.hash.replace(/^#\/?/,"") ); }; var computeWindowScale = function ( config ) { var hScale = window.innerHeight / config.height, wScale = window.innerWidth / config.width, scale = hScale > wScale ? wScale : hScale; if (config.maxScale && scale > config.maxScale) { scale = config.maxScale; } if (config.minScale && scale < config.minScale) { scale = config.minScale; } return scale; }; // CHECK SUPPORT var body = document.body; var ua = navigator.userAgent.toLowerCase(); var impressSupported = ( pfx("perspective") !== null ) && ( body.classList ) && ( body.dataset ) && ( ua.search(/(iphone)|(ipod)|(android)/) === -1 ); if (!impressSupported) { // we can't be sure that `classList` is supported body.className += " impress-not-supported "; } else { body.classList.remove("impress-not-supported"); body.classList.add("impress-supported"); } // cross-browser transitionEnd event name // based on https://developer.mozilla.org/en/CSS/CSS_transitions var transitionEnd = ({ 'transition':'transitionEnd', 'OTransition':'oTransitionEnd', 'msTransition':'MSTransitionEnd', // who knows how it will end up? 'MozTransition':'transitionend', 'WebkitTransition':'webkitTransitionEnd' })[pfx("transition")]; var roots = {}; var defaults = { width: 1024, height: 768, maxScale: 1, minScale: 0, perspective: 1000, transitionDuration: 1000 }; var empty = function () { return false; }; var impress = window.impress = function ( rootId ) { // if impress.js is not supported by the browser return a dummy API // it may not be a perfect solution but we return early and avoid // running code that may use features not implemented in the browser if (!impressSupported) { return { init: empty, goto: empty, prev: empty, next: empty }; } rootId = rootId || "impress"; // if already initialized just return the API if (roots["impress-root-" + rootId]) { return roots["impress-root-" + rootId]; } // data of all presentation steps var stepsData = {}; // element of currently active step var activeStep = null; // current state (position, rotation and scale) of the presentation var currentState = null; // array of step elements var steps = null; // configuration options var config = null; // scale factor of the browser window var windowScale = null; // root presentation elements var root = byId( rootId ); var canvas = document.createElement("div"); var initialized = false; // step events var lastEntered = null; var onStepEnter = function (step) { if (lastEntered !== step) { triggerEvent(step, "impress:stepenter"); lastEntered = step; } }; var onStepLeave = function (step) { if (lastEntered === step) { triggerEvent(step, "impress:stepleave"); lastEntered = null; } }; // transitionEnd event handler var expectedTransitionTarget = null; var onTransitionEnd = function (event) { // we only care about transitions on `root` and `canvas` elements if (event.target === expectedTransitionTarget) { onStepEnter(activeStep); event.stopPropagation(); // prevent propagation from `canvas` to `root` } }; var initStep = function ( el, idx ) { var data = el.dataset, step = { translate: { x: toNumber(data.x), y: toNumber(data.y), z: toNumber(data.z) }, rotate: { x: toNumber(data.rotateX), y: toNumber(data.rotateY), z: toNumber(data.rotateZ || data.rotate) }, scale: toNumber(data.scale, 1), el: el }; if ( !el.id ) { el.id = "step-" + (idx + 1); } stepsData["impress-" + el.id] = step; css(el, { position: "absolute", transform: "translate(-50%,-50%)" + translate(step.translate) + rotate(step.rotate) + scale(step.scale), transformStyle: "preserve-3d" }); }; var init = function () { if (initialized) { return; } // setup viewport for mobile devices var meta = $("meta[name='viewport']") || document.createElement("meta"); meta.content = "width=device-width, minimum-scale=1, maximum-scale=1, user-scalable=no"; if (meta.parentNode !== document.head) { meta.name = 'viewport'; document.head.appendChild(meta); } // initialize configuration object var rootData = root.dataset; config = { width: toNumber( rootData.width, defaults.width ), height: toNumber( rootData.height, defaults.height ), maxScale: toNumber( rootData.maxScale, defaults.maxScale ), minScale: toNumber( rootData.minScale, defaults.minScale ), perspective: toNumber( rootData.perspective, defaults.perspective ), transitionDuration: toNumber( rootData.transitionDuration, defaults.transitionDuration ) }; windowScale = computeWindowScale( config ); // wrap steps with "canvas" element arrayify( root.childNodes ).forEach(function ( el ) { canvas.appendChild( el ); }); root.appendChild(canvas); // set initial styles document.documentElement.style.height = "100%"; css(body, { height: "100%", overflow: "hidden" }); var rootStyles = { position: "absolute", transformOrigin: "top left", transition: "all 0s ease-in-out", transformStyle: "preserve-3d" }; css(root, rootStyles); css(root, { top: "50%", left: "50%", transform: perspective( config.perspective/windowScale ) + scale( windowScale ) }); css(canvas, rootStyles); root.addEventListener(transitionEnd, onTransitionEnd, false); canvas.addEventListener(transitionEnd, onTransitionEnd, false); body.classList.remove("impress-disabled"); body.classList.add("impress-enabled"); // get and init steps steps = $$(".step", root); steps.forEach( initStep ); currentState = { translate: { x: 0, y: 0, z: 0 }, rotate: { x: 0, y: 0, z: 0 }, scale: 1 }; initialized = true; triggerEvent(root, "impress:init", { api: roots[ "impress-root-" + rootId ] }); }; var getStep = function ( step ) { if (typeof step === "number") { step = step < 0 ? steps[ steps.length + step] : steps[ step ]; } else if (typeof step === "string") { step = byId(step); } return (step && step.id && stepsData["impress-" + step.id]) ? step : null; }; var goto = function ( el, duration ) { if ( !initialized || !(el = getStep(el)) ) { // presentation not initialized or given element is not a step return false; } // Sometimes it's possible to trigger focus on first link with some keyboard action. // Browser in such a case tries to scroll the page to make this element visible // (even that body overflow is set to hidden) and it breaks our careful positioning. // // So, as a lousy (and lazy) workaround we will make the page scroll back to the top // whenever slide is selected // // If you are reading this and know any better way to handle it, I'll be glad to hear about it! window.scrollTo(0, 0); var step = stepsData["impress-" + el.id]; if ( activeStep ) { activeStep.classList.remove("active"); body.classList.remove("impress-on-" + activeStep.id); } el.classList.add("active"); body.classList.add("impress-on-" + el.id); var target = { rotate: { x: -step.rotate.x, y: -step.rotate.y, z: -step.rotate.z }, translate: { x: -step.translate.x, y: -step.translate.y, z: -step.translate.z }, scale: 1 / step.scale }; // check if the transition is zooming in or not var zoomin = target.scale >= currentState.scale; duration = toNumber(duration, config.transitionDuration); var delay = (duration / 2); if (el === activeStep) { windowScale = computeWindowScale(config); } var targetScale = target.scale * windowScale; expectedTransitionTarget = target.scale > currentState.scale ? root : canvas; if (activeStep && activeStep !== el) { onStepLeave(activeStep); } css(root, { // to keep the perspective look similar for different scales // we need to 'scale' the perspective, too transform: perspective( config.perspective / targetScale ) + scale( targetScale ), transitionDuration: duration + "ms", transitionDelay: (zoomin ? delay : 0) + "ms" }); css(canvas, { transform: rotate(target.rotate, true) + translate(target.translate), transitionDuration: duration + "ms", transitionDelay: (zoomin ? 0 : delay) + "ms" }); currentState = target; activeStep = el; if (duration === 0) { onStepEnter(activeStep); } return el; }; var prev = function () { var prev = steps.indexOf( activeStep ) - 1; prev = prev >= 0 ? steps[ prev ] : steps[ steps.length-1 ]; return goto(prev); }; var next = function () { var next = steps.indexOf( activeStep ) + 1; next = next < steps.length ? steps[ next ] : steps[ 0 ]; return goto(next); }; root.addEventListener("impress:init", function(){ // STEP CLASSES steps.forEach(function (step) { step.classList.add("future"); }); root.addEventListener("impress:stepenter", function (event) { event.target.classList.remove("past"); event.target.classList.remove("future"); event.target.classList.add("present"); }, false); root.addEventListener("impress:stepleave", function (event) { event.target.classList.remove("present"); event.target.classList.add("past"); }, false); }, false); root.addEventListener("impress:init", function(){ // HASH CHANGE var lastHash = ""; // `#/step-id` is used instead of `#step-id` to prevent default browser // scrolling to element in hash // // and it has to be set after animation finishes, because in Chrome it // causes transtion being laggy // BUG: http://code.google.com/p/chromium/issues/detail?id=62820 root.addEventListener("impress:stepenter", function (event) { window.location.hash = lastHash = "#/" + event.target.id; }, false); window.addEventListener("hashchange", function () { // don't go twice to same element if (window.location.hash !== lastHash) { goto( getElementFromUrl() ); } }, false); // START // by selecting step defined in url or first step of the presentation goto(getElementFromUrl() || steps[0], 0); }, false); body.classList.add("impress-disabled"); return (roots[ "impress-root-" + rootId ] = { init: init, goto: goto, next: next, prev: prev }); }; impress.supported = impressSupported; })(document, window); // EVENTS (function ( document, window ) { 'use strict'; // throttling function calls, by Remy Sharp // http://remysharp.com/2010/07/21/throttling-function-calls/ var throttle = function (fn, delay) { var timer = null; return function () { var context = this, args = arguments; clearTimeout(timer); timer = setTimeout(function () { fn.apply(context, args); }, delay); }; }; document.addEventListener("impress:init", function (event) { var api = event.detail.api; // keyboard navigation handlers // prevent default keydown action when one of supported key is pressed document.addEventListener("keydown", function ( event ) { if ( event.keyCode === 9 || ( event.keyCode >= 32 && event.keyCode <= 34 ) || (event.keyCode >= 37 && event.keyCode <= 40) ) { event.preventDefault(); } }, false); // trigger impress action on keyup document.addEventListener("keyup", function ( event ) { if ( event.keyCode === 9 || ( event.keyCode >= 32 && event.keyCode <= 34 ) || (event.keyCode >= 37 && event.keyCode <= 40) ) { switch( event.keyCode ) { case 33: // pg up case 37: // left case 38: // up api.prev(); break; case 9: // tab case 32: // space case 34: // pg down case 39: // right case 40: // down api.next(); break; } event.preventDefault(); } }, false); // delegated handler for clicking on the links to presentation steps document.addEventListener("click", function ( event ) { // event delegation with "bubbling" // check if event target (or any of its parents is a link) var target = event.target; while ( (target.tagName !== "A") && (target !== document.documentElement) ) { target = target.parentNode; } if ( target.tagName === "A" ) { var href = target.getAttribute("href"); // if it's a link to presentation step, target this step if ( href && href[0] === '#' ) { target = document.getElementById( href.slice(1) ); } } if ( api.goto(target) ) { event.stopImmediatePropagation(); event.preventDefault(); } }, false); // delegated handler for clicking on step elements document.addEventListener("click", function ( event ) { var target = event.target; // find closest step element that is not active while ( !(target.classList.contains("step") && !target.classList.contains("active")) && (target !== document.documentElement) ) { target = target.parentNode; } if ( api.goto(target) ) { event.preventDefault(); } }, false); // touch handler to detect taps on the left and right side of the screen document.addEventListener("touchstart", function ( event ) { if (event.touches.length === 1) { var x = event.touches[0].clientX, width = window.innerWidth * 0.3, result = null; if ( x < width ) { result = api.prev(); } else if ( x > window.innerWidth - width ) { result = api.next(); } if (result) { event.preventDefault(); } } }, false); // rescale presentation when window is resized window.addEventListener("resize", throttle(function () { // force going to active step again, to trigger rescaling api.goto( document.querySelector(".active"), 500 ); }, 250), false); }, false); })(document, window);
JavaScript
$(document).ready(function(){ $(".flip").click(function(){ $(".panel").slideToggle("slow"); }); }); $(document).ready(function(){ $("p.box2").hide(); }); $(document).ready(function(){ $("#box").mouseenter(function(){ $("p.box2").show("slow"); }); }); $(document).ready(function(){ $("#box").mouseleave(function(){ $("p.box2").hide("slow"); }); });
JavaScript
$(document).ready(function(){ $("img.small").mouseover(function(){ $("img.small").css("height","80px"); }); }); $(document).ready(function(){ $("img.small").mouseout(function(){ $("img.small").css("height","50px"); }); });
JavaScript
/*! * jQuery blockUI plugin * Version 2.53 (01-NOV-2012) * @requires jQuery v1.3 or later * * Examples at: http://malsup.com/jquery/block/ * Copyright (c) 2007-2012 M. Alsup * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * * Thanks to Amir-Hossein Sobhi for some excellent contributions! */ ;(function() { "use strict"; function setup($) { if (/^1\.(0|1|2)/.test($.fn.jquery)) { /*global alert:true */ alert('blockUI requires jQuery v1.3 or later! You are using v' + $.fn.jquery); return; } $.fn._fadeIn = $.fn.fadeIn; var noOp = $.noop || function() {}; // this bit is to ensure we don't call setExpression when we shouldn't (with extra muscle to handle // retarded userAgent strings on Vista) var msie = /MSIE/.test(navigator.userAgent); var ie6 = /MSIE 6.0/.test(navigator.userAgent); var mode = document.documentMode || 0; // var setExpr = msie && (($.browser.version < 8 && !mode) || mode < 8); var setExpr = $.isFunction( document.createElement('div').style.setExpression ); // global $ methods for blocking/unblocking the entire page $.blockUI = function(opts) { install(window, opts); }; $.unblockUI = function(opts) { remove(window, opts); }; // convenience method for quick growl-like notifications (http://www.google.com/search?q=growl) $.growlUI = function(title, message, timeout, onClose) { var $m = $('<div class="growlUI"></div>'); if (title) $m.append('<h1>'+title+'</h1>'); if (message) $m.append('<h2>'+message+'</h2>'); if (timeout === undefined) timeout = 3000; $.blockUI({ message: $m, fadeIn: 700, fadeOut: 1000, centerY: false, timeout: timeout, showOverlay: false, onUnblock: onClose, css: $.blockUI.defaults.growlCSS }); }; // plugin method for blocking element content $.fn.block = function(opts) { var fullOpts = $.extend({}, $.blockUI.defaults, opts || {}); this.each(function() { var $el = $(this); if (fullOpts.ignoreIfBlocked && $el.data('blockUI.isBlocked')) return; $el.unblock({ fadeOut: 0 }); }); return this.each(function() { if ($.css(this,'position') == 'static') this.style.position = 'relative'; this.style.zoom = 1; // force 'hasLayout' in ie install(this, opts); }); }; // plugin method for unblocking element content $.fn.unblock = function(opts) { return this.each(function() { remove(this, opts); }); }; $.blockUI.version = 2.53; // 2nd generation blocking at no extra cost! // override these in your code to change the default behavior and style $.blockUI.defaults = { // message displayed when blocking (use null for no message) message: '<h1>Please wait...</h1>', title: null, // title string; only used when theme == true draggable: true, // only used when theme == true (requires jquery-ui.js to be loaded) theme: false, // set to true to use with jQuery UI themes // styles for the message when blocking; if you wish to disable // these and use an external stylesheet then do this in your code: // $.blockUI.defaults.css = {}; css: { padding: 0, margin: 0, width: '30%', top: '40%', left: '35%', textAlign: 'center', color: '#000', border: '3px solid #aaa', backgroundColor:'#fff', cursor: 'wait' }, // minimal style set used when themes are used themedCSS: { width: '30%', top: '40%', left: '35%' }, // styles for the overlay overlayCSS: { backgroundColor: '#000', opacity: 0.6, cursor: 'wait' }, // style to replace wait cursor before unblocking to correct issue // of lingering wait cursor cursorReset: 'default', // styles applied when using $.growlUI growlCSS: { width: '350px', top: '10px', left: '', right: '10px', border: 'none', padding: '5px', opacity: 0.6, cursor: 'default', color: '#fff', backgroundColor: '#000', '-webkit-border-radius':'10px', '-moz-border-radius': '10px', 'border-radius': '10px' }, // IE issues: 'about:blank' fails on HTTPS and javascript:false is s-l-o-w // (hat tip to Jorge H. N. de Vasconcelos) /*jshint scripturl:true */ iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank', // force usage of iframe in non-IE browsers (handy for blocking applets) forceIframe: false, // z-index for the blocking overlay baseZ: 1000, // set these to true to have the message automatically centered centerX: true, // <-- only effects element blocking (page block controlled via css above) centerY: true, // allow body element to be stetched in ie6; this makes blocking look better // on "short" pages. disable if you wish to prevent changes to the body height allowBodyStretch: true, // enable if you want key and mouse events to be disabled for content that is blocked bindEvents: true, // be default blockUI will supress tab navigation from leaving blocking content // (if bindEvents is true) constrainTabKey: true, // fadeIn time in millis; set to 0 to disable fadeIn on block fadeIn: 200, // fadeOut time in millis; set to 0 to disable fadeOut on unblock fadeOut: 400, // time in millis to wait before auto-unblocking; set to 0 to disable auto-unblock timeout: 0, // disable if you don't want to show the overlay showOverlay: true, // if true, focus will be placed in the first available input field when // page blocking focusInput: true, // suppresses the use of overlay styles on FF/Linux (due to performance issues with opacity) // no longer needed in 2012 // applyPlatformOpacityRules: true, // callback method invoked when fadeIn has completed and blocking message is visible onBlock: null, // callback method invoked when unblocking has completed; the callback is // passed the element that has been unblocked (which is the window object for page // blocks) and the options that were passed to the unblock call: // onUnblock(element, options) onUnblock: null, // callback method invoked when the overlay area is clicked. // setting this will turn the cursor to a pointer, otherwise cursor defined in overlayCss will be used. onOverlayClick: null, // don't ask; if you really must know: http://groups.google.com/group/jquery-en/browse_thread/thread/36640a8730503595/2f6a79a77a78e493#2f6a79a77a78e493 quirksmodeOffsetHack: 4, // class name of the message block blockMsgClass: 'blockMsg', // if it is already blocked, then ignore it (don't unblock and reblock) ignoreIfBlocked: false }; // private data and functions follow... var pageBlock = null; var pageBlockEls = []; function install(el, opts) { var css, themedCSS; var full = (el == window); var msg = (opts && opts.message !== undefined ? opts.message : undefined); opts = $.extend({}, $.blockUI.defaults, opts || {}); if (opts.ignoreIfBlocked && $(el).data('blockUI.isBlocked')) return; opts.overlayCSS = $.extend({}, $.blockUI.defaults.overlayCSS, opts.overlayCSS || {}); css = $.extend({}, $.blockUI.defaults.css, opts.css || {}); if (opts.onOverlayClick) opts.overlayCSS.cursor = 'pointer'; themedCSS = $.extend({}, $.blockUI.defaults.themedCSS, opts.themedCSS || {}); msg = msg === undefined ? opts.message : msg; // remove the current block (if there is one) if (full && pageBlock) remove(window, {fadeOut:0}); // if an existing element is being used as the blocking content then we capture // its current place in the DOM (and current display style) so we can restore // it when we unblock if (msg && typeof msg != 'string' && (msg.parentNode || msg.jquery)) { var node = msg.jquery ? msg[0] : msg; var data = {}; $(el).data('blockUI.history', data); data.el = node; data.parent = node.parentNode; data.display = node.style.display; data.position = node.style.position; if (data.parent) data.parent.removeChild(node); } $(el).data('blockUI.onUnblock', opts.onUnblock); var z = opts.baseZ; // blockUI uses 3 layers for blocking, for simplicity they are all used on every platform; // layer1 is the iframe layer which is used to supress bleed through of underlying content // layer2 is the overlay layer which has opacity and a wait cursor (by default) // layer3 is the message content that is displayed while blocking var lyr1, lyr2, lyr3, s; if (msie || opts.forceIframe) lyr1 = $('<iframe class="blockUI" style="z-index:'+ (z++) +';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="'+opts.iframeSrc+'"></iframe>'); else lyr1 = $('<div class="blockUI" style="display:none"></div>'); if (opts.theme) lyr2 = $('<div class="blockUI blockOverlay ui-widget-overlay" style="z-index:'+ (z++) +';display:none"></div>'); else lyr2 = $('<div class="blockUI blockOverlay" style="z-index:'+ (z++) +';display:none;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>'); if (opts.theme && full) { s = '<div class="blockUI ' + opts.blockMsgClass + ' blockPage ui-dialog ui-widget ui-corner-all" style="z-index:'+(z+10)+';display:none;position:fixed">'; if ( opts.title ) { s += '<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(opts.title || '&nbsp;')+'</div>'; } s += '<div class="ui-widget-content ui-dialog-content"></div>'; s += '</div>'; } else if (opts.theme) { s = '<div class="blockUI ' + opts.blockMsgClass + ' blockElement ui-dialog ui-widget ui-corner-all" style="z-index:'+(z+10)+';display:none;position:absolute">'; if ( opts.title ) { s += '<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(opts.title || '&nbsp;')+'</div>'; } s += '<div class="ui-widget-content ui-dialog-content"></div>'; s += '</div>'; } else if (full) { s = '<div class="blockUI ' + opts.blockMsgClass + ' blockPage" style="z-index:'+(z+10)+';display:none;position:fixed"></div>'; } else { s = '<div class="blockUI ' + opts.blockMsgClass + ' blockElement" style="z-index:'+(z+10)+';display:none;position:absolute"></div>'; } lyr3 = $(s); // if we have a message, style it if (msg) { if (opts.theme) { lyr3.css(themedCSS); lyr3.addClass('ui-widget-content'); } else lyr3.css(css); } // style the overlay if (!opts.theme /*&& (!opts.applyPlatformOpacityRules)*/) lyr2.css(opts.overlayCSS); lyr2.css('position', full ? 'fixed' : 'absolute'); // make iframe layer transparent in IE if (msie || opts.forceIframe) lyr1.css('opacity',0.0); //$([lyr1[0],lyr2[0],lyr3[0]]).appendTo(full ? 'body' : el); var layers = [lyr1,lyr2,lyr3], $par = full ? $('body') : $(el); $.each(layers, function() { this.appendTo($par); }); if (opts.theme && opts.draggable && $.fn.draggable) { lyr3.draggable({ handle: '.ui-dialog-titlebar', cancel: 'li' }); } // ie7 must use absolute positioning in quirks mode and to account for activex issues (when scrolling) var expr = setExpr && (!$.support.boxModel || $('object,embed', full ? null : el).length > 0); if (ie6 || expr) { // give body 100% height if (full && opts.allowBodyStretch && $.support.boxModel) $('html,body').css('height','100%'); // fix ie6 issue when blocked element has a border width if ((ie6 || !$.support.boxModel) && !full) { var t = sz(el,'borderTopWidth'), l = sz(el,'borderLeftWidth'); var fixT = t ? '(0 - '+t+')' : 0; var fixL = l ? '(0 - '+l+')' : 0; } // simulate fixed position $.each(layers, function(i,o) { var s = o[0].style; s.position = 'absolute'; if (i < 2) { if (full) s.setExpression('height','Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.support.boxModel?0:'+opts.quirksmodeOffsetHack+') + "px"'); else s.setExpression('height','this.parentNode.offsetHeight + "px"'); if (full) s.setExpression('width','jQuery.support.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"'); else s.setExpression('width','this.parentNode.offsetWidth + "px"'); if (fixL) s.setExpression('left', fixL); if (fixT) s.setExpression('top', fixT); } else if (opts.centerY) { if (full) s.setExpression('top','(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"'); s.marginTop = 0; } else if (!opts.centerY && full) { var top = (opts.css && opts.css.top) ? parseInt(opts.css.top, 10) : 0; var expression = '((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + '+top+') + "px"'; s.setExpression('top',expression); } }); } // show the message if (msg) { if (opts.theme) lyr3.find('.ui-widget-content').append(msg); else lyr3.append(msg); if (msg.jquery || msg.nodeType) $(msg).show(); } if ((msie || opts.forceIframe) && opts.showOverlay) lyr1.show(); // opacity is zero if (opts.fadeIn) { var cb = opts.onBlock ? opts.onBlock : noOp; var cb1 = (opts.showOverlay && !msg) ? cb : noOp; var cb2 = msg ? cb : noOp; if (opts.showOverlay) lyr2._fadeIn(opts.fadeIn, cb1); if (msg) lyr3._fadeIn(opts.fadeIn, cb2); } else { if (opts.showOverlay) lyr2.show(); if (msg) lyr3.show(); if (opts.onBlock) opts.onBlock(); } // bind key and mouse events bind(1, el, opts); if (full) { pageBlock = lyr3[0]; pageBlockEls = $(':input:enabled:visible',pageBlock); if (opts.focusInput) setTimeout(focus, 20); } else center(lyr3[0], opts.centerX, opts.centerY); if (opts.timeout) { // auto-unblock var to = setTimeout(function() { if (full) $.unblockUI(opts); else $(el).unblock(opts); }, opts.timeout); $(el).data('blockUI.timeout', to); } } // remove the block function remove(el, opts) { var full = (el == window); var $el = $(el); var data = $el.data('blockUI.history'); var to = $el.data('blockUI.timeout'); if (to) { clearTimeout(to); $el.removeData('blockUI.timeout'); } opts = $.extend({}, $.blockUI.defaults, opts || {}); bind(0, el, opts); // unbind events if (opts.onUnblock === null) { opts.onUnblock = $el.data('blockUI.onUnblock'); $el.removeData('blockUI.onUnblock'); } var els; if (full) // crazy selector to handle odd field errors in ie6/7 els = $('body').children().filter('.blockUI').add('body > .blockUI'); else els = $el.find('>.blockUI'); // fix cursor issue if ( opts.cursorReset ) { if ( els.length > 1 ) els[1].style.cursor = opts.cursorReset; if ( els.length > 2 ) els[2].style.cursor = opts.cursorReset; } if (full) pageBlock = pageBlockEls = null; if (opts.fadeOut) { els.fadeOut(opts.fadeOut); setTimeout(function() { reset(els,data,opts,el); }, opts.fadeOut); } else reset(els, data, opts, el); } // move blocking element back into the DOM where it started function reset(els,data,opts,el) { els.each(function(i,o) { // remove via DOM calls so we don't lose event handlers if (this.parentNode) this.parentNode.removeChild(this); }); if (data && data.el) { data.el.style.display = data.display; data.el.style.position = data.position; if (data.parent) data.parent.appendChild(data.el); $(el).removeData('blockUI.history'); } if (typeof opts.onUnblock == 'function') opts.onUnblock(el,opts); // fix issue in Safari 6 where block artifacts remain until reflow var body = $(document.body), w = body.width(), cssW = body[0].style.width; body.width(w-1).width(w); body[0].style.width = cssW; } // bind/unbind the handler function bind(b, el, opts) { var full = el == window, $el = $(el); // don't bother unbinding if there is nothing to unbind if (!b && (full && !pageBlock || !full && !$el.data('blockUI.isBlocked'))) return; $el.data('blockUI.isBlocked', b); // don't bind events when overlay is not in use or if bindEvents is false if (!opts.bindEvents || (b && !opts.showOverlay)) return; // bind anchors and inputs for mouse and key events var events = 'mousedown mouseup keydown keypress touchstart touchend touchmove'; if (b) $(document).bind(events, opts, handler); else $(document).unbind(events, handler); // former impl... // var $e = $('a,:input'); // b ? $e.bind(events, opts, handler) : $e.unbind(events, handler); } // event handler to suppress keyboard/mouse events when blocking function handler(e) { // allow tab navigation (conditionally) if (e.keyCode && e.keyCode == 9) { if (pageBlock && e.data.constrainTabKey) { var els = pageBlockEls; var fwd = !e.shiftKey && e.target === els[els.length-1]; var back = e.shiftKey && e.target === els[0]; if (fwd || back) { setTimeout(function(){focus(back);},10); return false; } } } var opts = e.data; var target = $(e.target); if (target.hasClass('blockOverlay') && opts.onOverlayClick) opts.onOverlayClick(); // allow events within the message content if (target.parents('div.' + opts.blockMsgClass).length > 0) return true; // allow events for content that is not being blocked return target.parents().children().filter('div.blockUI').length === 0; } function focus(back) { if (!pageBlockEls) return; var e = pageBlockEls[back===true ? pageBlockEls.length-1 : 0]; if (e) e.focus(); } function center(el, x, y) { var p = el.parentNode, s = el.style; var l = ((p.offsetWidth - el.offsetWidth)/2) - sz(p,'borderLeftWidth'); var t = ((p.offsetHeight - el.offsetHeight)/2) - sz(p,'borderTopWidth'); if (x) s.left = l > 0 ? (l+'px') : '0'; if (y) s.top = t > 0 ? (t+'px') : '0'; } function sz(el, p) { return parseInt($.css(el,p),10)||0; } } /*global define:true */ if (typeof define === 'function' && define.amd && define.amd.jQuery) { define(['jquery'], setup); } else { setup(jQuery); } })();
JavaScript
/** * impress.js * * impress.js is a presentation tool based on the power of CSS3 transforms and transitions * in modern browsers and inspired by the idea behind prezi.com. * * * Copyright 2011-2012 Bartek Szopka (@bartaz) * * Released under the MIT and GPL Licenses. * * ------------------------------------------------ * author: Bartek Szopka * version: 0.5.1 * url: http://bartaz.github.com/impress.js/ * source: http://github.com/bartaz/impress.js/ */ /*jshint bitwise:true, curly:true, eqeqeq:true, forin:true, latedef:true, newcap:true, noarg:true, noempty:true, undef:true, strict:true, browser:true */ (function ( document, window ) { 'use strict'; // HELPER FUNCTIONS var pfx = (function () { var style = document.createElement('dummy').style, prefixes = 'Webkit Moz O ms Khtml'.split(' '), memory = {}; return function ( prop ) { if ( typeof memory[ prop ] === "undefined" ) { var ucProp = prop.charAt(0).toUpperCase() + prop.substr(1), props = (prop + ' ' + prefixes.join(ucProp + ' ') + ucProp).split(' '); memory[ prop ] = null; for ( var i in props ) { if ( style[ props[i] ] !== undefined ) { memory[ prop ] = props[i]; break; } } } return memory[ prop ]; }; })(); var arrayify = function ( a ) { return [].slice.call( a ); }; var css = function ( el, props ) { var key, pkey; for ( key in props ) { if ( props.hasOwnProperty(key) ) { pkey = pfx(key); if ( pkey !== null ) { el.style[pkey] = props[key]; } } } return el; }; var toNumber = function (numeric, fallback) { return isNaN(numeric) ? (fallback || 0) : Number(numeric); }; var byId = function ( id ) { return document.getElementById(id); }; var $ = function ( selector, context ) { context = context || document; return context.querySelector(selector); }; var $$ = function ( selector, context ) { context = context || document; return arrayify( context.querySelectorAll(selector) ); }; var triggerEvent = function (el, eventName, detail) { var event = document.createEvent("CustomEvent"); event.initCustomEvent(eventName, true, true, detail); el.dispatchEvent(event); }; var translate = function ( t ) { return " translate3d(" + t.x + "px," + t.y + "px," + t.z + "px) "; }; var rotate = function ( r, revert ) { var rX = " rotateX(" + r.x + "deg) ", rY = " rotateY(" + r.y + "deg) ", rZ = " rotateZ(" + r.z + "deg) "; return revert ? rZ+rY+rX : rX+rY+rZ; }; var scale = function ( s ) { return " scale(" + s + ") "; }; var perspective = function ( p ) { return " perspective(" + p + "px) "; }; var getElementFromUrl = function () { // get id from url # by removing `#` or `#/` from the beginning, // so both "fallback" `#slide-id` and "enhanced" `#/slide-id` will work return byId( window.location.hash.replace(/^#\/?/,"") ); }; var computeWindowScale = function ( config ) { var hScale = window.innerHeight / config.height, wScale = window.innerWidth / config.width, scale = hScale > wScale ? wScale : hScale; if (config.maxScale && scale > config.maxScale) { scale = config.maxScale; } if (config.minScale && scale < config.minScale) { scale = config.minScale; } return scale; }; // CHECK SUPPORT var body = document.body; var ua = navigator.userAgent.toLowerCase(); var impressSupported = ( pfx("perspective") !== null ) && ( body.classList ) && ( body.dataset ) && ( ua.search(/(iphone)|(ipod)|(android)/) === -1 ); if (!impressSupported) { // we can't be sure that `classList` is supported body.className += " impress-not-supported "; } else { body.classList.remove("impress-not-supported"); body.classList.add("impress-supported"); } // cross-browser transitionEnd event name // based on https://developer.mozilla.org/en/CSS/CSS_transitions var transitionEnd = ({ 'transition':'transitionEnd', 'OTransition':'oTransitionEnd', 'msTransition':'MSTransitionEnd', // who knows how it will end up? 'MozTransition':'transitionend', 'WebkitTransition':'webkitTransitionEnd' })[pfx("transition")]; var roots = {}; var defaults = { width: 1024, height: 768, maxScale: 1, minScale: 0, perspective: 1000, transitionDuration: 1000 }; var empty = function () { return false; }; var impress = window.impress = function ( rootId ) { // if impress.js is not supported by the browser return a dummy API // it may not be a perfect solution but we return early and avoid // running code that may use features not implemented in the browser if (!impressSupported) { return { init: empty, goto: empty, prev: empty, next: empty }; } rootId = rootId || "impress"; // if already initialized just return the API if (roots["impress-root-" + rootId]) { return roots["impress-root-" + rootId]; } // data of all presentation steps var stepsData = {}; // element of currently active step var activeStep = null; // current state (position, rotation and scale) of the presentation var currentState = null; // array of step elements var steps = null; // configuration options var config = null; // scale factor of the browser window var windowScale = null; // root presentation elements var root = byId( rootId ); var canvas = document.createElement("div"); var initialized = false; // step events var lastEntered = null; var onStepEnter = function (step) { if (lastEntered !== step) { triggerEvent(step, "impress:stepenter"); lastEntered = step; } }; var onStepLeave = function (step) { if (lastEntered === step) { triggerEvent(step, "impress:stepleave"); lastEntered = null; } }; // transitionEnd event handler var expectedTransitionTarget = null; var onTransitionEnd = function (event) { // we only care about transitions on `root` and `canvas` elements if (event.target === expectedTransitionTarget) { onStepEnter(activeStep); event.stopPropagation(); // prevent propagation from `canvas` to `root` } }; var initStep = function ( el, idx ) { var data = el.dataset, step = { translate: { x: toNumber(data.x), y: toNumber(data.y), z: toNumber(data.z) }, rotate: { x: toNumber(data.rotateX), y: toNumber(data.rotateY), z: toNumber(data.rotateZ || data.rotate) }, scale: toNumber(data.scale, 1), el: el }; if ( !el.id ) { el.id = "step-" + (idx + 1); } stepsData["impress-" + el.id] = step; css(el, { position: "absolute", transform: "translate(-50%,-50%)" + translate(step.translate) + rotate(step.rotate) + scale(step.scale), transformStyle: "preserve-3d" }); }; var init = function () { if (initialized) { return; } // setup viewport for mobile devices var meta = $("meta[name='viewport']") || document.createElement("meta"); meta.content = "width=device-width, minimum-scale=1, maximum-scale=1, user-scalable=no"; if (meta.parentNode !== document.head) { meta.name = 'viewport'; document.head.appendChild(meta); } // initialize configuration object var rootData = root.dataset; config = { width: toNumber( rootData.width, defaults.width ), height: toNumber( rootData.height, defaults.height ), maxScale: toNumber( rootData.maxScale, defaults.maxScale ), minScale: toNumber( rootData.minScale, defaults.minScale ), perspective: toNumber( rootData.perspective, defaults.perspective ), transitionDuration: toNumber( rootData.transitionDuration, defaults.transitionDuration ) }; windowScale = computeWindowScale( config ); // wrap steps with "canvas" element arrayify( root.childNodes ).forEach(function ( el ) { canvas.appendChild( el ); }); root.appendChild(canvas); // set initial styles document.documentElement.style.height = "100%"; css(body, { height: "100%", overflow: "hidden" }); var rootStyles = { position: "absolute", transformOrigin: "top left", transition: "all 0s ease-in-out", transformStyle: "preserve-3d" }; css(root, rootStyles); css(root, { top: "50%", left: "50%", transform: perspective( config.perspective/windowScale ) + scale( windowScale ) }); css(canvas, rootStyles); root.addEventListener(transitionEnd, onTransitionEnd, false); canvas.addEventListener(transitionEnd, onTransitionEnd, false); body.classList.remove("impress-disabled"); body.classList.add("impress-enabled"); // get and init steps steps = $$(".step", root); steps.forEach( initStep ); currentState = { translate: { x: 0, y: 0, z: 0 }, rotate: { x: 0, y: 0, z: 0 }, scale: 1 }; initialized = true; triggerEvent(root, "impress:init", { api: roots[ "impress-root-" + rootId ] }); }; var getStep = function ( step ) { if (typeof step === "number") { step = step < 0 ? steps[ steps.length + step] : steps[ step ]; } else if (typeof step === "string") { step = byId(step); } return (step && step.id && stepsData["impress-" + step.id]) ? step : null; }; var goto = function ( el, duration ) { if ( !initialized || !(el = getStep(el)) ) { // presentation not initialized or given element is not a step return false; } // Sometimes it's possible to trigger focus on first link with some keyboard action. // Browser in such a case tries to scroll the page to make this element visible // (even that body overflow is set to hidden) and it breaks our careful positioning. // // So, as a lousy (and lazy) workaround we will make the page scroll back to the top // whenever slide is selected // // If you are reading this and know any better way to handle it, I'll be glad to hear about it! window.scrollTo(0, 0); var step = stepsData["impress-" + el.id]; if ( activeStep ) { activeStep.classList.remove("active"); body.classList.remove("impress-on-" + activeStep.id); } el.classList.add("active"); body.classList.add("impress-on-" + el.id); var target = { rotate: { x: -step.rotate.x, y: -step.rotate.y, z: -step.rotate.z }, translate: { x: -step.translate.x, y: -step.translate.y, z: -step.translate.z }, scale: 1 / step.scale }; // check if the transition is zooming in or not var zoomin = target.scale >= currentState.scale; duration = toNumber(duration, config.transitionDuration); var delay = (duration / 2); if (el === activeStep) { windowScale = computeWindowScale(config); } var targetScale = target.scale * windowScale; expectedTransitionTarget = target.scale > currentState.scale ? root : canvas; if (activeStep && activeStep !== el) { onStepLeave(activeStep); } css(root, { // to keep the perspective look similar for different scales // we need to 'scale' the perspective, too transform: perspective( config.perspective / targetScale ) + scale( targetScale ), transitionDuration: duration + "ms", transitionDelay: (zoomin ? delay : 0) + "ms" }); css(canvas, { transform: rotate(target.rotate, true) + translate(target.translate), transitionDuration: duration + "ms", transitionDelay: (zoomin ? 0 : delay) + "ms" }); currentState = target; activeStep = el; if (duration === 0) { onStepEnter(activeStep); } return el; }; var prev = function () { var prev = steps.indexOf( activeStep ) - 1; prev = prev >= 0 ? steps[ prev ] : steps[ steps.length-1 ]; return goto(prev); }; var next = function () { var next = steps.indexOf( activeStep ) + 1; next = next < steps.length ? steps[ next ] : steps[ 0 ]; return goto(next); }; root.addEventListener("impress:init", function(){ // STEP CLASSES steps.forEach(function (step) { step.classList.add("future"); }); root.addEventListener("impress:stepenter", function (event) { event.target.classList.remove("past"); event.target.classList.remove("future"); event.target.classList.add("present"); }, false); root.addEventListener("impress:stepleave", function (event) { event.target.classList.remove("present"); event.target.classList.add("past"); }, false); }, false); root.addEventListener("impress:init", function(){ // HASH CHANGE var lastHash = ""; // `#/step-id` is used instead of `#step-id` to prevent default browser // scrolling to element in hash // // and it has to be set after animation finishes, because in Chrome it // causes transtion being laggy // BUG: http://code.google.com/p/chromium/issues/detail?id=62820 root.addEventListener("impress:stepenter", function (event) { window.location.hash = lastHash = "#/" + event.target.id; }, false); window.addEventListener("hashchange", function () { // don't go twice to same element if (window.location.hash !== lastHash) { goto( getElementFromUrl() ); } }, false); // START // by selecting step defined in url or first step of the presentation goto(getElementFromUrl() || steps[0], 0); }, false); body.classList.add("impress-disabled"); return (roots[ "impress-root-" + rootId ] = { init: init, goto: goto, next: next, prev: prev }); }; impress.supported = impressSupported; })(document, window); // EVENTS (function ( document, window ) { 'use strict'; // throttling function calls, by Remy Sharp // http://remysharp.com/2010/07/21/throttling-function-calls/ var throttle = function (fn, delay) { var timer = null; return function () { var context = this, args = arguments; clearTimeout(timer); timer = setTimeout(function () { fn.apply(context, args); }, delay); }; }; document.addEventListener("impress:init", function (event) { var api = event.detail.api; // keyboard navigation handlers // prevent default keydown action when one of supported key is pressed document.addEventListener("keydown", function ( event ) { if ( event.keyCode === 9 || ( event.keyCode >= 32 && event.keyCode <= 34 ) || (event.keyCode >= 37 && event.keyCode <= 40) ) { event.preventDefault(); } }, false); // trigger impress action on keyup document.addEventListener("keyup", function ( event ) { if ( event.keyCode === 9 || ( event.keyCode >= 32 && event.keyCode <= 34 ) || (event.keyCode >= 37 && event.keyCode <= 40) ) { switch( event.keyCode ) { case 33: // pg up case 37: // left case 38: // up api.prev(); break; case 9: // tab case 32: // space case 34: // pg down case 39: // right case 40: // down api.next(); break; } event.preventDefault(); } }, false); // delegated handler for clicking on the links to presentation steps document.addEventListener("click", function ( event ) { // event delegation with "bubbling" // check if event target (or any of its parents is a link) var target = event.target; while ( (target.tagName !== "A") && (target !== document.documentElement) ) { target = target.parentNode; } if ( target.tagName === "A" ) { var href = target.getAttribute("href"); // if it's a link to presentation step, target this step if ( href && href[0] === '#' ) { target = document.getElementById( href.slice(1) ); } } if ( api.goto(target) ) { event.stopImmediatePropagation(); event.preventDefault(); } }, false); // delegated handler for clicking on step elements document.addEventListener("click", function ( event ) { var target = event.target; // find closest step element that is not active while ( !(target.classList.contains("step") && !target.classList.contains("active")) && (target !== document.documentElement) ) { target = target.parentNode; } if ( api.goto(target) ) { event.preventDefault(); } }, false); // touch handler to detect taps on the left and right side of the screen document.addEventListener("touchstart", function ( event ) { if (event.touches.length === 1) { var x = event.touches[0].clientX, width = window.innerWidth * 0.3, result = null; if ( x < width ) { result = api.prev(); } else if ( x > window.innerWidth - width ) { result = api.next(); } if (result) { event.preventDefault(); } } }, false); // rescale presentation when window is resized window.addEventListener("resize", throttle(function () { // force going to active step again, to trigger rescaling api.goto( document.querySelector(".active"), 500 ); }, 250), false); }, false); })(document, window);
JavaScript
var xmlHttp var at function Showchat(name,str,atti) { xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } var url="Chat/GetChat.php" url=url+"?q="+str url=url+"&n="+name url=url+"&a="+atti url=url+"&sid="+Math.random() //document.write(url); xmlHttp.onreadystatechange=stateChanged xmlHttp.open("GET",url,true) xmlHttp.send(null) at=atti } function stateChanged() { //document.write(xmlHttp.readyState); //document.write(xmlHttp.readyState); if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("Chatdata").innerHTML=xmlHttp.responseText setTimeout("Showchat('','',at)",2000); var div = document.getElementById('Chatdata'); div.scrollTop = div.scrollHeight; } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; }
JavaScript
var xmlHttprole var nam function Showroleinfo(name) { xmlHttprole=GetXmlHttpObject() if (xmlHttprole==null) { alert ("Browser does not support HTTP Request") return } var url="Ajax/Getroleinfo.php" url=url+"?name="+name url=url+"&sid="+Math.random() //document.write(url); xmlHttprole.onreadystatechange=stateChangedrole xmlHttprole.open("GET",url,true) xmlHttprole.send(null) nam=name } function stateChangedrole() { //document.write(xmlHttp.readyState); //document.write(xmlHttp.readyState); if (xmlHttprole.readyState==4 || xmlHttprole.readyState=="complete") { document.getElementById("Roledata").innerHTML=xmlHttprole.responseText setTimeout("Showroleinfo(nam)",1000); } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; }
JavaScript
var reg1 var att function Showplayer(atti) { reg1=GetXmlHttpObject1() if (reg1==null) { alert ("Browser does not support HTTP Request") return } att=atti var url1="Ajax/PlayerAttend.php" url1=url1+"?att="+atti url1=url1+"&sid="+Math.random() //document.write(url); reg1.onreadystatechange=stateChanged1 reg1.open("GET",url1,true) reg1.send(null) } function stateChanged1() { //document.write(xmlHttp2.readyState); if (reg1.readyState==4 || reg1.readyState=="complete") { //document.write(xmlHttp2.responseText) document.getElementById("Playerattend").innerHTML=reg1.responseText setTimeout("Showplayer(att)",3000); } } function GetXmlHttpObject1() { var reg=null; try { // Firefox, Opera 8.0+, Safari reg=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { reg=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { reg=new ActiveXObject("Microsoft.XMLHTTP"); } } return reg; }
JavaScript
var xmlHttpres var nam function Showresinfo(name) { xmlHttpres=GetXmlHttpObject() if (xmlHttpres==null) { alert ("Browser does not support HTTP Request") return } var url="Ajax/Getresinfo.php" url=url+"?name="+name url=url+"&sid="+Math.random() //document.write(url); xmlHttpres.onreadystatechange=stateChangedres xmlHttpres.open("GET",url,true) xmlHttpres.send(null) nam=name } function stateChangedres() { //document.write(xmlHttp.readyState); //document.write(xmlHttp.readyState); if (xmlHttpres.readyState==4 || xmlHttpres.readyState=="complete") { document.getElementById("Resdata").innerHTML=xmlHttpres.responseText setTimeout("Showresinfo(nam)",10000); } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; }
JavaScript
var xmlHttpinfo var at function Showinfo(atti) { xmlHttpinfo=GetXmlHttpObject() if (xmlHttpinfo==null) { alert ("Browser does not support HTTP Request") return } var url="Ajax/Getinformation.php" url=url+"?a="+atti url=url+"&sid="+Math.random() //document.write(url); xmlHttpinfo.onreadystatechange=stateChangedinfo xmlHttpinfo.open("GET",url,true) xmlHttpinfo.send(null) at=atti } function stateChangedinfo() { //document.write(xmlHttp.readyState); //document.write(xmlHttp.readyState); if (xmlHttpinfo.readyState==4 || xmlHttpinfo.readyState=="complete") { document.getElementById("Status").innerHTML=xmlHttpinfo.responseText setTimeout("Showinfo(at)",2000); } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; }
JavaScript
$(document).ready(function(){ $(".flip").click(function(){ $(".panel").slideToggle("slow"); }); }); $(document).ready(function(){ $("p.box2").hide(); }); $(document).ready(function(){ $("#box").mouseenter(function(){ $("p.box2").show("slow"); }); }); $(document).ready(function(){ $("#box").mouseleave(function(){ $("p.box2").hide("slow"); }); });
JavaScript
$(document).ready(function(){ $("img.small").mouseover(function(){ $("img.small").css("height","80px"); }); }); $(document).ready(function(){ $("img.small").mouseout(function(){ $("img.small").css("height","50px"); }); });
JavaScript
/*! * jQuery blockUI plugin * Version 2.53 (01-NOV-2012) * @requires jQuery v1.3 or later * * Examples at: http://malsup.com/jquery/block/ * Copyright (c) 2007-2012 M. Alsup * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * * Thanks to Amir-Hossein Sobhi for some excellent contributions! */ ;(function() { "use strict"; function setup($) { if (/^1\.(0|1|2)/.test($.fn.jquery)) { /*global alert:true */ alert('blockUI requires jQuery v1.3 or later! You are using v' + $.fn.jquery); return; } $.fn._fadeIn = $.fn.fadeIn; var noOp = $.noop || function() {}; // this bit is to ensure we don't call setExpression when we shouldn't (with extra muscle to handle // retarded userAgent strings on Vista) var msie = /MSIE/.test(navigator.userAgent); var ie6 = /MSIE 6.0/.test(navigator.userAgent); var mode = document.documentMode || 0; // var setExpr = msie && (($.browser.version < 8 && !mode) || mode < 8); var setExpr = $.isFunction( document.createElement('div').style.setExpression ); // global $ methods for blocking/unblocking the entire page $.blockUI = function(opts) { install(window, opts); }; $.unblockUI = function(opts) { remove(window, opts); SynClean();}; // convenience method for quick growl-like notifications (http://www.google.com/search?q=growl) $.growlUI = function(title, message, timeout, onClose) { var $m = $('<div class="growlUI"></div>'); if (title) $m.append('<h1>'+title+'</h1>'); if (message) $m.append('<h2>'+message+'</h2>'); if (timeout === undefined) timeout = 3000; $.blockUI({ message: $m, fadeIn: 700, fadeOut: 1000, centerY: false, timeout: timeout, showOverlay: false, onUnblock: onClose, css: $.blockUI.defaults.growlCSS }); }; // plugin method for blocking element content $.fn.block = function(opts) { var fullOpts = $.extend({}, $.blockUI.defaults, opts || {}); this.each(function() { var $el = $(this); if (fullOpts.ignoreIfBlocked && $el.data('blockUI.isBlocked')) return; $el.unblock({ fadeOut: 0 }); }); return this.each(function() { if ($.css(this,'position') == 'static') this.style.position = 'relative'; this.style.zoom = 1; // force 'hasLayout' in ie install(this, opts); }); }; // plugin method for unblocking element content $.fn.unblock = function(opts) { return this.each(function() { remove(this, opts); }); }; $.blockUI.version = 2.53; // 2nd generation blocking at no extra cost! // override these in your code to change the default behavior and style $.blockUI.defaults = { // message displayed when blocking (use null for no message) message: '<h1>Please wait...</h1>', title: null, // title string; only used when theme == true draggable: true, // only used when theme == true (requires jquery-ui.js to be loaded) theme: false, // set to true to use with jQuery UI themes // styles for the message when blocking; if you wish to disable // these and use an external stylesheet then do this in your code: // $.blockUI.defaults.css = {}; css: { padding: 0, margin: 0, width: '30%', top: '40%', left: '35%', textAlign: 'center', color: '#000', border: '3px solid #aaa', backgroundColor:'#fff', cursor: 'wait' }, // minimal style set used when themes are used themedCSS: { width: '30%', top: '40%', left: '35%' }, // styles for the overlay overlayCSS: { backgroundColor: '#000', opacity: 0.6, cursor: 'wait' }, // style to replace wait cursor before unblocking to correct issue // of lingering wait cursor cursorReset: 'default', // styles applied when using $.growlUI growlCSS: { width: '350px', top: '10px', left: '', right: '10px', border: 'none', padding: '5px', opacity: 0.6, cursor: 'default', color: '#fff', backgroundColor: '#000', '-webkit-border-radius':'10px', '-moz-border-radius': '10px', 'border-radius': '10px' }, // IE issues: 'about:blank' fails on HTTPS and javascript:false is s-l-o-w // (hat tip to Jorge H. N. de Vasconcelos) /*jshint scripturl:true */ iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank', // force usage of iframe in non-IE browsers (handy for blocking applets) forceIframe: false, // z-index for the blocking overlay baseZ: 1000, // set these to true to have the message automatically centered centerX: true, // <-- only effects element blocking (page block controlled via css above) centerY: true, // allow body element to be stetched in ie6; this makes blocking look better // on "short" pages. disable if you wish to prevent changes to the body height allowBodyStretch: true, // enable if you want key and mouse events to be disabled for content that is blocked bindEvents: true, // be default blockUI will supress tab navigation from leaving blocking content // (if bindEvents is true) constrainTabKey: true, // fadeIn time in millis; set to 0 to disable fadeIn on block fadeIn: 200, // fadeOut time in millis; set to 0 to disable fadeOut on unblock fadeOut: 400, // time in millis to wait before auto-unblocking; set to 0 to disable auto-unblock timeout: 0, // disable if you don't want to show the overlay showOverlay: true, // if true, focus will be placed in the first available input field when // page blocking focusInput: true, // suppresses the use of overlay styles on FF/Linux (due to performance issues with opacity) // no longer needed in 2012 // applyPlatformOpacityRules: true, // callback method invoked when fadeIn has completed and blocking message is visible onBlock: null, // callback method invoked when unblocking has completed; the callback is // passed the element that has been unblocked (which is the window object for page // blocks) and the options that were passed to the unblock call: // onUnblock(element, options) onUnblock: null, // callback method invoked when the overlay area is clicked. // setting this will turn the cursor to a pointer, otherwise cursor defined in overlayCss will be used. onOverlayClick: null, // don't ask; if you really must know: http://groups.google.com/group/jquery-en/browse_thread/thread/36640a8730503595/2f6a79a77a78e493#2f6a79a77a78e493 quirksmodeOffsetHack: 4, // class name of the message block blockMsgClass: 'blockMsg', // if it is already blocked, then ignore it (don't unblock and reblock) ignoreIfBlocked: false }; // private data and functions follow... var pageBlock = null; var pageBlockEls = []; function install(el, opts) { var css, themedCSS; var full = (el == window); var msg = (opts && opts.message !== undefined ? opts.message : undefined); opts = $.extend({}, $.blockUI.defaults, opts || {}); if (opts.ignoreIfBlocked && $(el).data('blockUI.isBlocked')) return; opts.overlayCSS = $.extend({}, $.blockUI.defaults.overlayCSS, opts.overlayCSS || {}); css = $.extend({}, $.blockUI.defaults.css, opts.css || {}); if (opts.onOverlayClick) opts.overlayCSS.cursor = 'pointer'; themedCSS = $.extend({}, $.blockUI.defaults.themedCSS, opts.themedCSS || {}); msg = msg === undefined ? opts.message : msg; // remove the current block (if there is one) if (full && pageBlock) remove(window, {fadeOut:0}); // if an existing element is being used as the blocking content then we capture // its current place in the DOM (and current display style) so we can restore // it when we unblock if (msg && typeof msg != 'string' && (msg.parentNode || msg.jquery)) { var node = msg.jquery ? msg[0] : msg; var data = {}; $(el).data('blockUI.history', data); data.el = node; data.parent = node.parentNode; data.display = node.style.display; data.position = node.style.position; if (data.parent) data.parent.removeChild(node); } $(el).data('blockUI.onUnblock', opts.onUnblock); var z = opts.baseZ; // blockUI uses 3 layers for blocking, for simplicity they are all used on every platform; // layer1 is the iframe layer which is used to supress bleed through of underlying content // layer2 is the overlay layer which has opacity and a wait cursor (by default) // layer3 is the message content that is displayed while blocking var lyr1, lyr2, lyr3, s; if (msie || opts.forceIframe) lyr1 = $('<iframe class="blockUI" style="z-index:'+ (z++) +';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="'+opts.iframeSrc+'"></iframe>'); else lyr1 = $('<div class="blockUI" style="display:none"></div>'); if (opts.theme) lyr2 = $('<div class="blockUI blockOverlay ui-widget-overlay" style="z-index:'+ (z++) +';display:none"></div>'); else lyr2 = $('<div class="blockUI blockOverlay" style="z-index:'+ (z++) +';display:none;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>'); if (opts.theme && full) { s = '<div class="blockUI ' + opts.blockMsgClass + ' blockPage ui-dialog ui-widget ui-corner-all" style="z-index:'+(z+10)+';display:none;position:fixed">'; if ( opts.title ) { s += '<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(opts.title || '&nbsp;')+'</div>'; } s += '<div class="ui-widget-content ui-dialog-content"></div>'; s += '</div>'; } else if (opts.theme) { s = '<div class="blockUI ' + opts.blockMsgClass + ' blockElement ui-dialog ui-widget ui-corner-all" style="z-index:'+(z+10)+';display:none;position:absolute">'; if ( opts.title ) { s += '<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(opts.title || '&nbsp;')+'</div>'; } s += '<div class="ui-widget-content ui-dialog-content"></div>'; s += '</div>'; } else if (full) { s = '<div class="blockUI ' + opts.blockMsgClass + ' blockPage" style="z-index:'+(z+10)+';display:none;position:fixed"></div>'; } else { s = '<div class="blockUI ' + opts.blockMsgClass + ' blockElement" style="z-index:'+(z+10)+';display:none;position:absolute"></div>'; } lyr3 = $(s); // if we have a message, style it if (msg) { if (opts.theme) { lyr3.css(themedCSS); lyr3.addClass('ui-widget-content'); } else lyr3.css(css); } // style the overlay if (!opts.theme /*&& (!opts.applyPlatformOpacityRules)*/) lyr2.css(opts.overlayCSS); lyr2.css('position', full ? 'fixed' : 'absolute'); // make iframe layer transparent in IE if (msie || opts.forceIframe) lyr1.css('opacity',0.0); //$([lyr1[0],lyr2[0],lyr3[0]]).appendTo(full ? 'body' : el); var layers = [lyr1,lyr2,lyr3], $par = full ? $('body') : $(el); $.each(layers, function() { this.appendTo($par); }); if (opts.theme && opts.draggable && $.fn.draggable) { lyr3.draggable({ handle: '.ui-dialog-titlebar', cancel: 'li' }); } // ie7 must use absolute positioning in quirks mode and to account for activex issues (when scrolling) var expr = setExpr && (!$.support.boxModel || $('object,embed', full ? null : el).length > 0); if (ie6 || expr) { // give body 100% height if (full && opts.allowBodyStretch && $.support.boxModel) $('html,body').css('height','100%'); // fix ie6 issue when blocked element has a border width if ((ie6 || !$.support.boxModel) && !full) { var t = sz(el,'borderTopWidth'), l = sz(el,'borderLeftWidth'); var fixT = t ? '(0 - '+t+')' : 0; var fixL = l ? '(0 - '+l+')' : 0; } // simulate fixed position $.each(layers, function(i,o) { var s = o[0].style; s.position = 'absolute'; if (i < 2) { if (full) s.setExpression('height','Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.support.boxModel?0:'+opts.quirksmodeOffsetHack+') + "px"'); else s.setExpression('height','this.parentNode.offsetHeight + "px"'); if (full) s.setExpression('width','jQuery.support.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"'); else s.setExpression('width','this.parentNode.offsetWidth + "px"'); if (fixL) s.setExpression('left', fixL); if (fixT) s.setExpression('top', fixT); } else if (opts.centerY) { if (full) s.setExpression('top','(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"'); s.marginTop = 0; } else if (!opts.centerY && full) { var top = (opts.css && opts.css.top) ? parseInt(opts.css.top, 10) : 0; var expression = '((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + '+top+') + "px"'; s.setExpression('top',expression); } }); } // show the message if (msg) { if (opts.theme) lyr3.find('.ui-widget-content').append(msg); else lyr3.append(msg); if (msg.jquery || msg.nodeType) $(msg).show(); } if ((msie || opts.forceIframe) && opts.showOverlay) lyr1.show(); // opacity is zero if (opts.fadeIn) { var cb = opts.onBlock ? opts.onBlock : noOp; var cb1 = (opts.showOverlay && !msg) ? cb : noOp; var cb2 = msg ? cb : noOp; if (opts.showOverlay) lyr2._fadeIn(opts.fadeIn, cb1); if (msg) lyr3._fadeIn(opts.fadeIn, cb2); } else { if (opts.showOverlay) lyr2.show(); if (msg) lyr3.show(); if (opts.onBlock) opts.onBlock(); } // bind key and mouse events bind(1, el, opts); if (full) { pageBlock = lyr3[0]; pageBlockEls = $(':input:enabled:visible',pageBlock); if (opts.focusInput) setTimeout(focus, 20); } else center(lyr3[0], opts.centerX, opts.centerY); if (opts.timeout) { // auto-unblock var to = setTimeout(function() { if (full) $.unblockUI(opts); else $(el).unblock(opts); }, opts.timeout); $(el).data('blockUI.timeout', to); } } // remove the block function remove(el, opts) { var full = (el == window); var $el = $(el); var data = $el.data('blockUI.history'); var to = $el.data('blockUI.timeout'); if (to) { clearTimeout(to); $el.removeData('blockUI.timeout'); } opts = $.extend({}, $.blockUI.defaults, opts || {}); bind(0, el, opts); // unbind events if (opts.onUnblock === null) { opts.onUnblock = $el.data('blockUI.onUnblock'); $el.removeData('blockUI.onUnblock'); } var els; if (full) // crazy selector to handle odd field errors in ie6/7 els = $('body').children().filter('.blockUI').add('body > .blockUI'); else els = $el.find('>.blockUI'); // fix cursor issue if ( opts.cursorReset ) { if ( els.length > 1 ) els[1].style.cursor = opts.cursorReset; if ( els.length > 2 ) els[2].style.cursor = opts.cursorReset; } if (full) pageBlock = pageBlockEls = null; if (opts.fadeOut) { els.fadeOut(opts.fadeOut); setTimeout(function() { reset(els,data,opts,el); }, opts.fadeOut); } else reset(els, data, opts, el); } // move blocking element back into the DOM where it started function reset(els,data,opts,el) { els.each(function(i,o) { // remove via DOM calls so we don't lose event handlers if (this.parentNode) this.parentNode.removeChild(this); }); if (data && data.el) { data.el.style.display = data.display; data.el.style.position = data.position; if (data.parent) data.parent.appendChild(data.el); $(el).removeData('blockUI.history'); } if (typeof opts.onUnblock == 'function') opts.onUnblock(el,opts); // fix issue in Safari 6 where block artifacts remain until reflow var body = $(document.body), w = body.width(), cssW = body[0].style.width; body.width(w-1).width(w); body[0].style.width = cssW; } // bind/unbind the handler function bind(b, el, opts) { var full = el == window, $el = $(el); // don't bother unbinding if there is nothing to unbind if (!b && (full && !pageBlock || !full && !$el.data('blockUI.isBlocked'))) return; $el.data('blockUI.isBlocked', b); // don't bind events when overlay is not in use or if bindEvents is false if (!opts.bindEvents || (b && !opts.showOverlay)) return; // bind anchors and inputs for mouse and key events var events = 'mousedown mouseup keydown keypress touchstart touchend touchmove'; if (b) $(document).bind(events, opts, handler); else $(document).unbind(events, handler); // former impl... // var $e = $('a,:input'); // b ? $e.bind(events, opts, handler) : $e.unbind(events, handler); } // event handler to suppress keyboard/mouse events when blocking function handler(e) { // allow tab navigation (conditionally) if (e.keyCode && e.keyCode == 9) { if (pageBlock && e.data.constrainTabKey) { var els = pageBlockEls; var fwd = !e.shiftKey && e.target === els[els.length-1]; var back = e.shiftKey && e.target === els[0]; if (fwd || back) { setTimeout(function(){focus(back);},10); return false; } } } var opts = e.data; var target = $(e.target); if (target.hasClass('blockOverlay') && opts.onOverlayClick) opts.onOverlayClick(); // allow events within the message content if (target.parents('div.' + opts.blockMsgClass).length > 0) return true; // allow events for content that is not being blocked return target.parents().children().filter('div.blockUI').length === 0; } function focus(back) { if (!pageBlockEls) return; var e = pageBlockEls[back===true ? pageBlockEls.length-1 : 0]; if (e) e.focus(); } function center(el, x, y) { var p = el.parentNode, s = el.style; var l = ((p.offsetWidth - el.offsetWidth)/2) - sz(p,'borderLeftWidth'); var t = ((p.offsetHeight - el.offsetHeight)/2) - sz(p,'borderTopWidth'); if (x) s.left = l > 0 ? (l+'px') : '0'; if (y) s.top = t > 0 ? (t+'px') : '0'; } function sz(el, p) { return parseInt($.css(el,p),10)||0; } } /*global define:true */ if (typeof define === 'function' && define.amd && define.amd.jQuery) { define(['jquery'], setup); } else { setup(jQuery); } })();
JavaScript
/** * impress.js * * impress.js is a presentation tool based on the power of CSS3 transforms and transitions * in modern browsers and inspired by the idea behind prezi.com. * * * Copyright 2011-2012 Bartek Szopka (@bartaz) * * Released under the MIT and GPL Licenses. * * ------------------------------------------------ * author: Bartek Szopka * version: 0.5.1 * url: http://bartaz.github.com/impress.js/ * source: http://github.com/bartaz/impress.js/ */ /*jshint bitwise:true, curly:true, eqeqeq:true, forin:true, latedef:true, newcap:true, noarg:true, noempty:true, undef:true, strict:true, browser:true */ (function ( document, window ) { 'use strict'; // HELPER FUNCTIONS var pfx = (function () { var style = document.createElement('dummy').style, prefixes = 'Webkit Moz O ms Khtml'.split(' '), memory = {}; return function ( prop ) { if ( typeof memory[ prop ] === "undefined" ) { var ucProp = prop.charAt(0).toUpperCase() + prop.substr(1), props = (prop + ' ' + prefixes.join(ucProp + ' ') + ucProp).split(' '); memory[ prop ] = null; for ( var i in props ) { if ( style[ props[i] ] !== undefined ) { memory[ prop ] = props[i]; break; } } } return memory[ prop ]; }; })(); var arrayify = function ( a ) { return [].slice.call( a ); }; var css = function ( el, props ) { var key, pkey; for ( key in props ) { if ( props.hasOwnProperty(key) ) { pkey = pfx(key); if ( pkey !== null ) { el.style[pkey] = props[key]; } } } return el; }; var toNumber = function (numeric, fallback) { return isNaN(numeric) ? (fallback || 0) : Number(numeric); }; var byId = function ( id ) { return document.getElementById(id); }; var $ = function ( selector, context ) { context = context || document; return context.querySelector(selector); }; var $$ = function ( selector, context ) { context = context || document; return arrayify( context.querySelectorAll(selector) ); }; var triggerEvent = function (el, eventName, detail) { var event = document.createEvent("CustomEvent"); event.initCustomEvent(eventName, true, true, detail); el.dispatchEvent(event); }; var translate = function ( t ) { return " translate3d(" + t.x + "px," + t.y + "px," + t.z + "px) "; }; var rotate = function ( r, revert ) { var rX = " rotateX(" + r.x + "deg) ", rY = " rotateY(" + r.y + "deg) ", rZ = " rotateZ(" + r.z + "deg) "; return revert ? rZ+rY+rX : rX+rY+rZ; }; var scale = function ( s ) { return " scale(" + s + ") "; }; var perspective = function ( p ) { return " perspective(" + p + "px) "; }; var getElementFromUrl = function () { // get id from url # by removing `#` or `#/` from the beginning, // so both "fallback" `#slide-id` and "enhanced" `#/slide-id` will work return byId( window.location.hash.replace(/^#\/?/,"") ); }; var computeWindowScale = function ( config ) { var hScale = window.innerHeight / config.height, wScale = window.innerWidth / config.width, scale = hScale > wScale ? wScale : hScale; if (config.maxScale && scale > config.maxScale) { scale = config.maxScale; } if (config.minScale && scale < config.minScale) { scale = config.minScale; } return scale; }; // CHECK SUPPORT var body = document.body; var ua = navigator.userAgent.toLowerCase(); var impressSupported = ( pfx("perspective") !== null ) && ( body.classList ) && ( body.dataset ) && ( ua.search(/(iphone)|(ipod)|(android)/) === -1 ); if (!impressSupported) { // we can't be sure that `classList` is supported body.className += " impress-not-supported "; } else { body.classList.remove("impress-not-supported"); body.classList.add("impress-supported"); } // cross-browser transitionEnd event name // based on https://developer.mozilla.org/en/CSS/CSS_transitions var transitionEnd = ({ 'transition':'transitionEnd', 'OTransition':'oTransitionEnd', 'msTransition':'MSTransitionEnd', // who knows how it will end up? 'MozTransition':'transitionend', 'WebkitTransition':'webkitTransitionEnd' })[pfx("transition")]; var roots = {}; var defaults = { width: 1024, height: 768, maxScale: 1, minScale: 0, perspective: 1000, transitionDuration: 1000 }; var empty = function () { return false; }; var impress = window.impress = function ( rootId ) { // if impress.js is not supported by the browser return a dummy API // it may not be a perfect solution but we return early and avoid // running code that may use features not implemented in the browser if (!impressSupported) { return { init: empty, goto: empty, prev: empty, next: empty }; } rootId = rootId || "impress"; // if already initialized just return the API if (roots["impress-root-" + rootId]) { return roots["impress-root-" + rootId]; } // data of all presentation steps var stepsData = {}; // element of currently active step var activeStep = null; // current state (position, rotation and scale) of the presentation var currentState = null; // array of step elements var steps = null; // configuration options var config = null; // scale factor of the browser window var windowScale = null; // root presentation elements var root = byId( rootId ); var canvas = document.createElement("div"); var initialized = false; // step events var lastEntered = null; var onStepEnter = function (step) { if (lastEntered !== step) { triggerEvent(step, "impress:stepenter"); lastEntered = step; } }; var onStepLeave = function (step) { if (lastEntered === step) { triggerEvent(step, "impress:stepleave"); lastEntered = null; } }; // transitionEnd event handler var expectedTransitionTarget = null; var onTransitionEnd = function (event) { // we only care about transitions on `root` and `canvas` elements if (event.target === expectedTransitionTarget) { onStepEnter(activeStep); event.stopPropagation(); // prevent propagation from `canvas` to `root` } }; var initStep = function ( el, idx ) { var data = el.dataset, step = { translate: { x: toNumber(data.x), y: toNumber(data.y), z: toNumber(data.z) }, rotate: { x: toNumber(data.rotateX), y: toNumber(data.rotateY), z: toNumber(data.rotateZ || data.rotate) }, scale: toNumber(data.scale, 1), el: el }; if ( !el.id ) { el.id = "step-" + (idx + 1); } stepsData["impress-" + el.id] = step; css(el, { position: "absolute", transform: "translate(-50%,-50%)" + translate(step.translate) + rotate(step.rotate) + scale(step.scale), transformStyle: "preserve-3d" }); }; var init = function () { if (initialized) { return; } // setup viewport for mobile devices var meta = $("meta[name='viewport']") || document.createElement("meta"); meta.content = "width=device-width, minimum-scale=1, maximum-scale=1, user-scalable=no"; if (meta.parentNode !== document.head) { meta.name = 'viewport'; document.head.appendChild(meta); } // initialize configuration object var rootData = root.dataset; config = { width: toNumber( rootData.width, defaults.width ), height: toNumber( rootData.height, defaults.height ), maxScale: toNumber( rootData.maxScale, defaults.maxScale ), minScale: toNumber( rootData.minScale, defaults.minScale ), perspective: toNumber( rootData.perspective, defaults.perspective ), transitionDuration: toNumber( rootData.transitionDuration, defaults.transitionDuration ) }; windowScale = computeWindowScale( config ); // wrap steps with "canvas" element arrayify( root.childNodes ).forEach(function ( el ) { canvas.appendChild( el ); }); root.appendChild(canvas); // set initial styles document.documentElement.style.height = "100%"; css(body, { height: "100%", overflow: "hidden" }); var rootStyles = { position: "absolute", transformOrigin: "top left", transition: "all 0s ease-in-out", transformStyle: "preserve-3d" }; css(root, rootStyles); css(root, { top: "50%", left: "50%", transform: perspective( config.perspective/windowScale ) + scale( windowScale ) }); css(canvas, rootStyles); root.addEventListener(transitionEnd, onTransitionEnd, false); canvas.addEventListener(transitionEnd, onTransitionEnd, false); body.classList.remove("impress-disabled"); body.classList.add("impress-enabled"); // get and init steps steps = $$(".step", root); steps.forEach( initStep ); currentState = { translate: { x: 0, y: 0, z: 0 }, rotate: { x: 0, y: 0, z: 0 }, scale: 1 }; initialized = true; triggerEvent(root, "impress:init", { api: roots[ "impress-root-" + rootId ] }); }; var getStep = function ( step ) { if (typeof step === "number") { step = step < 0 ? steps[ steps.length + step] : steps[ step ]; } else if (typeof step === "string") { step = byId(step); } return (step && step.id && stepsData["impress-" + step.id]) ? step : null; }; var goto = function ( el, duration ) { if ( !initialized || !(el = getStep(el)) ) { // presentation not initialized or given element is not a step return false; } // Sometimes it's possible to trigger focus on first link with some keyboard action. // Browser in such a case tries to scroll the page to make this element visible // (even that body overflow is set to hidden) and it breaks our careful positioning. // // So, as a lousy (and lazy) workaround we will make the page scroll back to the top // whenever slide is selected // // If you are reading this and know any better way to handle it, I'll be glad to hear about it! window.scrollTo(0, 0); var step = stepsData["impress-" + el.id]; if ( activeStep ) { activeStep.classList.remove("active"); body.classList.remove("impress-on-" + activeStep.id); } el.classList.add("active"); body.classList.add("impress-on-" + el.id); var target = { rotate: { x: -step.rotate.x, y: -step.rotate.y, z: -step.rotate.z }, translate: { x: -step.translate.x, y: -step.translate.y, z: -step.translate.z }, scale: 1 / step.scale }; // check if the transition is zooming in or not var zoomin = target.scale >= currentState.scale; duration = toNumber(duration, config.transitionDuration); var delay = (duration / 2); if (el === activeStep) { windowScale = computeWindowScale(config); } var targetScale = target.scale * windowScale; expectedTransitionTarget = target.scale > currentState.scale ? root : canvas; if (activeStep && activeStep !== el) { onStepLeave(activeStep); } css(root, { // to keep the perspective look similar for different scales // we need to 'scale' the perspective, too transform: perspective( config.perspective / targetScale ) + scale( targetScale ), transitionDuration: duration + "ms", transitionDelay: (zoomin ? delay : 0) + "ms" }); css(canvas, { transform: rotate(target.rotate, true) + translate(target.translate), transitionDuration: duration + "ms", transitionDelay: (zoomin ? 0 : delay) + "ms" }); currentState = target; activeStep = el; if (duration === 0) { onStepEnter(activeStep); } return el; }; var prev = function () { var prev = steps.indexOf( activeStep ) - 1; prev = prev >= 0 ? steps[ prev ] : steps[ steps.length-1 ]; return goto(prev); }; var next = function () { var next = steps.indexOf( activeStep ) + 1; next = next < steps.length ? steps[ next ] : steps[ 0 ]; return goto(next); }; root.addEventListener("impress:init", function(){ // STEP CLASSES steps.forEach(function (step) { step.classList.add("future"); }); root.addEventListener("impress:stepenter", function (event) { event.target.classList.remove("past"); event.target.classList.remove("future"); event.target.classList.add("present"); }, false); root.addEventListener("impress:stepleave", function (event) { event.target.classList.remove("present"); event.target.classList.add("past"); }, false); }, false); root.addEventListener("impress:init", function(){ // HASH CHANGE var lastHash = ""; // `#/step-id` is used instead of `#step-id` to prevent default browser // scrolling to element in hash // // and it has to be set after animation finishes, because in Chrome it // causes transtion being laggy // BUG: http://code.google.com/p/chromium/issues/detail?id=62820 root.addEventListener("impress:stepenter", function (event) { window.location.hash = lastHash = "#/" + event.target.id; }, false); window.addEventListener("hashchange", function () { // don't go twice to same element if (window.location.hash !== lastHash) { goto( getElementFromUrl() ); } }, false); // START // by selecting step defined in url or first step of the presentation goto(getElementFromUrl() || steps[0], 0); }, false); body.classList.add("impress-disabled"); return (roots[ "impress-root-" + rootId ] = { init: init, goto: goto, next: next, prev: prev }); }; impress.supported = impressSupported; })(document, window); // EVENTS (function ( document, window ) { 'use strict'; // throttling function calls, by Remy Sharp // http://remysharp.com/2010/07/21/throttling-function-calls/ var throttle = function (fn, delay) { var timer = null; return function () { var context = this, args = arguments; clearTimeout(timer); timer = setTimeout(function () { fn.apply(context, args); }, delay); }; }; document.addEventListener("impress:init", function (event) { var api = event.detail.api; // keyboard navigation handlers // prevent default keydown action when one of supported key is pressed document.addEventListener("keydown", function ( event ) { if ( event.keyCode === 9 || ( event.keyCode >= 32 && event.keyCode <= 34 ) || (event.keyCode >= 37 && event.keyCode <= 40) ) { event.preventDefault(); } }, false); // trigger impress action on keyup document.addEventListener("keyup", function ( event ) { if ( event.keyCode === 9 || ( event.keyCode >= 32 && event.keyCode <= 34 ) || (event.keyCode >= 37 && event.keyCode <= 40) ) { switch( event.keyCode ) { case 33: // pg up case 37: // left case 38: // up api.prev(); break; case 9: // tab case 32: // space case 34: // pg down case 39: // right case 40: // down api.next(); break; } event.preventDefault(); } }, false); // delegated handler for clicking on the links to presentation steps document.addEventListener("click", function ( event ) { // event delegation with "bubbling" // check if event target (or any of its parents is a link) var target = event.target; while ( (target.tagName !== "A") && (target !== document.documentElement) ) { target = target.parentNode; } if ( target.tagName === "A" ) { var href = target.getAttribute("href"); // if it's a link to presentation step, target this step if ( href && href[0] === '#' ) { target = document.getElementById( href.slice(1) ); } } if ( api.goto(target) ) { event.stopImmediatePropagation(); event.preventDefault(); } }, false); // delegated handler for clicking on step elements document.addEventListener("click", function ( event ) { var target = event.target; // find closest step element that is not active while ( !(target.classList.contains("step") && !target.classList.contains("active")) && (target !== document.documentElement) ) { target = target.parentNode; } if ( api.goto(target) ) { event.preventDefault(); } }, false); // touch handler to detect taps on the left and right side of the screen document.addEventListener("touchstart", function ( event ) { if (event.touches.length === 1) { var x = event.touches[0].clientX, width = window.innerWidth * 0.3, result = null; if ( x < width ) { result = api.prev(); } else if ( x > window.innerWidth - width ) { result = api.next(); } if (result) { event.preventDefault(); } } }, false); // rescale presentation when window is resized window.addEventListener("resize", throttle(function () { // force going to active step again, to trigger rescaling api.goto( document.querySelector(".active"), 500 ); }, 250), false); }, false); })(document, window);
JavaScript
var xmlHttp var at function Showchat(name,str,atti) { xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } var url="Chat/GetChat.php" url=url+"?q="+str url=url+"&n="+name url=url+"&a="+atti url=url+"&sid="+Math.random() //document.write(url); xmlHttp.onreadystatechange=stateChanged xmlHttp.open("GET",url,true) xmlHttp.send(null) at=atti } function stateChanged() { //document.write(xmlHttp.readyState); //document.write(xmlHttp.readyState); if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("Chatdata").innerHTML=xmlHttp.responseText setTimeout("Showchat('','',at)",2000); var div = document.getElementById('Chatdata'); div.scrollTop = div.scrollHeight; } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; }
JavaScript
var xmlHttpskill var nam function Showskills(name) { xmlHttpskill=GetXmlHttpObject() if (xmlHttpskill==null) { alert ("Browser does not support HTTP Request") return } var url="Ajax/GetSkills.php" url=url+"?name="+name url=url+"&sid="+Math.random() //document.write(url); xmlHttpskill.onreadystatechange=stateChangedskill xmlHttpskill.open("GET",url,true) xmlHttpskill.send(null) nam=name } function stateChangedskill() { //document.write(xmlHttp.readyState); //document.write(xmlHttp.readyState); if (xmlHttpskill.readyState==4 || xmlHttpskill.readyState=="complete") { document.getElementById("Skills").innerHTML=xmlHttpskill.responseText SHH(); SH(); } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; }
JavaScript
function DeHeHS() { document.getElementById("DeHeH").style.display='inline' } function DeHeHH() { document.getElementById("DeHeH").style.display='none' } function DeArHS() { document.getElementById("DeArH").style.display='inline' } function DeArHH() { document.getElementById("DeArH").style.display='none' } function DeShHS() { document.getElementById("DeShH").style.display='inline' } function DeShHH() { document.getElementById("DeShH").style.display='none' } function TranHS() { document.getElementById("TranH").style.display='inline' } function TranHH() { document.getElementById("TranH").style.display='none' } function TrHS() { document.getElementById("TrH").style.display='inline' } function TrHH() { document.getElementById("TrH").style.display='none' } function AHS() { document.getElementById("AH").style.display='inline' } function AHH() { document.getElementById("AH").style.display='none' } function WHS() { document.getElementById("WH").style.display='inline' } function WHH() { document.getElementById("WH").style.display='none' } function DeHeS() { document.getElementById("DeHe").style.display='inline' } function DeHeH() { document.getElementById("DeHe").style.display='none' } function DeArS() { document.getElementById("DeAr").style.display='inline' } function DeArH() { document.getElementById("DeAr").style.display='none' } function DeShS() { document.getElementById("DeSh").style.display='inline' } function DeShH() { document.getElementById("DeSh").style.display='none' } function TranS() { document.getElementById("Tran").style.display='inline' } function TranH() { document.getElementById("Tran").style.display='none' } function TrS() { document.getElementById("Tr").style.display='inline' } function TrH() { document.getElementById("Tr").style.display='none' } function AS() { document.getElementById("A").style.display='inline' } function AH() { document.getElementById("A").style.display='none' } function WS() { document.getElementById("W").style.display='inline' } function WH() { document.getElementById("W").style.display='none' } function Bag1HS() { document.getElementById("Bag1H").style.display='inline' } function Bag1HH() { document.getElementById("Bag1H").style.display='none' } function Bag2HS() { document.getElementById("Bag2H").style.display='inline' } function Bag2HH() { document.getElementById("Bag2H").style.display='none' } function Bag3HS() { document.getElementById("Bag3H").style.display='inline' } function Bag3HH() { document.getElementById("Bag3H").style.display='none' } function Bag4HS() { document.getElementById("Bag4H").style.display='inline' } function Bag4HH() { document.getElementById("Bag4H").style.display='none' } function Bag5HS() { document.getElementById("Bag5H").style.display='inline' } function Bag5HH() { document.getElementById("Bag5H").style.display='none' } function Bag1S() { document.getElementById("Bag1").style.display='inline' } function Bag1H() { document.getElementById("Bag1").style.display='none' } function Bag2S() { document.getElementById("Bag2").style.display='inline' } function Bag2H() { document.getElementById("Bag2").style.display='none' } function Bag3S() { document.getElementById("Bag3").style.display='inline' } function Bag3H() { document.getElementById("Bag3").style.display='none' } function Bag4S() { document.getElementById("Bag4").style.display='inline' } function Bag4H() { document.getElementById("Bag4").style.display='none' } function Bag5S() { document.getElementById("Bag5").style.display='inline' } function Bag5H() { document.getElementById("Bag5").style.display='none' } function S1S() { document.getElementById("S1").style.display='inline' } function S1H() { document.getElementById("S1").style.display='none' } function S2S() { document.getElementById("S2").style.display='inline' } function S2H() { document.getElementById("S2").style.display='none' } function S3S() { document.getElementById("S3").style.display='inline' } function S3H() { document.getElementById("S3").style.display='none' } function S4S() { document.getElementById("S4").style.display='inline' } function S4H() { document.getElementById("S4").style.display='none' } function S5S() { document.getElementById("S5").style.display='inline' } function S5H() { document.getElementById("S5").style.display='none' } function S6S() { document.getElementById("S6").style.display='inline' } function S6H() { document.getElementById("S6").style.display='none' } function S7S() { document.getElementById("S7").style.display='inline' } function S7H() { document.getElementById("S7").style.display='none' } function S8S() { document.getElementById("S8").style.display='inline' } function S8H() { document.getElementById("S8").style.display='none' } function S9S() { document.getElementById("S9").style.display='inline' } function S9H() { document.getElementById("S9").style.display='none' } function S10S() { document.getElementById("S10").style.display='inline' } function S10H() { document.getElementById("S10").style.display='none' } function S11S() { document.getElementById("S11").style.display='inline' } function S11H() { document.getElementById("S11").style.display='none' } function S12S() { document.getElementById("S12").style.display='inline' } function S12H() { document.getElementById("S12").style.display='none' } function S13S() { document.getElementById("S13").style.display='inline' } function S13H() { document.getElementById("S13").style.display='none' } function S14S() { document.getElementById("S14").style.display='inline' } function S14H() { document.getElementById("S14").style.display='none' } function S15S() { document.getElementById("S15").style.display='inline' } function S15H() { document.getElementById("S15").style.display='none' } function S1HS() { document.getElementById("S1H").style.display='inline' } function S1HH() { document.getElementById("S1H").style.display='none' } function S2HS() { document.getElementById("S2H").style.display='inline' } function S2HH() { document.getElementById("S2H").style.display='none' } function S3HS() { document.getElementById("S3H").style.display='inline' } function S3HH() { document.getElementById("S3H").style.display='none' } function S4HS() { document.getElementById("S4H").style.display='inline' } function S4HH() { document.getElementById("S4H").style.display='none' } function S5HS() { document.getElementById("S5H").style.display='inline' } function S5HH() { document.getElementById("S5H").style.display='none' } function S6HS() { document.getElementById("S6H").style.display='inline' } function S6HH() { document.getElementById("S6H").style.display='none' } function S7HS() { document.getElementById("S7H").style.display='inline' } function S7HH() { document.getElementById("S7H").style.display='none' } function S8HS() { document.getElementById("S8H").style.display='inline' } function S8HH() { document.getElementById("S8H").style.display='none' } function S9HS() { document.getElementById("S9H").style.display='inline' } function S9HH() { document.getElementById("S9H").style.display='none' } function S10HS() { document.getElementById("S10H").style.display='inline' } function S10HH() { document.getElementById("S10H").style.display='none' } function S11HS() { document.getElementById("S11H").style.display='inline' } function S11HH() { document.getElementById("S11H").style.display='none' } function S12HS() { document.getElementById("S12H").style.display='inline' } function S12HH() { document.getElementById("S12H").style.display='none' } function S13HS() { document.getElementById("S13H").style.display='inline' } function S13HH() { document.getElementById("S13H").style.display='none' } function S14HS() { document.getElementById("S14H").style.display='inline' } function S14HH() { document.getElementById("S14H").style.display='none' } function S15HS() { document.getElementById("S15H").style.display='inline' } function S15HH() { document.getElementById("S15H").style.display='none' } function SHH() { S1HH(); S2HH(); S3HH(); S4HH(); S5HH(); S6HH(); S7HH(); S8HH(); S9HH(); S10HH(); S11HH(); S12HH(); S13HH(); S14HH(); S15HH(); } function SS() { S1S(); S2S(); S3S(); S4S(); S5S(); S6S(); S7S(); S8S(); S9S(); S10S(); S11S(); S12S(); S13S(); S14S(); S15S(); } function SH() { S1H(); S2H(); S3H(); S4H(); S5H(); S6H(); S7H(); S8H(); S9H(); S10H(); S11H(); S12H(); S13H(); S14H(); S15H(); } var xmlHttpresoperation function stateChangedresoperation() { //document.write(xmlHttp.readyState); //document.write(xmlHttp.readyState); if (xmlHttpresoperation.readyState==4 || xmlHttpresoperation.readyState=="complete") { Showresinfo(nam); Showroleinfo(nam); //document.getElementById("Resdata").innerHTML=xmlHttpres.responseText; if(xmlHttpresoperation.responseText=='full') alert('背包已满!'); } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } function Drop(id) { xmlHttpresoperation=GetXmlHttpObject() if (xmlHttpresoperation==null) { alert ("Browser does not support HTTP Request") return } var url="Ajax/Resoperation.php" url=url+"?dropid="+id url=url+"&sid="+Math.random() //document.write(url); xmlHttpresoperation.onreadystatechange=stateChangedresoperation xmlHttpresoperation.open("GET",url,true) xmlHttpresoperation.send(null) } function Use(id) { xmlHttpresoperation=GetXmlHttpObject() if (xmlHttpresoperation==null) { alert ("Browser does not support HTTP Request") return } var url="Ajax/Resoperation.php" url=url+"?useid="+id url=url+"&sid="+Math.random() //document.write(url); xmlHttpresoperation.onreadystatechange=stateChangedresoperation xmlHttpresoperation.open("GET",url,true) xmlHttpresoperation.send(null) } function Unequip(id) { xmlHttpresoperation=GetXmlHttpObject() if (xmlHttpresoperation==null) { alert ("Browser does not support HTTP Request") return } var url="Ajax/Resoperation.php" url=url+"?unequipid="+id url=url+"&sid="+Math.random() //document.write(url); xmlHttpresoperation.onreadystatechange=stateChangedresoperation xmlHttpresoperation.open("GET",url,true) xmlHttpresoperation.send(null) }
JavaScript
function Showlocation(lo) { switch(lo){ case 1: allhide() alllocationnone(); document.getElementById("L1").style.display='none'; document.getElementById("L1H").style.display='inline'; break; case 2: allhide() alllocationnone(); document.getElementById("L2").style.display='none'; document.getElementById("L2H").style.display='inline'; break; case 3: allhide() alllocationnone(); document.getElementById("L3").style.display='none'; document.getElementById("L3H").style.display='inline'; break; case 4: allhide() alllocationnone(); document.getElementById("L4").style.display='none'; document.getElementById("L4H").style.display='inline'; break; case 5: allhide() alllocationnone(); document.getElementById("L5").style.display='none'; document.getElementById("L5H").style.display='inline'; break; case 6: allhide() alllocationnone(); document.getElementById("L6").style.display='none'; document.getElementById("L6H").style.display='inline'; break; case 7: allhide() alllocationnone(); document.getElementById("L7").style.display='none'; document.getElementById("L7H").style.display='inline'; break; case 8: allhide() alllocationnone(); document.getElementById("L8").style.display='none'; document.getElementById("L8H").style.display='inline'; break; case 9: allhide() alllocationnone(); document.getElementById("L9").style.display='none'; document.getElementById("L9H").style.display='inline'; break; case 10: allhide() alllocationnone(); document.getElementById("L10").style.display='none'; document.getElementById("L10H").style.display='inline'; break; case 11: allhide() alllocationnone(); document.getElementById("L11").style.display='none'; document.getElementById("L11H").style.display='inline'; break; case 12: allhide() alllocationnone(); document.getElementById("L12").style.display='none'; document.getElementById("L12H").style.display='inline'; break; case 13: allhide() alllocationnone(); document.getElementById("L13").style.display='none'; document.getElementById("L13H").style.display='inline'; break; case 14: allhide() alllocationnone(); document.getElementById("L14").style.display='none'; document.getElementById("L14H").style.display='inline'; break; default: allhide() alllocationnone(); } } function alllocationnone() { document.getElementById("L1").style.display='inline'; document.getElementById("L2").style.display='inline'; document.getElementById("L3").style.display='inline'; document.getElementById("L4").style.display='inline'; document.getElementById("L5").style.display='inline'; document.getElementById("L6").style.display='inline'; document.getElementById("L7").style.display='inline'; document.getElementById("L8").style.display='inline'; document.getElementById("L9").style.display='inline'; document.getElementById("L10").style.display='inline'; document.getElementById("L11").style.display='inline'; document.getElementById("L12").style.display='inline'; document.getElementById("L13").style.display='inline'; document.getElementById("L14").style.display='inline'; } function allhide() { document.getElementById("L1H").style.display='none'; document.getElementById("L2H").style.display='none'; document.getElementById("L3H").style.display='none'; document.getElementById("L4H").style.display='none'; document.getElementById("L5H").style.display='none'; document.getElementById("L6H").style.display='none'; document.getElementById("L7H").style.display='none'; document.getElementById("L8H").style.display='none'; document.getElementById("L9H").style.display='none'; document.getElementById("L10H").style.display='none'; document.getElementById("L11H").style.display='none'; document.getElementById("L12H").style.display='none'; document.getElementById("L13H").style.display='none'; document.getElementById("L14H").style.display='none'; } function locationchange(lo) { xmlHttplocation=GetXmlHttpObject() if (xmlHttplocation==null) { alert ("Browser does not support HTTP Request") return } var url="Ajax/Location.php" url=url+"?locationid="+lo url=url+"&sid="+Math.random() //document.write(url); xmlHttplocation.onreadystatechange=stateChangedlocation xmlHttplocation.open("GET",url,true) xmlHttplocation.send(null) } function stateChangedlocation() { //document.write(xmlHttp.readyState); //document.write(xmlHttp.readyState); if (xmlHttplocation.readyState==4 || xmlHttplocation.readyState=="complete") { var newlocation; newlocation= xmlHttplocation.responseText; newlocation=trim(newlocation); locationvalue=newlocation-0; if(locationvalue>0) Showlocation(locationvalue); } } function trim(str){ //删除左右两端的空格    return str.replace(/(^\s*)|(\s*$)/g, "");    } function ltrim(str){ //删除左边的空格    return str.replace(/(^\s*)/g,"");    } function rtrim(str){ //删除右边的空格    return str.replace(/(\s*$)/g,"");    }
JavaScript
var xmlHttprole var nam function Showroleinfo(name) { xmlHttprole=GetXmlHttpObject() if (xmlHttprole==null) { alert ("Browser does not support HTTP Request") return } var url="Ajax/Getroleinfo.php" url=url+"?name="+name url=url+"&sid="+Math.random() //document.write(url); xmlHttprole.onreadystatechange=stateChangedrole xmlHttprole.open("GET",url,true) xmlHttprole.send(null) nam=name } function stateChangedrole() { //document.write(xmlHttp.readyState); //document.write(xmlHttp.readyState); if (xmlHttprole.readyState==4 || xmlHttprole.readyState=="complete") { document.getElementById("Roledata").innerHTML=xmlHttprole.responseText } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; }
JavaScript
var xmlHttpsyn; var xmlHttpsynsubmit; var nam; var syn=''; var flag1=0; var flag2=0; var flag3=0; var flag4=0; var flag5=0; function SynAdd1() { if(document.getElementById("Bag1syid").textContent!='0'&&flag1==0) { add=document.getElementById("Bag1syid").textContent; add+=','; syn+=add; document.getElementById("chain1").style.display='inline'; flag1=1; } } function SynAdd2() { if(document.getElementById("Bag2syid").textContent!='0'&&flag2==0) { add=document.getElementById("Bag2syid").textContent; add+=','; syn+=add; document.getElementById("chain2").style.display='inline'; flag2=1; } } function SynAdd3() { if(document.getElementById("Bag3syid").textContent!='0'&&flag3==0) { add=document.getElementById("Bag3syid").textContent add+=',' syn+=add; document.getElementById("chain3").style.display='inline'; flag3=1; } } function SynAdd4() { if(document.getElementById("Bag4syid").textContent!='0'&&flag4==0) { add=document.getElementById("Bag4syid").textContent add+=',' syn+=add; document.getElementById("chain4").style.display='inline'; flag4=1; } } function SynAdd5() { if(document.getElementById("Bag5syid").textContent!='0'&&flag5==0) { add=document.getElementById("Bag5syid").textContent add+=',' syn+=add; document.getElementById("chain5").style.display='inline'; flag5=1; } } function SynClean() { syn=''; flag1=0; flag2=0; flag3=0; flag4=0; flag5=0; } function SynSubmit() { xmlHttpsynsubmit=GetXmlHttpObject() if (xmlHttpsynsubmit==null) { alert ("Browser does not support HTTP Request") return } async: false; var url="Ajax/SynthesisSubmit.php" url=url+"?m="+syn; url=url+"&sid="+Math.random() //document.write(url); xmlHttpsynsubmit.onreadystatechange=stateChangedsynsubmit xmlHttpsynsubmit.open("GET",url,true) xmlHttpsynsubmit.send(null) } function stateChangedsynsubmit() { //document.write(xmlHttp.readyState); //document.write(xmlHttp.readyState); if (xmlHttpsynsubmit.readyState==4 || xmlHttpsynsubmit.readyState=="complete") { document.getElementById("SynthesisInterface").innerHTML=xmlHttpsynsubmit.responseText; SynClean(); Showresinfo(nam); Showbag(); } } function Showsyn(name) { xmlHttpsyn=GetXmlHttpObject() if (xmlHttpsyn==null) { alert ("Browser does not support HTTP Request") return } var url="Ajax/Synthesis.php" url=url+"?name="+name url=url+"&sid="+Math.random() //document.write(url); xmlHttpsyn.onreadystatechange=stateChangedsyn xmlHttpsyn.open("GET",url,true) xmlHttpsyn.send(null) nam=name } function stateChangedsyn() { //document.write(xmlHttp.readyState); //document.write(xmlHttp.readyState); if (xmlHttpsyn.readyState==4 || xmlHttpsyn.readyState=="complete") { document.getElementById("SynthesisInterface").innerHTML=xmlHttpsyn.responseText; } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } function allowDrop(ev) { ev.preventDefault(); } function drag(ev) { ev.dataTransfer.setData("Text",ev.target.id); } function drop(ev) { ev.preventDefault(); var data=ev.dataTransfer.getData("Text"); if(data=='Bag1Sy') {SynAdd1();} if(data=='Bag2Sy') {SynAdd2();} if(data=='Bag3Sy') {SynAdd3();} if(data=='Bag4Sy') {SynAdd4();} if(data=='Bag5Sy') {SynAdd5();} document.getElementById(data).style.display='none'; }
JavaScript
var reg1 var att function Showplayer(atti) { reg1=GetXmlHttpObject1() if (reg1==null) { alert ("Browser does not support HTTP Request") return } att=atti var url1="Ajax/PlayerAttend.php" url1=url1+"?att="+atti url1=url1+"&sid="+Math.random() //document.write(url); reg1.onreadystatechange=stateChanged1 reg1.open("GET",url1,true) reg1.send(null) } function stateChanged1() { //document.write(xmlHttp2.readyState); if (reg1.readyState==4 || reg1.readyState=="complete") { //document.write(xmlHttp2.responseText) document.getElementById("Playerattend").innerHTML=reg1.responseText setTimeout("Showplayer(att)",3000); } } function GetXmlHttpObject1() { var reg=null; try { // Firefox, Opera 8.0+, Safari reg=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { reg=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { reg=new ActiveXObject("Microsoft.XMLHTTP"); } } return reg; }
JavaScript
var xmlHttpres var nam function Showresinfo(name) { xmlHttpres=GetXmlHttpObject() if (xmlHttpres==null) { alert ("Browser does not support HTTP Request") return } var url="Ajax/Getresinfo.php" url=url+"?name="+name url=url+"&sid="+Math.random() //document.write(url); xmlHttpres.onreadystatechange=stateChangedres xmlHttpres.open("GET",url,true) xmlHttpres.send(null) nam=name } function stateChangedres() { //document.write(xmlHttp.readyState); //document.write(xmlHttp.readyState); if (xmlHttpres.readyState==4 || xmlHttpres.readyState=="complete") { document.getElementById("Resdata").innerHTML=xmlHttpres.responseText; DeHeHH(); DeArHH(); DeShHH(); TranHH(); TrHH(); AHH(); WHH(); Bag1H(); Bag2H(); Bag3H(); Bag4H(); Bag5H(); Bag1HH(); Bag2HH(); Bag3HH(); Bag4HH(); Bag5HH(); } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; }
JavaScript
var xmlHttpinfo var at function Showinfo(atti) { xmlHttpinfo=GetXmlHttpObject() if (xmlHttpinfo==null) { alert ("Browser does not support HTTP Request") return } var url="Ajax/Getinformation.php" url=url+"?a="+atti url=url+"&sid="+Math.random() //document.write(url); xmlHttpinfo.onreadystatechange=stateChangedinfo xmlHttpinfo.open("GET",url,true) xmlHttpinfo.send(null) at=atti } function stateChangedinfo() { //document.write(xmlHttp.readyState); //document.write(xmlHttp.readyState); if (xmlHttpinfo.readyState==4 || xmlHttpinfo.readyState=="complete") { document.getElementById("Status").innerHTML=xmlHttpinfo.responseText setTimeout("Showinfo(at)",2000); } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; }
JavaScript
var textFrame = null; var topFrame = null; function beginUsingTextFrame() { textFrame = $("#divText"); topFrame = $("#divFrame"); clearFramePicture(); setFrameHeight(); disableMainScrollbar(); $(window).resize(function () { setFrameHeight(); }); window.scrollToEnd = function () { textFrame.scrollTop(textFrame.attr("scrollHeight")); } window.clearScreen = function () { textFrame.html(""); createNewDiv("left"); } window.createNewDiv = function (alignment) { _divCount++; textFrame.append( $("<div/>", { id: "divOutputAlign" + _divCount, style: "text-align: " + alignment }) ); _currentDiv = $("#divOutputAlign" + _divCount); } createNewDiv("left"); } function setFrameHeight() { if (webPlayer) { setTimeout(function () { if (topFrame.is(":visible")) { textFrame.height($("#divOutput").height() - topFrame.height() - 6); } else { textFrame.height($("#divOutput").height() - 6); } scrollToEnd(); }, 100); } else { if (topFrame.is(":visible")) { textFrame.height($(window).height() - topFrame.position().top - topFrame.height() - 6); } else { textFrame.height($(window).height() - topFrame.position().top - 22); } scrollToEnd(); } } function setFramePicture(filename) { topFrame.show(); topFrame.html("<img src=\"" + filename + "\" onload=\"setFrameHeight()\"/>"); } function clearFramePicture(filename) { topFrame.hide(); setFrameHeight(); }
JavaScript
/* jjmenu - context menu jquery plugin * http://jursza.net/dev/jjmenu/ * * @author Jacek Jursza (okhan.pl@gmail.com) * @version 1.1.2 * @date 2010-08-28 * @category jQuery plugin * @copyright (c) 2009 Jacek Jursza (http://jursza.net/) * @licence MIT [http://www.opensource.org/licenses/mit-license.php] */ (function($){ $.fn.jjmenu = function (clickEvent, param, myReplaces, effect) { var global = this; var acceptEvent = false; if ( clickEvent == "rightClick" || clickEvent == "both" ) { global.mousedown(function(event) { if (event.button == 2 && (clickEvent == "rightClick" || clickEvent == "both")) { // right click global.pageX = event.pageX; global.pageY = event.pageY; event.preventDefault(); event.stopPropagation(); var mmain = new menu("main", param, myReplaces, this, effect); $(this)[0].oncontextmenu = function() { return false; } $(this).unbind('mouseup'); $(this).blur(); return false; } }); document.body.oncontextmenu = function() { if ($("div[id^=jjmenu_main]").length) return false; } } if ( clickEvent == "click" || clickEvent == "both" ) { global.click( function(event) { if (this == event.target) { global.pageX = event.pageX; global.pageY = event.pageY; event.preventDefault(); event.stopPropagation(); var mmain = new menu("main", param, myReplaces, this, effect); $(this).blur(); return false; } }); } $(document).click(function(event) { if (event.button!=2) $("div[id^=jjmenu]").remove(); }); /* Menu obeject */ function menu(id,param,myReplaces,el,effect) { var effect = getEffect(id, effect); if (id == "main") window.triggerElement = el; $("div[id^=jjmenu_"+id+"]").remove(); var m = document.createElement('div'); var ms = document.createElement('span'); $(m).append(ms); m.className = "jjmenu"; m.id = "jjmenu_"+id; $(m).css({display:'none'}); $(document.body).append(m); positionMenu(); var dynamicItems = false; for (var i in param) { if (param[i].get) { dynamicItems = true; $.getJSON(uReplace(param[i].get), function(data) { for (var ii in data) { putItem(data[ii]); } checkPosition(); }) $(this).ajaxError( function() { checkPosition(); }); } else if (param[i].getByFunction) { if (typeof(param[i].getByFunction) == "function") { var uF = param[i].getByFunction; } else { var uF = eval(param[i].getByFunction); } var uItems = uF(myReplaces); for (var ii in uItems) { putItem(uItems[ii]); } checkPosition(); } else { putItem(param[i]); } } if (!dynamicItems) checkPosition(); showMenu(); /* first position menu */ function positionMenu() { var pos = $(el).offset(); var t = pos.top; if (effect.xposition == "left") { var l = pos.left; } else { var l = pos.left+$(el).width()+10; } if (effect.xposition == "mouse") { l = global.pageX; } if (effect.yposition == "mouse") { t = global.pageY; } $(m).css({position:"absolute",top:t+"px",left:l+"px"}); } /* correct menu position */ function checkPosition() { var isHidden = $(m).css("display") == "none" ? true : false; var noAuto = false; if (effect.orientation == "top" || effect.orientation == "bottom") { noAuto = true; } if (isHidden) $(m).show(); var positionTop = $(m).offset().top; var positionLeft = $(m).offset().left; if (isHidden) $(m).hide(); var xPos = positionTop - $(window).scrollTop(); $(m).css({left:"0px"}); var menuHeight = $(m).outerHeight(); var menuWidth = $(m).outerWidth(); $(m).css({left:positionLeft+"px"}); var nleft = positionLeft; if ( positionLeft + menuWidth > $(window).width() ) { nleft = $(window).width() - menuWidth; } var spaceBottom = true; if (effect.yposition == "auto" && effect.xposition == "left") { if ( xPos + menuHeight + $(el).outerHeight() > $(window).height()) { spaceBottom = false; } } else { if ( xPos + menuHeight > $(window).height()) { spaceBottom = false; } } var spaceTop = true; if (positionTop - menuHeight < 0) { spaceTop = false; } if (effect.yposition == "bottom") { positionTop = positionTop + $(el).outerHeight(); } if ( (effect.orientation == "auto" && spaceBottom == false && spaceTop == true) || effect.orientation == "top") { // top orientation var ntop = parseInt(positionTop,10) - parseInt(menuHeight,10); $(m).addClass("topOriented"); } else { // bottom orientation $(m).addClass("bottomOriented"); if (effect.yposition == "auto" && effect.xposition == "left") { positionTop = positionTop + $(el).outerHeight(); } var ntop = parseInt(positionTop,10); } $(m).css({"top":ntop+"px", "left":nleft+"px"}); } /* show menu depends to effect.show */ function showMenu() { if (!effect || effect.show == "default") { $(m).show(); return false; } var speed = parseInt(effect.speed); speed = isNaN(speed) ? 500 : speed; switch (effect.show) { case "fadeIn": $(m).fadeIn(speed); break; case "slideDown": $(m).slideDown(speed); break; default: $(m).show(); break; } } /* put item to menu */ function putItem(n) { var item = document.createElement('div'); $(item).hover(function(){ $(this).addClass("jj_menu_item_hover") }, function(){ $(this).removeClass("jj_menu_item_hover") }); $(item).click( function(event) { event.stopPropagation(); doAction(n.action); }); var span = document.createElement('span'); $(item).append(span); switch (n.type) { case "sub": item.className = "jj_menu_item jj_menu_item_more"; $(item).click(function() { if ($("#jjmenu_"+id+"_sub").length > 0) { $("div[id^=jjmenu_"+id+"_sub]").remove(); } else { var sub = new menu(id+"_sub", n.src, myReplaces, this, effect); } }); break; default: $(item).hover(function() { $("div[id^=jjmenu_"+id+"_sub]").remove(); }); item.className = "jj_menu_item"; break; } if (n.customClass && n.customClass.length>0) { jQuery(span).addClass(n.customClass); } $(span).html(uReplace(n.title)); $(ms).append(item); } /* do action on menu item */ function doAction(act) { if (act) { switch (act.type) { case "gourl": if (act.target) { var newWindow = window.open(uReplace(act.url), act.target); newWindow.focus(); return false; } else { document.location.href=uReplace(act.url); } break; case "ajax": $.getJSON(uReplace(act.url), function(data) { var cb = eval(act.callback); if (typeof(cb) == "function") { cb(data); } }); break; case "fn": var callfn = 'var cb = '+act.callback; jQuery.globalEval(callfn); if (typeof(cb) == "function") { cb(myReplaces); } break; } } } /* replace string with user parameters */ function uReplace(str) { if (myReplaces) { for (var u in myReplaces) { str = str.replace("#"+u+"#", eval("myReplaces."+u)); } } return str; } /* get effect opbject */ function getEffect(id, effect) { var defEffect = { show:"default", xposition:"right", yposition:"auto", orientation:"auto" }; if (!effect) { return defEffect; } if (!effect.show) effect.show = "default"; var show = effect.show; if (!effect.xposition) effect.xposition = "right"; if (!effect.yposition) effect.yposition = "auto"; if (!effect.orientation) effect.orientation = "auto"; if (id != "main") { var subeffect = defEffect; subeffect.show = show; } return ( id == "main" ) ? effect : subeffect; } } // !menu }; })(jQuery);
JavaScript
var webPlayer = false; function scrollToEnd() { $('html, body').animate({ scrollTop: $(document).height() }, 0); } function sendCommand(text) { UIEvent("RunCommand", text); } function ASLEvent(event, parameter) { UIEvent("ASLEvent", event + ";" + parameter); } function goUrl(href) { UIEvent("GoURL", href); } function UIEvent(cmd, parameter) { var elem = $("#_UIEvent"); elem.html(cmd + " " + parameter); elem.click(); } function SetBackground(color) { document.body.style.background = color; } function gameFinished() { // we don't need to do anything - this function is just required for compatibility with WebPlayer } function disableMainScrollbar() { $("body").css("overflow", "hidden"); }
JavaScript
var _currentDiv = null; function addText(text) { if (_currentDiv == null) { createNewDiv("left"); } _currentDiv.append(text); scrollToEnd(); } var _divCount = 0; function createNewDiv(alignment) { _divCount++; $("<div/>", { id: "divOutputAlign" + _divCount, style: "text-align: " + alignment }).appendTo("#divOutput"); _currentDiv = $("#divOutputAlign" + _divCount); } function bindMenu(linkid, verbs, text) { var verbsList = verbs.split("/"); var options = []; $.each(verbsList, function (key, value) { options = options.concat({ title: value, action: { type: "fn", callback: "doMenuClick('" + value.toLowerCase() + " " + text.replace("'", "\\'") + "');"} }); }); $("#" + linkid).jjmenu("both", options, {}, { show: "fadeIn", speed: 100, xposition: "left", yposition: "auto", "orientation": "auto" }); } function doMenuClick(command) { $("div[id^=jjmenu]").remove(); sendCommand(command); } function clearScreen() { $("#divOutput").html(""); createNewDiv("left"); } function keyPressCode(e) { var keynum if (window.event) { keynum = e.keyCode } else if (e.which) { keynum = e.which } return keynum; } function AddYouTube(id) { var embedHTML = "<object width=\"425\" height=\"344\"><param name=\"movie\" value=\"http://www.youtube.com/v/" + id + "\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"http://www.youtube.com/v/" + id + "\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"425\" height=\"344\"></embed></object>"; addText(embedHTML); } function AddVimeo(id) { var embedHTML = "<object width=\"400\" height=\"225\"><param name=\"allowfullscreen\" value=\"true\" /><param name=\"allowscriptaccess\" value=\"always\" /><param name=\"movie\" value=\"http://vimeo.com/moogaloop.swf?clip_id=" + id + "&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1&amp;autoplay=0&amp;loop=0\" /><embed src=\"http://vimeo.com/moogaloop.swf?clip_id=" + id + "&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1&amp;autoplay=0&amp;loop=0\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" allowscriptaccess=\"always\" width=\"400\" height=\"225\"></embed></object>"; addText(embedHTML); }
JavaScript
/* jjmenu - context menu jquery plugin * http://jursza.net/dev/jjmenu/ * * @author Jacek Jursza (okhan.pl@gmail.com) * @version 1.1.2 * @date 2010-08-28 * @category jQuery plugin * @copyright (c) 2009 Jacek Jursza (http://jursza.net/) * @licence MIT [http://www.opensource.org/licenses/mit-license.php] */ (function($){ $.fn.jjmenu = function (clickEvent, param, myReplaces, effect) { var global = this; var acceptEvent = false; if ( clickEvent == "rightClick" || clickEvent == "both" ) { global.mousedown(function(event) { if (event.button == 2 && (clickEvent == "rightClick" || clickEvent == "both")) { // right click global.pageX = event.pageX; global.pageY = event.pageY; event.preventDefault(); event.stopPropagation(); var mmain = new menu("main", param, myReplaces, this, effect); $(this)[0].oncontextmenu = function() { return false; } $(this).unbind('mouseup'); $(this).blur(); return false; } }); document.body.oncontextmenu = function() { if ($("div[id^=jjmenu_main]").length) return false; } } if ( clickEvent == "click" || clickEvent == "both" ) { global.click( function(event) { if (this == event.target) { global.pageX = event.pageX; global.pageY = event.pageY; event.preventDefault(); event.stopPropagation(); var mmain = new menu("main", param, myReplaces, this, effect); $(this).blur(); return false; } }); } $(document).click(function(event) { if (event.button!=2) $("div[id^=jjmenu]").remove(); }); /* Menu obeject */ function menu(id,param,myReplaces,el,effect) { var effect = getEffect(id, effect); if (id == "main") window.triggerElement = el; $("div[id^=jjmenu_"+id+"]").remove(); var m = document.createElement('div'); var ms = document.createElement('span'); $(m).append(ms); m.className = "jjmenu"; m.id = "jjmenu_"+id; $(m).css({display:'none'}); $(document.body).append(m); positionMenu(); var dynamicItems = false; for (var i in param) { if (param[i].get) { dynamicItems = true; $.getJSON(uReplace(param[i].get), function(data) { for (var ii in data) { putItem(data[ii]); } checkPosition(); }) $(this).ajaxError( function() { checkPosition(); }); } else if (param[i].getByFunction) { if (typeof(param[i].getByFunction) == "function") { var uF = param[i].getByFunction; } else { var uF = eval(param[i].getByFunction); } var uItems = uF(myReplaces); for (var ii in uItems) { putItem(uItems[ii]); } checkPosition(); } else { putItem(param[i]); } } if (!dynamicItems) checkPosition(); showMenu(); /* first position menu */ function positionMenu() { var pos = $(el).offset(); var t = pos.top; if (effect.xposition == "left") { var l = pos.left; } else { var l = pos.left+$(el).width()+10; } if (effect.xposition == "mouse") { l = global.pageX; } if (effect.yposition == "mouse") { t = global.pageY; } $(m).css({position:"absolute",top:t+"px",left:l+"px"}); } /* correct menu position */ function checkPosition() { var isHidden = $(m).css("display") == "none" ? true : false; var noAuto = false; if (effect.orientation == "top" || effect.orientation == "bottom") { noAuto = true; } if (isHidden) $(m).show(); var positionTop = $(m).offset().top; var positionLeft = $(m).offset().left; if (isHidden) $(m).hide(); var xPos = positionTop - $(window).scrollTop(); $(m).css({left:"0px"}); var menuHeight = $(m).outerHeight(); var menuWidth = $(m).outerWidth(); $(m).css({left:positionLeft+"px"}); var nleft = positionLeft; if ( positionLeft + menuWidth > $(window).width() ) { nleft = $(window).width() - menuWidth; } var spaceBottom = true; if (effect.yposition == "auto" && effect.xposition == "left") { if ( xPos + menuHeight + $(el).outerHeight() > $(window).height()) { spaceBottom = false; } } else { if ( xPos + menuHeight > $(window).height()) { spaceBottom = false; } } var spaceTop = true; if (positionTop - menuHeight < 0) { spaceTop = false; } if (effect.yposition == "bottom") { positionTop = positionTop + $(el).outerHeight(); } if ( (effect.orientation == "auto" && spaceBottom == false && spaceTop == true) || effect.orientation == "top") { // top orientation var ntop = parseInt(positionTop,10) - parseInt(menuHeight,10); $(m).addClass("topOriented"); } else { // bottom orientation $(m).addClass("bottomOriented"); if (effect.yposition == "auto" && effect.xposition == "left") { positionTop = positionTop + $(el).outerHeight(); } var ntop = parseInt(positionTop,10); } $(m).css({"top":ntop+"px", "left":nleft+"px"}); } /* show menu depends to effect.show */ function showMenu() { if (!effect || effect.show == "default") { $(m).show(); return false; } var speed = parseInt(effect.speed); speed = isNaN(speed) ? 500 : speed; switch (effect.show) { case "fadeIn": $(m).fadeIn(speed); break; case "slideDown": $(m).slideDown(speed); break; default: $(m).show(); break; } } /* put item to menu */ function putItem(n) { var item = document.createElement('div'); $(item).hover(function(){ $(this).addClass("jj_menu_item_hover") }, function(){ $(this).removeClass("jj_menu_item_hover") }); $(item).click( function(event) { event.stopPropagation(); doAction(n.action); }); var span = document.createElement('span'); $(item).append(span); switch (n.type) { case "sub": item.className = "jj_menu_item jj_menu_item_more"; $(item).click(function() { if ($("#jjmenu_"+id+"_sub").length > 0) { $("div[id^=jjmenu_"+id+"_sub]").remove(); } else { var sub = new menu(id+"_sub", n.src, myReplaces, this, effect); } }); break; default: $(item).hover(function() { $("div[id^=jjmenu_"+id+"_sub]").remove(); }); item.className = "jj_menu_item"; break; } if (n.customClass && n.customClass.length>0) { jQuery(span).addClass(n.customClass); } $(span).html(uReplace(n.title)); $(ms).append(item); } /* do action on menu item */ function doAction(act) { if (act) { switch (act.type) { case "gourl": if (act.target) { var newWindow = window.open(uReplace(act.url), act.target); newWindow.focus(); return false; } else { document.location.href=uReplace(act.url); } break; case "ajax": $.getJSON(uReplace(act.url), function(data) { var cb = eval(act.callback); if (typeof(cb) == "function") { cb(data); } }); break; case "fn": var callfn = 'var cb = '+act.callback; jQuery.globalEval(callfn); if (typeof(cb) == "function") { cb(myReplaces); } break; } } } /* replace string with user parameters */ function uReplace(str) { if (myReplaces) { for (var u in myReplaces) { str = str.replace("#"+u+"#", eval("myReplaces."+u)); } } return str; } /* get effect opbject */ function getEffect(id, effect) { var defEffect = { show:"default", xposition:"right", yposition:"auto", orientation:"auto" }; if (!effect) { return defEffect; } if (!effect.show) effect.show = "default"; var show = effect.show; if (!effect.xposition) effect.xposition = "right"; if (!effect.yposition) effect.yposition = "auto"; if (!effect.orientation) effect.orientation = "auto"; if (id != "main") { var subeffect = defEffect; subeffect.show = show; } return ( id == "main" ) ? effect : subeffect; } } // !menu }; })(jQuery);
JavaScript
function setObject(src, left, top, className, alias) { var objAppended = $("<img src='/img/" + className + "s/" + src + ".png' id='" + src + "' tittle='" + alias + "' class='" + className + "' style='left:" + left + "%;top:" + top + "%'/>").appendTo($("#gameBorder")); $(objAppended).bind("click", function () { var alias = $(this).attr("tittle"); var action = /*(className == "thing") ? "take " :*/ "touch "; sendCommand(action + alias); /*if (className == "thing") $(this).remove();*/ }); } function setRoom(src) { $(".room").remove(); $(".thing").remove(); $(".actor").remove(); $("<img src='/img/rooms/" + src + ".png' class='room' />").appendTo($("#gameBorder")); }
JavaScript
function showDialog(caption, text) { $("#dialog").dialog({ title: caption, modal: true, position: ["center", "center"], buttons: { "Закрыть": function () { $(this).dialog("close"); } } }); $("#dialog").text(''); $("#dialog").text(text); } function showDialogTake(objname, caption, text) { $("#dialog").dialog({ title: caption, modal: true, position: ["center", "center"], buttons: { "Взять": function () { ASLEvent("SendTakeResult", caption); $("#" + objname).remove(); $(this).dialog("close"); }, "Закрыть": function () { $(this).dialog("close"); } } }); $("#dialog").text(''); $("#dialog").text(text); } function showDialogRadio(objname, caption, text, option1, option2, option3, option4, option5) { $("#dialog").dialog({ title: caption, modal: true, position: ["center", "center"], buttons: { "Ответить": function () { var res = $('input[name=variants]:checked').val(); if (typeof res != "undefined") ASLEvent("SendDialogResult", res + ";" + objname); $(this).dialog("close"); }, "Закрыть": function () { $(this).dialog("close"); } } }); $("#dialog").text(''); $('<p>').text(text).appendTo("#dialog"); $('<input>').attr({ type: 'radio', name: 'variants', value: "1", id: 'rb1' }).appendTo("#dialog"); $('<label>').attr({ for: 'rb1' }).text(option1).appendTo("#dialog"); $('</br>').appendTo("#dialog"); $('<input>').attr({ type: 'radio', name: 'variants', value: "2", id: 'rb2' }).appendTo("#dialog"); $('<label>').attr({ for: 'rb2' }).text(option2).appendTo("#dialog"); $('</br>').appendTo("#dialog"); if (option3.length > 0) { $('<input>').attr({ type: 'radio', name: 'variants', value: "3", id: 'rb3' }).appendTo("#dialog"); $('<label>').attr({ for: 'rb3' }).text(option3).appendTo("#dialog"); $('</br>').appendTo("#dialog"); if (option4.length > 0) { $('<input>').attr({ type: 'radio', name: 'variants', value: "4", id: 'rb4' }).appendTo("#dialog"); $('<label>').attr({ for: 'rb4' }).text(option4).appendTo("#dialog"); $('</br>').appendTo("#dialog"); if (option5.length > 0) { $('<input>').attr({ type: 'radio', name: 'variants', value: "5", id: 'rb5' }).appendTo("#dialog"); $('<label>').attr({ for: 'rb5' }).text(option5).appendTo("#dialog"); $('</br>').appendTo("#dialog"); } } } }
JavaScript
var _currentDiv = null; function addText(text) { if (_currentDiv == null) { createNewDiv("left"); } _currentDiv.append(text); scrollToEnd(); } var _divCount = 0; function createNewDiv(alignment) { _divCount++; $("<div/>", { id: "divOutputAlign" + _divCount, style: "text-align: " + alignment }).appendTo("#divOutput"); _currentDiv = $("#divOutputAlign" + _divCount); } function bindMenu(linkid, verbs, text) { var verbsList = verbs.split("/"); var options = []; $.each(verbsList, function (key, value) { options = options.concat({ title: value, action: { type: "fn", callback: "doMenuClick('" + value.toLowerCase() + " " + text.replace("'", "\\'") + "');"} }); }); $("#" + linkid).jjmenu("both", options, {}, { show: "fadeIn", speed: 100, xposition: "left", yposition: "auto", "orientation": "auto" }); } function doMenuClick(command) { $("div[id^=jjmenu]").remove(); sendCommand(command); } function clearScreen() { $("#divOutput").html(""); createNewDiv("left"); } function keyPressCode(e) { var keynum if (window.event) { keynum = e.keyCode } else if (e.which) { keynum = e.which } return keynum; } function AddYouTube(id) { var embedHTML = "<object width=\"425\" height=\"344\"><param name=\"movie\" value=\"http://www.youtube.com/v/" + id + "\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"http://www.youtube.com/v/" + id + "\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"425\" height=\"344\"></embed></object>"; addText(embedHTML); } function AddVimeo(id) { var embedHTML = "<object width=\"400\" height=\"225\"><param name=\"allowfullscreen\" value=\"true\" /><param name=\"allowscriptaccess\" value=\"always\" /><param name=\"movie\" value=\"http://vimeo.com/moogaloop.swf?clip_id=" + id + "&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1&amp;autoplay=0&amp;loop=0\" /><embed src=\"http://vimeo.com/moogaloop.swf?clip_id=" + id + "&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1&amp;autoplay=0&amp;loop=0\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" allowscriptaccess=\"always\" width=\"400\" height=\"225\"></embed></object>"; addText(embedHTML); }
JavaScript
function test(level) { var div = "<div>fff</div>"; addText(div); }
JavaScript
var $_GET = {}; var selectSizeWithoutStatus = 8; var selectSizeWithStatus = 6; var numCommands = 0; var thisCommand = 0; var commandsList = new Array(); var fluid = false; var webPlayer = true; var tmrTick = null; var tickCount = 0; var sendNextGameTickerAfter = 0; var inventoryVerbs = null; var placesObjectsVerbs = null; var verbButtonCount = 9; document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () { function decode(s) { return decodeURIComponent(s.split("+").join(" ")); } $_GET[decode(arguments[1])] = decode(arguments[2]); }); function init() { $("#jquery_jplayer").jPlayer({ supplied: "wav, mp3" }); showStatusVisible(false); fluid = ($_GET["style"] == "fluid"); if (fluid) { panesVisible(false); } $("#lstInventory").change(function () { updateVerbButtons($("#lstInventory"), inventoryVerbs, "cmdInventory"); }); $("#lstPlacesObjects").change(function () { updateVerbButtons($("#lstPlacesObjects"), placesObjectsVerbs, "cmdPlacesObjects"); }); } function showStatusVisible(visible) { if (visible) { $("#statusVars").show(); $("#lstInventory").attr("size", selectSizeWithStatus); $("#lstPlacesObjects").attr("size", selectSizeWithStatus); } else { $("#statusVars").hide(); $("#lstInventory").attr("size", selectSizeWithoutStatus); $("#lstPlacesObjects").attr("size", selectSizeWithoutStatus); } } function scrollToEnd() { if (fluid) { $('html, body').animate({ scrollTop: $(document).height() }, 10); } else { $("#divOutput").scrollTop($("#divOutput").attr("scrollHeight")); } } function updateLocation(text) { $("#location").html(text); } function setGameName(text) { $("#gameTitle").hide(); //document.title = text; } var _waitMode = false; var _pauseMode = false; var _waitingForSoundToFinish = false; function beginWait() { _waitMode = true; $("#endWaitLink").show(); } function endWait() { _waitMode = false; $("#endWaitLink").hide(); window.setTimeout(function () { $("#fldUIMsg").val("endwait"); $("#cmdSubmit").click(); }, 100); } function beginPause(ms) { _pauseMode = true; window.setTimeout(function () { endPause() }, ms); } function endPause() { _pauseMode = false; window.setTimeout(function () { $("#fldUIMsg").val("endpause"); $("#cmdSubmit").click(); }, 100); } function globalKey(e) { if (_waitMode) { endWait(); return; } } function prepareCommand(command) { $("#fldUITickCount").val(getTickCountAndStopTimer()); $("#fldUIMsg").val("command " + command); } function showQuestion(title) { $("#msgboxCaption").html(title); var msgboxOptions = { modal: true, autoOpen: false, buttons: [ { text: "Yes", click: function () { msgboxSubmit("yes"); } }, { text: "No", click: function () { msgboxSubmit("no"); } } ], closeOnEscape: false, open: function (event, ui) { $(".ui-dialog-titlebar-close").hide(); } // suppresses "close" button }; $("#msgbox").dialog(msgboxOptions); $("#msgbox").dialog("open"); } function msgboxSubmit(text) { $("#msgbox").dialog("close"); window.setTimeout(function () { $("#fldUIMsg").val("msgbox " + text); $("#cmdSubmit").click(); }, 100); } var _menuSelection = ""; function showMenu(title, options, allowCancel) { $("#dialogOptions").empty(); $.each(options, function (key, value) { $("#dialogOptions").append( $("<option/>").attr("value", key).text(value) ); }); $("#dialogCaption").html(title); var dialogOptions = { modal: true, autoOpen: false, buttons: [{ text: "Select", click: function () { dialogSelect(); } }] }; if (allowCancel) { dialogOptions.buttons = dialogOptions.buttons.concat([{ text: "Cancel", click: function () { dialogCancel(); } }]); dialogOptions.close = function (event, ui) { dialogClose(); }; } else { dialogOptions.closeOnEscape = false; dialogOptions.open = function (event, ui) { $(".ui-dialog-titlebar-close").hide(); }; // suppresses "close" button } _menuSelection = ""; $("#dialog").dialog(dialogOptions); $("#dialog").dialog("open"); } function dialogSelect() { _menuSelection = $("#dialogOptions").val(); if (_menuSelection.length > 0) { $("#dialog").dialog("close"); window.setTimeout(function () { $("#fldUIMsg").val("choice " + _menuSelection); $("#cmdSubmit").click(); }, 100); } } function dialogCancel() { $("#dialog").dialog("close"); } function dialogClose() { if (_menuSelection.length == 0) { dialogSendCancel(); } } function dialogSendCancel() { window.setTimeout(function () { $("#fldUIMsg").val("choicecancel"); $("#cmdSubmit").click(); }, 100); } function sessionTimeout() { disableInterface(); } function gameFinished() { disableInterface(); } function disableInterface() { $("#gamePanesRunning").hide(); $("#gamePanesFinished").show(); } var _currentPlayer = ""; function playWav(filename, sync, looped) { if (!document.createElement('audio').canPlayType) { // no <audio> support, so we must play WAVs using <embed> as the // jPlayer Flash fallback does not support WAV. var extra = ""; if (looped) { extra = " loop=\"true\""; } $("#audio_embed").html("<embed src=\"" + filename + "\" autostart=\"true\" width=\"0\" height=\"0\" type=\"audio/wav\"" + extra + ">"); _currentPlayer = "embed"; } else { playAudio(filename, "wav", sync, looped); } } function playMp3(filename, sync, looped) { playAudio(filename, "mp3", sync, looped); } function playAudio(filename, format, sync, looped) { _currentPlayer = "jplayer"; $("#jquery_jplayer").unbind($.jPlayer.event.ended); if (looped) { // TO DO: This works in Firefox. In Chrome the event does fire but the audio doesn't restart. endFunction = function () { $("#jquery_jplayer").jPlayer("play"); }; } else if (sync) { _waitingForSoundToFinish = true; endFunction = function () { finishSync(); }; } else { endFunction = null; } //$("#jquery_jplayer").bind($.jPlayer.event.error, function (event) { alert(event.jPlayer.error.type); }); if (endFunction != null) { $("#jquery_jplayer").bind($.jPlayer.event.ended, function (event) { endFunction(); }); } if (format == "wav") $("#jquery_jplayer").jPlayer("setMedia", { wav: filename }); if (format == "mp3") $("#jquery_jplayer").jPlayer("setMedia", { mp3: filename }); $("#jquery_jplayer").jPlayer("play"); } function stopAudio() { if (_currentPlayer == "jplayer") { $("#jquery_jplayer").jPlayer("stop"); } else if (_currentPlayer == "embed") { $("#audio_embed").html(""); } } function finishSync() { _waitingForSoundToFinish = false; window.setTimeout(function () { $("#fldUIMsg").val("endwait"); $("#cmdSubmit").click(); }, 100); } function panesVisible(visible) { if (visible) { $("#gamePanes").show(); } else { $("#gamePanes").hide(); } } function uiShow(element) { $(element).show(); } function uiHide(element) { $(element).hide(); } var _compassDirs = ["northwest", "north", "northeast", "west", "east", "southwest", "south", "southeast", "up", "down", "in", "out"]; function updateList(listName, listData) { var listElement = ""; if (listName == "inventory") { listElement = "#lstInventory"; inventoryVerbs = new Array(); } if (listName == "placesobjects") { listElement = "#lstPlacesObjects"; placesObjectsVerbs = new Array(); } $(listElement).empty(); $.each(listData, function (key, value) { var splitString = value.split(":"); var objectDisplayName = splitString[0]; var objectVerbs = splitString[1]; if (listName == "inventory") { inventoryVerbs.push(objectVerbs); } if (listName == "placesobjects") { placesObjectsVerbs.push(objectVerbs); } if (listName == "inventory" || $.inArray(objectDisplayName, _compassDirs) == -1) { $(listElement).append( $("<option/>").attr("value", key).text(objectDisplayName) ); } }); } function updateCompass(listData) { var directions = listData.split("/"); updateDir(directions, "NW", _compassDirs[0]); updateDir(directions, "N", _compassDirs[1]); updateDir(directions, "NE", _compassDirs[2]); updateDir(directions, "W", _compassDirs[3]); updateDir(directions, "E", _compassDirs[4]); updateDir(directions, "SW", _compassDirs[5]); updateDir(directions, "S", _compassDirs[6]); updateDir(directions, "SE", _compassDirs[7]); updateDir(directions, "U", _compassDirs[8]); updateDir(directions, "D", _compassDirs[9]); updateDir(directions, "In", _compassDirs[10]); updateDir(directions, "Out", _compassDirs[11]); } function updateDir(directions, label, dir) { $("#cmdCompass" + label).attr("disabled", $.inArray(dir, directions) == -1); } function paneButtonClick(target, verb) { var selectedObject = $(target + " option:selected").text(); if (selectedObject.length > 0) { var cmd = verb + " " + selectedObject; sendCommand(cmd.toLowerCase()); } } function compassClick(direction) { sendCommand(direction); } function sendCommand(text) { if (_pauseMode || _waitingForSoundToFinish) return; if (_waitMode) { endWait(); return; } window.setTimeout(function () { prepareCommand(text); $("#cmdSubmit").click(); }, 100); } function updateStatus(text) { if (text.length > 0) { showStatusVisible(true); $("#statusVars").html(text.replace(/\n/g, "<br/>")); } else { showStatusVisible(false); } } function setBackground(col) { //$("#divOutput").css("background-color", col); } function ASLEvent(event, parameter) { // using setTimeout here to work around a double-submission race condition which seems to only affect Firefox, // even though we use "return false" to suppress submission of the form with the Enter key. window.setTimeout(function () { $("#fldUIMsg").val("event " + event + ";" + parameter); $("#cmdSubmit").click(); }, 100); } function disableMainScrollbar() { $("#divOutput").css("overflow", "hidden"); } function startTimer() { tickCount = 0; tmrTick = setInterval(function () { timerTick(); }, 1000); } function stopTimer() { clearInterval(tmrTick); } function timerTick() { tickCount++; if (sendNextGameTickerAfter > 0 && tickCount >= sendNextGameTickerAfter) { $("#fldUITickCount").val(getTickCountAndStopTimer()); $("#fldUIMsg").val("tick"); $("#cmdSubmit").click(); } } function getTickCountAndStopTimer() { stopTimer(); return tickCount; } function requestNextTimerTick(seconds) { sendNextGameTickerAfter = seconds; startTimer(); } function goUrl(href) { window.open(href); } function setCompassDirections(directions) { _compassDirs = directions; $("#cmdCompassNW").attr("title", _compassDirs[0]); $("#cmdCompassN").attr("title", _compassDirs[1]); $("#cmdCompassNE").attr("title", _compassDirs[2]); $("#cmdCompassW").attr("title", _compassDirs[3]); $("#cmdCompassE").attr("title", _compassDirs[4]); $("#cmdCompassSW").attr("title", _compassDirs[5]); $("#cmdCompassS").attr("title", _compassDirs[6]); $("#cmdCompassSE").attr("title", _compassDirs[7]); } function setInterfaceString(name, text) { switch (name) { case "InventoryLabel": $("#inventoryLabel").html(text); break; case "PlacesObjectsLabel": $("#placesObjectsLabel").html(text); break; case "CompassLabel": $("#compassLabel").html(text); break; case "InButtonLabel": $("#cmdCompassIn").attr("value", text); break; case "OutButtonLabel": $("#cmdCompassOut").attr("value", text); break; case "EmptyListLabel": break; case "NothingSelectedLabel": break; } } function updateVerbButtons(list, verbsArray, idprefix) { var selectedIndex = list.attr("selectedIndex"); var verbs = verbsArray[selectedIndex].split("/"); var count = 1; $.each(verbs, function () { var target = $("#" + idprefix + count); target.attr("value", this); target.show(); count++; }); for (var i = count; i <= verbButtonCount; i++) { var target = $("#" + idprefix + i); target.hide(); } }
JavaScript
function inputKeydown(id, event) { if (keyPressCode(event) == 13) { var text = (id == "mind1") ? $("#mind1").val() : $("#mind2").val(); $("#mind1").val(""); $("#mind2").val(""); addNewRow(); ASLEvent("ProcessInput", id + ";" + text); // returning false here to stop form being submitted twice return false; } } var currentSide = 0; var currentLeft = null; var currentRight = null; // using the proxy pattern http://docs.jquery.com/Types#Proxy%5FPattern to override the addText function (function () { var proxied = window.addText; window.addText = function (text) { if (currentSide == 0) { // We can access the original addText function like this. This is required so we can add twohalves.htm // to the output window in the first place! return proxied(text); } else { if (currentLeft == null) { addNewRow(); } if (currentSide == 1) { currentLeft.append(text); } else { currentRight.append(text); } scrollToEnd(); } }; })(); function setCurrentSide(side) { currentSide = side; } var rowCount = 0; function addNewRow() { rowCount++; var output = "<tr><td class=\"l\" id=\"left" + rowCount + "\"></td><td class=\"r\" id=\"right" + rowCount + "\"></td></tr>"; $("#splitTable tr:last").after(output); currentLeft = $("#left" + rowCount); currentRight = $("#right" + rowCount); } // using the proxy pattern http://docs.jquery.com/Types#Proxy%5FPattern to override the gameFinished function (function () { var proxied = window.gameFinished; window.gameFinished = function () { $("#mind1").hide(); $("#mind2").hide(); proxied(); }; })();
JavaScript
$(document).ready(function() { ItemDetails.init(); }); ItemDetails = {}; ItemDetails.init = function() { //Contact Seller $('#itemDetailsLinkContactSeller').bind('click', function() { $("#itemDetailsContatSellerDialog").dialog({ resizable : false, modal : true, minWidth: 500, draggable : false, buttons : [ { text : $('#itemDetailsContatSellerDialogOk').text(), click : function() { var inputSeller = $('#itemDetailsContatSellerDialogInputSeller').val(); var inputPartner = $('#itemDetailsContatSellerDialogInputPartner').val(); var inputItemTitle = $('#itemDetailsContatSellerDialogInputItemTitle').val(); var inputMessage = $('#itemDetailsContatSellerDialogInputMessage').val(); if(inputMessage.trim() != ''){ var link = $('#itemDetailsLinkContactSeller').attr('link'); $.post(link, { partner: inputPartner, extConversationId: 0 extUserId: inputSeller, extUserName: inputSeller, recipient: inputSeller, message : inputItemTitle+'\n'+inputMessage }); $('#itemDetailsContatSellerDialogInputMessage').val(''); $(this).dialog("close"); } } }, { text : $('#itemDetailsContatSellerDialogCancel').text(), click : function() { $(this).dialog("close"); } } ] }); return false; }); //Admin Delete $('#itemActionLinkDeleteAdmin').bind('click', function() { $("#itemActionDeleteAdminConfirmDialog").dialog({ resizable : false, modal : true, draggable: false, buttons : [ { text : $('#itemActionDeleteAdminConfirmDialogOk').text(), click : function() { Util.redirect($('#itemActionLinkDeleteAdmin').attr('link')); } }, { text : $('#itemActionDeleteAdminConfirmDialogCancel').text(), click : function() { $(this).dialog("close"); } } ] }); return false; }) //Seller Delete $('#itemActionLinkDeleteSeller').bind('click', function() { $("#itemActionDeleteSellerConfirmDialog").dialog({ resizable : false, modal : true, draggable: false, buttons : [ { text : $('#itemActionDeleteSellerConfirmDialogOk').text(), click : function() { Util.redirect($('#itemActionLinkDeleteSeller').attr('link')); } }, { text : $('#itemActionDeleteSellerConfirmDialogCancel').text(), click : function() { $(this).dialog("close"); } } ] }); return false; }) //Rating Box var ratingBox = $('#itemDetailsGiveFeedbackRatingBox'); var ratingRuby = new Array(); ratingRuby[0] = $('#itemDetailsGiveFeedbackRatingBoxRuby1'); ratingRuby[1] = $('#itemDetailsGiveFeedbackRatingBoxRuby2'); ratingRuby[2] = $('#itemDetailsGiveFeedbackRatingBoxRuby3'); ratingRuby[3] = $('#itemDetailsGiveFeedbackRatingBoxRuby4'); ratingRuby[4] = $('#itemDetailsGiveFeedbackRatingBoxRuby5'); var ratingInput = $('#itemDetailsGiveFeedbackRatingInput'); var setRubyFromInput = function(){ var value = ratingInput.val(); if(Util.isNumber(value) && value <= 5 && value >= 1){ setRuby(value-1); }else{ setRuby(-1); } } var clickRuby = function(v){ ratingInput.val(v+1); } var setRuby = function(v){ for(var i = 0; i < 5;i++){ if(i <= v){ ratingRuby[i].css('backgroundImage', 'url(/images/rating/ruby_full.png)'); }else{ ratingRuby[i].css('backgroundImage', 'url(/images/rating/ruby_empty.png)') } } } ratingRuby[0].mouseover(function(e){setRuby(0)}); ratingRuby[1].mouseover(function(e){setRuby(1)}); ratingRuby[2].mouseover(function(e){setRuby(2)}); ratingRuby[3].mouseover(function(e){setRuby(3)}); ratingRuby[4].mouseover(function(e){setRuby(4)}); ratingRuby[0].click(function(e){clickRuby(0)}); ratingRuby[1].click(function(e){clickRuby(1)}); ratingRuby[2].click(function(e){clickRuby(2)}); ratingRuby[3].click(function(e){clickRuby(3)}); ratingRuby[4].click(function(e){clickRuby(4)}); ratingBox.mouseout(function(e){ setRubyFromInput(); }); //First Time load setRubyFromInput(); //Feedback remove links (admin) $('.feedbackRemoveLink').click(function(e){ var id = $(this).attr('feedbackId') $("#itemFeedbackRemoveConfirmDialog").dialog({ resizable : false, modal : true, draggable: false, buttons : [ { text : $('#itemFeedbackRemoveConfirmDialogOk').text(), click : function() { Util.redirect('/item/action/removeFeedback/'+id); } }, { text : $('#itemFeedbackRemoveConfirmDialogCancel').text(), click : function() { $(this).dialog("close"); } } ] }); return false; }); $('#imageFrameLeft').disableSelection(); $('#imageFrameRight').disableSelection(); //ImageSwitcher if(ItemDetails.maxImage > 0){ $('#imageFrameLeft').bind('click', function(e){ if(ItemDetails.currentImage == 0){ ItemDetails.showImage((ItemDetails.maxImage-1)); }else{ ItemDetails.showImage((ItemDetails.currentImage - 1)); } }); $('#imageFrameRight').bind('click', function(e){ if(ItemDetails.currentImage == (ItemDetails.maxImage-1)){ ItemDetails.showImage(0); }else{ ItemDetails.showImage((ItemDetails.currentImage + 1)); } }); ItemDetails.showImage(0); }else{ $('#imageBotText').html('<br>'); } //Google Map var locationLatitude = $('#locationLatitude').val(); var locationLongitude = $('#locationLongitude').val(); if(locationLatitude != '' && locationLongitude != ''){ var geoCoder = new google.maps.Geocoder(); geoCoder.geocode({'latLng': new google.maps.LatLng(locationLatitude, locationLongitude)}, function(results, status) { if(results.length == 0) { console.log('not found'); return false; } if(status == google.maps.GeocoderStatus.OK) { if(results[0]) { $('#itemLocation').html('<b>' + results[0].formatted_address + '</b> <a href="#showMap" onclick="javascript:ItemDetails.showMap();return false;"><img style="vertical-align: middle;padding-bottom:2px;" src="/images/icons/map.png"></a>'); ItemDetails.foundAddress = true; } } else { //Error.. just ignore } }); } } ItemDetails.showMap = function(){ var locationLatitude = $('#locationLatitude').val(); var locationLongitude = $('#locationLongitude').val(); $('#mapDialog').dialog({ width : 500, height : 400, modal : true }); var mapOptions = { center: new google.maps.LatLng(locationLatitude, locationLongitude), zoom: 15, mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById("dialogMapCanvas"), mapOptions); marker = new google.maps.Marker({ map: map, position: map.getCenter() }); } ItemDetails.foundAddress = false; ItemDetails.currentImage = 0; ItemDetails.maxImage = 0; ItemDetails.showImage = function(imageN){ ItemDetails.hideAllImages(); ItemDetails.currentImage = imageN; $('#imageId-'+imageN).css('display', 'block'); $('#imageBotTextCurrent').text((imageN+1)); } ItemDetails.hideAllImages = function(){ for(var i = 0; i < ItemDetails.maxImage; i++){ $('#imageId-'+i).css('display', 'none'); } }
JavaScript
$(document).ready(function() { UploadItem.init(); }); UploadItem = {}; UploadItem.acceptFileTypes = new Array('jpg', 'jpeg', 'png', 'JPG', 'JPEG', 'PNG'); UploadItem.init = function() { $('#itemUploadFileInput').change(function(e) { var fileInput = $(this); var file = $(this).val(); if (file) { var fileType = UploadItem.getFileExtension(file); if ($.inArray(fileType, UploadItem.acceptFileTypes) > -1) { //File is oky... } else { $('#dialogErrorFileType').dialog({ modal : true, buttons : { Ok : function() { $(this).dialog("close"); } } }); } } else { //No file selected... } }); //Image remove $('.itemUploadImageFrame').bind('click', function(e){ var id = $(this).attr('imageId') $("#itemUploadRemoveImageConfirmDialog").dialog({ resizable : false, modal : true, draggable: false, buttons : [ { text : $('#itemUploadRemoveImageConfirmDialogOk').text(), click : function() { Util.redirect('/item/action/removeImage/'+id); } }, { text : $('#itemUploadRemoveImageConfirmDialogCancel').text(), click : function() { $(this).dialog("close"); } } ] }); return false; }); } UploadItem.getFileExtension = function(filename) { var parts = filename.split('.'); return parts[parts.length - 1]; }
JavaScript
$(document).ready(function() { UserMessages.init(); }); UserMessages = {}; UserMessages.init = function() { $("#userMessagesTabs").tabs(); $('.userMessagesTable').bind('click', function(e) { if($(e.target).prop("tagName") != 'A' && $(e.target).prop("tagName") != 'a'){ var conversationContainer = $(this).closest('.userMessagesPrivateContainer'); var messageListContainer = conversationContainer.find('#messageListContainer'); var unreadIdInput = conversationContainer.find('#unreadIds'); var jumpId = conversationContainer.find('#jumpId').val(); if(messageListContainer.css('display') == 'none'){ messageListContainer.css('display', 'block'); if(unreadIdInput.val() != ''){ UserMessages.markRead(unreadIdInput.val()); unreadIdInput.val(''); } }else{ messageListContainer.css('display', 'none'); } if(jumpId != ''){ location.hash = ''; location.hash = '#message-'+jumpId; } } }); $('.sendPrivateMessageButton').bind('click', function(e) { var form = $(this).closest('form'); var messageContentInput = form.find('#messageContent'); var recipientId = form.find('#recipientId').val(); var messageContent = messageContentInput.val().replace(/&/g, '&amp;').replace(/</g, '&lt;') .replace(/>/g, '&gt;').replace(/"/g, '&quot;'); if(messageContent.trim() != ''){ var template = UserMessages.addTemplate(form, messageContent); var successFunc = function(jsonData){ $('#randomKeyInput').val(jsonData.randomKey); if (jsonData.status == 'success') { template.find('#status').attr('class', 'userMessagesAjaxCheck'); } else { template.find('#status').attr('class', 'userMessagesAjaxError'); } } var failFunc = function(){ template.find('#status').attr('class', 'userMessagesAjaxError'); } UserMessages.sendPrivateAnswer(recipientId, messageContent, successFunc, failFunc); messageContentInput.val(''); } return false; }); $('.sendPrivateMessageExtButton').bind('click', function(e) { var form = $(this).closest('form'); var messageContentInput = form.find('#messageContent'); var partnerId = form.find('#partnerId').val(); var extUserId = form.find('#extUserId').val(); var extUserName = form.find('#extUserName').val(); var extConversationId = form.find('#extConversationId').val(); var recipientId = form.find('#recipientId').val(); var messageContent = messageContentInput.val().replace(/&/g, '&amp;').replace(/</g, '&lt;') .replace(/>/g, '&gt;').replace(/"/g, '&quot;'); if(messageContent.trim() != ''){ var template = UserMessages.addTemplate(form, messageContent); var successFunc = function(jsonData){ $('#randomKeyInput').val(jsonData.randomKey); if (jsonData.status == 'success') { template.find('#status').attr('class', 'userMessagesAjaxCheck'); } else { template.find('#status').attr('class', 'userMessagesAjaxError'); } } var failFunc = function(){ template.find('#status').attr('class', 'userMessagesAjaxError'); } UserMessages.sendPrivateAnswerExt(recipientId, partnerId, messageContent, successFunc, failFunc, extUserId, extUserName, extConversationId); messageContentInput.val(''); } return false; }); /* * Item Message */ $('.sendItemMessageButton').bind('click', function(e) { var form = $(this).closest('form'); var messageContentInput = form.find('#messageContent'); var recipientId = form.find('#recipientId').val(); var itemId = form.find('#itemId').val(); var messageContent = messageContentInput.val(); if(messageContent.trim() != ''){ var template = UserMessages.addTemplate(form, messageContent); var successFunc = function(jsonData){ $('#randomKeyInput').val(jsonData.randomKey); if (jsonData.status == 'success') { template.find('#status').attr('class', 'userMessagesAjaxCheck'); } else { template.find('#status').attr('class', 'userMessagesAjaxError'); } } var failFunc = function(){ template.find('#status').attr('class', 'userMessagesAjaxError'); } UserMessages.sendItemAnswer(recipientId, messageContent, itemId, successFunc, failFunc); messageContentInput.val(''); } return false; }); $('.sendItemMessageExtButton').bind('click', function(e) { var form = $(this).closest('form'); var messageContentInput = form.find('#messageContent'); var recipientId = form.find('#recipientId').val(); var partnerId = form.find('#partnerId').val(); var extUserId = form.find('#extUserId').val(); var extUserName = form.find('#extUserName').val(); var extConversationId = form.find('#extConversationId').val(); var itemId = form.find('#itemId').val(); var messageContent = messageContentInput.val(); if(messageContent.trim() != ''){ var template = UserMessages.addTemplate(form, messageContent); var successFunc = function(jsonData){ $('#randomKeyInput').val(jsonData.randomKey); if (jsonData.status == 'success') { template.find('#status').attr('class', 'userMessagesAjaxCheck'); } else { template.find('#status').attr('class', 'userMessagesAjaxError'); } } var failFunc = function(){ template.find('#status').attr('class', 'userMessagesAjaxError'); } UserMessages.sendItemAnswerExt(recipientId, partnerId, itemId, messageContent, successFunc, failFunc, extUserId, extUserName, extConversationId); messageContentInput.val(''); } return false; }); /* * Multi Message */ $('.sendMultiMessageButton').bind('click', function(e) { var messageContent = $('#multiMessageContent').val(); if(messageContent.trim() != '' && UserMessages.recipientList.length > 0){ var successFunc = function(jsonData){ $('#randomKeyInput').val(jsonData.randomKey); if (jsonData.status == 'success') { $('#multiMessageStatus').attr('class', 'userMessagesAjaxCheck'); } else { $('#multiMessageStatus').attr('class', 'userMessagesAjaxError'); } } var failFunc = function(){ $('#multiMessageStatus').attr('class', 'userMessagesAjaxError'); } UserMessages.sendMultiMessage(messageContent, successFunc, failFunc); $('#multiMessageContent').val(''); var l = UserMessages.recipientList.length; for(var i = 0; i < l; i++){ UserMessages.removeRecipient(UserMessages.recipientList[0]); } } return false; }); if(location.hash != ''){ location.hash = ''; /* var jumpElement = location.hash; var element = $(jumpElement); if(element.size() > 0){ var messageListContainer = element.closest('.userMessagesPrivateContainer').find('#messageListContainer'); messageListContainer.css('display', 'block'); location.hash = ''; location.hash = jumpElement; } */ } $("#recipientInput").autocomplete({ source : "/ajax/usernameSearch", minLength : 2, select : function(event, ui) { $("#recipientInput").val(''); UserMessages.addRecipient(ui.item.id, ui.item.value); return false; } }); } UserMessages.sendPrivateAnswer = function(recipient, text, successFunc, failFunc) { var link = '/ajax/messageService/sendMessage'; $.ajax({ url : link, type : "POST", data : { randomKey: $('#randomKeyInput').val(), recipient : recipient, message : text }, dataType : "json" }).done(successFunc).fail(failFunc); } UserMessages.sendItemAnswer = function(recipient, text, itemId, successFunc, failFunc) { var link = '/ajax/messageService/sendMessage'; $.ajax({ url : link, type : "POST", data : { randomKey: $('#randomKeyInput').val(), recipient : recipient, message : text, item: itemId }, dataType : "json" }).done(successFunc).fail(failFunc); } UserMessages.sendPrivateAnswerExt = function(recipient, partner, text, successFunc, failFunc, extUserId, extUserName, extConversationId) { var link = '/ajax/messageService/sendMessageExt'; $.ajax({ url : link, type : "POST", data : { randomKey: $('#randomKeyInput').val(), extConversationId:extConversationId, extUserId:extUserId, extUserName:extUserName, recipient : recipient, partner : partner, message : text }, dataType : "json" }).done(successFunc).fail(failFunc); } UserMessages.sendItemAnswerExt = function(recipient, partner, itemId, text, successFunc, failFunc, extUserId, extUserName, extConversationId) { var link = '/ajax/messageService/sendMessageExt'; $.ajax({ url : link, type : "POST", data : { randomKey: $('#randomKeyInput').val(), extConversationId:extConversationId, extUserId:extUserId, extUserName:extUserName, item: itemId, recipient : recipient, partner : partner, message : text }, dataType : "json" }).done(successFunc).fail(failFunc); } UserMessages.markRead = function(unreadIds) { var link = '/ajax/messageService/markRead'; $.ajax({ url : link, type : "POST", data : { ids : unreadIds }, dataType : "json" }); } UserMessages.sendMultiMessage = function(messageContent, successFunc, failFunc) { var link = '/ajax/messageService/sendMultiMessage'; $.ajax({ url : link, type : "POST", data : { recipients : UserMessages.recipientList, randomKey: $('#randomKeyInput').val(), message : messageContent }, dataType : "json" }).done(successFunc).fail(failFunc); } UserMessages.addTemplate = function(form, text) { var template = form.find('#messageTemplate').clone(); template.attr('class', 'userMessagesPrivateMessage'); template.find('#text').html(text.replace(/\n/g, "<br>")); form.before(template); return template; } UserMessages.recipientList = new Array(); UserMessages.addRecipient = function(userid, username) { if($.inArray(userid, UserMessages.recipientList)==-1){ UserMessages.recipientList.push(userid); $('#recipientList').append('<div style="padding:2px; cursor:pointer;" id="recipient-'+userid+'"><img style="vertical-align: middle;" src="/images/icons/user_gray.png"><span style="padding-left: 5px;">'+username+'</span></div>'); $('#recipient-'+userid).bind('click', function(){UserMessages.removeRecipient(userid)}); } } UserMessages.removeRecipient = function(userid) { UserMessages.recipientList.splice( $.inArray(userid , UserMessages.recipientList), 1 ); $('#recipient-'+userid).remove(); }
JavaScript
$(document).ready(function() { EditItem.init(); }); EditItem = {}; EditItem.init = function() { $('#itemEditSubmitButton').click(function(e){ $('#itemEditForm').submit(); return false; }); $('#itemEditBackButton').click(function(e){ Util.redirect($('#itemEditBackButton').attr('link')); return false; }); }
JavaScript
$(document).ready(function() { ItemDetails.init(); }); ItemDetails = {}; ItemDetails.init = function() { //Contact Seller $('#itemDetailsLinkContactSeller').bind('click', function() { $("#itemDetailsContatSellerDialog").dialog({ resizable : false, modal : true, minWidth: 500, draggable : false, buttons : [ { text : $('#itemDetailsContatSellerDialogOk').text(), click : function() { var inputSeller = $('#itemDetailsContatSellerDialogInputSeller').val(); var inputItem = $('#itemDetailsContatSellerDialogInputItem').val(); var inputMessage = $('#itemDetailsContatSellerDialogInputMessage').val(); if(inputMessage.trim() != ''){ var link = $('#itemDetailsLinkContactSeller').attr('link'); $.post(link, { recipient: inputSeller, item: inputItem, message : inputMessage }); $('#itemDetailsContatSellerDialogInputMessage').val(''); $(this).dialog("close"); } } }, { text : $('#itemDetailsContatSellerDialogCancel').text(), click : function() { $(this).dialog("close"); } } ] }); return false; }); //Admin Delete $('#itemActionLinkDeleteAdmin').bind('click', function() { $("#itemActionDeleteAdminConfirmDialog").dialog({ resizable : false, modal : true, draggable: false, buttons : [ { text : $('#itemActionDeleteAdminConfirmDialogOk').text(), click : function() { Util.redirect($('#itemActionLinkDeleteAdmin').attr('link')); } }, { text : $('#itemActionDeleteAdminConfirmDialogCancel').text(), click : function() { $(this).dialog("close"); } } ] }); return false; }) //Seller Delete $('#itemActionLinkDeleteSeller').bind('click', function() { $("#itemActionDeleteSellerConfirmDialog").dialog({ resizable : false, modal : true, draggable: false, buttons : [ { text : $('#itemActionDeleteSellerConfirmDialogOk').text(), click : function() { Util.redirect($('#itemActionLinkDeleteSeller').attr('link')); } }, { text : $('#itemActionDeleteSellerConfirmDialogCancel').text(), click : function() { $(this).dialog("close"); } } ] }); return false; }) //Rating Box var ratingBox = $('#itemDetailsGiveFeedbackRatingBox'); var ratingRuby = new Array(); ratingRuby[0] = $('#itemDetailsGiveFeedbackRatingBoxRuby1'); ratingRuby[1] = $('#itemDetailsGiveFeedbackRatingBoxRuby2'); ratingRuby[2] = $('#itemDetailsGiveFeedbackRatingBoxRuby3'); ratingRuby[3] = $('#itemDetailsGiveFeedbackRatingBoxRuby4'); ratingRuby[4] = $('#itemDetailsGiveFeedbackRatingBoxRuby5'); var ratingInput = $('#itemDetailsGiveFeedbackRatingInput'); var setRubyFromInput = function(){ var value = ratingInput.val(); if(Util.isNumber(value) && value <= 5 && value >= 1){ setRuby(value-1); }else{ setRuby(-1); } } var clickRuby = function(v){ ratingInput.val(v+1); } var setRuby = function(v){ for(var i = 0; i < 5;i++){ if(i <= v){ ratingRuby[i].css('backgroundImage', 'url(/images/rating/ruby_full.png)'); }else{ ratingRuby[i].css('backgroundImage', 'url(/images/rating/ruby_empty.png)') } } } ratingRuby[0].mouseover(function(e){setRuby(0)}); ratingRuby[1].mouseover(function(e){setRuby(1)}); ratingRuby[2].mouseover(function(e){setRuby(2)}); ratingRuby[3].mouseover(function(e){setRuby(3)}); ratingRuby[4].mouseover(function(e){setRuby(4)}); ratingRuby[0].click(function(e){clickRuby(0)}); ratingRuby[1].click(function(e){clickRuby(1)}); ratingRuby[2].click(function(e){clickRuby(2)}); ratingRuby[3].click(function(e){clickRuby(3)}); ratingRuby[4].click(function(e){clickRuby(4)}); ratingBox.mouseout(function(e){ setRubyFromInput(); }); //First Time load setRubyFromInput(); //Feedback remove links (admin) $('.feedbackRemoveLink').click(function(e){ var id = $(this).attr('feedbackId') $("#itemFeedbackRemoveConfirmDialog").dialog({ resizable : false, modal : true, draggable: false, buttons : [ { text : $('#itemFeedbackRemoveConfirmDialogOk').text(), click : function() { Util.redirect('/item/action/removeFeedback/'+id); } }, { text : $('#itemFeedbackRemoveConfirmDialogCancel').text(), click : function() { $(this).dialog("close"); } } ] }); return false; }); $('#imageFrameLeft').disableSelection(); $('#imageFrameRight').disableSelection(); //ImageSwitcher if(ItemDetails.maxImage > 0){ $('#imageFrameLeft').bind('click', function(e){ if(ItemDetails.currentImage == 0){ ItemDetails.showImage((ItemDetails.maxImage-1)); }else{ ItemDetails.showImage((ItemDetails.currentImage - 1)); } }); $('#imageFrameRight').bind('click', function(e){ if(ItemDetails.currentImage == (ItemDetails.maxImage-1)){ ItemDetails.showImage(0); }else{ ItemDetails.showImage((ItemDetails.currentImage + 1)); } }); ItemDetails.showImage(0); }else{ $('#imageBotText').html('<br>'); } //Google Map var locationLatitude = $('#locationLatitude').val(); var locationLongitude = $('#locationLongitude').val(); if(locationLatitude != '' && locationLongitude != ''){ var geoCoder = new google.maps.Geocoder(); geoCoder.geocode({'latLng': new google.maps.LatLng(locationLatitude, locationLongitude)}, function(results, status) { if(results.length == 0) { console.log('not found'); return false; } if(status == google.maps.GeocoderStatus.OK) { if(results[0]) { $('#itemLocation').html('<b>' + results[0].formatted_address + '</b> <a href="#showMap" onclick="javascript:ItemDetails.showMap();return false;"><img style="vertical-align: middle;padding-bottom:2px;" src="/images/icons/map.png"></a>'); ItemDetails.foundAddress = true; } } else { //Error.. just ignore } }); } } ItemDetails.showMap = function(){ var locationLatitude = $('#locationLatitude').val(); var locationLongitude = $('#locationLongitude').val(); $('#mapDialog').dialog({ width : 500, height : 400, modal : true }); var mapOptions = { center: new google.maps.LatLng(locationLatitude, locationLongitude), zoom: 15, mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById("dialogMapCanvas"), mapOptions); marker = new google.maps.Marker({ map: map, position: map.getCenter() }); } ItemDetails.foundAddress = false; ItemDetails.currentImage = 0; ItemDetails.maxImage = 0; ItemDetails.showImage = function(imageN){ ItemDetails.hideAllImages(); ItemDetails.currentImage = imageN; $('#imageId-'+imageN).css('display', 'block'); $('#imageBotTextCurrent').text((imageN+1)); } ItemDetails.hideAllImages = function(){ for(var i = 0; i < ItemDetails.maxImage; i++){ $('#imageId-'+i).css('display', 'none'); } }
JavaScript
$(document).ready(function() { LanguageChanger.init(); Tooltip.init(); SearchBar.init(); }); /** * SearchBar */ SearchBar = {}; SearchBar.init = function() { $('#searchInput').keypress(function(e) { if(e.which == 13) { $(this).blur(); SearchBar.submitSearch(); } }); $('#searchInputButton').click(function(e){ SearchBar.submitSearch(); }); $("#searchInput").autocomplete({ source : "/ajax/itemSearch", minLength : 2, select : function(event, ui) { window.location = "/item/" + ui.item.id; return true; }, search: function( event, ui ) { SearchBar.cloudSearch(event.target.value); } }); } SearchBar.runningCloudSearch = false; SearchBar.cloudSearch = function(val){ $.ajax({ url : '/ajax/ajaxWordCloud', type : "POST", data : { query : val, limit : '6' } }).done(function(data){ if(data.length > 0){ var s = ""; for(var i = 0; i < data.length; i++){ s = s + "<a href=\"/search?query="+data[i]+"\">"+data[i]+"</a>"; if(i != (data.length-1)){ s = s + ", "; } } $('#partnerWordCloud').html('<br>Maybe you are interested in: '+s+' ?'); } }); } SearchBar.submitSearch = function(){ var query = $('#searchInput').val().trim(); if(query != '') Util.redirect('/search?query='+query); } /** * Language Changer */ LanguageChanger = {}; LanguageChanger.init = function() { $('#languageDropdown').change(function(e) { LanguageChanger.onChange(); }); } LanguageChanger.onChange = function() { var parameters = Util.getURLParameters($(location).attr('href')); parameters['locale'] = $('#languageDropdown').val(); var url = $(location).attr('href').replace(/[\?#].*/, '') + '?' + decodeURIComponent($.param(parameters)) + $(location).attr('hash'); Util.redirect(url); } /** * Tooltip */ Tooltip = {}; Tooltip.init = function() { $(document).tooltip({ show : false, hide : false, position : { at: "right+3 top-15", collision: "fit" } }); } /** * Utilities */ Util = {}; Util.redirect = function(url) { window.location.href = url } Util.getURLParameters = function(url) { var vars = {}; var parts = url.replace(/[?&]+([^=&#]+)=([^&#]*)/gi, function(m, key, value) { vars[key] = value; }); return vars; } //Because JavaScript IsNumeric means whitespace is a number... Util.isNumber = function(n) { return !isNaN(parseFloat(n)) && isFinite(n); } function getURLParameter(name) { return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null; }
JavaScript
$(document).ready(function() { AddItem.init(); }); AddItem = {}; AddItem.acceptFileTypes = new Array('jpg', 'jpeg', 'png'); AddItem.init = function() { $('#itemAddSubmitButton').click(function(e){ $('#itemAddForm').submit(); }); }
JavaScript
$(document).ready(function() { Search.init(); }); Search = {}; Search.selectSum = 1; Search.init = function() { var sortLink = $("#sortAddLink"); Search.selectSum = $('.searchSortOption').length-1; if(Search.selectSum > 1) Search.addDeleteButton(); $('#newSearchFieldLink').click(function(e){ if(Search.selectSum < 5){ Search.selectSum++; var template = $("#sorttemplate").clone(); template.css('display', 'table-row'); template.attr('id', 'sort'+Search.selectSum); template.find('select').attr('name', 'sort'+Search.selectSum); $('.searchSortOptionRow').find('.searchSortOptionDelete a').remove(); template.find('.searchSortOptionDelete').html('<a href="#">x</a>'); sortLink.before(template); Search.addDeleteButton(); /* template.find('.searchSortOptionDelete').find('a').click(function(e){ Search.removeFunction(); return false; }); */ if(Search.selectSum == 5){ $('#newSearchFieldLink').css('display', 'none'); } } return false; }); } Search.removeFunction = function(){ $("#sort"+Search.selectSum).remove(); Search.selectSum--; if(Search.selectSum > 1){ Search.addDeleteButton(); } if(Search.selectSum < 5){ $('#newSearchFieldLink').css('display', 'table-row'); } } Search.addDeleteButton = function(){ $("#sort"+Search.selectSum).find('.searchSortOptionDelete').html('<a href="#">x</a>'); $("#sort"+Search.selectSum).find('.searchSortOptionDelete').find('a').click(function(e){ Search.removeFunction(); return false; }); }
JavaScript
$(document).ready(function() { UploadUser.init(); }); UploadUser = {}; UploadUser.acceptFileTypes = new Array('jpg', 'jpeg', 'png', 'JPG', 'JPEG', 'PNG'); UploadUser.init = function() { $('#userUploadFileInput').change(function(e) { var fileInput = $(this); var file = $(this).val(); if (file) { var fileType = UploadUser.getFileExtension(file); if ($.inArray(fileType, UploadUser.acceptFileTypes) > -1) { //File is oky... } else { $('#dialogErrorFileType').dialog({ modal : true, buttons : { Ok : function() { $(this).dialog("close"); } } }); } } else { //No file selected... } }); } UploadUser.getFileExtension = function(filename) { var parts = filename.split('.'); return parts[parts.length - 1]; }
JavaScript
$(document).ready(function() { UserProfile.init(); }); UserProfile = {}; UserProfile.init = function() { //Contact Seller $('#userProfileLinkContact').bind('click', function() { $('#userProfileContactDialog').dialog({ resizable : false, modal : true, minWidth: 500, draggable : false, buttons : [ { text : $('#userProfileContactDialogOk').text(), click : function() { var inputUser = $('#userProfileContactInputUser').val(); var inputMessage = $('#userProfileContactInputMessage').val(); if(inputMessage.trim() != ''){ var link = $('#userProfileLinkContact').attr('link'); $.post(link, { recipient: inputUser, message : inputMessage }); $('#userProfileContactInputMessage').val(''); $(this).dialog("close"); } } }, { text : $('#userProfileContactDialogCancel').text(), click : function() { $(this).dialog("close"); } } ] }); return false; }); }
JavaScript
function BcClient(socket) { this.socket = socket; // todo rename to serverInterface? this.users = new TList().bindSource(socket, 'users'); this.currentUser = new User(); // do not replace this.users.bindSlave(this.currentUser); this.premades = new TList().bindSource(socket, 'premades'); this.currentPremade = new Premade(); // do not replace this.premades.bindSlave(this.currentPremade); this.goals = new TList().bindSource(socket, 'goals'); this.courses = new TList().bindSource(socket, 'courses'); this.exercises = new TList().bindSource(socket, 'exercises'); this.messages = new TList().bindSource(socket, 'messages'); this.premadeUsers = new TList().bindSource(socket, 'premade.users'); this.premadeMessages = new TList().bindSource(socket, 'premade.messages'); // todo move to premade object? this.tankStack = new TList().bindSource(socket, 'game.botStack'); this.field = new Field(13 * 32, 13 * 32); TList.prototype.bindSource.call(this.field, socket, 'f'); this.vmRunner = new VmRunner(this); var self = this; this.socket.on('logged', function(data) { self.currentUser.unserialize(data.user); }); this.socket.on('joined', function(data) { // do not replace this.currentPremade self.currentPremade.unserialize(data.premade); }); this.socket.on('unjoined', function() { // do not replace this.currentPremade self.currentPremade.unserialize([]); }); }; Eventable(BcClient.prototype); //===== actions ================================================================ BcClient.prototype.connect = function() { this.socket.socket.connect(); }; BcClient.prototype.login = function(nick) { this.socket.emit('login', { nick : nick }); }; BcClient.prototype.setCourse = function(id) { this.socket.emit('set-course', { id: id }); }; BcClient.prototype.say = function(text) { this.socket.emit('say', { text : text }); }; BcClient.prototype.join = function(name, gameType) { this.socket.emit('join', { name : name, gameType : gameType }); }; BcClient.prototype.unjoin = function() { this.socket.emit('unjoin'); }; BcClient.prototype.startGame = function(level) { var self = this; this.socket.emit('start', { level: level }); }; BcClient.prototype.stopGame = function() { if (this.currentPremade.type == 'createbot') { this.socket.emit('stop-game'); } }; BcClient.prototype.executeCode = function(code) { if (this.currentPremade.gameRun) { this.socket.emit('execute', { code: code }); this.vmRunner.executeCode(code); } }; BcClient.prototype.control = function(commands) { this.socket.emit('control', commands); }; BcClient.prototype.turn = function(direction) { this.control({ turn: direction }); }; BcClient.prototype.move = function(distance) { this.control({ move: distance }); }; BcClient.prototype.startMove = function() { this.control({ startMove: 1 }); }; BcClient.prototype.stopMove = function() { this.control({ stopMove: 1 }); }; BcClient.prototype.fire = function() { this.control({ fire: 1 }); }; //===== events ================================================================= BcClient.prototype.onConnect = function(handler) { this.socket.on('connect', handler); }; BcClient.prototype.onConnectFail = function(handler) { this.socket.on('connect_failed', handler).on('error', handler); };
JavaScript
TankController = function TankController(tank) { this.tank = tank; var controller = this; $(window.document).keydown(this.controlEvent.bind(this)); $(window.document).keyup (this.controlEvent.bind(this)); }; TankController.prototype.controlEvent = function(e) { if ($('.CodeMirror textarea').get(0) == window.document.activeElement) { return; } if ($('#game').hasClass('create-bot')) { return; } // console.log(e.keyCode); // console.log(e.type); if (e.keyCode == 38 /*up*/) { if (e.type == 'keydown') { this.tank.turn('north'); this.tank.startMove(); } else if (e.type == 'keyup') { this.tank.stopMove(); } } if (e.keyCode == 39 /*right*/) { if (e.type == 'keydown') { this.tank.turn('east'); this.tank.startMove(); } else if (e.type == 'keyup') { this.tank.stopMove(); } } if (e.keyCode == 40 /*down*/) { if (e.type == 'keydown') { this.tank.turn('south'); this.tank.startMove(); } else if (e.type == 'keyup') { this.tank.stopMove(); } } if (e.keyCode == 37 /*left*/) { if (e.type == 'keydown') { this.tank.turn('west'); this.tank.startMove(); } else if (e.type == 'keyup') { this.tank.stopMove(); } } if (e.keyCode == 70 /*f*/ || e.keyCode == 32) { this.tank.fire(); } };
JavaScript
// there are all existing global vars below var bcClient, uiManager; var codeMirror = null; // todo better place? $(function() { new WidgetLangSelector(); if (typeof WebSocket == 'undefined' && typeof MozWebSocket == 'undefined') { $('.ui-block').hide().filter('#nowebsocket').show(); } else { // hack to substitute ws. var wsDomain = 'ws.' + location.hostname + (location.port ? ':' + location.port : ''); var src = 'http://' + wsDomain + '/socket.io/socket.io.js'; $.getScript(src, function(){ var socket = io.connect(wsDomain, { 'auto connect' : false, 'reconnect' : false // todo learn reconnection abilities }); bcClient = new BcClient(socket); uiManager = new UiManager(bcClient); bcClient.connect(); }); } $(window).resize(); });
JavaScript
isArray = Array.isArray; ServerUser = function ServerUser(course) { User.call(this, arguments); this.collections = {}; this.updateCollector = {}; this.messages = 0; this.countMessageFrom = Date.now(); this.setCurrentCourse(course); }; ServerUser.maxMessages = 10; // per minute ServerUser._eventTypeMap = {'add': 'a', 'change': 'c', 'remove': 'r'}; ServerUser.prototype = new User(); ServerUser.prototype.constructor = ServerUser; ServerUser.prototype.setCurrentCourse = function(course) { this.unwatchCollection('exercises'); this.currentCourse = course; this.watchCollection(course.execises, 'exercises'); this.emit('change'); }; ServerUser.prototype.serialize = function() { return [ serializeTypeMatches[this.constructor.name] // 0 , this.id // 1 , this.nick // 2 , this.lives // 3 , this.points // 4 , this.clan ? this.clan.n : 0 // 5 , this.premade ? this.premade.id : 0 // 6 , this.positionId // 7 , this.tank ? this.tank.id : 0 // 8 , this.currentCourse ? this.currentCourse.id : 0 // 9 ]; }; ServerUser.prototype.sendUpdatesToClient = function() { if ((this.countMessageFrom + 60*1000) < Date.now()) { this.countMessageFrom = Date.now(); this.messages = 0; } var lastSync = this.lastSync, data = {}, itemData; // events may occur is this milliseconds, so do not record it as synced, and "- 1" this.lastSync = Date.now() - 1; var collections = 0; for (var key in this.updateCollector) { data[key] = []; for (var i in this.updateCollector[key]) { data[key].push(this.updateCollector[key][i]); delete this.updateCollector[key][i]; } if (data[key].length == 0) { delete data[key]; } else { collections++; } } if (collections) { this.clientMessage('sync', data); } }; ServerUser.prototype.control = function(event) { // if have tank and tank is on the field if (this.tank && this.tank.field) { if (event.turn) { this.tank.turn(event.turn); } if (event.startMove) { this.tank.startMove(); } if (event.stopMove) { this.tank.stopMove(); } if (event.fire) { this.tank.fire(); } if (event.move) { this.tank.move(event.move); } } }; ServerUser.prototype.say = function(text) { if (this.messages < ServerUser.maxMessages) { var message = new Message(text); message.user = this; if (this.premade) { this.premade.say(message); } else { registry.messages.say(message); } this.messages++; return true; } else { return false; } }; ServerUser.prototype.hit = function() { if (this.premade) { this.lives -= 1; if (this.lives < 0) { this.tank.field.remove(this.tank); } else { this.tank.lives = 1; this.tank.resetPosition(); } this.emit('change'); } }; ServerUser.prototype.addReward = function(reward) { this.points += reward; this.emit('change'); }; ServerUser.prototype.clientMessage = function(type, data) { if (this.socket) { this.socket.emit(type, data); } else { console.log('Trying to send data to disconnected client.'); // todo bug? // console.trace(); } }; ServerUser.prototype.onCollectionUpdate = function(syncKey, item, type /*, fields*/) { var data = item.serialize(); this.updateCollector[syncKey][item.id] = [ServerUser._eventTypeMap[type], data]; }; /** * @param collection * @param syncKey ключ, по которому клиент узнает к какой группе относятся объекты */ ServerUser.prototype.watchCollection = function(collection, syncKey) { this.unwatchCollection(syncKey); // сюда будут складываться объновления объектов this.updateCollector[syncKey] = []; var user = this; var addCallback = function(item) { user.onCollectionUpdate(syncKey, item, 'add'); }; var changeCallback = function(item) { user.onCollectionUpdate(syncKey, item, 'change'); }; var removeCallback = function(item) { user.onCollectionUpdate(syncKey, item, 'remove'); }; // подписываемся на обновления collection.on('add', addCallback); collection.on('change', changeCallback); collection.on('remove', removeCallback); // запоминаем callback, чтобы при отключении от группы, можно было удалить обработчик this.collections[syncKey] = { 'addCallback': addCallback, 'changeCallback': changeCallback, 'removeCallback': removeCallback, 'collection': collection }; // отправляем клиенту все объекты группы, как вновь созданные collection.traversal(function(item){ this.onCollectionUpdate(syncKey, item, 'add'); }, this); }; ServerUser.prototype.unwatchCollection = function(syncKey) { if (this.collections[syncKey]) { // удаляем обработчик this.collections[syncKey].collection.removeListener('add', this.collections[syncKey].addCallback); this.collections[syncKey].collection.removeListener('change', this.collections[syncKey].changeCallback); this.collections[syncKey].collection.removeListener('remove', this.collections[syncKey].removeCallback); // сообщаем клиенту, чтобы он удалил у себя эту группу this.clientMessage('clearCollection', syncKey); delete this.collections[syncKey]; delete this.updateCollector[syncKey]; } }; ServerUser.prototype.unwatchAll = function() { for (var syncKey in this.collections) { this.unwatchCollection(syncKey); } };
JavaScript
TMessageList = function TMessageList() { TList.apply(this, arguments); }; TMessageList.prototype = new TList(); TMessageList.prototype.constructor = TMessageList; TMessageList.prototype.say = function(message) { this.add(message); for (var i in this.items) { if (this.items[i].time + 5 * 60 * 1000 < Date.now()) { this.remove(this.items[i]); } } };
JavaScript
TPremadeList = function TPremadeList() { TList.apply(this, arguments); }; TPremadeList.prototype = new TList(); TPremadeList.prototype.constructor = TPremadeList; TPremadeList.prototype.join = function(event, user) { var gameName = event.name && event.name.substr(0,20); if (!user.premade) { var premade; for (var i in this.items) { if (this.items[i].name == gameName) { premade = this.items[i]; break; } } if (!premade) { if (this.count() >= 100) { // games limit throw {message: "Не получается создать игру. Достигнут максимум одновременных игр на сервере."}; } else { premade = new Premade(gameName, event.gameType); this.add(premade); } } premade.join(user); } else { throw {message: "User already in premade - " + user.premade.id + " (bug?)"}; } };
JavaScript
var http = require("http"), url = require("url"), path = require("path"), fs = require("fs"); // todo globals registry = {}; require('../common/event'); require('../common/list'); require('../common/game'); require('../common/premade'); require('../server/premadelist'); require('../common/user'); require('../server/user'); require('../common/message'); require('../server/messagelist'); require('../common/func'); require('../common/map_tiled'); require('../battle-city/field'); require('../battle-city/bot-emitter'); require('../battle-city/objects/abstract'); require('../battle-city/objects/animation'); require('../battle-city/objects/bullet'); require('../battle-city/objects/tank'); require('../battle-city/objects/tankbot'); require('../battle-city/objects/wall'); require('../battle-city/objects/delimiter'); require('../battle-city/objects/base'); require('../battle-city/objects/bonus'); require('../battle-city/objects/trees'); require('../battle-city/objects/water'); require('../battle-city/objects/ice'); require('../battle-city/objects/checkpoint'); require('../battle-city/goals'); require('../battle-city/clan'); require('../edu/course'); require('../edu/courselist'); require('../edu/exercise'); require('../edu/exerciselist'); require('../common/server'); registry.users = new TList(); registry.premades = new TPremadeList(); registry.messages = new TMessageList(); registry.courses = new CoursesList(); process.on('uncaughtException', function(ex) { if (ex.stack) { console.log(ex.stack); } else { console.log(ex); console.trace(); } }); /** * Server is responsible for accepting user connections. */ var server = require('http').createServer(function(request, response) { if (process.argv.indexOf('serve-static') == -1) { // static served with haproxy + nginx response.writeHead(301, {'Location':'http://'+request.headers.host.replace(/:\d+$/, '')}); response.end(); } else { var uri = url.parse(request.url).pathname; if (uri == '/') { uri = '/index.html'; } var filename = path.join(process.cwd(), uri); path.exists(filename, function(exists) { if(!exists) { response.writeHead(404, {"Content-Type": "text/plain"}); response.write("404 Not Found\n"); response.end(); return; } fs.readFile(filename, "binary", function(err, file) { if(err) { response.writeHead(500, {"Content-Type": "text/plain"}); response.write(err + "\n"); response.end(); return; } var exts = { '.html': 'text/html', '.js': 'application/x-javascript', '.png': 'image/png', '.css': 'text/css' }; response.writeHead(200, { 'Content-Type': exts[path.extname(filename)] }); response.write(file, "binary"); response.end(); }); }); } }); server.listen(8124); var io = require('socket.io'); var config = { 'browser client minification': true, 'browser client etag': true, 'browser client gzip': true, 'transports': ['websocket'], 'log level': 1 }; io.listen(server, config).sockets.on('connection', function(socket) { new BcServerInterface(socket); });
JavaScript
ExerciseList = function ExerciseList() { TList.apply(this, arguments); }; ExerciseList.prototype = new TList(); ExerciseList.prototype.constructor = ExerciseList;
JavaScript
CoursesList = function CoursesList() { TList.apply(this, arguments); this.add(new CoursePascalBasics()); this.add(new CourseAlgoritms()); }; CoursesList.prototype = new TList(); CoursesList.prototype.constructor = CoursesList;
JavaScript
Course = function Course(id, name) { this.id = id; this.name = name; // this.execises = new TList(); }; Course.prototype.serialize = function() { return [ serializeTypeMatches[this.constructor.name], // 0 this.id, // 1 this.name // 2 ]; // z is constant }; Course.prototype.unserialize = function(data) { this.id = data[1]; this.name = data[2]; }; CoursePascalBasics = function CoursePascalBasics() { this.execises = new TList(); this.execises.add(new Exercise('pascal-algoritm1', 1)); this.execises.add(new Exercise('pascal-algoritm2', 2)); this.execises.add(new Exercise('pascal-if-statement', 3)); this.execises.add(new Exercise('pascal-for-statement', 4)); }; CoursePascalBasics.prototype = new Course(1, 'course-pascal-basics'); CourseAlgoritms = function CourseAlgoritms() { this.execises = new TList(); this.execises.add(new Exercise('algoritms-wayfinder', 1)); }; CourseAlgoritms.prototype = new Course(2, 'course-algoritms');
JavaScript
Exercise = function Exercise(name, level) { this.name = name; this.level = level; }; Exercise.prototype.serialize = function() { return [ serializeTypeMatches[this.constructor.name], // 0 this.id, // 1 this.name, // 2 this.level // 3 ]; // z is constant }; Exercise.prototype.unserialize = function(data) { this.id = data[1]; this.name = data[2]; this.level = data[3]; };
JavaScript
if (!window.availableLangs['/src/edu/course-pascal-basics/ex1']) { window.availableLangs['/src/edu/course-pascal-basics/ex1'] = {}; } window.availableLangs['/src/edu/course-pascal-basics/ex1']['en'] = { 'exercise-help-content': '<h1>Exercise 1</h1>\ \ <p>In this exercise you goal is to write a program which will lead a tank towards\ checkpoint. Program is a sequence of instructons perfoming consequently step by step.\ One example of insctuction is a procedure call:</p>\ \ <pre class="code">move(steps);</pre>\ \ <p>With this instruction you can make tank to move given steps forward. In this\ example \'move\' is a procedure name. Next after a procedure name are argument list\ encolsed with round brackets. There are only one argument in the example above,\ and this argument are number of step to move forward.</p>\ \ <p>Another procedure call can be this:</p>\ \ <pre class="code">turn(direction);</pre>\ \ <p>This instruction make tank to turn to gived direction. \'direction\' arugument\ of \'turn\' procedure should be a string. Strings in the Pascal language should be\ enclosed with single quoted. This is need by a compiler to split strings and\ keywords or procedure\'s names. So to turn tank to the east, you\ should write this:</p>\ \ <pre class="code">turn(\'east\');</pre>\ \ <p>other appropriate values are \'west\' - turn westward, \'north\' -\ turn northward and \'south\' - turn southward.</p>\ \ <p>In this exercise tank should move 11 steps forward, then turn to the right\ and move another 10 step forward.</p>\ \ <p>Here is a final program source code:</p>\ \ <pre class="code">\ Program Level1;\n\ begin\n\ move(11);\n\ turn(\'east\');\n\ move(10);\n\ end.\n\ </pre>\ \ <p>After you finish writing program, click "Execute code" button to run a program.</p>' };
JavaScript
if (!window.availableLangs['/src/edu/course-pascal-basics/ex2']) { window.availableLangs['/src/edu/course-pascal-basics/ex2'] = {}; } window.availableLangs['/src/edu/course-pascal-basics/ex2']['ru'] = { 'exercise-help-content': '<h1>Задача</h1>\ \ <p>Во втором упражнении вам необходимо проехать через две контрольные точки.</p>\ \ <p>Вот готовый вариант решения задания:</p>\ \ <pre class="code">\ Program Program2;\n\ begin\n\ move(11);\n\ turn(\'east\');\n\ move(10);\n\ turn(\'north\');\n\ move(4);\n\ turn(\'west\');\n\ move(12);\n\ end.\n\ </pre>\ ' };
JavaScript
if (!window.availableLangs['/src/edu/course-pascal-basics/ex3']) { window.availableLangs['/src/edu/course-pascal-basics/ex3'] = {}; } window.availableLangs['/src/edu/course-pascal-basics/ex3']['ru'] = { 'exercise-help-content': '<h1>Задача</h1>\ \ <p>В третьем упражнении цель появляется в одном из двух мест. Но заранее неизвестно в каком именно. \ Чтобы стало понятно о чем речь, нажмите несколько раз кнопку "Начать заново", и вы увидете, что иногда цель \ перемещается на новое место. То есть танку нужно будет проехать 11 шагов вверх, \ затем повернуть вправо или влево, и проехать еще 5 шагов.</p>\ \ <p>Чтобы узнать в какую именно сторону нужно повернуть танк, в этом упражнении будут доступны \ две переменные с именами "x" и "checkpointx". Сравнив какая их этих переменных больше, \ вы сможете решить в какую сторону поворачивать танк. Для этого вам нужно будет использовать \ следующую конструкцию:</p>\ \ <pre class="code">\ if условие then\n\ оператор1\n\ else\n\ оператор2;\n\ </pre>\ \ <p>Во ходе выполнения программы будет вычислено <b>условие</b>, и, если условие верно, \ будет выполнен <b>оператор1</b>, а если условие не верно, то будет выполнен <b>оператор2</b>. \ Обратите внимание, что перед ключевым словом <b>else</b> нет запятой.</p>\ \ <p>Вот готовый вариант решения задания:</p>\ \ <pre class="code">\ Program Program3;\n\ begin\n\ move(11);\n\ if x>checkpointx then\n\ turn(\'west\')\n\ else\n\ turn(\'east\');\n\ move(5);\n\ end.\n\ </pre>\ ' };
JavaScript
if (!window.availableLangs['/src/edu/course-pascal-basics/ex4']) { window.availableLangs['/src/edu/course-pascal-basics/ex4'] = {}; } window.availableLangs['/src/edu/course-pascal-basics/ex4']['ru'] = { 'exercise-help-content': '<h1>Задача</h1>\ \ <p>В четвертом упражнении вам нужно объехать 3 цели. Но, как вы можете заметить, \ цели расположенны не хаотично и объехать их можно повторив три раза подряд одни и \ теже действия. Для этого существует оператор цикла:</p>\ \ <pre class="code">\n\ for переменная := значение1 to значение2 do\n\ оператор;\n\ </pre>\n\ \ <p>Оператор for будет увеличивать значение переменной <b>переменная</b> на еденицу, \ начиная со значения1 и заканчивая значением2, каждый раз выполняя <b>оператор</b>, следующий за <b>do</b>. \ То есть, чтобы выполнить <b>оператор</b> 3 раза, нужно будет написать:</p>\ \ <pre class="code">\n\ for переменная := 1 to 3 do\n\ оператор;\n\ </pre>\n\ \ <p>Но переменная <b>переменная</b> должна быть сначала объявлена, для этого сразу после \ строки <b>Program Program4;</b> нужно написать:</p>\ \ <pre class="code">\n\ var a: integer;\n\ </pre>\n\ <p>Тем самым мы определили переменную <b>a</b> и сам цикл можем записать в следующем виде:</p>\ \ <pre class="code">\n\ for a := 1 to 3 do\n\ оператор;\n\ </pre>\n\ \ <p>Но нам в цикле нужно выполнить не один оператор, а несколько. Для этого можно объеденить \ группу операторов операторными скобками <b>begin</b> и <b>end</b>. В результате получим \ например такой вариант решения задания:</p>\ \ <pre class="code">\n\ Program Program4;\n\ var a: integer;\n\ begin\n\ for a:=1 to 3 do begin\n\ move(5);\n\ turn(\'left\');\n\ move(5);\n\ turn(\'left\');\n\ turn(\'left\');\n\ end\n\ end.\n\ </pre>\n\ ' };
JavaScript
if (!window.availableLangs['/src/edu/course-pascal-basics/ex1']) { window.availableLangs['/src/edu/course-pascal-basics/ex1'] = {}; } window.availableLangs['/src/edu/course-pascal-basics/ex1']['ru'] = { 'exercise-help-content': '<h1>Задача</h1>\ \ <p>В первом упражнении вам необходимо написать программу управления танком, которая \ приведет его в точку назначения. Программа представляет собой набор инструкций, \ выполняемых последовательно, одна за другой. Одним из примеров иструкции, может \ быть вызов процедуры:</p>\ \ <pre class="code">move(steps);</pre>\ \ <p>С помощью этого вызова можно указать танку двигаться вперед на заданное \ количество шагов. В данном случае, move - это имя процедуры. После имени \ процедуры может идти заключенный в круглые скобки список аргументов. Тут у нас \ только один аргумент steps - целое число, указывающее количество шагов, которые \ должен совершить танк.</p>\ \ <p>Другой полезной процедурой будет:</p>\ \ <pre class="code">turn(direction);</pre>\ \ <p>Эта процедура указывает танку повернуться в указанную сторону. Параметром \ direction должна быть строка. Cтроки в Pascal заключаются в одинарные \ кавычки, чтобы компилятор не путал строки с названием процедур или переменных. \ Например чтобы танк повернулся вправо (на восток), нужно написать:</p>\ \ <pre class="code">turn(\'east\');</pre>\ \ <p>остальными вариантами будут: \'west\' - налево (на запад), \'north\' - вверх (на \ север) и \'south\' - вниз (на юг).</p>\ \ <p>В данном задании, танк должен проехать вверх на 11 шагов, затем повернуться \ направо, и проехать еще 10 шагов.</p>\ \ <p>Вот готовый вариант решения задания:</p>\ \ <pre class="code">\ Program Level1;\n\ begin\n\ move(11);\n\ turn(\'east\');\n\ move(10);\n\ end.\n\ </pre>\ \ <p>Скопируйте код на вкладку "Редактор кода", после чего нажмите кнопку "Выполнить код".</p>' };
JavaScript
BotEmitter = function BotEmitter(x, y) { this.x = x; this.y = y; };
JavaScript
(function(){ window.images = {}; var sprites = [ 'img/tank1-down-s1.png' , 'img/tank1-down-s2.png' , 'img/tank1-up-s1.png' , 'img/tank1-up-s2.png' , 'img/tank1-right-s1.png' , 'img/tank1-right-s2.png' , 'img/tank1-left-s1.png' , 'img/tank1-left-s2.png' , 'img/tank2-down-s1.png' , 'img/tank2-down-s2.png' , 'img/tank2-up-s1.png' , 'img/tank2-up-s2.png' , 'img/tank2-right-s1.png' , 'img/tank2-right-s2.png' , 'img/tank2-left-s1.png' , 'img/tank2-left-s2.png' , 'img/normal-bot-down-s1.png' , 'img/normal-bot-down-s2.png' , 'img/normal-bot-down-s1-blink.png' , 'img/normal-bot-down-s2-blink.png' , 'img/normal-bot-up-s1.png' , 'img/normal-bot-up-s2.png' , 'img/normal-bot-up-s1-blink.png' , 'img/normal-bot-up-s2-blink.png' , 'img/normal-bot-right-s1.png' , 'img/normal-bot-right-s2.png' , 'img/normal-bot-right-s1-blink.png' , 'img/normal-bot-right-s2-blink.png' , 'img/normal-bot-left-s1.png' , 'img/normal-bot-left-s2.png' , 'img/normal-bot-left-s1-blink.png' , 'img/normal-bot-left-s2-blink.png' , 'img/fast-bullet-bot-down-s1.png' , 'img/fast-bullet-bot-down-s2.png' , 'img/fast-bullet-bot-down-s1-blink.png' , 'img/fast-bullet-bot-down-s2-blink.png' , 'img/fast-bullet-bot-up-s1.png' , 'img/fast-bullet-bot-up-s2.png' , 'img/fast-bullet-bot-up-s1-blink.png' , 'img/fast-bullet-bot-up-s2-blink.png' , 'img/fast-bullet-bot-right-s1.png' , 'img/fast-bullet-bot-right-s2.png' , 'img/fast-bullet-bot-right-s1-blink.png' , 'img/fast-bullet-bot-right-s2-blink.png' , 'img/fast-bullet-bot-left-s1.png' , 'img/fast-bullet-bot-left-s2.png' , 'img/fast-bullet-bot-left-s1-blink.png' , 'img/fast-bullet-bot-left-s2-blink.png' , 'img/fast-bot-down-s1.png' , 'img/fast-bot-down-s2.png' , 'img/fast-bot-down-s1-blink.png' , 'img/fast-bot-down-s2-blink.png' , 'img/fast-bot-up-s1.png' , 'img/fast-bot-up-s2.png' , 'img/fast-bot-up-s1-blink.png' , 'img/fast-bot-up-s2-blink.png' , 'img/fast-bot-right-s1.png' , 'img/fast-bot-right-s2.png' , 'img/fast-bot-right-s1-blink.png' , 'img/fast-bot-right-s2-blink.png' , 'img/fast-bot-left-s1.png' , 'img/fast-bot-left-s2.png' , 'img/fast-bot-left-s1-blink.png' , 'img/fast-bot-left-s2-blink.png' , 'img/heavy-bot-down-s1.png' , 'img/heavy-bot-down-s2.png' , 'img/heavy-bot-down-s1-blink.png' , 'img/heavy-bot-down-s2-blink.png' , 'img/heavy-bot-up-s1.png' , 'img/heavy-bot-up-s2.png' , 'img/heavy-bot-up-s1-blink.png' , 'img/heavy-bot-up-s2-blink.png' , 'img/heavy-bot-right-s1.png' , 'img/heavy-bot-right-s2.png' , 'img/heavy-bot-right-s1-blink.png' , 'img/heavy-bot-right-s2-blink.png' , 'img/heavy-bot-left-s1.png' , 'img/heavy-bot-left-s2.png' , 'img/heavy-bot-left-s1-blink.png' , 'img/heavy-bot-left-s2-blink.png' , 'img/bullet-up.png' , 'img/bullet-down.png' , 'img/bullet-left.png' , 'img/bullet-right.png' , 'img/brick-wall.png' , 'img/black.png' , 'img/base.png' , 'img/base-hit.png' , 'img/birth1.png' , 'img/birth2.png' , 'img/steel-wall.png' , 'img/star.png' , 'img/grenade.png' , 'img/shovel.png' , 'img/trees.png' , 'img/water1.png' , 'img/water2.png' , 'img/hit1.png' , 'img/hit2.png' , 'img/hit3.png' , 'img/helmet.png' , 'img/live.png' , 'img/timer.png' , 'img/armored1.png' , 'img/armored2.png' , 'img/ice.png' , 'img/checkpoint.png' ]; for (var i in sprites) { window.images[sprites[i]] = new Image(); window.images[sprites[i]].src = sprites[i]; } })();
JavaScript
Goal = function Goal(clan) { this.clan = clan; this.status = 0; // 0 - active, 1 - done }; Eventable(Goal.prototype); Goal.prototype.check = function() { throw new Error('subclass responsibility'); }; Goal.prototype.reset = function(field) { this.status = 0; }; GoalCheckPoint = function GoalCheckPoint(clan, x, y) { Goal.call(this, clan); this.checkpoint = new Checkpoint(x, y); }; GoalCheckPoint.prototype = new Goal(); GoalCheckPoint.prototype.constructor = GoalCheckPoint; GoalCheckPoint.prototype.check = function() { var res = this.clan.game.field.intersect(this.checkpoint); var clan = this.clan; for (var i in res) { if (res[i] instanceof Tank && res[i].clan == clan.enemiesClan) { clan.game.field.remove(this.checkpoint); this.status = 1; this.emit('change'); } } }; GoalCheckPoint.prototype.reset = function() { this.status = 0; this.clan.game.field.add(this.checkpoint); }; GoalCheckPoint.prototype.serialize = function() { return [ serializeTypeMatches[this.constructor.name], // 0 this.id, // 1 this.status, // 2 this.checkpoint.x, // 3 this.checkpoint.y // 4 ]; }; GoalCheckPoint.prototype.unserialize = function(data) { this.id = data[1]; this.status = data[2]; this.checkpoint = new Checkpoint(data[3], data[4]); };
JavaScript
/** * drawable * coordinates */ Bonus = function Bonus(x, y) { AbstractGameObject.call(this, 16, 16); this.x = x; this.y = y; this.z = 2; }; Bonus.prototype = new AbstractGameObject(); Bonus.prototype.constructor = Bonus; Eventable(Bonus.prototype); Bonus.prototype.serialize = function() { return [ serializeTypeMatches[this.constructor.name], this.id, this.x, this.y ]; // z is constant }; Bonus.prototype.unserialize = function(data) { this.id = data[1]; if (this.field) { this.field.setXY(this, data[2], data[3]); } else { // first unserialize, before adding to field -> may set x and y directly this.x = data[2]; this.y = data[3]; } }; Bonus.prototype.hit = function(bullet) { return false; }; BonusStar = function BonusStar(x, y) { Bonus.apply(this, arguments); this.img[0] = 'img/star.png'; }; BonusStar.prototype = new Bonus(); BonusStar.prototype.constructor = BonusStar; BonusStar.prototype.applyTo = function(tank) { if (tank.maxBullets == 1) { tank.maxBullets = 2; } else if (tank.bulletPower == 1) { tank.bulletPower = 2; } }; BonusGrenade = function BonusGrenade(x, y) { Bonus.apply(this, arguments); this.img[0] = 'img/grenade.png'; }; BonusGrenade.prototype = new Bonus(); BonusGrenade.prototype.constructor = BonusGrenade; BonusGrenade.prototype.applyTo = function(tank) { // hit() cause splice tank.clan.enemiesClan.users, so collect tanks first var tanks = []; for (var i in tank.clan.enemiesClan.users) { tanks.push(tank.clan.enemiesClan.users[i].tank); } for (var i in tanks) { tanks[i].hit(); } }; BonusShovel = function BonusShovel(x, y) { Bonus.apply(this, arguments); this.img[0] = 'img/shovel.png'; }; BonusShovel.prototype = new Bonus(); BonusShovel.prototype.constructor = BonusShovel; BonusShovel.prototype.applyTo = function(tank) { if (!tank.clan.isBots()) { tank.clan.base.armor(); } }; BonusHelmet = function BonusHelmet(x, y) { Bonus.apply(this, arguments); this.img[0] = 'img/helmet.png'; }; BonusHelmet.prototype = new Bonus(); BonusHelmet.prototype.constructor = BonusHelmet; BonusHelmet.prototype.applyTo = function(tank) { tank.armoredTimer = tank.clan.defaultArmoredTimer; }; BonusLive = function BonusLive(x, y) { Bonus.apply(this, arguments); this.img[0] = 'img/live.png'; }; BonusLive.prototype = new Bonus(); BonusLive.prototype.constructor = BonusLive; BonusLive.prototype.applyTo = function(tank) { tank.user.lives++; tank.user.emit('change'); }; BonusTimer = function BonusTimer(x, y) { Bonus.apply(this, arguments); this.img[0] = 'img/timer.png'; }; BonusTimer.prototype = new Bonus(); BonusTimer.prototype.constructor = BonusTimer; BonusTimer.prototype.applyTo = function(tank) { tank.clan.enemiesClan.pauseTanks(); };
JavaScript
AbstractGameObject = function AbstractGameObject(hw, hh) { // for intersection (when speedX > hw) this.hw = this.boundX = hw; //for intersection (when speedY > hh) this.hh = this.boundY = hh; this.speedX; // set only through setSpeedX() this.speedY; // set only through setSpeedY() this.img = []; }; AbstractGameObject.prototype.z = 1; AbstractGameObject.prototype.setSpeedX = function(value) { this.speedX = value; this.boundX = this.speedX ? Math.max(this.hw, Math.abs(this.speedX)) : this.hw; }; AbstractGameObject.prototype.setSpeedY = function(value) { this.speedY = value; this.boundY = this.speedY ? Math.max(this.hh, Math.abs(this.speedY)) : this.hh; }; // sample AbstractGameObject.prototype.serialize = function() { // zero element is always type, first - id return [ serializeTypeMatches['AbstractGameObject'], this.id // ... ]; }; //sample AbstractGameObject.prototype.unserialize = function(data) { this.id = data[1]; // ... };
JavaScript
Delimiter = function Delimiter(x, y, hw, hh) { AbstractGameObject.call(this, hw, hh); this.x = x; this.y = y; this.z = 1; this.hw = hw; // half width this.hh = hh; // half height this.img[0] = 'img/black.png'; }; Delimiter.prototype = new AbstractGameObject(); Delimiter.prototype.constructor = Delimiter; Eventable(Delimiter.prototype); Delimiter.prototype.serialize = function() { return [ serializeTypeMatches['Delimiter'], // 0 this.id, // 1 this.x, this.y, this.hw, this.hh ]; }; Delimiter.prototype.unserialize = function(data) { this.id = data[1]; if (this.field) { this.field.setXY(this, data[2], data[3]); } else { // first unserialize, before adding to field -> may set x and y directly this.x = data[2]; this.y = data[3]; } this.hw = data[4]; this.hh = data[5]; }; Delimiter.prototype.hit = function() { return true; };
JavaScript
/** * drawable * coordinates */ Water = function Water(x, y) { AbstractGameObject.call(this, 8, 8); this.x = x; this.y = y; this.z = 1; this.img[0] = 'img/water1.png'; }; Water.prototype = new AbstractGameObject(); Water.prototype.constructor = Water; Eventable(Water.prototype); Water.prototype.serialize = function() { return [ serializeTypeMatches['Water'], // 0 this.id, // 1 this.x, this.y ]; // z is constant }; Water.prototype.unserialize = function(data) { this.id = data[1]; if (this.field) { this.field.setXY(this, data[2], data[3]); } else { // first unserialize, before adding to field -> may set x and y directly this.x = data[2]; this.y = data[3]; } }; Water.prototype.hit = function(bullet) { return false; }; Water.prototype.animateStep = function(step) { if (step % 10 == 0) { if (step % 20 >= 10) { this.img[0] = 'img/water2.png'; } else { this.img[0] = 'img/water1.png'; } } };
JavaScript
/** * drawable * coordinates */ Bullet = function Bullet(speedX, speedY) { AbstractGameObject.call(this, 4, 4); this.x = 0; this.y = 0; this.z = 1; // bullet is rectangle step of bullet this.setSpeedX(speedX); this.setSpeedY(speedY); this.finalX = 0; // for proper hit animation (todo ugly) this.finalY = 0; // for proper hit animation (todo ugly) this.power = 1; this.setDirectionImage(); }; Bullet.prototype = new AbstractGameObject(); Bullet.prototype.constructor = Bullet; Eventable(Bullet.prototype); Bullet.prototype.setDirectionImage = function() { var dir = 'up'; if (this.speedY > 0) { dir = 'down'; } else if (this.speedY < 0) { dir = 'up'; } else if (this.speedX > 0) { dir = 'right'; } else if (this.speedX < 0) { dir = 'left'; } this.img[0] = 'img/bullet-' + dir + '.png'; }; Bullet.prototype.step = function() { if (this.field.move(this, this.x + this.speedX, this.y + this.speedY)) { this.emit('change'); } }; Bullet.prototype.hit = function() { this.field.remove(this); return true; }; Bullet.prototype.onIntersect = function(items) { var canMoveThrowItems = true; for (var i in items) { if (items[i] == this.tank) continue; // todo neiberhood wall can be already removed if (items[i].hit && items[i].hit(this)) { if (this.speedX) this.finalX = items[i].x - items[i].hw * vector(this.speedX); else this.finalX = this.x; if (this.speedY) this.finalY = items[i].y - items[i].hh * vector(this.speedY); else this.finalY = this.y; canMoveThrowItems = false; } } if (!canMoveThrowItems) { this.field.remove(this); } return canMoveThrowItems; }; Bullet.prototype.serialize = function() { return [ serializeTypeMatches['Bullet'], // 0 this.id, // 1 this.x, // 2 this.y, // 3 this.speedX, // 4 this.speedY, // 5 this.finalX, // 6 todo remove this.finalY // 7 todo remove ]; }; Bullet.prototype.unserialize = function(data) { this.id = data[1]; if (this.field) { this.field.setXY(this, data[2], data[3]); } else { // first unserialize, before adding to field -> may set x and y directly this.x = data[2]; this.y = data[3]; } this.setSpeedX(data[4]); this.setSpeedY(data[5]); this.finalX = data[6]; this.finalY = data[7]; this.setDirectionImage(); };
JavaScript
/** * drawable * coordinates * * interface: * fire() * turn(direction) * startMove() * stopMove() * * В этом классе перемешанны: * - сама сущность * - отрисовка (setDirectionImage(), imgBase, clanN, trackStep, blink) * - пуле устанавливаются координаты напрямую, а для этого надо знать, * что можно задавать x и y напрямую, только до добавления объекта * в map_tiled (можно переделать map_tiled чтобы он слушал gameBus, * а объекты просто кидали событие move). * - distanceLeft и this.emit('task-done') - знание о том что vm на клиенте * ждет этого события, чтобы продолжить выполнять код (можно выделить * в tankController). * - не понятно куда пристроить обработку бонусов, толи this.onBonus толи в * bonus.onIntersect. А может вообще в отдельный класс? * - сериализация * * Этот класс знает о: * - о своих пулях (bullets) * - об игровом поле (field) * - бонусах (onBonus) * - о льде (Ice) * - о кланах (clan) * - о виртуальной машине на клиенте (this.emit('task-done')) * - о спрайтах для отрисовки * - serializeTypeMatches * - о пользователях (bullet.tank.user.addReward(this.reward)) * */ Tank = function Tank(x, y) { AbstractGameObject.call(this, 16, 16); this.initialPosition = { x: x, y: y }; this.x = x; this.y = y; this.z = 1; this.moveOn = 0; // flag used in Tank.step() this.distanceLeft = null; this.setSpeedX(0); this.setSpeedY(-this.speed); this.direction = null; this.setDirectionImage(); this.maxBullets = 1; this.bulletPower = 1; this.bullets = new Array(); // can move to current direction? this.stuck = false; this.lives = 1; this.bonus = false; this.clan = null; this.armoredTimer = Tank.defaultArmoredTimer; // 30ms step this.trackStep = 1; // 1 or 2 this.birthTimer = 1 * 1000/30; // 30ms step this.fireTimer = 0; this.onIce = false; this.glidingTimer = 0; this.blink = false; }; Tank.defaultArmoredTimer = 10 * 1000/30; // 30ms step Tank.prototype = new AbstractGameObject(); Tank.prototype.constructor = Tank; Tank.prototype.imgBase = 'img/tank'; Tank.prototype.reward = 100; Tank.prototype.speed = 2; // default speed Tank.prototype.bulletSpeed = 5; // default speed Eventable(Tank.prototype); Tank.prototype.onAddToField = function() { var self = this; this.field.on('remove', function(object) { for (var i in self.bullets) { if (self.bullets[i] == object) { self.bullets.splice(i, 1); } } }); }; Tank.prototype.fire = function() { if (this.birthTimer <= 0 && this.bullets.length < this.maxBullets && !(this.bullets.length > 0 && this.fireTimer > 0)) { if (this.bullets.length > 0) { // to not second fire too fast this.fireTimer = 0.5 * 1000/30; // 30ms step } var bullet = new Bullet(); bullet.tank = this; bullet.clan = this.clan; bullet.setSpeedX(vector(this.speedX) * this.bulletSpeed); bullet.setSpeedY(vector(this.speedY) * this.bulletSpeed); // before adding to field (may set x, y directly) bullet.x = this.x + (this.hw - 2) * vector(this.speedX); bullet.y = this.y + (this.hh - 2) * vector(this.speedY); bullet.power = this.bulletPower; this.bullets.push(bullet); this.field.add(bullet); } this.emit('task-done'); }; Tank.prototype.step = function(paused) { if (this.fireTimer > 0) this.fireTimer--; if ((this.birthTimer > 0)) { this.birthTimer--; this.emit('change'); return; } if (this.armoredTimer > 0) { this.armoredTimer--; if (this.armoredTimer <= 0) { this.emit('change'); } } if (paused) return; var onIce = false; if (this.moveOn || this.glidingTimer > 0) { // todo field.move()? var sx = this.distanceLeft && this.distanceLeft < this.speedX ? vector(this.speedX) * this.distanceLeft : this.speedX; var sy = this.distanceLeft && this.distanceLeft < this.speedY ? vector(this.speedY) * this.distanceLeft : this.speedY; this.stuck = false; var intersect = this.field.intersect(this, this.x + sx, this.y + sy); if (intersect.length > 0) { for (var i in intersect) { switch (true) { case intersect[i] instanceof Bonus: this.onBonus(intersect[i]); break; case intersect[i] instanceof Ice: onIce = true; // no break! before default! default: // power === undefined is a hack for fast bullet detection if (intersect[i].z == this.z && intersect[i].power === undefined) { this.stuck = true; this.glidingTimer = 0; } } } } if (!this.stuck) { this.field.setXY(this, this.x + sx, this.y + sy); if (this.distanceLeft) { this.distanceLeft -= Math.abs(sx + sy); // sx == 0 || sy == 0 if (this.distanceLeft == 0) { this.emit('task-done'); this.distanceLeft = null; this.moveOn = false; } } } this.onIce = onIce; if (this.glidingTimer > 0) { if (onIce) { this.glidingTimer--; } else { this.glidingTimer = 0; } } this.emit('change'); } }; Tank.prototype.onBonus = function(bonus) { bonus.applyTo(this); this.field.remove(bonus); }; //function for override for different sprites Tank.prototype.setDirectionImage = function() { var dir = 'up'; if (this.speedY > 0) { dir = 'down'; } else if (this.speedY < 0) { dir = 'up'; } else if (this.speedX > 0) { dir = 'right'; } else if (this.speedX < 0) { dir = 'left'; } this.img[0] = (((this.imgBase == 'img/tank') ? this.imgBase + this.clanN : this.imgBase) // todo clanN hack + '-' + dir + '-s' + this.trackStep + (this.blink ? '-blink' : '') + '.png'); }; Tank.prototype.serialize = function() { return [ serializeTypeMatches[this.constructor.name], // 0 this.id, // 1 this.x, // 2 this.y, // 3 this.speedX, // 4 this.speedY, // 5 this.bonus, // 6 Math.round(this.armoredTimer), // 7 Math.round(this.birthTimer), // 8 this.clan.n // 9 ]; }; Tank.prototype.unserialize = function(data) { this.id = data[1]; if (this.field) { this.field.setXY(this, data[2], data[3]); } else { // first unserialize, before adding to field -> may set x and y directly this.x = data[2]; this.y = data[3]; } this.setSpeedX(data[4]); this.setSpeedY(data[5]); this.bonus = data[6]; this.armoredTimer = data[7]; this.birthTimer = data[8]; this.clanN = data[9]; }; Tank.prototype.animateStep = function(step) { if (this.birthTimer > 0) { this.img[0] = 'img/birth' + ((step % 6) > 3 ? 1 : 2) + '.png'; delete this.img[1]; } else { if (this.moveOn) { this.trackStep = step % 2 + 1; } if (this.bonus) { this.blink = (step % 10) > 5; } else if(this.blink) { this.blink = false; } this.setDirectionImage(); if (this.armoredTimer > 0) { this.img[1] = step % 2 ? 'img/armored1.png' : 'img/armored2.png'; } else { delete this.img[1]; } } }; /** * There are circumstances when turning is impossible, so return bool * * @todo too long function * @param direction * @return bool */ Tank.prototype.turn = function(direction) { var canTurn = true; if (direction == 'right') { switch (true) { case this.speedX > 0: direction = 'south'; break; case this.speedX < 0: direction = 'north'; break; case this.speedY > 0: direction = 'west'; break; case this.speedY < 0: direction = 'east'; break; } } if (direction == 'left') { switch (true) { case this.speedX > 0: direction = 'north'; break; case this.speedX < 0: direction = 'south'; break; case this.speedY > 0: direction = 'east'; break; case this.speedY < 0: direction = 'west'; break; } } if (this.direction != direction) { // emulate move back tank for 1 pixel // doto this may be a bug, if tank just change direction to opposite var vx = this.speedX > 0 ? 1 : -1; var vy = this.speedY > 0 ? 1 : -1; // 1, 2 - first try turn with backward adjust, second try turn with forward adjust var newX1, newY1, newX2, newY2, newSpeedX, newSpeedY; switch (direction) { case 'north': newSpeedX = 0; newSpeedY = -this.speed; if (this.x % 16 > 8 + vx) { newX1 = this.x + 16 - this.x % 16; newX2 = this.x - this.x % 16; } else { newX1 = this.x - this.x % 16; newX2 = this.x + 16 - this.x % 16; } newY1 = newY2 = this.y; break; case 'east': newSpeedX = this.speed; newSpeedY = 0; newX1 = newX2 = this.x; if (this.y % 16 > 8 + vy) { newY1 = this.y + 16 - this.y % 16; newY2 = this.y - this.y % 16; } else { newY1 = this.y - this.y % 16; newY2 = this.y + 16 - this.y % 16; } break; case 'south': newSpeedX = 0; newSpeedY = this.speed; if (this.x % 16 > 8 + vx) { newX1 = this.x + 16 - this.x % 16; newX2 = this.x - this.x % 16; } else { newX1 = this.x - this.x % 16; newX2 = this.x + 16 - this.x % 16; } newY1 = newY2 = this.y; break; case 'west': newSpeedX = -this.speed; newSpeedY = 0; newX1 = newX2 = this.x; if (this.y % 16 > 8 + vy) { newY1 = this.y + 16 - this.y % 16; newY2 = this.y - this.y % 16; } else { newY1 = this.y - this.y % 16; newY2 = this.y + 16 - this.y % 16; } break; default: this.emit('task-done', 'Unknown direction "' + direction + '"'); throw new Error('Unknown direction "' + direction + '"'); } var intersects = this.field.intersect(this, newX1, newY1); for (var i in intersects) { if (intersects[i].z == this.z) { canTurn = false; } } if (canTurn) { // new place is clear, turn: this.field.setXY(this, newX1, newY1); this.setSpeedX(newSpeedX); this.setSpeedY(newSpeedY); this.direction = direction; this.emit('change'); } else { canTurn = true; var intersects = this.field.intersect(this, newX2, newY2); for (var i in intersects) { if (intersects[i].z == this.z) { canTurn = false; } } if (canTurn) { // new place is clear, turn: this.field.setXY(this, newX2, newY2); this.setSpeedX(newSpeedX); this.setSpeedY(newSpeedY); this.direction = direction; this.emit('change'); }; } } this.emit('task-done'); return canTurn; }; Tank.prototype.move = function(distance) { this.distanceLeft = distance; this.moveOn = true; }; Tank.prototype.startMove = function() { this.distanceLeft = null; this.moveOn = true; }; Tank.prototype.stopMove = function() { this.distanceLeft = null; this.moveOn = false; if (this.onIce) { this.glidingTimer = 1000/30; // 30ms step } }; /** * Bullet may be undefined (see BonusGrenade) */ Tank.prototype.hit = function(bullet) { if (this.armoredTimer > 0) { return true; } // do not hit your confederates (or yourself) if (!bullet || this.clan != bullet.clan) { if (bullet) { this.lives--; } else { this.lives = 0; } if (this.lives <= 0) { if (bullet && bullet.tank.user) { bullet.tank.user.addReward(this.reward); } if (this.user) { this.user.hit(); } else { this.field.remove(this); } } if (bullet && (this.bonus || (this.user && !this.clan.enemiesClan.isBots()))) { this.bonus = false; var bonuses = [BonusStar, BonusGrenade, BonusShovel, BonusHelmet, BonusLive, BonusTimer]; this.field.add(new (bonuses[Math.floor(Math.random()*(bonuses.length-0.0001))])( Math.round((Math.random() * (this.field.width / 16 - 2))) * 16 + 16, Math.round((Math.random() * (this.field.height / 16 - 2))) * 16 + 16 )); } } return true; }; Tank.prototype.resetPosition = function() { this.maxBullets = 1; this.bulletPower = 1; this.distanceLeft = null; this.direction = null; this.moveOn = 0; this.setSpeedX(0); this.setSpeedY(-this.speed); this.bullets = []; this.armoredTimer = this.clan ? this.clan.defaultArmoredTimer : Tank.defaultArmoredTimer; this.birthTimer = 1 * 1000/30; // 30ms step if (this.field) { this.field.setXY(this, this.initialPosition.x, this.initialPosition.y); } this.emit('change'); };
JavaScript
/** * drawable * coordinates */ Trees = function Trees(x, y) { AbstractGameObject.call(this, 8, 8); this.x = x; this.y = y; this.z = 2; this.img[0] = 'img/trees.png'; }; Trees.prototype = new AbstractGameObject(); Trees.prototype.constructor = Trees; Eventable(Trees.prototype); Trees.prototype.serialize = function() { return [ serializeTypeMatches['Trees'], // 0 this.id, // 1 this.x, this.y ]; // z is constant }; Trees.prototype.unserialize = function(data) { this.id = data[1]; if (this.field) { this.field.setXY(this, data[2], data[3]); } else { // first unserialize, before adding to field -> may set x and y directly this.x = data[2]; this.y = data[3]; } }; Trees.prototype.hit = function(bullet) { return false; };
JavaScript
Base = function Base(x, y) { AbstractGameObject.call(this, 16, 16); this.x = x; this.y = y; this.img[0] = 'img/base.png'; this.shootDown = false; }; Base.prototype = new AbstractGameObject(); Base.prototype.constructor = Base; Base.prototype.baseEdge = { 1: [ {x: 11, y: 23} , {x: 11, y: 24} , {x: 11, y: 25} , {x: 12, y: 23} , {x: 13, y: 23} , {x: 14, y: 23} , {x: 14, y: 24} , {x: 14, y: 25}], 2: [ {x: 11, y: 0} , {x: 11, y: 1} , {x: 11, y: 2} , {x: 12, y: 2} , {x: 13, y: 2} , {x: 14, y: 2} , {x: 14, y: 1} , {x: 14, y: 0}] }; Eventable(Base.prototype); Base.prototype.serialize = function() { return [ serializeTypeMatches['Base'], this.id, this.x, this.y, this.shootDown ]; // z is constant }; Base.prototype.unserialize = function(data) { this.id = data[1]; if (this.field) { this.field.setXY(this, data[2], data[3]); } else { // first unserialize, before adding to field -> may set x and y directly this.x = data[2]; this.y = data[3]; } this.shootDown = data[4]; }; Base.prototype.hit = function() { this.shootDown = true; this.clan.premade.gameOver(this.clan.enemiesClan, 2000); this.emit('change'); return true; }; Base.prototype.armor = function() { this.armoredTimer = 10 * 1000/30; // 30ms step var edge = this.baseEdge[this.clan.n]; for (var i in edge) { var walls = this.field.intersect(this, edge[i].x*16+8, edge[i].y*16+8, 8, 8); var convert = true; for (var j in walls) { if (!(walls[j] instanceof Wall)) { convert = false; } } if (convert) { for (var j in walls) { this.field.remove(walls[j]); } this.field.add(new SteelWall(edge[i].x*16+8, edge[i].y*16+8)); } } }; Base.prototype.disarm = function() { var edge = this.baseEdge[this.clan.n]; for (var i in edge) { var walls = this.field.intersect(this, edge[i].x*16+8, edge[i].y*16+8, 8, 8); var convert = true; for (var j in walls) { if (!(walls[j] instanceof Wall)) { convert = false; } } if (convert) { for (var j in walls) { this.field.remove(walls[j]); } this.field.add(new Wall(edge[i].x*16+ 4, edge[i].y*16+ 4)); this.field.add(new Wall(edge[i].x*16+ 4, edge[i].y*16+12)); this.field.add(new Wall(edge[i].x*16+12, edge[i].y*16+ 4)); this.field.add(new Wall(edge[i].x*16+12, edge[i].y*16+12)); } } }; Base.prototype.step = function() { if (this.armoredTimer > 0) { if (--this.armoredTimer <= 0) { this.disarm(); } } }; Base.prototype.animateStep = function(step) { if (this.shootDown) { this.img[0] = 'img/base-hit.png'; } };
JavaScript
OnFieldAnimation = function OnFieldAnimation(step, hw, hh) { AbstractGameObject.call(this, hw, hh); this.firstStep = step; }; OnFieldAnimation.prototype = new AbstractGameObject(); OnFieldAnimation.prototype.constructor = OnFieldAnimation; BulletHitAnimation = function BulletHitAnimation(step, x, y) { OnFieldAnimation.call(this, step, 16, 16); this.x = x; this.y = y; this.img[0] = 'img/hit1.png'; }; BulletHitAnimation.prototype = new OnFieldAnimation(); BulletHitAnimation.prototype.constructor = BulletHitAnimation; BulletHitAnimation.prototype.animateStep = function(step) { if (step - this.firstStep > 2) { this.field.remove(this); } else if (step - this.firstStep > 1) { this.img[0] = 'img/hit2.png'; } }; TankHitAnimation = function TankHitAnimation(step, x, y) { OnFieldAnimation.call(this, step, 16, 16); this.x = x; this.y = y; this.img[0] = 'img/hit1.png'; }; TankHitAnimation.prototype = new OnFieldAnimation(); TankHitAnimation.prototype.constructor = TankHitAnimation; TankHitAnimation.prototype.animateStep = function(step) { if (step - this.firstStep > 5) { this.field.remove(this); } else if (step - this.firstStep > 3) { this.hw = this.hh = 32; // don't care about intersections this.img[0] = 'img/hit3.png'; } else if (step - this.firstStep > 1) { this.img[0] = 'img/hit2.png'; } };
JavaScript
TankBot = function TankBot(x, y, bonus) { Tank.apply(this, arguments); // call parent constructor this.setSpeedY(this.speed); this.moveOn = true; this.bonus = bonus; this.clan = null; this.armoredTimer = 0; this.fireTimer = 0; // do not fire too fast }; TankBot.prototype = new Tank(); TankBot.prototype.constructor = TankBot; TankBot.prototype.reward = 100; TankBot.prototype.imgBase = 'img/normal-bot'; TankBot.prototype.step = function(paused) { if ((this.birthTimer <= 0) && !paused) { if ((this.stuck || Math.random() < 0.03) && this.fireTimer <= 0) { this.fire(); this.fireTimer = 0.5 * 1000/30; // 30ms step } if (this.stuck || Math.random() < 0.007) { // move percents var mp = { 'north': this.y / 500, 'east': (416 - this.x) / 416, 'south': (500 - this.y) / 500, 'west': this.x / 416 }; var percent = Math.random() * (mp['north'] + mp['east'] + mp['south'] + mp['west']); for (var i in mp) { percent -= mp[i]; if (percent < 0) { this.turn(i); break; } } } } Tank.prototype.step.call(this, paused); }; TankBot.prototype.onBonus = function(bonus) { }; FastBulletTankBot = function FastBulletTankBot(x, y, bonus) { TankBot.apply(this, arguments); // call parent constructor }; FastBulletTankBot.prototype = new TankBot(); FastBulletTankBot.prototype.constructor = FastBulletTankBot; FastBulletTankBot.prototype.reward = 200; FastBulletTankBot.prototype.imgBase = 'img/fast-bullet-bot'; FastBulletTankBot.prototype.bulletSpeed = 8; // default speed FastTankBot = function FastTankBot(x, y, bonus) { TankBot.apply(this, arguments); // call parent constructor }; FastTankBot.prototype = new TankBot(); FastTankBot.prototype.constructor = FastTankBot; FastTankBot.prototype.reward = 300; FastTankBot.prototype.imgBase = 'img/fast-bot'; FastTankBot.prototype.speed = 3; // default speed HeavyTankBot = function HeavyTankBot(x, y, bonus) { TankBot.apply(this, arguments); // call parent constructor this.lives = 3; }; HeavyTankBot.prototype = new TankBot(); HeavyTankBot.prototype.constructor = HeavyTankBot; HeavyTankBot.prototype.reward = 400; HeavyTankBot.prototype.imgBase = 'img/heavy-bot';
JavaScript
/** * drawable * coordinates */ Wall = function Wall(x, y, hw, hh) { AbstractGameObject.call(this, hw ? hw : 4, hh ? hh : 4); this.x = x; this.y = y; this.z = 1; this.img[0] = 'img/brick-wall.png'; }; Wall.prototype = new AbstractGameObject(); Wall.prototype.constructor = Wall; Eventable(Wall.prototype); Wall.prototype.serialize = function() { return [ serializeTypeMatches[this.constructor.name], // 0 this.id, // 1 this.x, this.y ]; // z is constant }; Wall.prototype.unserialize = function(data) { this.id = data[1]; if (this.field) { this.field.setXY(this, data[2], data[3]); } else { // first unserialize, before adding to field -> may set x and y directly this.x = data[2]; this.y = data[3]; } }; Wall.prototype.hit = function(bullet) { // coordinate for search niarest objects var x = this.x, y = this.y; if (bullet.speedX != 0) { switch (Math.ceil((y % 32) / 8)) { case 1: case 3: y += 8; break; case 2: case 4: y -= 8; break; } } else { // if (bullet.speedY > 0) switch (Math.ceil((x % 32) / 8)) { case 1: case 3: x += 8; break; case 2: case 4: x -= 8; break; } } this.field.remove(this); // after remove to avoid recusion var intersect = this.field.intersect(this, x, y, 1, 1); for (var i in intersect) { if (typeof intersect[i]['hit'] == 'function') { intersect[i].hit(bullet); } } return true; }; SteelWall = function SteelWall(x, y) { Wall.call(this, x, y, 8, 8); this.img[0] = 'img/steel-wall.png'; }; SteelWall.prototype = new Wall(); SteelWall.prototype.constructor = SteelWall; SteelWall.prototype.hit = function(bullet) { if (bullet.power == 2) { this.field.remove(this); } return true; };
JavaScript
/** * drawable * coordinates */ Checkpoint = function Checkpoint(x, y) { AbstractGameObject.call(this, 16, 16); this.x = x; this.y = y; this.z = 0; this.img[0] = 'img/checkpoint.png'; }; Checkpoint.prototype = new AbstractGameObject(); Checkpoint.prototype.constructor = Checkpoint; Eventable(Checkpoint.prototype); Checkpoint.prototype.serialize = function() { return [ serializeTypeMatches[this.constructor.name], // 0 this.id, // 1 this.x, // 2 this.y // 3 ]; // z is constant }; Checkpoint.prototype.unserialize = function(data) { this.id = data[1]; if (this.field) { this.field.setXY(this, data[2], data[3]); } else { // first unserialize, before adding to field -> may set x and y directly this.x = data[2]; this.y = data[3]; } }; Checkpoint.prototype.hit = function(bullet) { return false; };
JavaScript
/** * drawable * coordinates */ Ice = function Ice(x, y) { AbstractGameObject.call(this, 8, 8); this.x = x; this.y = y; this.z = 0; this.img[0] = 'img/ice.png'; }; Ice.prototype = new AbstractGameObject(); Ice.prototype.constructor = Ice; Eventable(Ice.prototype); Ice.prototype.serialize = function() { return [ serializeTypeMatches['Ice'], // 0 this.id, // 1 this.x, this.y ]; // z is constant }; Ice.prototype.unserialize = function(data) { this.id = data[1]; if (this.field) { this.field.setXY(this, data[2], data[3]); } else { // first unserialize, before adding to field -> may set x and y directly this.x = data[2]; this.y = data[3]; } }; Ice.prototype.hit = function(bullet) { return false; };
JavaScript
Clan = function Clan(n, defaultArmoredTimer) { this.capacity = 2; // max users this.n = n; this.defaultArmoredTimer = defaultArmoredTimer; this.timer = 0; this.enemiesClan = null; this.users = []; this.goals = new TList(); this.base = new Base(); this.base.clan = this; this.tankPositions = Clan.tankPositions['clan' + n]; }; Clan.tankPositions = { 'clan1': [{x: 4, y: 12}, {x: 8, y: 12}], 'clan2': [{x: 4, y: 0}, {x: 8, y: 0}], 'bots' : [{x: 16, y: 16}, {x: 13*32 / 2, y: 16}, {x: 13*32 - 16, y: 16}] }; Clan.prototype.attachUser = function(user) { if (user.clan) user.clan.detachUser(user); for (var positionId = 0; positionId < this.capacity; positionId++) { if (this.users[positionId] === undefined) { this.users[positionId] = user; user.positionId = positionId; break; } } user.tank = new Tank(); user.tank.on('task-done', function(message){ user.clientMessage('task-done', message); }); user.tank.user = user; user.tank.clan = user.clan = this; user.emit('change'); }; Clan.prototype.detachUser = function(user) { if (this.users[user.positionId] == user) { delete this.users[user.positionId]; if (user.tank.field) { user.tank.field.remove(user.tank); } user.tank.clan = null; user.tank = null; user.clan = null; user.emit('change'); } }; Clan.prototype.size = function() { var res = 0; for (var i = 0; i < this.capacity; i++) { if (this.users[i]) { res++; } } return res; }; Clan.prototype.isFull = function() { return this.size() == this.capacity; }; /** * is this clan of classic bot team * @return */ Clan.prototype.isBots = function() { return false; }; Clan.prototype.step = function() { var activeUsers = 0; for (var i in this.users) { if (this.users[i].lives >= 0) { this.users[i].tank.step(this.timer > 0); activeUsers++; } } if (activeUsers == 0) { this.base.hit(); } this.base.step(); this.timer > 0 && this.timer--; }; Clan.prototype.startGame = function(game) { this.game = game; for (var i in this.users) { var user = this.users[i]; if (user.lives < 0) user.lives = 0; // todo hack // before add to field, may set x y directly user.tank.initialPosition.x = user.tank.x = 32*this.tankPositions[i].x + user.tank.hw; user.tank.initialPosition.y = user.tank.y = 32*this.tankPositions[i].y + user.tank.hh; user.tank.resetPosition(); this.game.field.add(user.tank); user.emit('change'); // user.tankId } this.base.shootDown = false; this.base.x = this.game.field.width / 2; this.base.y = (this.n == 1) ? (this.game.field.height - 16) : 16; this.game.field.add(this.base); }; Clan.prototype.pauseTanks = function() { this.timer = 3 * 30; // 30 steps per second }; BotsClan = function BotsClan(n) { Clan.apply(this, arguments); this.capacity = 6; this.tankPositions = Clan.tankPositions['bots']; }; BotsClan.prototype = new Clan(); BotsClan.prototype.constructor = BotsClan; BotsClan.prototype.isBots = function() { return true; }; BotsClan.prototype.step = function() { if (this.users.length == 0 && this.botStack.count() == 0) { this.base.hit(); } this.base.step(); if (!this.isFull() && this.botStack.count() > 0 && Math.random() < 0.01) { var botX = this.tankPositions[this.currentBotPosition].x; var botY = this.tankPositions[this.currentBotPosition].y; if (this.game && this.game.field.canPutTank(botX, botY)) { var bot = this.botStack.pop(); delete bot['id']; bot.removeAllListeners('change'); // before add to field, may set x y directly bot.x = botX; bot.y = botY; this.users.push({tank: bot}); this.game.field.add(bot); // "remove handler defined in constructor" WFT? this.currentBotPosition = (this.currentBotPosition + 1) % 3; } } for (var i in this.users) { this.users[i].tank.step(this.timer > 0); } this.timer > 0 && this.timer--; }; BotsClan.prototype.startGame = function(game, level) { this.game = game; var bots = this.users = []; this.game.field.on('remove', function(object) { for (var i in bots) { if (bots[i].tank == object) { bots.splice(i, 1); } } }); this.currentBotPosition = 0; this.botStack = new TList(); // todo move from this function var enemies = level.getEnemies(); for (var i = enemies.length - 1; i >= 0; i-- ) { var bonus = [3,10,17].indexOf(i) >= 0; var bot; // var bonus = true; switch (enemies[i]) { case 1: bot = new TankBot(0, 0, bonus); break; case 2: bot = new FastTankBot(0, 0, bonus); break; case 3: bot = new FastBulletTankBot(0, 0, bonus); break; case 4: bot = new HeavyTankBot(0, 0, bonus); break; } bot.clan = this; bot.id = Field.autoIncrement++; // todo hack, to bots in stack have id on client this.botStack.add(bot); } this.base.shootDown = false; }; BotsClan.prototype.pauseTanks = function() { this.timer = 10 * 1000/30; // 30ms step }; /** * FIXME should be a user's clan, not enemies * @param n * @return */ LearnerClan = function LearnerClan(n) { Clan.apply(this, arguments); }; LearnerClan.prototype = new Clan(); LearnerClan.prototype.constructor = LearnerClan; LearnerClan.prototype.startGame = function(game, level) { this.game = game; this.base.shootDown = false; this.base.x = this.game.field.width / 2; this.base.y = (this.n == 1) ? (this.game.field.height - 16) : 16; if (level.getGoals) { this.goals.clear(); var goals = level.getGoals(this); for (var i = 0 ; i < goals.length ; i++) { goals[i].reset(); this.goals.add(goals[i]); } } }; LearnerClan.prototype.step = function() { var self = this; if (this.goals.count() > 0) { var goals = 0; for (var i in this.goals.items) { this.goals.items[i].check(); if (this.goals.items[i].status) { goals++; } } if (goals == this.goals.count()) { self.premade.gameOver(self.enemiesClan, 1000); } } this.base.step(); };
JavaScript
Field = function Field(width, height) { this.width = width; this.height = height; this.objects = null; this.clear(); this.setMaxListeners(100); // @todo }; Eventable(Field.prototype); Field.autoIncrement = 1; // todo eliminate? Field.prototype.clear = function() { this.objects = new MapTiled(this.width, this.height); }; Field.prototype.add = function(object) { if (object.id === undefined) { object.id = Field.autoIncrement++; } object.field = this; this.objects.add(object); if (!isClient()) { this.emit('add', object); var self = this; object.on('change', function(){ self.emit('change', this); }); object.onAddToField && object.onAddToField(); } }; Field.prototype.remove = function(object) { if (this.objects.remove(object)) { this.emit('remove', object); object.removeAllListeners && object.removeAllListeners(); } }; Field.prototype.setXY = function(item, newX, newY) { return this.objects.setXY(item, newX, newY); }; Field.prototype.move = function(item, newX, newY) { return this.objects.move(item, newX, newY); }; Field.prototype.get = function(id) { return this.objects.get(id); }; /** * * @param object AbstractGameObject * @return */ Field.prototype.intersect = function(object, newX, newY, boundX, boundY) { return this.objects.intersects(object, newX, newY, boundX, boundY); }; Field.prototype.terrain = function(map) { this.add(new Delimiter( - 20, this.height / 2, 20, this.height / 2)); this.add(new Delimiter(this.width + 20, this.height / 2, 20, this.height / 2)); this.add(new Delimiter(this.width / 2, - 20, this.width / 2, 20)); this.add(new Delimiter(this.width / 2, this.height + 20, this.width / 2, 20)); for (var y = 0 ; y < 26 ; y++) { for (var x = 0 ; x < 26 ; x++) { switch (map[y][x]) { case 1: this.add(new Wall(x*16+ 4, y*16+ 4)); this.add(new Wall(x*16+12, y*16+ 4)); this.add(new Wall(x*16+ 4, y*16+12)); this.add(new Wall(x*16+12, y*16+12)); break; case 2: this.add(new SteelWall(x*16+8, y*16+8)); break; case 3: this.add(new Trees(x*16+8, y*16+8)); break; case 4: this.add(new Water(x*16+8, y*16+8)); break; case 5: this.add(new Ice(x*16+8, y*16+8)); break; } } } // this.add(new BonusTimer(10*16, 20*16)); }; Field.prototype.traversal = function(callback, thisObj) { this.objects.traversal(callback, thisObj); }; Field.prototype.canPutTank = function(x, y) { var res = true; var intersects = this.intersect({}, x, y, 16, 16); for (var i in intersects) { if (!(intersects[i] instanceof Bonus)) { res = false; } }; return res; }; //===== client methods ========================================================= /** * todo almost copy of TList.prototype.updateWith */ Field.prototype.updateWith = function(events) { for (var i in events) { var eventType = events[i][0/*type*/]; var eventData = events[i][1/*data*/]; var type = unserializeTypeMatches[eventData[0/*type*/]]; var id = parseInt(eventData[1/*id*/]); switch (eventType) { case 'r'/*remove*/: if (obj = this.objects.get(id)) { obj.unserialize(eventData); // for bullets finalX and finalY this.remove(obj); } break; case 'a'/*add*/: case 'c'/*change*/: var obj = this.objects.get(id); if (obj) { obj.unserialize(eventData); } else { obj = new (window[type])(); obj.unserialize(eventData); this.add(obj); } break; } } };
JavaScript
// 1 - wall // 2 - steel wall // 3 - trees module.exports.getMap = function() { return [ [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0] ]; }; module.exports.getGoals = function(clan) { return [new GoalCheckPoint(clan, 4*16, 20*16), new GoalCheckPoint(clan, 9*16, 15*16), new GoalCheckPoint(clan, 14*16, 20*16)]; }; /* Program Program4; var a: integer; begin for a:=1 to 3 do begin move(5); turn('left'); move(5); turn('left'); turn('left'); end end. */
JavaScript
// 1 - wall // 2 - steel wall // 3 - trees module.exports.getMap = function() { return [ [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0] ]; }; module.exports.getGoals = function(clan) { return [new GoalCheckPoint(clan, (9 + (Math.random() > 0.5 ? +5 : -5))*16, 14*16)]; }; /* Program Program3; begin move(11); if x>checkpointx then turn('west') else turn('east'); move(5); end. */
JavaScript
// 1 - wall // 2 - steel wall // 3 - trees module.exports.getMap = function() { return [ [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0] ]; }; module.exports.getGoals = function(clan) { return [new GoalCheckPoint(clan, 19*16, 14*16), new GoalCheckPoint(clan, 7*16, 10*16)]; };
JavaScript
// 1 - wall // 2 - steel wall // 3 - trees module.exports.getMap = function() { return [ [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0] ]; }; module.exports.getGoals = function(clan) { return [new GoalCheckPoint(clan, 19*16, 14*16)]; };
JavaScript
// 1 - wall // 2 - steel wall // 3 - trees // 4 - water module.exports.getMap = function() { return [ [0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,3,3,0,0,0,0], [0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,2,2,3,3,0,0,0,0], [1,1,0,0,0,0,0,0,0,0,0,0,0,0,3,3,0,2,2,2,2,0,0,0,1,1], [1,1,0,0,0,0,0,0,0,0,0,0,2,2,3,3,0,2,2,2,2,0,0,0,1,1], [0,0,0,0,0,0,0,0,3,3,0,2,2,2,2,0,0,0,2,2,3,3,0,0,0,0], [0,0,0,0,0,0,2,2,3,3,0,2,2,2,2,0,0,0,0,0,3,3,0,0,0,0], [0,0,0,0,0,2,2,2,2,0,0,0,2,2,3,3,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,2,2,2,2,0,0,0,0,0,3,3,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,2,2,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,3,3,0,0,3,3,0,0,3,3,0,0,3,3,0,0,0,0,0,0], [0,0,0,0,0,0,3,3,2,2,3,3,0,0,3,3,2,2,3,3,0,0,0,0,0,0], [2,2,1,1,0,0,0,2,2,2,2,0,0,0,0,2,2,2,2,0,0,0,1,1,2,2], [2,2,1,1,0,0,0,2,2,2,2,0,0,0,0,2,2,2,2,0,0,0,1,1,2,2], [0,0,0,0,0,0,3,3,2,2,3,3,0,0,3,3,2,2,3,3,0,0,0,0,0,0], [0,0,0,0,0,0,3,3,0,0,3,3,0,0,3,3,0,0,3,3,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0], [1,1,0,0,0,0,0,2,2,2,2,0,0,0,0,2,2,2,2,0,0,0,0,0,1,1], [1,1,0,0,0,0,0,2,2,2,2,0,0,0,0,2,2,2,2,0,0,0,0,0,1,1], [1,1,0,0,0,0,3,3,2,2,3,3,0,0,3,3,2,2,3,3,0,0,0,0,1,1], [1,1,0,0,0,0,3,3,0,0,3,3,0,0,3,3,0,0,3,3,0,0,0,0,1,1], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,1,1,0,0,0,0,0,1,1,1,1,0,0,0,0,0,1,1,0,0,0,0], [0,0,0,0,1,1,1,1,0,0,0,1,0,0,1,0,0,0,1,1,1,1,0,0,0,0], [0,0,0,0,1,1,1,1,0,0,0,1,0,0,1,0,0,0,1,1,1,1,0,0,0,0] ]; }; module.exports.getEnemies = function() { return [3,3,1,1,2,2,2,2,4,4,4,4,1,1,2,2,4,4,2,2]; //todo };
JavaScript
// 1 - wall // 2 - steel wall // 3 - trees // 4 - water module.exports.getMap = function() { return [ [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,2,2,3,3,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,2,2,3,3,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,3,3,0,0,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,3,3,0,0,3,3,2,2,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,3,3,0,0,0,0,0,0,0,0,3,3,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,3,3,0,0,0,0,0,0,0,0,3,3,1,1,0,0,0,0,0,0,0,0,0,0], [0,0,3,3,3,3,0,0,0,0,3,3,0,0,3,3,0,0,0,0,0,0,0,0,0,0], [0,0,3,3,3,3,0,0,0,0,3,3,0,0,3,3,2,2,0,0,0,0,0,0,0,0], [0,0,3,3,0,0,3,3,0,0,3,3,0,0,0,0,3,3,0,0,0,0,0,0,0,0], [0,0,3,3,0,0,3,3,0,0,3,3,0,0,0,0,3,3,1,1,0,0,0,0,0,0], [0,0,3,3,0,0,0,0,3,3,0,0,0,0,0,0,3,3,3,3,0,0,0,0,0,0], [0,0,3,3,0,0,0,0,3,3,0,0,0,0,0,0,3,3,3,3,2,2,0,0,0,0], [0,0,0,0,3,3,0,0,0,0,0,0,0,0,3,3,3,3,3,3,3,3,0,0,0,0], [0,0,0,0,3,3,0,0,0,0,0,0,0,0,3,3,3,3,3,3,3,3,1,1,0,0], [0,0,0,0,0,0,3,3,0,0,0,0,3,3,0,0,3,3,3,3,3,3,3,3,0,0], [0,0,0,0,0,0,3,3,0,0,0,0,3,3,0,0,3,3,3,3,3,3,3,3,0,0], [1,1,0,0,0,0,0,0,0,0,0,0,3,3,0,0,0,0,3,3,3,3,3,3,2,2], [1,1,0,0,0,0,0,0,0,0,0,0,3,3,0,0,0,0,3,3,3,3,3,3,2,2], [1,1,1,1,0,0,0,0,0,0,0,0,0,0,3,3,0,0,3,3,3,3,3,3,3,3], [1,1,1,1,0,0,0,0,0,0,0,0,0,0,3,3,0,0,3,3,3,3,3,3,3,3], [2,2,1,1,1,1,0,0,0,0,0,0,0,0,0,0,3,3,0,0,3,3,3,3,3,3], [2,2,1,1,1,1,0,0,0,0,0,1,1,1,1,0,3,3,0,0,3,3,3,3,3,3], [2,2,2,2,1,1,1,1,0,0,0,1,0,0,1,0,3,3,0,0,0,0,3,3,3,3], [2,2,2,2,1,1,1,1,0,0,0,1,0,0,1,0,3,3,0,0,0,0,3,3,3,3] ]; }; module.exports.getEnemies = function() { return [3,3,1,1,2,2,2,2,4,4,4,4,1,1,2,2,4,4,2,2]; //todo };
JavaScript
// 1 - wall // 2 - steel wall // 3 - trees // 4 - water // 5 - ice module.exports.getMap = function() { return [ [0,0,0,0,2,2,0,0,1,1,2,2,0,0,0,0,0,0,0,0,0,1,0,0,0,0], [0,0,0,0,2,2,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0], [0,0,0,0,1,1,0,0,1,1,3,3,0,0,1,1,1,1,1,1,1,1,0,0,0,0], [0,0,0,0,1,1,0,0,1,1,3,3,0,0,0,0,1,1,1,1,1,1,0,0,0,0], [0,0,3,3,3,3,0,0,1,1,3,3,0,1,1,0,0,0,0,0,0,0,2,2,2,2], [0,0,3,3,3,3,0,0,1,1,3,3,0,1,1,0,0,0,0,0,0,0,2,2,2,2], [3,3,3,3,3,3,3,3,3,3,3,3,1,1,1,1,1,1,0,0,0,1,1,1,0,0], [3,3,3,3,3,3,3,3,3,3,3,3,1,1,1,1,1,1,0,0,0,1,1,1,0,0], [0,0,0,0,3,3,3,3,0,0,0,0,2,2,1,1,0,0,0,1,1,1,1,1,0,1], [0,0,0,0,3,3,3,3,1,1,1,1,0,0,1,1,0,0,0,1,1,1,0,0,0,1], [1,1,2,2,0,0,0,0,1,1,1,1,0,0,0,0,0,0,1,1,1,1,0,0,0,1], [1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,1], [0,1,0,0,0,0,1,1,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5], [0,1,0,0,1,1,1,1,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5], [0,1,0,0,1,1,0,0,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5], [0,1,0,0,0,0,0,0,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5], [0,0,0,0,2,2,0,0,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5], [0,0,0,0,2,2,0,0,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5], [1,1,0,0,1,1,0,0,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5], [1,1,0,0,1,1,0,0,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5], [0,1,0,0,1,1,0,0,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5], [0,1,0,0,1,1,0,0,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5], [0,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,5,5,5,5,5,5,5,5,5,5], [0,1,0,0,1,1,0,0,0,0,0,1,1,1,1,0,5,5,5,5,5,5,5,5,5,5], [0,0,0,0,1,1,0,0,0,0,0,1,0,0,1,0,0,0,5,5,5,5,5,5,5,5], [0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,5,5,5,5,5,5,5,5] ]; }; module.exports.getEnemies = function() { return [3,3,1,1,2,2,2,2,4,4,4,4,1,1,2,2,4,4,2,2]; //todo };
JavaScript
// 1 - wall // 2 - steel wall // 3 - trees // 4 - water // 5 - ice module.exports.getMap = function() { return [ [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0], [3,3,0,0,0,0,3,3,1,1,3,3,1,1,3,3,0,0,0,0,3,3,0,0,0,0], [3,3,0,0,0,0,3,3,1,1,3,3,1,1,3,3,0,0,0,0,3,3,0,0,0,0], [1,1,3,3,3,3,1,1,1,1,1,1,1,1,1,1,3,3,3,3,1,1,3,3,0,0], [1,1,3,3,3,3,1,1,1,1,1,1,1,1,1,1,3,3,3,3,1,1,3,3,0,0], [1,1,1,1,1,1,1,1,2,2,1,1,2,2,1,1,1,1,1,1,1,1,3,3,0,0], [1,1,1,1,1,1,1,1,2,2,1,1,2,2,1,1,1,1,1,1,1,1,3,3,0,0], [4,4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,4,4,4,4,4,4,3,3,0,0], [4,4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,4,4,4,4,4,4,3,3,0,0], [4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,4,4,4,4,3,3], [4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,4,4,4,4,3,3], [1,1,1,1,1,1,4,4,1,1,1,1,1,1,4,4,1,1,1,1,1,1,3,3,3,3], [1,1,1,1,1,1,4,4,1,1,1,1,1,1,4,4,1,1,1,1,1,1,3,3,3,3], [1,1,1,1,4,4,4,4,4,4,1,1,4,4,4,4,4,4,1,1,1,1,4,4,4,4], [1,1,1,1,4,4,4,4,4,4,1,1,4,4,4,4,4,4,1,1,1,1,4,4,4,4], [3,3,4,4,4,4,3,3,3,3,3,3,3,3,3,3,4,4,4,4,3,3,4,4,3,3], [3,3,4,4,4,4,3,3,3,3,3,3,3,3,3,3,4,4,4,4,3,3,4,4,3,3], [0,0,3,3,3,3,0,0,0,0,0,0,0,0,0,0,3,3,3,3,0,0,3,3,0,0], [0,0,3,3,3,3,0,0,0,0,0,0,0,0,0,0,3,3,3,3,0,0,3,3,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0] ]; }; module.exports.getEnemies = function() { return [3,3,1,1,2,2,2,2,4,4,4,4,1,1,2,2,4,4,2,2]; //todo };
JavaScript
// 1 - wall // 2 - steel wall // 3 - trees // 4 - water // 5 - ice module.exports.getMap = function() { return [ [0,0,0,0,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,4,4,3,3,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0], [2,2,0,0,0,0,4,4,3,3,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0], [3,3,0,0,0,0,0,0,0,0,0,0,2,0,0,0,1,0,0,0,4,4,4,4,0,0], [3,3,2,2,0,0,0,0,0,0,0,0,2,0,0,0,1,0,0,0,4,4,4,4,0,0], [3,3,3,3,0,0,2,2,0,0,0,1,0,0,0,0,2,0,3,3,4,4,0,0,0,0], [3,3,3,3,0,0,0,0,1,1,0,1,0,0,0,0,2,0,3,3,4,4,0,0,0,0], [3,3,3,3,3,3,0,0,0,0,2,2,0,0,0,1,0,0,0,0,0,0,0,0,0,0], [3,3,3,3,3,3,0,0,0,0,2,2,1,1,0,1,0,0,0,0,0,0,0,0,2,2], [3,3,3,3,2,2,0,0,0,0,0,1,0,0,2,2,0,0,0,0,0,0,0,0,3,3], [3,3,3,3,0,0,2,2,0,0,0,1,0,0,2,2,1,1,0,0,0,0,2,2,3,3], [3,3,2,2,0,0,0,0,1,1,2,2,0,0,0,1,0,0,2,2,0,0,3,3,3,3], [3,3,0,0,0,0,0,0,0,0,2,2,0,0,0,1,0,0,0,0,0,0,3,3,3,3], [0,0,0,0,0,0,0,0,0,0,1,0,1,1,2,2,0,0,0,0,3,3,3,3,3,3], [0,0,0,0,0,0,0,0,0,0,1,0,0,0,2,2,0,0,0,0,3,3,3,3,3,3], [0,0,0,0,4,4,3,3,0,2,0,0,0,0,1,0,1,1,0,0,2,2,3,3,3,3], [0,0,0,0,4,4,3,3,0,2,0,0,0,0,1,0,0,0,2,2,0,0,3,3,3,3], [0,0,4,4,4,4,0,0,0,1,0,0,0,2,0,0,0,0,0,0,0,0,0,0,3,3], [0,0,4,4,4,4,0,0,0,1,0,0,0,2,0,0,0,0,0,0,0,0,0,0,3,3], [0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,3,3,4,4,0,0,0,0,2,2], [0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,3,3,4,4,0,0,0,0,0,0], [2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,4,4,0,0,0,0], [2,2,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,4,4,4,4,0,0,0,0], [2,2,2,2,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,2,2], [2,2,2,2,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,2,2] ]; }; module.exports.getEnemies = function() { return [3,3,1,1,2,2,2,2,4,4,4,4,1,1,2,2,4,4,2,2]; //todo };
JavaScript
// 1 - wall // 2 - steel wall // 3 - trees // 4 - water module.exports.getMap = function() { return [ [0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0], [0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0], [0,0,1,1,1,1,1,1,1,1,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,1,1,1,1], [0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1], [0,0,4,4,4,4,4,4,4,4,4,4,0,0,1,1,1,0,0,0,0,0,1,1,2,2], [0,0,4,4,4,4,4,4,4,4,4,4,0,0,1,1,1,0,0,0,0,0,1,1,0,0], [0,0,0,0,0,0,0,0,0,0,4,4,0,0,1,1,0,0,2,2,2,0,1,1,0,0], [0,0,0,0,2,2,2,2,2,2,4,4,0,0,1,1,0,0,2,2,2,0,1,1,0,0], [1,1,0,0,1,1,1,1,1,1,4,4,4,4,4,4,0,0,4,4,1,1,1,1,0,0], [1,1,0,0,1,1,1,1,1,1,4,4,4,4,4,4,0,0,4,4,1,1,1,1,0,0], [0,0,0,0,0,0,0,0,2,2,4,4,0,0,0,0,0,0,4,4,2,2,0,0,0,0], [0,0,0,0,0,0,0,0,2,2,4,4,0,0,0,0,0,0,4,4,0,0,0,0,0,0], [4,4,4,4,4,4,0,0,4,4,4,4,1,1,1,1,0,0,4,4,0,0,0,0,0,0], [4,4,4,4,4,4,0,0,4,4,4,4,1,1,1,1,0,0,4,4,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,1,1,2,2,2,2,0,0,4,4,4,4,4,4,0,0], [0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,4,4,4,4,4,4,0,0], [1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,1,1,0,0,2,2,2,2,0,0,0,0,0,0,1,1,1,1,0,0,0,1], [0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,1], [1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,1], [1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,1,1,0,0,0,0,1,1], [0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0] ]; }; module.exports.getEnemies = function() { return [3,3,1,1,2,2,2,2,4,4,4,4,1,1,2,2,4,4,2,2]; //todo };
JavaScript
// 1 - wall // 2 - steel wall // 3 - trees // 4 - water module.exports.getMap = function() { return [ [0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,2,2,2,2,2,2,0,0,0,0], [2,2,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0], [2,2,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0], [2,2,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0], [1,1,0,0,1,1,1,1,1,1,0,0,1,1,1,1,0,0,4,4,4,4,0,0,4,4], [1,1,0,0,1,1,1,1,1,1,0,0,1,1,1,1,0,0,4,4,4,4,0,0,4,4], [1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,4,4,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,4,4,4,4,0,0,4,4,4,4,4,4,0,0,1,1,1,1], [0,0,0,0,1,1,0,0,4,4,4,4,0,0,4,4,4,4,4,4,0,0,1,1,1,1], [1,1,1,1,0,0,0,0,4,4,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0], [1,1,1,1,0,0,0,0,4,4,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,4,4,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0], [0,0,0,0,0,0,0,0,4,4,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0], [4,4,4,4,4,4,0,0,4,4,0,0,2,2,0,0,1,1,0,0,0,2,0,0,0,0], [4,4,4,4,4,4,0,0,4,4,0,0,2,2,0,0,1,1,0,0,0,2,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,1,1,1,1], [0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,2,1,1,1,1], [0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0], [1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0], [1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,1,1,0,0,0,0], [1,1,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0] ]; }; module.exports.getEnemies = function() { return [3,3,3,3,3,4,4,1,1,1,1,1,1,1,1,2,2,2,2,2]; };
JavaScript
// 1 - wall // 2 - steel wall // 3 - trees // 4 - water module.exports.getMap = function() { return [ [0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,3,3,3,3,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,3,3,3,3,0,0,0,0,0,0], [0,0,1,0,0,2,0,0,1,0,0,0,0,0,0,0,0,1,3,3,1,0,0,1,3,3], [0,0,1,0,0,2,0,0,1,0,0,0,0,0,0,0,0,1,3,3,1,0,0,1,3,3], [0,0,1,0,0,2,0,0,1,0,0,0,1,1,0,0,0,1,3,3,1,0,0,1,3,3], [0,0,1,0,0,2,0,0,1,0,0,0,1,1,0,0,0,1,3,3,1,0,0,1,3,3], [0,0,1,1,0,0,0,0,1,1,0,0,2,2,0,0,1,1,3,3,0,0,1,1,3,3], [0,0,1,1,0,0,0,0,1,1,0,0,2,2,0,0,1,1,3,3,0,0,1,1,3,3], [0,0,0,0,0,0,0,1,2,2,0,0,1,1,0,0,1,1,2,0,0,0,3,3,3,3], [0,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,0,0,2,0,0,0,3,3,3,3], [1,1,1,1,1,0,0,0,0,0,3,3,1,1,3,3,0,0,0,0,0,1,1,1,1,1], [1,1,1,1,1,0,0,0,0,0,3,3,1,1,3,3,0,0,0,0,0,1,1,1,1,1], [0,0,0,0,0,0,0,0,0,1,3,3,3,3,3,3,1,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,1,3,3,3,3,3,3,1,0,0,0,0,0,0,0,0,0], [2,2,1,1,1,1,0,0,1,1,3,3,3,3,3,3,1,1,0,1,1,1,1,1,2,2], [2,2,1,1,1,1,0,0,0,0,0,3,3,3,3,3,0,0,0,1,1,1,1,1,2,2], [2,2,2,2,2,2,0,0,0,0,0,0,3,3,0,0,0,0,0,0,2,2,2,2,2,2], [0,0,0,0,0,0,0,0,1,1,0,0,3,3,0,0,1,1,0,0,0,0,0,0,0,0], [0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0], [0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0], [0,0,1,1,1,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,1,1,1,3,3], [0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,3,3], [0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,3,3], [0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,3,3,3,3,3,3], [0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,3,3,3,3], [0,0,0,0,1,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,1,3,3,3,3] ]; }; module.exports.getEnemies = function() { return [3,3,3,3,3,3,3,2,2,1,1,1,1,1,1,1,1,1,4,4]; };
JavaScript