Bug 623679 - Add unique classes to fields prefilled by desktop and mobile feedback add-ons [r=vingtetun]

This commit is contained in:
Mark Finkle 2011-01-07 10:25:27 -05:00
parent d051a2c8fd
commit 3248037484
2 changed files with 35 additions and 13 deletions

View File

@ -1,14 +1,36 @@
function populateFeedback(aMessage) {
content.document.getElementById("id_url").value = aMessage.json.referrer;
let json = aMessage.json;
let device = content.document.getElementById("id_device");
if (device)
device.value = aMessage.json.device || "";
let referrer = json.referrer;
let URLElem = content.document.getElementById("id_url");
if (URLElem)
URLElem.value = referrer;
let manufacturer = content.document.getElementById("id_manufacturer");
if (manufacturer)
manufacturer.value = aMessage.json.manufacturer || "";
let URLElems = content.document.getElementsByClassName("url");
URLElems.forEach(function(aElement) {
aElement.value = referrer;
});
let device = json.device || "";
let deviceElem = content.document.getElementById("id_device");
if (deviceElem)
deviceElem.value = device;
let deviceElems = content.document.getElementsByClassName("device");
deviceElems.forEach(function(aElement) {
aElement.value = device;
});
let manufacturer = json.manufacturer || "";
let manufacturerElem = content.document.getElementById("id_manufacturer");
if (manufacturerElem)
manufacturerElem.value = manufacturer;
let manufacturerElems = content.document.getElementsByClassName("manufacturer");
manufacturerElems.forEach(function(aElement) {
aElement.value = manufacturer;
});
}
addMessageListener("Feedback:InitPage", populateFeedback);

View File

@ -41,14 +41,14 @@ var Feedback = {
_manufacturer: "",
init: function(aEvent) {
let appInfo = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULAppInfo);
document.getElementById("feedback-about").setAttribute("desc", appInfo.version);
// A simple frame script to fill in the referrer page and device info
messageManager.loadFrameScript("chrome://feedback/content/content.js", true);
// Delay the widget initialization during startup.
window.addEventListener("UIReadyDelayed", function(aEvent) {
let appInfo = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULAppInfo);
document.getElementById("feedback-about").setAttribute("desc", appInfo.version);
// A simple frame script to fill in the referrer page and device info
messageManager.loadFrameScript("chrome://feedback/content/content.js", true);
window.removeEventListener(aEvent.type, arguments.callee, false);
document.getElementById("feedback-container").hidden = false;