Get current active theme in #JetPack

Categories Jetpack, Mozilla, Technologies

I need to know ID of current active Firefox Persona in order to get the textcolor value from users.pref to be able to display different icons on my widget, because I don’t wont to display blue icon on blue background.

This tutorial shows:

      How to access Addon Manager from a JetPack script
      How to get all Addons based on their type [extension, theme, locale, multipackage]
      How to get Active Persona’s ID

It’s a lot for such short script, isn’t it?


//we need this component
const {Cu} = require("chrome");

//import AddonManager
var AddonManager = Cu.import("resource://gre/modules/AddonManager.jsm")
                              .AddonManager;

//We need to get all Addons that are with type 'theme'
var types =['theme'];

//get all themes
var currentTheme = AddonManager
                          .getAddonsByTypes(types,function(addons){
	//Firefox always shows active theme as 0 element (not sure, need confirmation)
       
       //get the ID of the active theme/persona
	var tid=addons[0].id.toString();
      
        //show it in console 
        console.log("Current Id:"+ tid);
});

Unfortunatelly textcolor value is not part of the object (yet) and the only way to find it is to check with this id (tid) in prefs.js

#Javascript survey results and #jetpack

Categories Jetpack, Mozilla, Technologies

Some time ago I have posted a call for javascript hackers to fill a survey in order to help me to create a better world.

0. Here are the results:

What OS you are using while hacking the code?

Gnu/Linux 239 40%
MS Windows 236 39%
MacOS 291 48%
Other 7 1%

What’s your location?

Europe 394 65%
South America 7 1%
North America 161 27%
Asia 23 4%
Africa 1 0%
Australia 8 1%
New Zealand 3 0%
Moon :) 17 3%
Other 15 2%
People may select more than one checkbox, so percentages may add up to more than 100%.

What is your IDE?

This was an input filed:
Aptana, Eclipse, TextMate,BBedit,Coda, Dreamweaver and more as you can see here.

Why I need that?

I am part of Mozilla’s JetPack community and I am researching how to make our life easier by creating plugins and snippets (maybe debuggers) for most popular IDE’s in the #JS world in order to allow rapid development of Firefox Addons using AddonSDK (a.k.a JetPack).

You can see my prototype here and version 0.2 here.

Can I help?

Of course you can. If you know how to write plugins for any IDE or if you have any other idea how we can make our life easier – please drop me a note here or on identi.ca nor twitter

JetPack: How to add a button to a webpage + events

Categories Jetpack, Kindle, Mozilla, Open Technologies, Technologies

This is a Jetpack example for beginners that shows:

0. How to add a simple DOM element – button to a webpage using Mozilla Addon SDK (Jetpack)
1. How to attach an event
2. And how to handle it.

If you want to try it – go here click on Test icon and when it loads, visit: http://talkweb.eu/labs/jetpack/button.html or use your own SDK


var buttonScript = [
'var butt = document.createElement("button");', //define button element
'var btext = document.createTextNode("Click me");', //define the text
'butt.appendChild(btext);', //attach text to the button
'butt.addEventListener("click", function(){document.bgColor="red"} , false)', //handle onclick event
'document.getElementById("test").appendChild(butt);' //put the button on the page
];
 

var pageButton = require("page-mod").PageMod({
include: 'http://talkweb.eu/labs/jetpack/button.html', // this script will works only on this website
contentScriptWhen: 'ready',
contentScript: buttonScript
});

Is it (Mozilla) Jetpack still confusing?

Categories Jetpack, Mozilla, Technologies

If you want to create an unique technology maybe you should to create an unique name or create an unique strategy to connect the term with your technology and leave others alone :)

Currently there are a lot of JetPack terms related to technology:

0. JetPack me – Great, great WordPress plugin
1. Microsoft JetPack
2. A game
3. An AD system
4. Mozilla JetPack

Do you think It’s a bit still confusing for a developer who is looking for some help to find it?

Are you interested in learning something new and cool?

Categories Community Management, Drumbeat, Jetpack, Mozilla, Open Technologies, Technologies

Well, why don’t you join me at P2PU in a Mozilla JetPack course. The main idea of P2PU is to give the opportunity to anyone to teach anyone to a certain topic.

It doesn’t matter if you are beginner or if you are Mozilla JetPack guru – P2PU course perfect place for you to learn or to share knowledge.

If you are part of Facebook, please join the JetHack group also.