Click here to Skip to main content
15,900,477 members
Home / Discussions / Web Development
   

Web Development

 
AnswerRe: PHP4.3 Mod, coloring table rows Pin
Richard Deeming1-Dec-20 21:55
mveRichard Deeming1-Dec-20 21:55 
GeneralRe: PHP4.3 Mod, coloring table rows Pin
jkirkerx2-Dec-20 8:30
professionaljkirkerx2-Dec-20 8:30 
QuestionHow to insert roles in php and mysql? Pin
Nicolas Veloso16-Nov-20 6:04
Nicolas Veloso16-Nov-20 6:04 
SuggestionRe: How to insert roles in php and mysql? Pin
Richard Deeming16-Nov-20 21:51
mveRichard Deeming16-Nov-20 21:51 
QuestionBlazor SPA Pin
Super Lloyd16-Nov-20 1:26
Super Lloyd16-Nov-20 1:26 
QuestionDesign questions about asp.net core website and asp.net core webapi Pin
instantmaker13-Nov-20 9:04
instantmaker13-Nov-20 9:04 
AnswerRe: Design questions about asp.net core website and asp.net core webapi Pin
Afzaal Ahmad Zeeshan14-Nov-20 1:50
professionalAfzaal Ahmad Zeeshan14-Nov-20 1:50 
GeneralRe: Design questions about asp.net core website and asp.net core webapi Pin
instantmaker14-Nov-20 2:49
instantmaker14-Nov-20 2:49 
GeneralRe: Design questions about asp.net core website and asp.net core webapi Pin
Afzaal Ahmad Zeeshan14-Nov-20 3:17
professionalAfzaal Ahmad Zeeshan14-Nov-20 3:17 
GeneralRe: Design questions about asp.net core website and asp.net core webapi Pin
instantmaker16-Nov-20 13:03
instantmaker16-Nov-20 13:03 
AnswerRe: Design questions about asp.net core website and asp.net core webapi Pin
Leif Simon Goodwin22-Dec-20 7:17
Leif Simon Goodwin22-Dec-20 7:17 
GeneralRe: Design questions about asp.net core website and asp.net core webapi Pin
instantmaker22-Dec-20 7:34
instantmaker22-Dec-20 7:34 
GeneralRe: Design questions about asp.net core website and asp.net core webapi Pin
Leif Simon Goodwin22-Dec-20 9:07
Leif Simon Goodwin22-Dec-20 9:07 
GeneralRe: Design questions about asp.net core website and asp.net core webapi Pin
instantmaker22-Dec-20 10:39
instantmaker22-Dec-20 10:39 
QuestionDesign question with asp.net core and asp.net core api Pin
instantmaker13-Nov-20 6:18
instantmaker13-Nov-20 6:18 
QuestionI keep getting a “Call to undefined function..” error displaying Pin
IAmSirAskAlot9-Nov-20 18:25
IAmSirAskAlot9-Nov-20 18:25 
QuestionWeb API Deserialization Problem Pin
Kevin Marois9-Nov-20 8:04
professionalKevin Marois9-Nov-20 8:04 
AnswerRe: Web API Deserialization Problem Pin
Richard Deeming9-Nov-20 22:20
mveRichard Deeming9-Nov-20 22:20 
GeneralRe: Web API Deserialization Problem Pin
Kevin Marois10-Nov-20 7:18
professionalKevin Marois10-Nov-20 7:18 
GeneralRe: Web API Deserialization Problem Pin
Richard Deeming10-Nov-20 21:41
mveRichard Deeming10-Nov-20 21:41 
GeneralRe: Web API Deserialization Problem Pin
Kevin Marois11-Nov-20 7:16
professionalKevin Marois11-Nov-20 7:16 
GeneralRe: Web API Deserialization Problem Pin
Kevin Marois11-Nov-20 7:54
professionalKevin Marois11-Nov-20 7:54 
GeneralRe: Web API Deserialization Problem Pin
Richard Deeming11-Nov-20 22:42
mveRichard Deeming11-Nov-20 22:42 
GeneralRe: Web API Deserialization Problem Pin
Kevin Marois12-Nov-20 6:49
professionalKevin Marois12-Nov-20 6:49 
Question[Solved] Firefox storage get undefined Pin
Valentinor2-Nov-20 21:56
Valentinor2-Nov-20 21:56 
I'm trying to make an add-on for Firefox that will store some values which will be used later on in an contextMenus.

Getting the value and setting a new one in options_ui works just fine. The problem is when I try to get the value by using the new contextMenu I am adding in background.js. The new contextMenu it is added, the window for saving the file appers, but the value from storage returns undefined. Can anyone help me with this, point me where I'm doing something wrong?
I am setting a new value before using the contextMenu.

background.js
var gettingValue = browser.storage.sync.get("number");
gettingValue.then(item =>{
	browser.contextMenus.create({
		id: "save-image",
		title: "Save image",
		contexts: ["image"],
	});
	
	browser.contextMenus.onClicked.addListener((info, tab) => {
		if (info.menuItemId === "save-image") {
			let name = "Initial";
			if(item) {
				name = item.number;
			} else {
				name = "Number not found";
			}
			browser.downloads.download({
				url : info.srcUrl,
				filename : name + ".jpg",
				saveAs : true
			});
		}
	});
});


options.js
function saveOptions(e) {
	e.preventDefault();
	browser.storage.sync.set({
		number: document.querySelector("#newNumber").value
	});
}

function restoreOptions() {
	let getting = browser.storage.sync.get("number");
	getting.then(setCurrentChoice, onError);
	
	function setCurrentChoice(result) {
		document.querySelector("#newNumber").value = result.number || "No number was set";
	}

	function onError(error) {
		console.log(`Error: ${error}`);
	}
}

document.addEventListener("DOMContentLoaded", restoreOptions);
document.querySelector("form").addEventListener("submit", saveOptions);


options.html
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
  </head>
  <body>
    <form>
        <label>Number input: <input type="text" id="newNumber" ></label>
        <button type="submit">Save</button>
    </form>
    <script src="options.js"></script>
  </body>
</html>


Permissions in manifest
"permissions": [
    "contextMenus",
    "downloads",
    "storage"
],


modified 4-Nov-20 9:02am.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.