mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 948897 - Move inline scripts and styles into separate file for mobile/android/chrome/content/aboutFeedback.xhtml. r=mbrubeck
This commit is contained in:
parent
2c70257b82
commit
9739090d03
116
mobile/android/chrome/content/aboutFeedback.js
Normal file
116
mobile/android/chrome/content/aboutFeedback.js
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
let Cc = Components.classes;
|
||||||
|
let Ci = Components.interfaces;
|
||||||
|
let Cu = Components.utils;
|
||||||
|
|
||||||
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
|
function dump(a) {
|
||||||
|
Services.console.logStringMessage(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
function sendMessageToJava(aMessage) {
|
||||||
|
Services.androidBridge.handleGeckoMessage(JSON.stringify(aMessage));
|
||||||
|
}
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
let sumoLink = Services.urlFormatter.formatURLPref("app.support.baseURL");
|
||||||
|
document.getElementById("sumo-link").href = sumoLink;
|
||||||
|
|
||||||
|
window.addEventListener("popstate", function (aEvent) {
|
||||||
|
updateActiveSection(aEvent.state ? aEvent.state.section : "intro")
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
// Fill "Last visited site" input with most recent history entry URL.
|
||||||
|
Services.obs.addObserver(function observer(aSubject, aTopic, aData) {
|
||||||
|
document.getElementById("last-url").value = aData;
|
||||||
|
}, "Feedback:LastUrl", false);
|
||||||
|
|
||||||
|
sendMessageToJava({ type: "Feedback:LastUrl" });
|
||||||
|
}
|
||||||
|
|
||||||
|
function uninit() {
|
||||||
|
Services.obs.removeObserver(this, "Feedback:LastUrl");
|
||||||
|
}
|
||||||
|
|
||||||
|
function switchSection(aSection) {
|
||||||
|
history.pushState({ section: aSection }, aSection);
|
||||||
|
updateActiveSection(aSection);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateActiveSection(aSection) {
|
||||||
|
document.querySelector("section[active]").removeAttribute("active");
|
||||||
|
document.getElementById(aSection).setAttribute("active", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function openPlayStore() {
|
||||||
|
sendMessageToJava({ type: "Feedback:OpenPlayStore" });
|
||||||
|
|
||||||
|
window.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
function maybeLater() {
|
||||||
|
window.close();
|
||||||
|
|
||||||
|
sendMessageToJava({ type: "Feedback:MaybeLater" });
|
||||||
|
}
|
||||||
|
|
||||||
|
function sendFeedback(aEvent) {
|
||||||
|
// Prevent the page from reloading.
|
||||||
|
aEvent.preventDefault();
|
||||||
|
|
||||||
|
let section = history.state.section;
|
||||||
|
|
||||||
|
// Sanity check.
|
||||||
|
if (section != "sad") {
|
||||||
|
Cu.reportError("Trying to send feedback from an invalid section: " + section);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let sectionElement = document.getElementById(section);
|
||||||
|
let descriptionElement = sectionElement.querySelector(".description");
|
||||||
|
|
||||||
|
// Bail if the description value isn't valid. HTML5 form validation will take care
|
||||||
|
// of showing an error message for us.
|
||||||
|
if (!descriptionElement.validity.valid)
|
||||||
|
return;
|
||||||
|
|
||||||
|
let data = new FormData();
|
||||||
|
data.append("description", descriptionElement.value);
|
||||||
|
data.append("_type", 2);
|
||||||
|
|
||||||
|
let urlElement = document.getElementById("last-url");
|
||||||
|
// Bail if the URL value isn't valid. HTML5 form validation will take care
|
||||||
|
// of showing an error message for us.
|
||||||
|
if (!urlElement.validity.valid)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Only send a URL string if the user provided one.
|
||||||
|
if (urlElement.value) {
|
||||||
|
data.append("add_url", true);
|
||||||
|
data.append("url", urlElement.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
let sysInfo = Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2);
|
||||||
|
data.append("device", sysInfo.get("device"));
|
||||||
|
data.append("manufacturer", sysInfo.get("manufacturer"));
|
||||||
|
|
||||||
|
let req = new XMLHttpRequest();
|
||||||
|
req.addEventListener("error", function() {
|
||||||
|
Cu.reportError("Error sending feedback to input.mozilla.org: " + req.statusText);
|
||||||
|
}, false);
|
||||||
|
req.addEventListener("abort", function() {
|
||||||
|
Cu.reportError("Aborted sending feedback to input.mozilla.org: " + req.statusText);
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
let postURL = Services.urlFormatter.formatURLPref("app.feedback.postURL");
|
||||||
|
req.open("POST", postURL, true);
|
||||||
|
req.send(data);
|
||||||
|
|
||||||
|
switchSection("thanks-" + section);
|
||||||
|
}
|
@ -74,118 +74,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<script type="application/javascript;version=1.8"><![CDATA[
|
<script type="application/javascript;version=1.8" src="chrome://browser/content/aboutFeedback.js"></script>
|
||||||
let Cc = Components.classes;
|
|
||||||
let Ci = Components.interfaces;
|
|
||||||
let Cu = Components.utils;
|
|
||||||
|
|
||||||
Cu.import("resource://gre/modules/Services.jsm");
|
|
||||||
|
|
||||||
function dump(a) {
|
|
||||||
Services.console.logStringMessage(a);
|
|
||||||
}
|
|
||||||
|
|
||||||
function sendMessageToJava(aMessage) {
|
|
||||||
Services.androidBridge.handleGeckoMessage(JSON.stringify(aMessage));
|
|
||||||
}
|
|
||||||
|
|
||||||
function init() {
|
|
||||||
let sumoLink = Services.urlFormatter.formatURLPref("app.support.baseURL");
|
|
||||||
document.getElementById("sumo-link").href = sumoLink;
|
|
||||||
|
|
||||||
window.addEventListener("popstate", function (aEvent) {
|
|
||||||
updateActiveSection(aEvent.state ? aEvent.state.section : "intro")
|
|
||||||
}, false);
|
|
||||||
|
|
||||||
// Fill "Last visited site" input with most recent history entry URL.
|
|
||||||
Services.obs.addObserver(function observer(aSubject, aTopic, aData) {
|
|
||||||
document.getElementById("last-url").value = aData;
|
|
||||||
}, "Feedback:LastUrl", false);
|
|
||||||
|
|
||||||
sendMessageToJava({ type: "Feedback:LastUrl" });
|
|
||||||
}
|
|
||||||
|
|
||||||
function uninit() {
|
|
||||||
Services.obs.removeObserver(this, "Feedback:LastUrl");
|
|
||||||
}
|
|
||||||
|
|
||||||
function switchSection(aSection) {
|
|
||||||
history.pushState({ section: aSection }, aSection);
|
|
||||||
updateActiveSection(aSection);
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateActiveSection(aSection) {
|
|
||||||
document.querySelector("section[active]").removeAttribute("active");
|
|
||||||
document.getElementById(aSection).setAttribute("active", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function openPlayStore() {
|
|
||||||
sendMessageToJava({ type: "Feedback:OpenPlayStore" });
|
|
||||||
|
|
||||||
window.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
function maybeLater() {
|
|
||||||
window.close();
|
|
||||||
|
|
||||||
sendMessageToJava({ type: "Feedback:MaybeLater" });
|
|
||||||
}
|
|
||||||
|
|
||||||
function sendFeedback(aEvent) {
|
|
||||||
// Prevent the page from reloading.
|
|
||||||
aEvent.preventDefault();
|
|
||||||
|
|
||||||
let section = history.state.section;
|
|
||||||
|
|
||||||
// Sanity check.
|
|
||||||
if (section != "sad") {
|
|
||||||
Cu.reportError("Trying to send feedback from an invalid section: " + section);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let sectionElement = document.getElementById(section);
|
|
||||||
let descriptionElement = sectionElement.querySelector(".description");
|
|
||||||
|
|
||||||
// Bail if the description value isn't valid. HTML5 form validation will take care
|
|
||||||
// of showing an error message for us.
|
|
||||||
if (!descriptionElement.validity.valid)
|
|
||||||
return;
|
|
||||||
|
|
||||||
let data = new FormData();
|
|
||||||
data.append("description", descriptionElement.value);
|
|
||||||
data.append("_type", 2);
|
|
||||||
|
|
||||||
let urlElement = document.getElementById("last-url");
|
|
||||||
// Bail if the URL value isn't valid. HTML5 form validation will take care
|
|
||||||
// of showing an error message for us.
|
|
||||||
if (!urlElement.validity.valid)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Only send a URL string if the user provided one.
|
|
||||||
if (urlElement.value) {
|
|
||||||
data.append("add_url", true);
|
|
||||||
data.append("url", urlElement.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
let sysInfo = Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2);
|
|
||||||
data.append("device", sysInfo.get("device"));
|
|
||||||
data.append("manufacturer", sysInfo.get("manufacturer"));
|
|
||||||
|
|
||||||
let req = new XMLHttpRequest();
|
|
||||||
req.addEventListener("error", function() {
|
|
||||||
Cu.reportError("Error sending feedback to input.mozilla.org: " + req.statusText);
|
|
||||||
}, false);
|
|
||||||
req.addEventListener("abort", function() {
|
|
||||||
Cu.reportError("Aborted sending feedback to input.mozilla.org: " + req.statusText);
|
|
||||||
}, false);
|
|
||||||
|
|
||||||
let postURL = Services.urlFormatter.formatURLPref("app.feedback.postURL");
|
|
||||||
req.open("POST", postURL, true);
|
|
||||||
req.send(data);
|
|
||||||
|
|
||||||
switchSection("thanks-" + section);
|
|
||||||
}
|
|
||||||
]]></script>
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -16,6 +16,7 @@ chrome.jar:
|
|||||||
content/aboutDownloads.xhtml (content/aboutDownloads.xhtml)
|
content/aboutDownloads.xhtml (content/aboutDownloads.xhtml)
|
||||||
content/aboutDownloads.js (content/aboutDownloads.js)
|
content/aboutDownloads.js (content/aboutDownloads.js)
|
||||||
content/aboutFeedback.xhtml (content/aboutFeedback.xhtml)
|
content/aboutFeedback.xhtml (content/aboutFeedback.xhtml)
|
||||||
|
content/aboutFeedback.js (content/aboutFeedback.js)
|
||||||
content/aboutPrivateBrowsing.xhtml (content/aboutPrivateBrowsing.xhtml)
|
content/aboutPrivateBrowsing.xhtml (content/aboutPrivateBrowsing.xhtml)
|
||||||
content/aboutReader.html (content/aboutReader.html)
|
content/aboutReader.html (content/aboutReader.html)
|
||||||
content/aboutReader.js (content/aboutReader.js)
|
content/aboutReader.js (content/aboutReader.js)
|
||||||
|
Loading…
Reference in New Issue
Block a user