Skip to content

Instantly share code, notes, and snippets.

@tebriel
Last active December 24, 2015 09:49
Show Gist options
  • Select an option

  • Save tebriel/6779910 to your computer and use it in GitHub Desktop.

Select an option

Save tebriel/6779910 to your computer and use it in GitHub Desktop.
var insert = "INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES ";
var docs = "polymaps.org/docs/";
var type='Method'
var sections = []
$('a', $('ul', $('.sidebar'))).each(function(index, link) {
atag = $(link)
var path=docs+atag.attr('href')
var name=atag.text()
sections.push("('"+name+"', 'Section', '"+path+"')");
});
console.log(insert+sections.join(', ')+";");
//map.html
var methods = []
$('dl.function').each(function(index, item){
var dltag=$(item);
name=dltag.attr('id');
path=docs+"map.html#"+name;
if ((name.indexOf('map.') === -1) && (name.indexOf('po.') === -1)) {
name = "map."+name;
}
methods.push("('"+name+"', 'Method', '"+path+"')");
});
console.log(insert+methods.join(', ')+";");
// image.html
var methods = []
$('dl.function').each(function(index, item){
var dltag=$(item);
name=dltag.attr('id');
path=docs+"image.html#"+name;
if (name.indexOf('po.') === -1) {
name = "image."+name;
}
methods.push("('"+name+"', 'Method', '"+path+"')");
});
console.log(insert+methods.join(', ')+";");
// layer.html
var methods = []
var title='layer'
var type='Method'
$('dl.function').each(function(index, item){
var dltag=$(item);
var curMethod = type;
name=dltag.attr('id');
path=docs+title+".html#"+name;
if (name.indexOf('po.') === -1) {
name = title+"."+name;
} else {
curMethod = 'Constructor';
}
methods.push("('"+name+"', '"+curMethod+"', '"+path+"')");
});
console.log(insert+methods.join(', ')+";");
// geoJson.html
var methods = []
var title='geoJson'
var type='Method'
$('dl.function').each(function(index, item){
var dltag=$(item);
var curMethod = type;
name=dltag.attr('id');
path=docs+title+".html#"+name;
if (name.indexOf('po.') === -1) {
name = title+"."+name;
} else {
curMethod = 'Constructor';
}
methods.push("('"+name+"', '"+curMethod+"', '"+path+"')");
});
console.log(insert+methods.join(', ')+";");
// arrow.html
var methods = []
var title='arrow'
var jq = document.createElement('script');
jq.src = "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
// ... give time for script to load, then type.
setTimeout(function(){
var insert = "INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES ";
var docs = "polymaps.org/docs/";
var type='Method';
var methods = [];
var title=$('h2').text();
$('dl.function').each(function(index, item){
var dltag=$(item);
var curMethod = type;
name=dltag.attr('id');
path=docs+title+".html#"+name;
if (name.indexOf('po.') === -1) {
name = title+"."+name;
} else {
curMethod = 'Constructor';
}
methods.push("('"+name+"', '"+curMethod+"', '"+path+"')");
});
console.log(insert+methods.join(', ')+";");
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment