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.

Add a message when you disconnect from the Internet

+2
Wizzard
كونان2000
6 posters

Go down

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

Post by كونان2000 June 6th 2024, 7:15 am

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 September 17th 2024, 5:35 am; edited 2 times in total
كونان2000
كونان2000
Forumember

Male Posts : 282
Reputation : 118
Language : Arabic

https://anime.forumperso.com/

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

Back to top Go down

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

Post by Wizzard June 6th 2024, 10:03 am

Interesting idea, I love it.
Wizzard
Wizzard
Forumember

Male Posts : 96
Reputation : 22
Language : English

https://net-cafe.forumotion.com/

كونان2000 likes this post

Back to top Go down

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

Post by Jucarese June 6th 2024, 11:49 am

Jucarese
Jucarese
Hyperactive

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

http://asistencia.foroactivo.com/u23082

كونان2000 likes this post

Back to top Go down

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

Post by كونان2000 June 7th 2024, 4:56 am

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
كونان2000
كونان2000
Forumember

Male Posts : 282
Reputation : 118
Language : Arabic

https://anime.forumperso.com/

poesia-verses and Wizzard like this post

Back to top Go down

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

Post by YoshiGM June 7th 2024, 5:00 pm

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
YoshiGM
YoshiGM
Active Poster

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

http://asistencia.foroactivo.com/u21373

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

Back to top Go down

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

Post by كونان2000 June 8th 2024, 7:04 am

Haha, glad you find it creative! Very Happy
it could save us from those frustrating moments.
Thanks @YoshiGM for the Your comment ^^,
كونان2000
كونان2000
Forumember

Male Posts : 282
Reputation : 118
Language : Arabic

https://anime.forumperso.com/

Back to top Go down

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

Post by skouliki June 8th 2024, 7:26 am

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
skouliki
skouliki
Manager
Manager

Female Posts : 15363
Reputation : 1706
Language : English,Greek
Location : Greece

http://iconskouliki.forumgreek.com

TonnyKamper and كونان2000 like this post

Back to top Go down

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

Post by Mihai August 9th 2024, 1:49 am

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
Mihai
Mihai
Forumember

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

https://fgsuport.forumotion.com/

كونان2000 likes this post

Back to top Go down

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

Post by كونان2000 August 9th 2024, 3:17 pm

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
كونان2000
كونان2000
Forumember

Male Posts : 282
Reputation : 118
Language : Arabic

https://anime.forumperso.com/

Back to top Go down

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

Post by Jucarese August 10th 2024, 2:17 pm

كونان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
Jucarese
Jucarese
Hyperactive

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

http://asistencia.foroactivo.com/u23082

Back to top Go down

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

Post by كونان2000 August 10th 2024, 5:36 pm

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!
كونان2000
كونان2000
Forumember

Male Posts : 282
Reputation : 118
Language : Arabic

https://anime.forumperso.com/

Back to top Go down

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

Post by Jucarese August 10th 2024, 8:17 pm

Add a message when you disconnect from the Internet RXNsOgF

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

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

http://asistencia.foroactivo.com/u23082

كونان2000 likes this post

Back to top Go down

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

Post by كونان2000 August 10th 2024, 9:25 pm

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
كونان2000
كونان2000
Forumember

Male Posts : 282
Reputation : 118
Language : Arabic

https://anime.forumperso.com/

Back to top Go down

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

Post by Jucarese August 11th 2024, 12:42 pm

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
Jucarese
Jucarese
Hyperactive

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

http://asistencia.foroactivo.com/u23082

كونان2000 likes this post

Back to top Go down

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

Post by كونان2000 August 11th 2024, 5:00 pm

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:
كونان2000
كونان2000
Forumember

Male Posts : 282
Reputation : 118
Language : Arabic

https://anime.forumperso.com/

Back to top Go down

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

Post by Jucarese August 11th 2024, 8:39 pm

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

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

http://asistencia.foroactivo.com/u23082

كونان2000 likes this post

Back to top Go down

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

Post by Mihai August 13th 2024, 2:03 am

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
Mihai
Mihai
Forumember

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

https://fgsuport.forumotion.com/

كونان2000 likes this post

Back to top Go down

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

Post by Jucarese August 13th 2024, 12:16 pm

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

First forum is free
Jucarese
Jucarese
Hyperactive

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

http://asistencia.foroactivo.com/u23082

كونان2000 likes this post

Back to top Go down

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

Post by كونان2000 August 13th 2024, 4:26 pm

@jucarese
This is a screenshot of your forum.
Add a message when you disconnect from the Internet Animat21
كونان2000
كونان2000
Forumember

Male Posts : 282
Reputation : 118
Language : Arabic

https://anime.forumperso.com/

Jucarese likes this post

Back to top Go down

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

Post by Jucarese August 13th 2024, 7:35 pm

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.
Jucarese
Jucarese
Hyperactive

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

http://asistencia.foroactivo.com/u23082

Back to top Go down

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

Post by Mihai August 13th 2024, 11:31 pm

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
Mihai
Mihai
Forumember

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

https://fgsuport.forumotion.com/

Jucarese likes this post

Back to top Go down

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

Post by Jucarese August 14th 2024, 7:29 pm

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
Jucarese
Jucarese
Hyperactive

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

http://asistencia.foroactivo.com/u23082

كونان2000 likes this post

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum