2
* Copyright (C) 2011 Apple Inc. All rights reserved.
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions
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.
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.
26
var bugzilla = bugzilla || {};
37
function createDetachedFragment(htmlFragment)
39
// Step 1: Create a detached Document to perform the parsing.
40
var detachedDocument = document.implementation.createHTMLDocument();
42
// Step 2: Create a detached Element associated with the detached Document.
43
var container = detachedDocument.createElement('div');
45
// Step 3: Pull the trigger.
46
container.innerHTML = htmlFragment;
50
var g_searchCache = new base.AsynchronousCache(function(query, callback) {
51
var url = config.kBugzillaURL + '/buglist.cgi?' + $.param({
53
order: 'bugs.bug_id desc',
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].textContent;
61
var fragment = createDetachedFragment(htmlFragment);
62
var statusRow = fragment.querySelector('tr.bz_feed_bug_status');
64
title: entry.getElementsByTagName('title')[0].textContent,
65
url: entry.getElementsByTagName('id')[0].textContent,
66
status: statusRow.cells[1].textContent,
73
bugzilla.bugURL = function(bugNumber)
75
return config.kBugzillaURL + '/show_bug.cgi?id=' + bugNumber;
78
bugzilla.quickSearch = function(query, callback)
80
g_searchCache.get(query, callback);
83
bugzilla.isOpenStatus = function(status)
85
return status in kOpenStatuses;
88
// This value is built-in to all Bugzilla installations. See <http://webkit.org/b/61660>.
89
bugzilla.kMaximumBugTitleLength = 255;