OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) 2011 Apple Inc. All rights reserved. | |
3 * | |
4 * Redistribution and use in source and binary forms, with or without | |
5 * modification, are permitted provided that the following conditions | |
6 * are met: | |
7 * 1. Redistributions of source code must retain the above copyright | |
8 * notice, this list of conditions and the following disclaimer. | |
9 * 2. Redistributions in binary form must reproduce the above copyright | |
10 * notice, this list of conditions and the following disclaimer in the | |
11 * documentation and/or other materials provided with the distribution. | |
12 * | |
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | |
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | |
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | |
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
23 * THE POSSIBILITY OF SUCH DAMAGE. | |
24 */ | |
25 | |
26 var bugzilla = bugzilla || {}; | |
27 | |
28 (function() { | |
29 | |
30 var kOpenStatuses = { | |
31 UNCONFIRMED: true, | |
32 NEW: true, | |
33 ASSIGNED: true, | |
34 REOPENED: true, | |
35 }; | |
36 | |
37 function createDetachedFragment(htmlFragment) | |
38 { | |
39 // Step 1: Create a detached Document to perform the parsing. | |
40 var detachedDocument = document.implementation.createHTMLDocument(); | |
41 | |
42 // Step 2: Create a detached Element associated with the detached Document. | |
43 var container = detachedDocument.createElement('div'); | |
44 | |
45 // Step 3: Pull the trigger. | |
46 container.innerHTML = htmlFragment; | |
47 return container; | |
48 } | |
49 | |
50 var g_searchCache = new base.AsynchronousCache(function(query, callback) { | |
51 var url = config.kBugzillaURL + '/buglist.cgi?' + $.param({ | |
52 ctype: 'rss', | |
53 order: 'bugs.bug_id desc', | |
54 quicksearch: query, | |
55 }); | |
56 | |
57 net.get(url, function(responseXML) { | |
58 var entries = responseXML.getElementsByTagName('entry'); | |
59 var results = Array.prototype.map.call(entries, function(entry) { | |
60 var htmlFragment = entry.getElementsByTagName('summary')[0].textCont
ent; | |
61 var fragment = createDetachedFragment(htmlFragment); | |
62 var statusRow = fragment.querySelector('tr.bz_feed_bug_status'); | |
63 return { | |
64 title: entry.getElementsByTagName('title')[0].textContent, | |
65 url: entry.getElementsByTagName('id')[0].textContent, | |
66 status: statusRow.cells[1].textContent, | |
67 }; | |
68 }); | |
69 callback(results); | |
70 }); | |
71 }); | |
72 | |
73 bugzilla.bugURL = function(bugNumber) | |
74 { | |
75 return config.kBugzillaURL + '/show_bug.cgi?id=' + bugNumber; | |
76 }; | |
77 | |
78 bugzilla.quickSearch = function(query, callback) | |
79 { | |
80 g_searchCache.get(query, callback); | |
81 }; | |
82 | |
83 bugzilla.isOpenStatus = function(status) | |
84 { | |
85 return status in kOpenStatuses; | |
86 }; | |
87 | |
88 // This value is built-in to all Bugzilla installations. See <http://webkit.org/
b/61660>. | |
89 bugzilla.kMaximumBugTitleLength = 255; | |
90 | |
91 })(); | |
OLD | NEW |