rejetto forum

On - Off Script on website

0 Members and 1 Guest are viewing this topic.

Offline Johannes51

  • Occasional poster
  • *
    • Posts: 11
    • View Profile
Hello,

Is it possible to automatically create a script on and off at HFS server. I have a website where you can go to the HFS server, but no one can see if he is on or off. I can through a script on my website which then shows that it is on or off by a plate of On and Off. I am really a beginner, but would like to learn. sorry for my bad English

Is there anyone who can help me with it.

thanks

Johan


Offline bmartino1

  • Tireless poster
  • ****
    • Posts: 901
  • I'm only trying to help i mean no offense.
    • View Profile
    • My HFS Google Drive Shared Link
let me get this straight, you want a site to show the hfs log to see who is/has connected?

or you want a template that shows your users and who is currently online/connected?

This is possible via macros in the hfs template and new scripting commands....
You would have to accomplish this by going to a website on hfs???

(i don't know the commands / macros enough to help you on this....)
Just trying to be sure what your are trying to accomplish...?
« Last Edit: June 11, 2015, 06:12:22 PM by bmartino1 »
Files i try to keep and share can be found on my google drive:

https://drive.google.com/drive/folders/1FOWi3Gqaldld6JLXvZ-biDv4RSguf0IC


Offline Johannes51

  • Occasional poster
  • *
    • Posts: 11
    • View Profile
thanks for your answer,

I turn an ordinary website. through an iframe you can on the website come on the HFS server. Now I would like my regular website will show whether the server on or offline state.

Can this be made with a script and where can I find it? Maybe I did not properly explains.


Johannnes


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2043
    • View Profile
There are two macros to stop or restart HFS, they are more useful in the events for example define the hours of access, you must realize that if you Stop the server, the program continues to run but the connection to http server is lost until you restart it manualy or by an event    (see wiki hfs.events)


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13310
    • View Profile
an easy (not perfect) solution is: your main website tries to call HFS. If it doesn't reply, you remove the iframe and display a message.
If you are good with jquery this is not hard. Something like

<script>
$(function(){
  $.ajax(HFS_URL).fail(function(){
     $('iframe').replaceWith('Sorry, not available');
  });
});
</script>

I didn't test it
Trying to do the opposite (HFS notifying of its state) would be unreliable.


Offline Johannes51

  • Occasional poster
  • *
    • Posts: 11
    • View Profile
thnx for help, i have to try this script, but don't work.

Try to make it a little clearer

I just have a website, I want to show on the website or the server off or on state. Here I actually looking for a script that I can put on the website so that members can see if the server on or off

Is this possible and where can I find such a thing.

Johannes


Offline bmartino1

  • Tireless poster
  • ****
    • Posts: 901
  • I'm only trying to help i mean no offense.
    • View Profile
    • My HFS Google Drive Shared Link
What rejeto was saying is instead of HFS notifying you, have a webpage to run a script to see if that link is live.

so a html page that has Iframes, that run a script simalr to this...

Lets call the site
AmIUp

<!DOCTYPE html>
<html>
<head>
<title>Am I Up</title>
</head>

<body>
<!-- Iframe test script wil be hear -->
<!-- Using jquery??? -->
<script>
$(function(){
  $.ajax("Site URL will be here www.domain.com without quotes").fail(function(){
     $('iframe').replaceWith('Sorry, not available');
  });
});
</script>
</body>
</html>

---------------
From there you will need remote desktop control to login and start/ stop server...

The script Rejeto postede isn't test / not guaranteed to work, need the site address and some other info to "html program" what rejeto is recommending...

this script doesn't work , it will display a balnk page... need to find html coding/ other way to get a redirect on iframes....
http://stackoverflow.com/questions/3922989/how-to-check-if-page-exists-using-javascript
« Last Edit: July 03, 2015, 11:38:10 AM by bmartino1 »
Files i try to keep and share can be found on my google drive:

https://drive.google.com/drive/folders/1FOWi3Gqaldld6JLXvZ-biDv4RSguf0IC


Offline Johannes51

  • Occasional poster
  • *
    • Posts: 11
    • View Profile
Thank you for your clear explanation, but I do not really like I have in my mind. I have therefore made a picture how it should be.

Johannes ;) ;)


Offline bmartino1

  • Tireless poster
  • ****
    • Posts: 901
  • I'm only trying to help i mean no offense.
    • View Profile
    • My HFS Google Drive Shared Link
ok, thats fine, unfortunate, i haven't seen that feature, nor of a way to accomplish waht you want from the picture...

