Mercurial > bugzilla-dashboard
comparison file-bug.js @ 17:4a698ea4be60
Added a really simple bug filing page w/ autocomplete for product/component.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Wed, 10 Mar 2010 12:39:14 -0800 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
16:c4de72b56b3e | 17:4a698ea4be60 |
---|---|
1 $(window).ready( | |
2 function() { | |
3 const EM_DASH = "\u2014"; | |
4 | |
5 var cache = buildCache("#form-cache .data"); | |
6 var config = cache.get("configuration"); | |
7 var categories; | |
8 var queuedRespond; | |
9 | |
10 function buildCategories() { | |
11 categories = []; | |
12 for (product in config.product) | |
13 for (component in config.product[product].component) | |
14 categories.push(product + EM_DASH + component); | |
15 } | |
16 | |
17 var categoryOptions = { | |
18 source: function(request, response) { | |
19 function respond() { | |
20 queuedRespond = null; | |
21 | |
22 var suggs = []; | |
23 var terms = request.term.split(" "); | |
24 | |
25 if (!categories) | |
26 buildCategories(); | |
27 | |
28 categories.forEach( | |
29 function(category) { | |
30 for (var i = 0; i < terms.length; i++) | |
31 if (!category.match(terms[i], "i")) | |
32 return; | |
33 suggs.push(category); | |
34 }); | |
35 | |
36 response(suggs); | |
37 }; | |
38 | |
39 if (!config) | |
40 queuedRespond = respond; | |
41 else | |
42 respond(); | |
43 } | |
44 }; | |
45 | |
46 $("input#category").autocomplete(categoryOptions); | |
47 $("#file-bug").submit( | |
48 function(event) { | |
49 event.preventDefault(); | |
50 var parts = $("input#category").val().split(EM_DASH); | |
51 window.open(Bugzilla.BASE_UI_URL + "/enter_bug.cgi?" + | |
52 "product=" + encodeURI(parts[0]) + "&" + | |
53 "component=" + encodeURI(parts[1])); | |
54 }); | |
55 | |
56 Bugzilla.ajax({url: "/configuration", | |
57 success: function(result) { | |
58 config = result; | |
59 cache.set("configuration", result); | |
60 if (queuedRespond) | |
61 queuedRespond(); | |
62 }}); | |
63 }); |