Difference between revisions of "Widget:Pamela"

From Whitespace (Hackerspace Gent)
Jump to: navigation, search
m
Line 23: Line 23:
 
{
 
{
 
     var macs, i;
 
     var macs, i;
 +
    var pamTalkPeople = ['is nobody', 'is one person', 'are two people', 'are three people', 'are four people', 'are five people'];
 +
    var pamTalkMachines = ['are no machines', 'is one machine', 'are two machines', 'are three machines', 'are four machines', 'are five machines'];
  
 
     if ( !(xmlHttp.readyState == 4 && xmlHttp.status == 200))
 
     if ( !(xmlHttp.readyState == 4 && xmlHttp.status == 200))
Line 30: Line 32:
  
 
     var macs = eval ( "(" + xmlHttp.responseText + ")" );
 
     var macs = eval ( "(" + xmlHttp.responseText + ")" );
 +
 
     var people = [];
 
     var people = [];
 
     var services = [];
 
     var services = [];
 +
    var entities = [];
  
 
     for (i = macs.length -1; i >= 0; i--) {
 
     for (i = macs.length -1; i >= 0; i--) {
Line 38: Line 42:
 
         }
 
         }
 
         else if ( macs[i].split( ':' ).length == 6 ) {
 
         else if ( macs[i].split( ':' ).length == 6 ) {
             people.push(macs[i]);
+
             entities.push(macs[i]);
 
         }
 
         }
 
         else {
 
         else {
Line 48: Line 52:
  
 
     if ( macs.length > 0 ) {
 
     if ( macs.length > 0 ) {
        var msg = "According to <a href='" + window.location.protocol + "//0x20.be/Pamela'>Pamela</a> there are " + macs.length + " devices active in the space: " + people.concat(services).join( ", " );
+
var msg = "";
 +
 
 +
        // Dealing with unknown entities
 +
        if ( entities.length > 0 ) {
 +
      msg = msg + "<span style='color:red'>WARNING: </span><span style='color:darkred'>According to <a href='" + window.location.protocol + "//0x20.be/Pamela'>Pamela</a> there ";
 +
      if ( entities.length == 1 ) {
 +
          msg = msg + "is 1 unkown entitie";
 +
              }
 +
              else {
 +
                  msg = msg + "are " + entities.length + " unkown entities";
 +
              }
 +
              msg = msg + " present in Whitespace!!!<br><p style='text-align:center'>>> " +  entities.join(", " ) + " <<</p></span>Further <a href='" + window.location.protocol + "//0x20.be/Pamela'>Pamela</a> says there";
 +
}
 +
        else {
 +
              msg = msg + "According to <a href='" + window.location.protocol + "//0x20.be/Pamela'>Pamela</a> there "
 +
}
 +
 
 +
        // Dealing with people
 +
if ( people.length > 5 ) {
 +
      msg = msg + " are " + people.length + " people";
 +
}
 +
        else {
 +
      msg = msg + pamTalkPeople[people.length];
 +
}
 +
msg = msg  + " in the space";
 +
        if ( people.length > 0 ) {
 +
              msg = msg + ", namely: " + people.join(", " );
 +
        }
 +
 
 +
        // Dealing with machines
 +
        msg = msg + " and there "
 +
if ( services.length > 5 ) {
 +
              msg = msg + services.length + " machines";
 +
}
 +
        else {
 +
      msg = msg + pamTalkMachines[services.length];
 +
}
 +
msg = msg + " active";
 +
if ( services.length > 0 ) {
 +
              msg = msg + ", namely: " + services.join(", " );
 +
}
 +
msg = msg + ".";
 
     }
 
     }
 
     else {
 
     else {
         var msg = "<span style='color:darkred'><b>THE WORLD EXPLODED!</b> According to <a href='" + window.location.protocol + "//0x20.be/Pamela'>Pamela</a> there are " + macs.length + " devices active in the space o_O!</span>";
+
         var msg = "<span style='color:red'><b>THE WORLD EXPLODED!!! </b></span><span style='color:darkred'>According to <a href='" + window.location.protocol + "//0x20.be/Pamela'>Pamela</a> there's no man or machine left alive!!!</span>";
 
     }
 
     }
  

Revision as of 01:15, 17 January 2011

The space is open!

Loading Pamela...