i would direct you to vhost and appache for that type of setup...

http://www.rejetto.com/forum/hfs-~-http-file-server/multiple-websites-with-hfs-like-vhost-in-apache/msg1060317/#msg1060317

--------------------------
HFS doesn't have a offline mode where it can be turned on form a website... there is no picture for it...

if its is in offline mode, you would still need a script to test it...

This may be of help:
http://www.rapidtables.com/web/tools/redirect-generator.htm

good luck

these may be of help, i can't seem to debug/ program a good working script...

http://stackoverflow.com/questions/3922989/how-to-check-if-page-exists-using-javascript

http://javascriptkit.com/script/script2/ajaxtooltip.shtml

i did find that the notepad doc had to be saved as a "*.xhtml file to test the script...

in either events, it still fails.../ doen't give results
The zip file is the end where i essentially give up... Tis an html button when clicked runs the script, it suppose to show online / offline, but does neither...

Good luck
« Last Edit: July 03, 2015, 12:44:43 PM by bmartino1 »
Files i try to keep and share can be found on my google drive:

https://drive.google.com/drive/folders/1FOWi3Gqaldld6JLXvZ-biDv4RSguf0IC


Offline Johannes51

  • Occasional poster
  • *
    • Posts: 11
    • View Profile
Hello,

Many thanks for your quick response, and thank you for a new challenge for me, I will try what I can do everything myself. I am a beginner in scripts and go to battle.

Many thanks for your advice and time

Johannes


Offline LeoNeeson

  • Tireless poster
  • ****
    • Posts: 769
  • Status: On hiatus (sporadically here)
    • View Profile
    • twitter.com/LeoNeeson
Doing a Google search, I've found this...

Code: [Select]
http://stackoverflow.com/questions/23997675/checking-if-web-server-is-online-offline
http://stackoverflow.com/questions/189430/detect-that-the-internet-connection-is-offline
http://stackoverflow.com/questions/4282151/is-it-possible-to-ping-a-server-from-javascript/

IMHO, this seems to be the easiest solution:

Code: [Select]
<img src="http://your-hfs-server.com/online.png" alt="status" onerror="this.src='files/offline.png'" />

"The setup is: An online icon (online.png) on the remote server [the HFS Server] you want to see the status of. An offline icon (offline.png) on the server that is going to show the status page." [Source]

Let us know which solution worked, if any of them do please! ;)
Greetings...
Leo.-


Offline bmartino1

  • Tireless poster
  • ****
    • Posts: 901
  • I'm only trying to help i mean no offense.
    • View Profile
    • My HFS Google Drive Shared Link

Code: [Select]
<img src="http://your-hfs-server.com/online.png" alt="status" onerror="this.src='files/offline.png'" />

Thank you Leo, i was able to make a working script with the events... here is a working test...

http://stackoverflow.com/questions/3984287/how-to-show-alternate-image-if-source-image-is-not-found-onerror-working-in-ie
---------
<!DOCTYPE html>
<html>
<body>

<p> <a href="Your HFS HTML SITE"> click here to go to HFS </a> </p>

<!-- Picture must come form your HFS SITE  -->
<img src="Your HFS HTML SITE\Online.jpg" onerror="myFunction()">

<!-- Write your comments here -->
<!-- http://www.w3schools.com/jsref/event_onerror.asp -->
<!-- If server is down, picture will not load, and display this text -->

<p id="demo"></p>
<script>
function myFunction() {
    document.getElementById("demo").innerHTML = "The server is offline.";
}
</script>

</body>
</html>
-------------
« Last Edit: July 07, 2015, 03:43:31 AM by bmartino1 »
Files i try to keep and share can be found on my google drive:

https://drive.google.com/drive/folders/1FOWi3Gqaldld6JLXvZ-biDv4RSguf0IC


Offline Johannes51

  • Occasional poster
  • *
    • Posts: 11
    • View Profile
Hello

Many thanks for your good script and explanation, and it works perfectly just need just a picture online and it all works.

I hope that more members have fun at it because really top


Johannes  ;D ;D ;D


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13310
    • View Profile

Offline Johannes51

  • Occasional poster
  • *
    • Posts: 11
    • View Profile
Put this on your website :

<script type="text/javascript">
   var url = "http://www.yourprivateserver.com/foo.gif";
   var img = new Image();
   img.src = url;

   img.onload = function()
   {
      // If the server is up, do this.
      alert("Server is up!");
   }

   img.onerror = function()
   {
      // If the server is down, do that.
      alert("Server is down!");
   }
</script>


and works great