changeset 1:311ba0249340

added basic form to index.html
author Atul Varma <avarma@mozilla.com>
date Wed, 02 Jun 2010 19:36:27 -0700
parents 1df0b76e8076
children 9f612c24ac23
files static-files/app.js static-files/index.html
diffstat 2 files changed, 73 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/static-files/app.js	Wed Jun 02 18:34:41 2010 -0700
+++ b/static-files/app.js	Wed Jun 02 19:36:27 2010 -0700
@@ -1,14 +1,32 @@
+function jsonRequest(url, data, cb) {
+  var options = {
+    type: "POST",
+    url: url,
+    contentType: "application/json",
+    data: JSON.stringify(data),
+    dataType: "text/plain",
+    success: function(response) {
+      cb(JSON.parse(response));
+    }
+  };
+  jQuery.ajax(options);
+}
+
 $(window).ready(
   function() {
-    var options = {
-      type: "POST",
-      url: "/try",
-      contentType: "application/json",
-      data: JSON.stringify({url: "file:///users/avarma/documents/temp-jetpack-sdk"}),
-      dataType: "text/plain",
-      success: function(data) {
-        console.log(" YEA", data);
-      }
-    };
-    jQuery.ajax(options);
+    $("form").submit(
+      function(event) {
+        event.preventDefault();
+        jsonRequest(
+          "/try",
+          {url: $("#pull-url").val()},
+          function(data) {
+            if (data.success) {
+              $("#success").slideDown();
+            } else {
+              $("#failure .log").text(data.log);
+              $("#failure").slideDown();
+            }
+          });
+      });
   });
--- a/static-files/index.html	Wed Jun 02 18:34:41 2010 -0700
+++ b/static-files/index.html	Wed Jun 02 19:36:27 2010 -0700
@@ -1,5 +1,48 @@
+<!DOCTYPE HTML>
 <html>
-hi.
+<head>
+  <title>Bugzilla Easy Patch Generator</title>
+  <style>
+  body {
+    font-family: Helvetica Neue, sans-serif;
+    font-size: 10pt;
+  }
+
+  input {
+    border: 1px solid gray;
+  }
+
+  input[type=text] {
+    width: 40em;
+  }
+
+  #success, #failure {
+    display: none;
+  }
+
+  #failure .log {
+    color: red;
+    font-family: Monaco, monospace;
+    white-space: pre-wrap;
+  }
+  </style>
+</head>
+<body>
+<form>
+  <div>
+  URL of HG repository containing your changes:
+    <input id="pull-url" type="text"/>
+  </div>
+  <input type="submit">
+</form>
+<div id="success">
+  <p>Yay, we got a patch!</p>
+</div>
+<div id="failure">
+  <p>Alas, failure:</p>
+  <div class="log"></div>
+</div>
 <script src="jquery.js"></script>
 <script src="app.js"></script>
+</body>
 </html>