last changes before BREAKING some shit|
This commit is contained in:
@@ -18,7 +18,7 @@ export class ForceNet {
|
||||
this.active_page = null;
|
||||
// this.nodes = {};
|
||||
this.simulation = forceSimulation()
|
||||
.velocityDecay(0.1)
|
||||
//.velocityDecay(0.1)
|
||||
.force("link", forceLink().id(d => d.title))
|
||||
.force("charge", forceManyBody())
|
||||
.force("radial", forceRadial(180, width/2, height/2));
|
||||
@@ -34,7 +34,7 @@ export class ForceNet {
|
||||
init_svg (svg) {
|
||||
this.svg = select(svg || "svg");
|
||||
this.zoom = zoom()
|
||||
.scaleExtent([1 / 16, 4])
|
||||
.scaleExtent([1 / 16, 16])
|
||||
.on("zoom", () => {
|
||||
this.content.attr("transform", event.transform);
|
||||
// console.log("transform", event.transform, this.content.attr("transform"));
|
||||
|
||||
22
src/wiki.js
22
src/wiki.js
@@ -106,28 +106,6 @@ export class Page {
|
||||
}
|
||||
async get_links () {
|
||||
return await this.get_prop("links", "pl");
|
||||
// // http://localhost/mw/api.php?action=query&prop=links&titles=Bienvenue_%C3%A0_l%E2%80%99erg
|
||||
// var ret = [];
|
||||
// var url = this.wiki.apiurl+"?action=query&format=json&formatversion=2&prop=links&titles="+encodeURIComponent(this.title);
|
||||
// while (true) {
|
||||
// var data = await fetchJsonp(url);
|
||||
// var json = await data.json();
|
||||
// // console.log("JSON", json);
|
||||
// if (json.query.pages[0]) {
|
||||
// var p = json.query.pages[0];
|
||||
// // extract any missing page info
|
||||
// if (p.ns && !this.ns) { this.ns = p.ns; }
|
||||
// if (p.pageid && !this.pageid) { this.pageid = p.pageid; }
|
||||
// }
|
||||
// if (json.query.pages[0].links) {
|
||||
// ret.push.apply(ret, json.query.pages[0].links);
|
||||
// }
|
||||
// if (!json.continue) { break; }
|
||||
// url = this.wiki.apiurl+"?action=query&format=json&formatversion=2&prop=links&plcontinue="+json.continue.plcontinue+"&titles="+encodeURIComponent(this.title);
|
||||
// }
|
||||
// ret = ret.map(x => this.wiki.page_for_object(x));
|
||||
// // map these to page objects
|
||||
// return ret;
|
||||
}
|
||||
async get_linkshere () {
|
||||
return await this.get_prop("linkshere", "lh");
|
||||
|
||||
@@ -31,7 +31,7 @@ export class Map {
|
||||
this.historylinks = {};
|
||||
this.links = null;
|
||||
this.highlight_category = null;
|
||||
this.show_history = false;
|
||||
this.show_history = true;
|
||||
}
|
||||
|
||||
nodeclick (d, elt) {
|
||||
@@ -148,6 +148,28 @@ export class Map {
|
||||
cat.append("span").attr("class", "count").html(d => d.tcount)
|
||||
}
|
||||
|
||||
async load_legend (src, elt) {
|
||||
var data = await json(src);
|
||||
console.log("load_legend", data);
|
||||
var cat = select(elt)
|
||||
.selectAll("div.cat")
|
||||
.data(data)
|
||||
.enter()
|
||||
.append("div")
|
||||
.attr("class", "cat icon");
|
||||
cat.append("span")
|
||||
.attr("class", "icon")
|
||||
.style("background-image", d => "url("+d.icon+")");
|
||||
cat.append("a")
|
||||
.attr("class", "label")
|
||||
.html(d => d.key)
|
||||
.attr("href", "#").on("click", d => {
|
||||
event.preventDefault();
|
||||
this.category_click(d);
|
||||
})
|
||||
cat.append("span").attr("class", "count").html(d => d.tcount)
|
||||
}
|
||||
|
||||
category_click (d) {
|
||||
console.log("category click", d);
|
||||
if (this.highlight_category) {
|
||||
|
||||
Reference in New Issue
Block a user