Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var lastEdit = 1461470645878;
- var respawnLoop = null, ejectorLoop = null, randomMoveLoop = null;
- var overlayClosed = false, spectatorMode = false;
- var profileSettings = {};
- var holdingKey = {};
- var canvas = document.getElementById('canvas');
- $(document).ready(function() {
- window.setAutoSpawn = function(e) {
- if(e) { if(!respawnLoop) respawnLoop = setInterval(startGame, 1000); }
- else { clearInterval(respawnLoop); respawnLoop = null; }
- };
- window.joinNewRoom = function() {
- var s = $('#gamemode').val();
- if(s == ':party') {
- $('#helloContainer').attr('data-party-state', '3');
- createParty();
- }
- else {
- setGameMode(':party');
- setGameMode(s);
- }
- };
- window.setSpectatorMode = function(e) { spectatorMode = e; };
- window.setRandomMove = function(e) {
- if(e) { if(!randomMoveLoop) randomMoveLoop = setInterval(randomMove, 5000); }
- else { clearInterval(randomMoveLoop); randomMoveLoop = null; }
- };
- window.toggleScriptInfo = function() { $('#infoPanel').fadeToggle(); };
- window.toggleScriptInfoChangelog = function() { $('#infoPanel-content a').next().slideToggle(); };
- $(document).on('keydown', function(evt) {
- var key = evt.which || evt.keyCode;
- var exKey = evt.ctrlKey || evt.shiftKey || evt.altKey;
- //console.log(key + ' ' + exKey + ' (' + evt.ctrlKey + ' ' + evt.shiftKey + ' ' + evt.altKey + ')');
- if($('#overlays').is(':hidden') && !exKey) {
- if(key == 27) { // KEY_ESC
- overlayClosed = false;
- setTimeout(function() { $('button[data-itr="spectate"]').removeAttr('disabled'); }, 100);
- }
- else if(key == 83) { // KEY_S
- if(!ejectorLoop) {
- ejectorLoop = setInterval(function() { sendEject(); }, 10);
- }
- }
- if(!holdingKey[key]) {
- if(key == 84) { // KEY_T
- for(var n = 1; n <= 4; n++) {
- setTimeout(function() { sendMitosis(); }, 60 * n);
- }
- }
- else if(key == 83) { // KEY_S
- var newPos = {clientX: innerWidth / 2, clientY: innerHeight / 2};
- canvas.onmousedown(newPos);
- }
- }
- holdingKey[key] = true;
- }
- });
- $(document).on('keyup', function(evt) {
- var key = evt.which || evt.keyCode
- holdingKey[key] = false;
- if(key == 83) { // KEY_S
- clearInterval(ejectorLoop);
- ejectorLoop = null;
- }
- });
- editPanel();
- hookOverlay();
- });
- function editPanel() {
- var btnGroup = $('#agario-main-buttons div').eq(0).children();
- btnGroup.eq(1).css('width', '230px');
- btnGroup.eq(2).css('width', '112px');
- btnGroup.eq(3).css('width', '112px').after('<button style="height: 35px; display: block; float: right;" class="btn btn-success btn-refresh" onclick="joinNewRoom(); return false;"><i class="glyphicon glyphicon-refresh"></i></button>');
- $('#helloContainer').css('height', '');
- $('#adbg').parent().hide().css('visibility', 'hidden');
- $('#agario-web-incentive, .agario-promo').remove();
- $('#connecting').css({'top': '13px', 'right': '185px', 'bottom': '', 'left': '', 'font-size': '13px'});
- $('#connecting h2').css({'display': 'inline-block'}).after('<span id="connectingToInfo" style="position: absolute; top: 5px; right: 15px;"></span>');
- $('#nick').attr('name', 'nick');
- $('#quality').css({'margin': '6px 0px'});
- setTimeout(function() { $('#___ytsubscribe_0').css({'width': '112px'})}, 12000);
- $('button[data-itr="logout"]').replaceWith('<button class="btn btn-danger btn-logout" data-itr="logout">Logout</button>');
- $('#options').append('<label style="margin-top: 7px; padding-top: 7px; border-top: 1px dashed #888; width: 188px;"><input type="checkbox" onchange="setAcid($(this).is(\':checked\'));"><span data-itr="option_acid_mode"> Modo Acido </span></label><label style="width: 188px;"><input type="checkbox" onchange="setAutoSpawn($(this).is(\':checked\'));"><span data-itr="option_auto_spawn"> Respawn automatico </span></label><label style="width: 188px;"><input type="checkbox" onchange="setSpectatorMode($(this).is(\':checked\'));"><span data-itr="option_spectator_mode"> Espectador al entrar</span></label><label style="width: 188px;"><input type="checkbox" onchange="setRandomMove($(this).is(\':checked\'));"><span data-itr="option_random_move"> Movimiento random </span></label>');
- $('#instructions center').after('<hr><div id="shortcuts" style="font-size: 85%;"><strong style="display: inline-block; width: 320px; text-align: center; padding-bottom: 10px;">Instrucciones:</strong><br><span style="display: block; width: 160px; float: left;">S: Dar masa sin parar.</span><span style="display: block; width: 160px; float: left;"></span><span style="display: block; width: 160px; float: left;"></span><span style="display: block; width: 160px; float: left;"></span><span style="display: block; width: 160px; float: left;">T: Dividirme 16 veces.</span><span style="display: block; width: 160px; float: left;"></span><span style="display: block; width: 160px; float: left;">D: Congelar mi celula.</span><span style="display: block; width: 160px; float: left;"></span><span style="display: block; width: 160px; float: left;"></span><span style="display: block; width: 160px; float: left;"></span></div>');
- $('#instructions center span[class="text-muted"] b').css({'background-color': '#333', 'color': '#EEE', 'padding': '1px 5px', 'border-radius': '3px'});
- $('#instructions').next().remove();
- $('#nick').before('<div id="profiles" style="margin-bottom: 6px;"><span>Perfiles: </span></div>');
- for(i=0; i<=10; i++) $('#profiles').append('<a onclick="setProfile(' + i + '); return false;" href="#" style="padding: 1px 5px; margin: 0px 1px; background-color: #222; color: #EEE; border-radius: 3px;">' + (i ? i : 'Default') + '</a>');
- $('#stats').css('height', '375px');
- $('#stats hr').remove();
- $('#socialStats').css('bottom', '65px');
- $('#statsContinue').css('bottom', '25px');
- $('#statsGraph').css('bottom', '120px').attr('height', '200px');
- $('#s300x250').css('z-index', '-10');
- $('footer.tosBox.left').removeClass('left').addClass('gamemode').css({'bottom': '30px', 'right': '0px', 'font-size': '12px', 'background-color': '#3071A9', 'border-radius': '15px 0px 0px 15px', 'padding-left': '18px'});
- $('footer.tosBox.right').removeClass('right').addClass('tos').css({'bottom': '0px', 'right': '0px', 'font-size': '12px', 'background-color': '#3071A9', 'border-radius': '15px 0px 0px 15px', 'padding-left': '18px'});
- $('footer.tosBox.update').css({'bottom': '0px', 'right': '280px', 'font-size': '12px', 'background-color': '#398439', 'border-radius': '5px 5px 0px 0px'});
- $('footer.tosBox.donate').css({'bottom': '-2px', 'right': '380px', 'font-size': '12px', 'background-color': 'transparent', 'padding': '0px'});
- $('footer.tosBox a').css('color', '#FFFFFF');
- }
- window.setProfile = function(x) {
- if(x == null) x = 0;
- $('#profiles a').eq(localStorage.getItem('activeprofile')).css({'background-color': '#222'});
- $('#profiles a').eq(x).css({'background-color': '#D00'});
- localStorage.setItem('activeprofile', x);
- profileSettings = JSON.parse(localStorage.getItem('profile' + x));
- var checkbox = $('#options input[type="checkbox"]');
- if(profileSettings == null) {
- profileSettings = {};
- if(localStorage.getItem('nick') != null && x == 0) $('#nick').val(localStorage.getItem('nick')).change();
- else $('#nick').val('ௌௌௌௌௌௌௌௌௌௌௌௌௌௌௌ').change();
- $('#gamemode').val('').change();
- }
- else {
- $('#nick, #gamemode, #region, #quality').each(function() { if(profileSettings[$(this).attr('id')] != null) { $(this).val(profileSettings[$(this).attr('id')]).change(); } });
- checkbox.each(function() {
- if($(this).prop('checked') == true && profileSettings[$(this).next().attr('data-itr')] != true) $(this).click();
- else if($(this).prop('checked') == false && profileSettings[$(this).next().attr('data-itr')] == true) $(this).click();
- });
- }
- }
- function startGame() { if(overlayClosed) setNick($('#nick').val()); }
- function randomMove() { var pos = {clientX: getRandomInt(0, innerWidth), clientY: getRandomInt(0, innerHeight)}; canvas.onmousedown(pos); }
- function hookOverlay() {
- $('button[data-itr="play"]').click(function() { overlayClosed = true; });
- $('button[data-itr="play_as_guest"]').click(function() { overlayClosed = true; });
- $('button[data-itr="spectate"]').click(function() { overlayClosed = false; });
- $('button[data-itr="logout"]').click(function() { var lg = confirm('Logout?'); if(lg) logout(); });
- $.each(['show', 'hide'], function (i, ev) { var el = $.fn[ev]; $.fn[ev] = function () { this.trigger(ev); return el.apply(this, arguments); }; });
- $('#connecting').on('show', function() { connectingInfo(); });
- $('#connecting').on('hide', function() { if(spectatorMode) $('button[data-itr="spectate"]').click(); leaderboardText(); });
- $('#openfl-content').on('hide', function() { setTimeout(function() { $('#openfl-content').css({'opacity' : '1'}); }, 10); });
- var checkbox = $('#options input[type="checkbox"]');
- checkbox.change(function() {
- profileSettings[$(this).next().attr('data-itr')] = $(this).prop('checked');
- localStorage.setItem('profile' + localStorage.getItem('activeprofile'), JSON.stringify(profileSettings));
- });
- $('#nick, #gamemode, #region, #quality').change(function() {
- profileSettings[$(this).attr('id')] = $(this).val();
- localStorage.setItem('profile' + localStorage.getItem('activeprofile'), JSON.stringify(profileSettings));
- });
- setTimeout(function() { setProfile(localStorage.getItem('activeprofile')) }, 1000);
- }
- function saveProfiles() {
- var checkbox = $('#options input[type="checkbox"]');
- checkbox.each(function() { profileSettings[$(this).next().attr('data-itr')] = $(this).prop('checked'); });
- $('#nick, #gamemode, #region, #quality').each(function() { profileSettings[$(this).attr('id')] = $(this).val(); });
- localStorage.setItem('profile' + localStorage.getItem('activeprofile'), JSON.stringify(profileSettings))
- }
- function connectingInfo() { $('#connectingToInfo').text($('#region option:selected').text().split(' (')[0] + ' - ' + $('#gamemode option:selected').text()) }
- function leaderboardText() {
- var curMode = $('#gamemode option:selected').text();
- if(curMode.length > 8) curMode = curMode.slice(0, 7) + '...';
- i18n.leaderboard = '≡ ' + curMode;
- }
- function timeSince(date) {
- var seconds = Math.floor((new Date() - date) / 1000);
- var interval = Math.floor(seconds / 31536000);
- if(interval > 1) return interval + ' years'; interval = Math.floor(seconds / 2592000);
- if(interval > 1) return interval + ' months'; interval = Math.floor(seconds / 86400);
- if(interval > 1) return interval + ' days'; interval = Math.floor(seconds / 3600);
- if(interval > 1) return interval + ' hours'; interval = Math.floor(seconds / 60);
- if(interval > 1) return interval + ' minutes';
- return Math.floor(seconds) + ' seconds';
- }
- function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement