<%@language = "javascript" %>
<% /*
     $Revision$
     $Id$

    File:               validateClient.asp
    Description:        Test bestand om functionaliteiten te valideren
    Parameters:

    Context:
    Note:                localStorage check

*/
ANONYMOUS_Allowed = 1;
%>
<!-- #include file="../Shared/common.inc" -->
<%
FCLTHeader.Requires({ plugins:["jQuery", "modernizr"],
                      js: ["jquery-ui.js"]
                    });

var ip = String(Request.ServerVariables("REMOTE_ADDR"));

%>
<html>
    <head>
<%  FCLTHeader.Generate(); %>
    <meta http-equiv="Content-Type" content="text/html;charset=windows-1252">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
    <style>
        body, td {
            font-family: Arial, Helvetica;
        }
        body {
            font-size: 90%!important;
        }
        div.content {
            text-align: left;
            margin: 8px 0px 0px 8px;
            border-radius: 10px;
            padding: 20px 20px 40px 20px;
            width: 800px;
            font-size:1em;
            font-weight: normal;
            color: black;
        }
        div.aiai {
            border: 3px solid #FF6F6F;
            background-color: #FFF0F0;
        }
        div.successful {
            border: 3px solid #6FBD6F;
            background-color: #F0FFF0;
        }
        table.inside {
            margin-left:1.5em;
        }
        table.inside td {
            font-size:0.8em;line-height:1.2em;
        }
    </style>
  </head>
<body>

  <noscript>
    <div class="content aiai">
      <h1 style="color:red">Aiai!</h1>
      Javascript must be enabled to use Facilitor.
    </div>
  </noscript>

  <script>

    $(function()
    {
      var error = 0;
      var msg   = "";
      var modernMsg = [];

      var resWidth  = window.screen.width  * window.devicePixelRatio;
      var resHeight = window.screen.height * window.devicePixelRatio;
      var scrnWidth   = window.innerWidth;
      var scrnHeight  = window.innerHeight;

      if (!localStorage)
          error = 1;
      else
      {
          var menuCollapsed   = localStorage.getItem("menuCollapsed");
          var selectedMenuTab = localStorage.getItem("selectedMenuTab");

          if ($.inArray(menuCollapsed,   [null, "0", "1"]     ) == -1 ||
              $.inArray(selectedMenuTab, [null, "0", "1", "2"]) == -1)
          {
              msg = "<br>Opgeslagen localStorage:<br><br>";

              for (var i in localStorage)
                  if (typeof localStorage[i] != "function" && i != "length")
                      msg += i + ": " + localStorage[i] + "<br>";

              error = 2;
          }
      }

      switch (error)
      {
        case 1: // localStorage not available
        {
            msg += "Your browser does not support localStorage which is required for Facilitor to properly operate<br>";
            break;
        }
        case 2: // corrupte localStorage
        {
            msg = "The values stored in localStorage needed for Facilitor are corrupt" + msg;
            break;
        }
        case 0: // Geen error
        default:
        {
            break;
        }
      }

/*    Totdat hier wat nuttigere informatie bijstaat; uitgecommentariëerd

      for (var feature in Modernizr)
      {
          if (Modernizr[feature] === false)
          {
              modernMsg.push("<tr><td>" + feature + ": </td><td>" + Modernizr[feature] + "</td></tr>");
          }
          else if (typeof Modernizr[feature] != "undefined")
          {
              for (var subFeature in Modernizr[feature])
              {
                  if (Modernizr[feature][subFeature] === false)
                  {
                      modernMsg.push("<tr><td>" + feature + "."+ subFeature + ": </td><td>" + Modernizr[feature][subFeature] + "</td></tr>");
                  }
              }
          }
      }

*/

      modernMsg = modernMsg.join("\n");

      if (modernMsg != "")
          modernMsg = "<br><table><tr><td colspan=2>Offline features according to Modernizer</td></tr>" + modernMsg + "</table>";

      if (error == 0) // Geen fouten
      {
          $("div.content").prepend("<h1 style=\"color:green\">Tests successful!</h1>"
                                 + "All tests were executed successfully.")
                          .addClass("successful");
      }
      else
      {
          $("div.content").prepend("<h1 style=\"color:red\">Aiai!</h1>"
                                 + "Something went wrong but this is most likely not your fault.<br>" + msg)
                          .addClass("aiai");
      }

<%
var allheaders = String(Request.ServerVariables("ALL_HTTP")).split("\n");
for (var i =0; i < allheaders.length; i++)
{
    if (allheaders[i].match(/^HTTP_COOKIE/))
    {
        allheaders.splice(i, 1)
    }
}
%>

      $("div.content").append("<table><tr><td>IP address: </td><td><%=ip%></td></tr>"
                            + "<tr><td>Screen resolution: </td><td>" + resWidth + "x" + resHeight + "</td></tr>"
                            + "<tr><td>Viewport resolution: </td><td>" + scrnWidth + "x" + scrnHeight + "</td></tr>"
                            + "<tr><td>Browser version: </td><td>" + navigator.userAgent + "</td></tr>"
                            + "<tr><td>Locale number: </td><td>" + (12345678.9).toLocaleString() + "</td></tr>"
                            + "<tr><td>Locale date: </td><td>" + (new Date()).toLocaleString() + "</td></tr>"
                            + "<tr><td>Locale list: </td><td>" + (['1', '2']).toLocaleString() + "</td></tr>"
                            + "</table>"
                            + modernMsg
                            + "HTTP Headers:<br><div style='margin-left:2em;font-size:0.8em;line-height:1.2em;'><%=safe.html(allheaders.join("\n"))%></div>"
                            + "<%=safe.jsstring(__DumpCollection(Session.Contents, { title: "Session", exclude: /ASPFIXATION|FACSESSIONID|RVT_TOKEN/i }))%>"
                            + "<tr><td>LCID: </td><td><%=Session.LCID%></td></tr>"
                            + "<br><span style='font-size:0.8em;'>Facilitor <%=(toISODateTimeString(new Date()))%></span>"
                            + "<br><span style='font-size:0.8em;'><%=safe.jsstring(HTTP.urlzelf())%></span>");
    });

  </script>

  <div class="content">
  </div>
</body>
</html><% ASPPAGE_END(); %>
