Example taken from activity launcher created by alexp2_ad
code:
function OnGetScriptMenu(nLocation){
var ScriptMenu = "<ScriptMenu>\n";
var submenus = new Array();
for(i=0;i<Activities.length;i++){
var found = false;
for(j=0;j<submenus.length;j++){
if(submenus[j][0] == Activities[i][3]){ submenus[j][submenus[j].length] = Activities[i]; found = true; }
}
if(!found){
var temp = submenus.length;
submenus[temp] = new Array();
submenus[temp][0] = Activities[i][3];
submenus[temp][1] = Activities[i];
}
}
for(i=0;i<submenus.length;i++){
ScriptMenu+="\t<SubMenu Label=\""+submenus[i][0]+"\">";
for(j=1;j<submenus[i].length;j++){
if(submenus[i][j][2]){
ScriptMenu+="\t\t<MenuEntry Id=\"Activity-"+submenus[i][j][1]+"\">"+MakeXmlFriendly(submenus[i][j][0])+"</MenuEntry>\n";
}
}
ScriptMenu+="\t</SubMenu>";
}
ScriptMenu+="\t<Separator/>\n";
ScriptMenu+="\t<MenuEntry Id=\"Configure\">Configure</MenuEntry>\n";
ScriptMenu+="\t<MenuEntry Id=\"Default\">Restore Default Activity List</MenuEntry>\n";
ScriptMenu+="\t<MenuEntry Id=\"About\">About This Script</MenuEntry>\n";
ScriptMenu+= "</ScriptMenu>";
return ScriptMenu;
}