Mercurial > bugzilla-dashboard
view js/bugzilla.js @ 19:42d621a98c93
Some CSS fixes, added instructions for bug-filer.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Wed, 10 Mar 2010 12:56:16 -0800 |
parents | b2e0ea0178fb |
children | 51c1829956d9 |
line wrap: on
line source
var Bugzilla = { BASE_URL: "https://api-dev.bugzilla.mozilla.org/latest", BASE_UI_URL: "https://bugzilla.mozilla.org", DEFAULT_OPTIONS: { method: "GET" }, getShowBugURL: function Bugzilla_getShowBugURL(id) { return this.BASE_UI_URL + "/show_bug.cgi?id=" + id; }, queryString: function Bugzilla_queryString(data) { var parts = []; for (name in data) { var values = data[name]; if (!values.forEach) values = [values]; values.forEach( function(value) { parts.push(encodeURI(name) + "=" + encodeURI(value)); }); } return parts.join("&"); }, ajax: function Bugzilla_ajax(options) { var newOptions = {__proto__: this.DEFAULT_OPTIONS}; for (name in options) newOptions[name] = options[name]; options = newOptions; function onLoad() { options.success(JSON.parse(xhr.responseText)); } var xhr = new XMLHttpRequest(); var url = this.BASE_URL + options.url; if (options.data) url = url + "?" + this.queryString(options.data); xhr.open(options.method, url); xhr.setRequestHeader("Accept", "application/json"); xhr.setRequestHeader("Content-Type", "application/json"); xhr.addEventListener("load", onLoad, false); xhr.send(null); return xhr; }, getBug: function Bugzilla_getBug(id, cb) { this.ajax({url: "/bug/" + id, success: cb}); }, search: function Bugzilla_search(query, cb) { this.ajax({url: "/bug", data: query, success: cb}); } };