Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(function () {
- window.setInterval(function () {
- if ($("#fleets-info-container").css('display') === 'none') return;
- var current_time = Math.floor(Date.now() / 1000) - 2;
- // time count
- $(".fleets").each(function () {
- var e = $(this).data("fleet-time") - (serverTime.getTime() - startTime) / 1000;
- if (e <= 0) {
- $(this).text("-")
- } else {
- $(this).text(GetRestTimeFormat(e))
- }
- });
- $(".fleet-time-return-remaning").each(function () {
- var e = $(this).data("return-remaning") - current_time;
- if (e <= 0) {
- $(this).text("-").css({'text-align': 'center'})
- }
- else {
- $(this).text(GetRestTimeFormat(e))
- }
- //change
- if ($(this).text() == "-" && $(this).data("lock") == "" && getCookie("connectionError") == undefined) {
- var fleetId = String($(this).data("fleet-id"));
- //console.log('fleetCookie полет назад ='+ getCookie(fleetId));
- //var fleetId = String($(this).data("fleet-id"));
- setCookie("connectionError", 'false', 15);
- $.ajax({
- method: "POST",
- url: "game.php?page=fleetTable&mode=show",
- success: function (data) {
- var html = $(data).find("#content").children().clone()
- $("#content").empty() // clean container
- $("#content").append(html) // output new html to container
- }
- })
- }
- });
- $(".fleet-time-arrive-remaining").each(function ()
- {
- var e3 = $(this).data("arrive-remaining") - current_time;
- var e33 = $(this).data("fleet-end-stay") - current_time;
- if (e3 <= 0) {
- $(this).text("").css({'text-align': 'center'});
- if (e33 > 0 || $(this).data('state') == 1 || $(this).data("lock") != "" || getCookie("connectionError") != undefined) { // trim cause return lots of spaces
- } else {
- if (!$('.fleets-info-container').is(":visible")) return
- setCookie("connectionError", 'false', 15);
- $.ajax({
- method: "POST",
- url: "game.php?page=fleetTable&mode=show",
- success: function (data) {
- var html = $(data).find("#content").children().clone()
- $("#content").empty() // clean container
- $("#content").append(html) // output new html to container
- }
- })
- }
- }
- else {
- $(this).text(GetRestTimeFormat(e3))
- }
- });
- $(".fleet-stay-container").each(function () {
- var e = $(this).children('.fleet-stay').data("fleet-stay") - (serverTime.getTime() - startTime) / 1000;
- if (e <= 0) {
- $(this).children('.fleet-stay').text("");
- $(this).children('.fleet-stay-remaning-time-title').text("");
- }
- else {
- $(this).children('.fleet-stay').text(GetRestTimeFormat(e))
- }
- });
- $(".icon-fleet-movement").each(function () {
- // var fleet_stay = $(this).data('fleet-stay') - (serverTime.getTime() - startTime) / 1000; // time left to stay; 10- server writing delay
- var fleet_stay = $(this).data('fleet-end-stay') - current_time;
- var flight_width = $('#fleet-movement-bg').width() - 16 - 35 - 35; // 16-ico size 35 - planetssize
- if ($(this).data('state') != 1)
- {
- if (current_time > $(this).data('arrive')) {//return
- if (fleet_stay <= '0') {
- // var full_time = $(this).data('return') - $(this).data('arrive');
- // var full_time = $(this).data('return') - $(this).data('arrive') - $(this).data('abs_stay_fleet');
- var full_time = $(this).data('return') - $(this).data('fleet-end-stay');
- var to_flew_time = $(this).data('return') - current_time;
- var to_flew_width = flight_width * to_flew_time / full_time;
- if (to_flew_width < 0) {
- to_flew_width = 0;
- }
- $(this).css({'transform': 'rotate(180deg)'});
- $(this).css({marginLeft: to_flew_width + 'px'});
- }
- else {
- if($(this).data("fleet-owner-status") == 0) {
- $(this).css({marginLeft: flight_width + 'px'});
- } else {
- $(this).css({marginRight: flight_width + 'px'});
- }
- }
- }
- else {
- if($(this).data("fleet-owner-status") == 0) {
- var full_time = $(this).data('arrive') - $(this).data('start-time');
- var flew_time = current_time - $(this).data('start-time');
- var flew_width = flight_width * flew_time / full_time;
- $(this).css({marginLeft: flew_width + 'px'});
- } else {
- var full_time = $(this).data('arrive') - $(this).data('start-time');
- var flew_time = current_time - $(this).data('start-time');
- var flew_width = flight_width * flew_time / full_time;
- $(this).css({marginRight: flew_width + 'px'});
- }
- }
- }
- else if ($(this).data('state') == '1')
- {
- if (fleet_stay <= '0') {
- var full_time = $(this).data('return') - $(this).data('fleet-end-stay');
- var to_flew_time = $(this).data('return') - current_time;
- var to_flew_width = flight_width * to_flew_time / full_time;
- if (to_flew_width < 0) {
- to_flew_width = 0;
- }
- $(this).css({'transform': 'rotate(180deg)'});
- $(this).css({marginLeft: to_flew_width + 'px'});
- }
- else {
- $(this).css({marginLeft: flight_width + 'px'});
- }
- }
- });
- window.setTimeout('FleetTime()', 1000);
- }, 1000);
- function fleets_info_show_hide() {
- if ($("#fleets-info-container").css('display') === 'none') {
- $("#fleets-info-container").show();
- $("#fleets-info-show-hide-1").css({background: 'url(/styles/images/fleet_arrow_top.png) no-repeat center center'});
- $("#fleets-info-show-hide-3").css({background: 'url(/styles/images/fleet_arrow_top.png) no-repeat center center'});
- $.ajax({
- method: "POST",
- url: "game.php?page=fleetTable&mode=setting",
- data: {setting: "1"}//open
- });
- }
- else {
- $("#fleets-info-container").hide();
- $("#fleets-info-show-hide-1").css({background: 'url(/styles/images/planet_selector_arrow.png) no-repeat'});
- $("#fleets-info-show-hide-3").css({background: 'url(/styles/images/planet_selector_arrow.png) no-repeat'});
- $.ajax({
- method: "POST",
- url: "game.php?page=fleetTable&mode=setting",
- data: {setting: "2"}//closed
- });
- }
- };
- $("#fleets-info-show-hide").on("click", fleets_info_show_hide);
- $("#fleets-info-show-hide-3").on("click", fleets_info_show_hide);
- $("#fleets-info-show-hide-1").on("click", fleets_info_show_hide);
- $("#fleets-info-show-hide-2").on("click", fleets_info_show_hide);
- })
- function setCookie(name, value, lifeTime) {
- var date = new Date();
- date.setTime(date.getTime()+(lifeTime*1000));
- var expires = "; expires="+date.toUTCString();
- document.cookie = name+"="+value+expires+"; path=/";
- }
- function getCookie(name) {
- var matches = document.cookie.match(new RegExp(
- "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
- ));
- return matches ? decodeURIComponent(matches[1]) : undefined;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement