Difference between revisions of "Widget:Pamela"

From Whitespace (Hackerspace Gent)
Jump to: navigation, search
(further styling)
 
(27 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
<noinclude>
 
<noinclude>
<div style="width: 845px;">
+
<div>
   <div id="openbanner">The space is open!</div>
+
   <div id="openbanner">[http://0x20.be/pam <span style="color:white">The space is open!</span>]</div>
 
</div>
 
</div>
 
{{#widget:Pamela}}</noinclude><includeonly>
 
{{#widget:Pamela}}</noinclude><includeonly>
<div id="pamelaWidget">Loading <a href='http://0x20.be/Pamela'>Pamela</a>...</div>
+
<div id="pamelaWidget">Loading <a href='/Pamela'>Pamela</a>...</div>
 
<script type="text/javascript">
 
<script type="text/javascript">
 
var xmlHttp = null;
 
var xmlHttp = null;
Line 10: Line 10:
 
function LoadPamelaCountWidget()
 
function LoadPamelaCountWidget()
 
{
 
{
     var Url = window.location.protocol + "//0x20.be/pam/macs";
+
     var Url = "/pam/data";
  
 
     xmlHttp = new XMLHttpRequest();
 
     xmlHttp = new XMLHttpRequest();
Line 22: Line 22:
 
function ProcessRequest()
 
function ProcessRequest()
 
{
 
{
     var macs, i;
+
     var data, i;
 
     var pamTalkPeople = ['is nobody', 'is one person', 'are two people', 'are three people', 'are four people', 'are five people'];
 
     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'];
 
     var pamTalkMachines = ['are no machines', 'is one machine', 'are two machines', 'are three machines', 'are four machines', 'are five machines'];
Line 31: Line 31:
 
         return;
 
         return;
  
     var macs = eval ( "(" + xmlHttp.responseText + ")" );
+
     var data = eval ( "(" + xmlHttp.responseText + ")" );
  
 
     var people = [];
 
     var people = [];
Line 37: Line 37:
 
     var entities = [];
 
     var entities = [];
  
     for (i = macs.length -1; i >= 0; i--) {
+
     for (i = data.length -1; i >= 0; i--) {
         if (macs[i].indexOf('(') != -1) {
+
         if (data[i].indexOf('(') != -1) {
             services.push('<span style="color:darkgray">' + macs[i] + '</span>');
+
             services.push('<span style="color:darkgray">' + data[i] + '</span>');
 
         }
 
         }
         else if ( macs[i].split( ':' ).length == 6 ) {
+
         else if (data[i].split( ':' ).length == 6) {
             entities.push(macs[i]);
+
             entities.push(data[i]);
 
         }
 
         }
 +
// Hack please remove once the pamela db has been fixed
 +
        else if (data[i] == 'the cable guy') {
 +
            services.push('<span style="color:darkgray">' + data[i] + '</span>');
 +
        }
 +
// End of code to remove
 
         else {
 
         else {
             people.unshift(macs[i]);
+
             people.unshift('<a href="/' + data[i] + '">' + data[i] + '</a>');
 
         }
 
         }
 
     }
 
     }
Line 51: Line 56:
 
     document.getElementById('openbanner').style.display = people.length > 0 ? 'block' : 'none';
 
     document.getElementById('openbanner').style.display = people.length > 0 ? 'block' : 'none';
  
     if ( macs.length > 0 ) {
+
     if ( data.length > 0 ) {
 
var msg = "";
 
var msg = "";
  
 
         // Dealing with unknown entities
 
         // Dealing with unknown entities
 
         if ( entities.length > 0 ) {
 
         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 ";
+
      msg = msg + "<p>";
 +
      msg = msg + "<span style='color:red;'>WARNING:</span>";
 +
      msg = msg + "<span style='color:darkred;'>According to <a href='/Pamela'>Pamela</a> there ";            
 
      if ( entities.length == 1 ) {
 
      if ( entities.length == 1 ) {
          msg = msg + "is 1 unkown entitie";
+
          msg = msg + "is 1 unknown entity";
 
               }
 
               }
 
               else {
 
               else {
                   msg = msg + "are " + entities.length + " unkown entities";
+
                   msg = msg + "are " + entities.length + " unknown 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 ";
+
               msg = msg + " present in Whitespace!!! >> " +  entities.join(", " ) + " <<";
 +
      msg = msg + "</p>";
 +
      msg = msg + "<p>";
 +
              msg = msg + "Furthermore <a href='/Pamela'>Pamela</a> says there ";
 
}
 
}
 
         else {
 
         else {
               msg = msg + "According to <a href='" + window.location.protocol + "//0x20.be/Pamela'>Pamela</a> there "
+
      msg = msg + "<p>";
 +
               msg = msg + "According to <a href='/Pamela'>Pamela</a> there "
 
}
 
}
  
Line 94: Line 105:
 
}
 
}
 
msg = msg + ".";
 
msg = msg + ".";
 +
        msg = msg + "</p>";
 
     }
 
     }
 
     else {
 
     else {
         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>";
+
         var msg = "<p><span style='color:red; font-weight: bold;'>THE WORLD EXPLODED!!!</span> ";
 +
        msg = msg + "<span style='color:darkred'>According to <a href='/Pamela'>Pamela</a> there's no man or machine left alive!!!</span></p>";
 
     }
 
     }
  

Latest revision as of 02:13, 8 March 2013

Loading Pamela...