示例#1
0
 static void HandleLedTargetHtml(RequestHandlerContext context)
 {
     string requestUri = context.BuildRequestUri("/led/target");
     var script =
         @"<html>
             <head>
               <script type=""text/javascript"">
                 var r;
                 try {
                   r = new XMLHttpRequest();
                 } catch (e) {
                   r = new ActiveXObject('Microsoft.XMLHTTP');
                 }
                 function put (content) {
                   r.open('PUT', '" + requestUri + @"');
                   r.setRequestHeader('Content-Type', 'text/plain');
                   r.send(content);
                 }
               </script>
             </head>
             <body>
               <p>
                 <input type=""button"" value=""Switch LED on""
                   onclick=""put('true')""/>
                 <input type=""button"" value=""Switch LED off""
                   onclick=""put('false')""/>
                 <input type=""button"" value=""Bah""
                   onclick=""put('bah')""/>
               </p>
             </body>
          </html>";
     context.SetResponse(script, "text/html");
 }
示例#2
0
 static void HandleBlinkTargetHtml(RequestHandlerContext context)
 {
     string requestUri =
         context.BuildRequestUri("/blinkingPeriod/target");
     var script =
         @"<html>
             <head>
               <script type=""text/javascript"">
                 var r;
                 try {
                   r = new XMLHttpRequest();
                 } catch (e) {
                   r = new ActiveXObject('Microsoft.XMLHTTP');
                 }
                 function put (content) {
                   r.open('PUT', '" + requestUri + @"');
                   r.setRequestHeader(""Content-Type"", ""text/plain"");
                   r.send(document.getElementById(""period"").value);
                 }
               </script>
             </head>
             <body>
               <p>
                 <input type=""text"" value=""500"" id=""period"">
                 <input
                   type=""button"" value=""Set"" onclick=""put()""/>
               </p>
             </body>
           </html>";
     context.SetResponse(script, "text/html");
 }