The forum of the forums

Would you like to react to this message? Create an account in a few clicks or log in to continue.
The forum of the forums
+2
Wizzard
كونان2000
6 posters

    Add a message when you disconnect from the Internet

    كونان2000
    كونان2000
    Forumember


    Male Posts : 271
    Reputation : 113
    Language : Arabic

    Add a message when you disconnect from the Internet Empty Add a message when you disconnect from the Internet

    Post by كونان2000 Thu 6 Jun 2024 - 7:15

    Welcome everyone
    Add a message when you disconnect from the Internet
    Add a message when you disconnect from the Internet Animat16

    The message appears as soon as the Internet connection is suddenly lost, and the message disappears once the Internet connection is restored

    The connection may be lost before you finish writing the post in the editor, and the submit button may be pressed without knowing that the connection has been lost.
    So it might be useful to display a message to members if they lose their internet connection  Very Happy
    ----



    Installing the JavaScript
    --------------------------

    Title : as you like
    Placement : In all the pages

    Code:
    window.addEventListener('DOMContentLoaded', function() {
      var messageElement = document.createElement('div');
      messageElement.id = 'connection-message';
      messageElement.innerHTML = 'The Internet connection has been disconnected';
      messageElement.style.cssText = `
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
       background: #9f180f;
        color: #fffdeb;
        font-size: 24px;
        font-weight: bold;
        padding: 10px;
        text-align: center;
        z-index: 9999;
        display: none;
      `;


      document.body.appendChild(messageElement);
      function showMessage() {
        messageElement.style.display = 'block';
        messageElement.style.animation = 'slideIn 0.5s ease-in-out';
      }
      function hideMessage() {
        messageElement.style.animation = 'slideOut 0.5s ease-in-out';
        setTimeout(function() {
          messageElement.style.display = 'none';
        }, 500);
      }
      window.addEventListener('offline', showMessage);
      window.addEventListener('online', hideMessage);
      function animate(element, animationName) {
        element.style.animationName = animationName;
        setTimeout(function() {
          element.style.animationName = '';
        }, 1000);
      }
      var slideInAnimation = `
        from {
          transform: translateY(100%);
          opacity: 0;
        }
        to {
          transform: translateY(0);
          opacity: 1;
        }
      `;

      var slideOutAnimation = `
        from {
          transform: translateY(0);
          opacity: 1;
        }
        to {
          transform: translateY(100%);
          opacity: 0;
        }
      `;
      messageElement.addEventListener('animationstart', function() {
        if (messageElement.style.animationName === slideInAnimation) {
          animate(messageElement, slideOutAnimation);
        }
      });
    });
    -------------------------------------------------------


    You can modify the message content, background and color from the JavaScript code
    Add a message when you disconnect from the Internet Animat14





    Last edited by كونان2000 on Tue 17 Sep 2024 - 5:35; edited 2 times in total

    skouliki, invisible_fa, YoshiGM, SarkZKalie, TonnyKamper, Jucarese, poesia-verses and Wizzard like this post

    Wizzard
    Wizzard
    Forumember


    Male Posts : 71
    Reputation : 16
    Language : English

    Add a message when you disconnect from the Internet Empty Re: Add a message when you disconnect from the Internet

    Post by Wizzard Thu 6 Jun 2024 - 10:03

    Interesting idea, I love it.

    كونان2000 likes this post

    Jucarese
    Jucarese
    Hyperactive


    Male Posts : 2539
    Reputation : 118
    Language : spanish
    Location : SSF Admin

    Add a message when you disconnect from the Internet Empty Re: Add a message when you disconnect from the Internet

    Post by Jucarese Thu 6 Jun 2024 - 11:49

    كونان2000 likes this post

    كونان2000
    كونان2000
    Forumember


    Male Posts : 271
    Reputation : 113
    Language : Arabic

    Add a message when you disconnect from the Internet Empty Re: Add a message when you disconnect from the Internet

    Post by كونان2000 Fri 7 Jun 2024 - 4:56

    Wizzard wrote:Interesting idea, I love it.
    thank you @Wizzard
    I'm glad you liked it Add a message when you disconnect from the Internet 45133
    -----------------------------------

    hello @jucarese

    The message appears before you click the send button Very Happy

    +

    Check your Java settings

    Add a message when you disconnect from the Internet Oci5a_10

    Add a message when you disconnect from the Internet Ocia_a20

    poesia-verses and Wizzard like this post

    YoshiGM
    YoshiGM
    Active Poster


    Male Posts : 1557
    Reputation : 146
    Language : Spanish & English
    Location : Mexico

    Add a message when you disconnect from the Internet Empty Re: Add a message when you disconnect from the Internet

    Post by YoshiGM Fri 7 Jun 2024 - 17:00

    Lol? I've never though in something like that.
    A message alert when you are replying a topic and your connection has lost.

    Very creative :p

    poesia-verses and كونان2000 like this post

    كونان2000
    كونان2000
    Forumember


    Male Posts : 271
    Reputation : 113
    Language : Arabic

    Add a message when you disconnect from the Internet Empty Re: Add a message when you disconnect from the Internet

    Post by كونان2000 Sat 8 Jun 2024 - 7:04

    Haha, glad you find it creative! Very Happy
    it could save us from those frustrating moments.
    Thanks @YoshiGM for the Your comment ^^,
    skouliki
    skouliki
    Manager
    Manager


    Female Posts : 15312
    Reputation : 1705
    Language : English,Greek
    Location : Greece

    Add a message when you disconnect from the Internet Empty Re: Add a message when you disconnect from the Internet

    Post by skouliki Sat 8 Jun 2024 - 7:26

    YoshiGM wrote:Lol? I've never though in something like that.
    A message alert when you are replying a topic and your connection has lost.

    Very creative :p

    i also have a similar code in my forum that automatically saves the post in case of internet crash

    TonnyKamper and كونان2000 like this post

    Mihai
    Mihai
    Forumember


    Male Posts : 926
    Reputation : 38
    Language : Romanian, English
    Location : Bucharest, Romania

    Add a message when you disconnect from the Internet Empty Re: Add a message when you disconnect from the Internet

    Post by Mihai Fri 9 Aug 2024 - 1:49

    Hello,

    Maybe you can make something similiar but like youtube in case your internet is disconnected or its offline?

    1 - set the message at the end of the homepage: https://prnt.sc/UkejhBeahOks (just like youtube)
    1 - do the same like youtube, but change the text and the background itself: https://prnt.sc/AQCGvZj2iC3c

    كونان2000 likes this post

    كونان2000
    كونان2000
    Forumember


    Male Posts : 271
    Reputation : 113
    Language : Arabic

    Add a message when you disconnect from the Internet Empty Re: Add a message when you disconnect from the Internet

    Post by كونان2000 Fri 9 Aug 2024 - 15:17

    hi @Mihai
    The code has been modified so that when the connection is lost, a red message appears with the words 'No Internet Connection'. When the connection is restored, a green message appears with the words 'Back Online'.

    But not in my first post Basketball


    Code:
    window.addEventListener('DOMContentLoaded', function() {
      var messageElement = document.createElement('div');
      messageElement.id = 'connection-message';
      messageElement.style.cssText = `
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        color: #fff;
        font-size: 24px;
        font-weight: bold;
        padding: 10px;
        text-align: center;
        z-index: 9999999999;
        display: none;
        transition: background 0.5s, color 0.5s;
      `;
      document.body.appendChild(messageElement);

      function showMessage(online) {
        if (online) {
          messageElement.innerHTML = 'Back Online';
          messageElement.style.backgroundColor = '#28a745'; // اللون الأخضر
        } else {
          messageElement.innerHTML = 'No Internet Connection';
          messageElement.style.backgroundColor = '#9f180f'; // اللون الأحمر
        }
        messageElement.style.display = 'block';
        messageElement.style.animation = 'slideIn 0.5s ease-in-out';
      }

      function hideMessage() {
        messageElement.style.animation = 'slideOut 0.5s ease-in-out';
        setTimeout(function() {
          messageElement.style.display = 'none';
        }, 500);
      }

      window.addEventListener('offline', function() {
        showMessage(false);
      });
     
      window.addEventListener('online', function() {
        showMessage(true);
        setTimeout(hideMessage, 3000); // إخفاء الرسالة بعد 3 ثوانٍ
      });

      var slideInAnimation = `
        from {
          transform: translateY(100%);
          opacity: 0;
        }
        to {
          transform: translateY(0);
          opacity: 1;
        }
      `;

      var slideOutAnimation = `
        from {
          transform: translateY(0);
          opacity: 1;
        }
        to {
          transform: translateY(100%);
          opacity: 0;
        }
      `;

      var styleSheet = document.createElement("style");
      styleSheet.type = "text/css";
      styleSheet.innerText = `
        @keyframes slideIn { ${slideInAnimation} }
        @keyframes slideOut { ${slideOutAnimation} }
      `;
      document.head.appendChild(styleSheet);
    });


    Add a message when you disconnect from the Internet Animat20

    Shake
    Jucarese
    Jucarese
    Hyperactive


    Male Posts : 2539
    Reputation : 118
    Language : spanish
    Location : SSF Admin

    Add a message when you disconnect from the Internet Empty Re: Add a message when you disconnect from the Internet

    Post by Jucarese Sat 10 Aug 2024 - 14:17

    كونان2000 wrote:
    hello @jucarese

    The message appears before you click the send button Very Happy

    +

    Check your Java settings

    Dont work for me ,and I’ve put the new code

    Add a message when you disconnect from the Internet 1FOu59o


    Add a message when you disconnect from the Internet Imagen20
    كونان2000
    كونان2000
    Forumember


    Male Posts : 271
    Reputation : 113
    Language : Arabic

    Add a message when you disconnect from the Internet Empty Re: Add a message when you disconnect from the Internet

    Post by كونان2000 Sat 10 Aug 2024 - 17:36

    hi @jucarese

    To test the 'Internet Disconnected' message,
    you don't need to write a message in the text editor.
    Simply install JavaScript, and after that, disconnect from the internet to see the message.
    This should work perfectly.

    lol!
    Jucarese
    Jucarese
    Hyperactive


    Male Posts : 2539
    Reputation : 118
    Language : spanish
    Location : SSF Admin

    Add a message when you disconnect from the Internet Empty Re: Add a message when you disconnect from the Internet

    Post by Jucarese Sat 10 Aug 2024 - 20:17

    Add a message when you disconnect from the Internet RXNsOgF

    It doesn't matter, its the same for the FF browser

    كونان2000 likes this post

    كونان2000
    كونان2000
    Forumember


    Male Posts : 271
    Reputation : 113
    Language : Arabic

    Add a message when you disconnect from the Internet Empty Re: Add a message when you disconnect from the Internet

    Post by كونان2000 Sat 10 Aug 2024 - 21:25

    Hmm mwii

    Strange, but it works on my test forum on all browsers Think

    and on the main forum
    https://anime.forumperso.com/

    Try it on my forum
    Jucarese
    Jucarese
    Hyperactive


    Male Posts : 2539
    Reputation : 118
    Language : spanish
    Location : SSF Admin

    Add a message when you disconnect from the Internet Empty Re: Add a message when you disconnect from the Internet

    Post by Jucarese Sun 11 Aug 2024 - 12:42

    Thanks, I tried, but neither with Chrome nor with FF, I'm telling you that it has happened to me with other codes. Some that I have put yours in the SSF work fine without problems, but this one on my side does not work, I don't know if other users do. They will see it or not, but I don't. It could be something in the configuration of my browsers.
    Thanks

    كونان2000 likes this post

    كونان2000
    كونان2000
    Forumember


    Male Posts : 271
    Reputation : 113
    Language : Arabic

    Add a message when you disconnect from the Internet Empty Re: Add a message when you disconnect from the Internet

    Post by كونان2000 Sun 11 Aug 2024 - 17:00

    hi @jucarese

    It might be related to the settings in your browsers or possibly outdated software on your system. I recommend checking your browser settings and making sure they are updated to the latest version. Also, make sure your operating system is up to date. Sometimes, updates can resolve compatibility issues with code or programs

    :rose:
    Jucarese
    Jucarese
    Hyperactive


    Male Posts : 2539
    Reputation : 118
    Language : spanish
    Location : SSF Admin

    Add a message when you disconnect from the Internet Empty Re: Add a message when you disconnect from the Internet

    Post by Jucarese Sun 11 Aug 2024 - 20:39

    @كونان2000 Everything is up to date, normally JS works well for me, but this one I don't know why not.
    Dont worry

    كونان2000 likes this post

    Mihai
    Mihai
    Forumember


    Male Posts : 926
    Reputation : 38
    Language : Romanian, English
    Location : Bucharest, Romania

    Add a message when you disconnect from the Internet Empty Re: Add a message when you disconnect from the Internet

    Post by Mihai Tue 13 Aug 2024 - 2:03

    jucarese wrote: @كونان2000 Everything is up to date, normally JS works well for me, but this one I don't know why not.
    Dont worry

    Hello @jucarese,

    Can i have please an test account to detect from where the problem is coming from (if you still wanna do it)

    Let me know thumright

    كونان2000 likes this post

    Jucarese
    Jucarese
    Hyperactive


    Male Posts : 2539
    Reputation : 118
    Language : spanish
    Location : SSF Admin

    Add a message when you disconnect from the Internet Empty Re: Add a message when you disconnect from the Internet

    Post by Jucarese Tue 13 Aug 2024 - 12:16

    @Mihai
    https://todasplataformas.foroactivo.com (prepod)
    Forumtest
    Forumtest2024

    First forum is free

    كونان2000 likes this post

    كونان2000
    كونان2000
    Forumember


    Male Posts : 271
    Reputation : 113
    Language : Arabic

    Add a message when you disconnect from the Internet Empty Re: Add a message when you disconnect from the Internet

    Post by كونان2000 Tue 13 Aug 2024 - 16:26

    @jucarese
    This is a screenshot of your forum.
    Add a message when you disconnect from the Internet Animat21

    Jucarese likes this post

    Jucarese
    Jucarese
    Hyperactive


    Male Posts : 2539
    Reputation : 118
    Language : spanish
    Location : SSF Admin

    Add a message when you disconnect from the Internet Empty Re: Add a message when you disconnect from the Internet

    Post by Jucarese Tue 13 Aug 2024 - 19:35

    I already told you that it doesn't work for me, and I don't know if it's because of the browsers and the security they have established + specific settings. That's why I said that if others can see it, that's perfect.
    Mihai
    Mihai
    Forumember


    Male Posts : 926
    Reputation : 38
    Language : Romanian, English
    Location : Bucharest, Romania

    Add a message when you disconnect from the Internet Empty Re: Add a message when you disconnect from the Internet

    Post by Mihai Tue 13 Aug 2024 - 23:31

    jucarese wrote: @Mihai
    https://todasplataformas.foroactivo.com (prepod)
    Forumtest
    Forumtest2024

    First forum is free
    You have specified an incorrect or inactive username, or an invalid password.

    In any case, try to remove your forum from prepod and try the script again - if its working that means its from prepod Embarassed

    Let me know Wink

    Jucarese likes this post

    Jucarese
    Jucarese
    Hyperactive


    Male Posts : 2539
    Reputation : 118
    Language : spanish
    Location : SSF Admin

    Add a message when you disconnect from the Internet Empty Re: Add a message when you disconnect from the Internet

    Post by Jucarese Wed 14 Aug 2024 - 19:29

    I already looked @كونان2000 , and yes, it comes up, the problem is on my side that there is something that does not allow that mess

    كونان2000 likes this post


      Current date/time is Mon 23 Sep 2024 - 9:33