Code Monkey home page Code Monkey logo

Comments (1)

gopikrish2000 avatar gopikrish2000 commented on August 19, 2024

Did a lot of analysis and fixed the issue myself . I think it can be done without using two dimensional array but getting some error on doing so. Any how finally did it .The below is the code to display popup of the favorite url's by just modifying the URLs constant.

// add links which u want it below, give a space can provide alias for the url
// if alias is not given then it will take appropriate word based on the url.
const URLs = [
"http://www.cricbuzz.com/ CB",
"http://www.cricinfo.com/",
"http://www.gmail.com/ ",
"http://torrentz.eu/ torrents",
"http://www.greatandhra.com/ GA"
];

var impWords = [ ]; // this is for getting the substring of the URLs for display in popups
//if the url doesn't contain a '.' then it will show favourite site with index in the display of popups
var fulltable = [[],]; // two dimentional array acts like dictionary ; add for attribute list
function init() {
for(i=0;i<URLs.length;i++) {
// initilize the keyWords for display between two dots in the url.
impWords[i] = URLs[i].indexOf(".")>0?URLs[i].substring(URLs[i].indexOf(".")+1,URLs[i].lastIndexOf(".")):URLs[i];
if((URLs[i].indexOf(".") == URLs[i].lastIndexOf(".")) && URLs[i].indexOf(".") != -1 ) { // handling only one '.'
impWords[i] = URLs[i].substring(7,URLs[i].lastIndexOf("."));
}
var url = URLs[i];
if(url.indexOf(" ")> 0) {
url = url.substring(url.indexOf(" ")+1);
impWords[i] = url.length>0?url:impWords[i];
}
//initiliaze fulltable with url , value for dictionary
fulltable[i] = [URLs[i],i];
}
}
FireGestures.API_loadFavSite = function(w) {
var url = URLs[w];
if(url.indexOf(" ")> 0) {
url = url.substring(0,url.indexOf(" "));
}
gBrowser.loadOneTab(url, null, null, null, true, false);
this.setStatusText("Redirecting to your favourite site " + URLs[w] );
this.clearStatusText(3000);
};
init();
var attrsList = fulltable.map(function(elt) {
if (!elt)
return null;
var index = elt[1];
var keyWord = impWords[index];
return {
label: keyWord,
oncommand: "this.API_loadFavSite(" + index + ");",
};
});

FireGestures.generatePopup(event,attrsList);

from firegestures.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.