Reputation: 189
Please be nice as I am still learning code in JavaScript.
I am working on a FireFox Add-on and would like to know how I could call a function from an external .js file.
I have a main.js file with the following code:
var self = require("sdk/self");
var pageMod = require("sdk/page-mod");
//var notification = require("notification-box");
//var notification = require("notification-box").NotificationBox({
//'value': 'important-message',
//'label': 'Secure Connection Established',
//'priority': 'WARNING_HIGH',
//'image': self.data.url("secure.png"),
//});
pageMod.PageMod({
include: "https://*",
var notification = require("notification-box").NotificationBox({
'value': 'important-message',
'label': 'Secure Connection Established',
'priority': 'WARNING_HIGH',
'image': self.data.url("secure.png"),
});
The NotificationBox function calls another external file called notification-box.js which its purpose is to show a notification bar at the top of the page.
The purpose of the above code is to show a notification if the the user visits a HTTPS page.
When I run the above code I get the error "missing : after property list"
Upvotes: 0
Views: 94
Reputation: 37228
You cant stick a var in the middle of an object:
pageMod.PageMod({
include: "https://*",
notification: require("notification-box").NotificationBox({
'value': 'important-message',
'label': 'Secure Connection Established',
'priority': 'WARNING_HIGH',
'image': self.data.url("secure.png"),
}),
'some_other_key': 'some other value'
});
Upvotes: 1
Reputation: 93
'image': self.data.url("secure.png"),
Remove ,
and it should be fine
Upvotes: 0