Galaxy AJAX

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

    • I managed to get it to work with the js code I added to page.galaxy.default.tpl, but I couldn't stop the page from refreshing. Can anyone help?
      Files
    • change in abstractgamepage.php

      PHP Source Code

      1. if(!AJAX_REQUEST)
      2. {
      3. $this->setWindow('full');
      4. if(!$this->disableEcoSystem)
      5. {
      6. $this->ecoObj = new ResourceUpdate();
      7. $this->ecoObj->CalcResource();
      8. }
      9. $this->initTemplate();
      10. } else {
      11. $this->setWindow('ajax');
      12. if(AJAX_REQUEST == 2){
      13. $this->initTemplate();
      14. }
      15. }
      Display All


      this ist the new part

      PHP Source Code

      1. $this->setWindow('ajax');
      2. if(AJAX_REQUEST == 2){
      3. $this->initTemplate();
      your ajaxscript can now call game.php?page=galaxy&ajax=2
      this prevents loading the whole site

      then change at the end of showgalaxypage.class.php

      PHP Source Code

      1. if(AJAX_REQUEST == 2){
      2. $this->display('page.galaxy.ajax.tpl');
      3. }else{
      4. $this->display('page.galaxy.default.tpl');
      5. }
      now make a file page.galaxy.ajax.tpl
      it only contains the part of the new table you want to innerHTML
      so alle in your tpl befor the script part
    • mimikri wrote:

      change in abstractgamepage.php

      PHP Source Code

      1. if(!AJAX_REQUEST)
      2. {
      3. $this->setWindow('full');
      4. if(!$this->disableEcoSystem)
      5. {
      6. $this->ecoObj = new ResourceUpdate();
      7. $this->ecoObj->CalcResource();
      8. }
      9. $this->initTemplate();
      10. } else {
      11. $this->setWindow('ajax');
      12. if(AJAX_REQUEST == 2){
      13. $this->initTemplate();
      14. }
      15. }
      Display All

      this ist the new part

      PHP Source Code

      1. $this->setWindow('ajax');
      2. if(AJAX_REQUEST == 2){
      3. $this->initTemplate();
      your ajaxscript can now call game.php?page=galaxy&ajax=2
      this prevents loading the whole site

      then change at the end of showgalaxypage.class.php

      PHP Source Code

      1. if(AJAX_REQUEST == 2){
      2. $this->display('page.galaxy.ajax.tpl');
      3. }else{
      4. $this->display('page.galaxy.default.tpl');
      5. }
      now make a file page.galaxy.ajax.tpl
      it only contains the part of the new table you want to innerHTML
      so alle in your tpl befor the script part
      I tried to do this with my own effort but I am missing a lot. Do you have codes that I can use to apply Ajax to 2Moons 1.8 Galaxy?
    • you might have to change the tpl files acording to your game.
      made it in 2moonz ant there all images are in webp format, wich ist much smaller when otheres without loosing noticable quality.
      you could paste your tpl inside the the galaxy_table_wrapper in the galaxy.default.tpl,
      and also in the galaxy.ajax.tpl but there is no wrapper around it.
    • mimikri wrote:

      here you can see it running ingame
      and here it is the github commit

      since the galaxy.js was changed you have to clear the cache in the browser, reloading with ctrl + f5, should do it.
      I edited it in the ogamewar.com/kalradya universe but it is not as fast as your game and it works incorrectly when I write the coordinates manually and click Show, I created an account for you to see, you can look.

      Player Name: mimikri
      Password: 123456
    • yes first version had this issues, updated the files
      in both tpl files the first form shall be without &ajax2, and in the glaxy.js ajax=2 is added to the url
      then the error with white page is gone when entering numbers
      don't forget to press ctrl + f5, to get the new galaxy.js in the browser.
      Files
      • 2Moonz.zip

        (8.12 kB, downloaded 35 times, last: )