Remove duration times 0 variation

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Remove duration times 0 variation

      Hello
      I am using 2moons version 2.0 and I want to remove the zeros in the times, so I will show in the example if a production is 00h 00m 16s, I want to show it as 16s, I want to remove the "0"s there, whatever the values are.

    • Source Code

      1. function GetRestTimeFormat(Secs) {
      2. var s = Secs;
      3. var m = 0;
      4. var h = 0;
      5. if (s > 59) {
      6. m = Math.floor(s / 60);
      7. s = s - m * 60;
      8. }
      9. if (m > 59) {
      10. h = Math.floor(m / 60);
      11. m = m - h * 60;
      12. }
      13. return dezInt(h, 2) + ':' + dezInt(m, 2) + ":" + dezInt(s, 2);
      14. }
      Display All
      If this is the place you're talking about, these are there. :)
    • Zeus wrote:

      Source Code

      1. función GetRestTimeFormat(Secs) {
      2. var s = Secs;
      3. var m = 0;
      4. donde h = 0;
      5. si (s > 59) {
      6. m = Math.piso(s / 60);
      7. s = s - m * 60;
      8. }
      9. y (m > 59) {
      10. h = Matemáticas.piso(m / 60);
      11. metro = metro - h * 60;
      12. }
      13. return dezInt(h, 2) + ':' + dezInt(m, 2) + ":" + dezInt(s, 2);
      14. }
      Display All
      Si este es el lugar del que estás hablando, estos están allí. :)
      Si bro en esa funcion debes hacer algunos cambios ya que los dezInt() son los que te completan con esos 0 que quieres quitar
    • Seria algo como esto:

      JavaScript Source Code: base.js

      1. function GetRestTimeFormat(Secs) {
      2. var s = Secs;
      3. var m = 0;
      4. var h = 0;
      5. if (s > 59) {
      6. m = Math.floor(s / 60);
      7. s = s - m * 60;
      8. }
      9. if (m > 59) {
      10. h = Math.floor(m / 60);
      11. m = m - h * 60;
      12. }
      13. if (h > 0) {
      14. return h + ':' + m + ':' + s;
      15. } elseif (m > 0) {
      16. return m + ':' + s;
      17. } else {
      18. return s;
      19. }
      20. }
      Display All
    • Zeus wrote:

      gracias por tu ayuda compañero

      Integré el código, lo probé con cero escáner, sigue igual :(
      Revise que sea esa la función que controla ese conteo por que al menos en 2moons 2.0 es esa la que lo realiza

      O de lo contrario envie el archivo js que se ejecuta en la página que enviaste en la imagen del primer comentario
    • buildings in the image

      I know it has to get it from base.js too
      but if it's from buildlist.js, I'm putting the code

      Source Code: buildlist.js

      1. var resttime = 0;
      2. var time = 0;
      3. var endtime = 0;
      4. var interval = 0;
      5. var buildname = "";
      6. function Buildlist() {
      7. var rest = resttime - (serverTime.getTime() - startTime) / 1000;
      8. if (rest <= 0) {
      9. window.clearInterval(interval);
      10. $('#time').text(Ready);
      11. $('#command').remove();
      12. document.title = Ready + ' - ' + Gamename;
      13. window.setTimeout(function() {
      14. window.location.href = 'game.php?page=buildings';
      15. }, 1000);
      16. return;
      17. }
      18. document.title = GetRestTimeFormat(rest) + ' - ' + buildname + ' - ' + Gamename;
      19. $('#time').text(GetRestTimeFormat(rest));
      20. }
      21. $(document).ready(function() {
      22. time = $('#time').data('time');
      23. resttime = $('#progressbar').data('time');
      24. endtime = $('.timer:first').data('time');
      25. buildname = $('.buildlist > table > tbody > tr > td:first').text().replace(/[0-9]+\.:/, '').trim();
      26. interval = window.setInterval(Buildlist, 1000);
      27. window.setTimeout(function () {
      28. if(time <= 0) return;
      29. $('#progressbar').progressbar({
      30. value: Math.max(100 - (resttime / time) * 100, 0.01)
      31. });
      32. $('.ui-progressbar-value').addClass('ui-corner-right').animate({width: "100%"}, resttime * 1000, "linear");
      33. }, 5);
      34. Buildlist();
      35. });
      Display All
    • Zeus wrote:

      edificios en la imagen

      Sé que también tiene que obtenerlo de base.js
      pero si es de buildlist.js, pongo el codigo

      Source Code: buildlist.js

      1. var tiempo restante = 0;
      2. var hora = 0;
      3. var hora de finalización = 0;
      4. intervalo var = 0;
      5. var nombreconstrucción = "";
      6. función Lista de compilación () {
      7. var rest = restTime - (serverTime.getTime() - startTime) / 1000;
      8. si (resto <= 0) {
      9. ventana.clearInterval(intervalo);
      10. $('#tiempo').texto(Listo);
      11. $('#comando').remove();
      12. document.title = Listo + ' - ' + Nombre del juego;
      13. ventana.setTimeout(función() {
      14. ventana.ubicación.href = 'juego.php?page=edificios';
      15. }, 1000);
      16. devolver;
      17. }
      18. document.title = GetRestTimeFormat(rest) + ' - ' + buildname + ' - ' + Gamename;
      19. $('#hora').texto(GetRestTimeFormat(resto));
      20. }
      21. $(documento).listo(función() {
      22. tiempo = $('#tiempo').datos('tiempo');
      23. tiempo de descanso = $('#barradeprogreso').data('tiempo');
      24. hora de finalización = $('.temporizador:primero').data('hora');
      25. buildname = $('.buildlist > table > tbody > tr > td:first').text().replace(/[0-9]+\.:/, '').trim();
      26. intervalo = ventana.setInterval(Lista de compilación, 1000);
      27. ventana.setTimeout(función () {
      28. si (tiempo <= 0) volver;
      29. $('#barradeprogreso').barradeprogreso({
      30. valor: Math.max (100 - (tiempo de descanso / tiempo) * 100, 0.01)
      31. });
      32. $('.ui-progressbar-value').addClass('ui-corner-right').animate({width: "100%"}, resttime * 1000, "linear");
      33. }, 5);
      34. lista de compilación();
      35. });
      Display All
      Si bro pero la funcion GetRestTimeFormat() entonces no la esta tomando del base.js y la debe estar tomando de otro archivo js de lo contrario te funcionaría
    • Source Code: base.js

      1. function dezInt(num, size, prefix) {
      2. prefix = (prefix) ? prefix : "0";
      3. var minus = (num < 0) ? "-" : "",
      4. result = (prefix == "0") ? minus : "";
      5. num = Math.abs(parseInt(num, 10));
      6. size -= ("" + num).length;
      7. for (var i = 1; i <= size; i++) {
      8. result += "" + prefix;
      9. }
      10. result += ((prefix != "0") ? minus : "") + num;
      11. return result;
      12. }
      13. function getFormatedTime(time) {
      14. hours = Math.floor(time / 3600);
      15. timeleft = time % 3600;
      16. minutes = Math.floor(timeleft / 60);
      17. timeleft = timeleft % 60;
      18. seconds = timeleft;
      19. return dezInt(hours, 2) + ":" + dezInt(minutes, 2) + ":" + dezInt(seconds, 2);
      20. }
      Display All
      The base.js file has the following code in it


      these other codes

      Source Code: base.js

      1. function dezInt(num, size, prefix) {
      2. prefix = (prefix) ? prefix : "0";
      3. var minus = (num < 0) ? "-" : "",
      4. result = (prefix == "0") ? minus : "";
      5. num = Math.abs(parseInt(num, 10));
      6. size -= ("" + num).length;
      7. for (var i = 1; i <= size; i++) {
      8. result += "" + prefix;
      9. }
      10. result += ((prefix != "0") ? minus : "") + num;
      11. return result;
      12. }
      13. function getFormatedTime(time) {
      14. hours = Math.floor(time / 3600);
      15. timeleft = time % 3600;
      16. minutes = Math.floor(timeleft / 60);
      17. timeleft = timeleft % 60;
      18. seconds = timeleft;
      19. return dezInt(hours, 2) + ":" + dezInt(minutes, 2) + ":" + dezInt(seconds, 2);
      20. }
      21. function GetRestTimeFormat(Secs) {
      22. var s = Secs;
      23. var m = 0;
      24. var h = 0;
      25. if (s > 59) {
      26. m = Math.floor(s / 60);
      27. s = s - m * 60;
      28. }
      29. if (m > 59) {
      30. h = Math.floor(m / 60);
      31. m = m - h * 60;
      32. }
      33. if (h > 0) {
      34. return h + ':' + m + ':' + s;
      35. } elseif (m > 0) {
      36. return m + ':' + s;
      37. } else {
      38. return s;
      39. }
      40. }
      Display All
    • I think you want to have this as final render



      Here is the code you need to modify

      saerch

      PHP Source Code: GeneralFunctions.php

      1. function pretty_time($seconds)
      2. {
      3. global $LNG;
      4. $day = floor($seconds / 86400);
      5. $hour = floor($seconds / 3600 % 24);
      6. $minute = floor($seconds / 60 % 60);
      7. $second = floor($seconds % 60);
      8. $time = '';
      9. if($day > 0) {
      10. $time .= sprintf('%d%s ', $day, $LNG['short_day']);
      11. }
      12. return $time.sprintf('%02d%s %02d%s %02d%s',
      13. $hour, $LNG['short_hour'],
      14. $minute, $LNG['short_minute'],
      15. $second, $LNG['short_second']
      16. );
      17. }
      Display All


      replace by

      Source Code: GeneralFunctions.php

      1. function pretty_time($seconds)
      2. {
      3. global $LNG;
      4. $day = floor($seconds / 86400);
      5. $hour = floor($seconds / 3600 % 24);
      6. $minute = floor($seconds / 60 % 60);
      7. $second = floor($seconds % 60);
      8. $time = '';
      9. if($day > 0) {
      10. $time .= sprintf('%d%s ', $day, $LNG['short_day']);
      11. }
      12. if($hour > 0) {
      13. $time .= sprintf('%02d%s ', $hour, $LNG['short_hour']);
      14. }
      15. if($minute > 0) {
      16. $time .= sprintf('%02d%s ', $minute, $LNG['short_minute']);
      17. }
      18. return $time.sprintf('%02d%s',
      19. $second, $LNG['short_second']
      20. );
      21. }
      Display All
      search

      JavaScript Source Code: base.js

      1. function getFormatedTime(time)
      replace by

      JavaScript Source Code: base.js

      1. function getFormatedTime(time) {
      2. hours = Math.floor(time / 3600);
      3. timeleft = time % 3600;
      4. minutes = Math.floor(timeleft / 60);
      5. timeleft = timeleft % 60;
      6. seconds = timeleft;
      7. var timeresponse = "";
      8. if (hours > 0) {
      9. timeresponse += dezInt(hours, 2) + "h ";
      10. }
      11. if (minutes > 0) {
      12. timeresponse += dezInt(minutes, 2) + "m ";
      13. }
      14. timeresponse += dezInt(seconds, 2) + "s";
      15. return timeresponse;
      16. }
      Display All
      search

      JavaScript Source Code: base.js

      1. function GetRestTimeFormat(Secs)
      replace by

      JavaScript Source Code: base.js

      1. function GetRestTimeFormat(Secs) {
      2. var s = Secs;
      3. var m = 0;
      4. var h = 0;
      5. var time = "";
      6. if (s > 59) {
      7. m = Math.floor(s / 60);
      8. s = s - m * 60;
      9. }
      10. if (m > 59) {
      11. h = Math.floor(m / 60);
      12. m = m - h * 60;
      13. }
      14. if (h > 0) {
      15. time += dezInt(h, 2) + "h ";
      16. }
      17. if (m > 0) {
      18. time += dezInt(m, 2) + "m ";
      19. }
      20. time += dezInt(s, 2) + "s";
      21. return time;
      22. }
      Display All
      enjoy ^^