special/recentfiles
This commit is contained in:
96
dist/app.js
vendored
96
dist/app.js
vendored
@@ -4483,7 +4483,7 @@ var app = (function (exports) {
|
||||
seconds = date.getUTCSeconds(),
|
||||
milliseconds = date.getUTCMilliseconds();
|
||||
return isNaN(date) ? "Invalid Date"
|
||||
: formatYear(date.getUTCFullYear(), 4) + "-" + pad(date.getUTCMonth() + 1, 2) + "-" + pad(date.getUTCDate(), 2)
|
||||
: formatYear(date.getUTCFullYear()) + "-" + pad(date.getUTCMonth() + 1, 2) + "-" + pad(date.getUTCDate(), 2)
|
||||
+ (milliseconds ? "T" + pad(hours, 2) + ":" + pad(minutes, 2) + ":" + pad(seconds, 2) + "." + pad(milliseconds, 3) + "Z"
|
||||
: seconds ? "T" + pad(hours, 2) + ":" + pad(minutes, 2) + ":" + pad(seconds, 2) + "Z"
|
||||
: minutes || hours ? "T" + pad(hours, 2) + ":" + pad(minutes, 2) + "Z"
|
||||
@@ -5169,7 +5169,8 @@ var app = (function (exports) {
|
||||
constructor (opts) {
|
||||
var width = 600,
|
||||
height = 600;
|
||||
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.zoom_level = opts.zoom || 1.5;
|
||||
this.apiurl = opts.apiurl;
|
||||
this.categorylabel = opts.categorylabel || "Category";
|
||||
@@ -5244,10 +5245,31 @@ var app = (function (exports) {
|
||||
});
|
||||
cat.append("span").attr("class", "count").html(d => d.tcount);
|
||||
|
||||
var set_active_url_from_window = () => {
|
||||
var title = this.wiki.unescapeTitle(window.location.hash.substring(1)),
|
||||
page = this.wiki.get_page_by_title(title),
|
||||
url = page.url();
|
||||
console.log("wikimap init", page.title, url);
|
||||
this.set_active_url(url);
|
||||
};
|
||||
|
||||
this.loaded = true;
|
||||
if (this.active_url) {
|
||||
if (window.location.hash) {
|
||||
set_active_url_from_window();
|
||||
} else if (this.active_url) {
|
||||
this.set_active_url(this.active_url);
|
||||
}
|
||||
|
||||
window.addEventListener("hashchange", e => {
|
||||
console.log("hashchange");
|
||||
set_active_url_from_window();
|
||||
});
|
||||
/*
|
||||
window.addEventListener("popstate", e => {
|
||||
// console.log("popstate", e);
|
||||
console.log("popstate: " + document.location + ", state: " + JSON.stringify(e.state));
|
||||
})
|
||||
*/
|
||||
}
|
||||
|
||||
on (message, callback, context) {
|
||||
@@ -5279,10 +5301,20 @@ var app = (function (exports) {
|
||||
.attr("class", "links");
|
||||
this.nodesg = this.content.append("g")
|
||||
.attr("class", "nodes");
|
||||
|
||||
// DEBUGGING
|
||||
this.svg.on("click", x => {
|
||||
// console.log("svg click", event.target);
|
||||
if (event.target == this.svg.node()) {
|
||||
console.log("(debug) BACKGROUND CLICK", this.active_page.x, this.active_page.y);
|
||||
this.centerOnItem(this.active_page);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dragstarted (d) {
|
||||
// if (!event.active) this.simulation.alphaTarget(0.3).restart();
|
||||
if (!event.active) this.simulation.alphaTarget(0.3).restart();
|
||||
// this.simulation.restart();
|
||||
d.fx = d.x;
|
||||
d.fy = d.y;
|
||||
}
|
||||
@@ -5293,7 +5325,7 @@ var app = (function (exports) {
|
||||
}
|
||||
|
||||
dragended(d) {
|
||||
// if (!event.active) this.simulation.alphaTarget(0);
|
||||
if (!event.active) this.simulation.alphaTarget(0);
|
||||
d.fx = null;
|
||||
d.fy = null;
|
||||
}
|
||||
@@ -5322,11 +5354,16 @@ var app = (function (exports) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
// function called on iframe load
|
||||
async set_active_url (url) {
|
||||
this.active_url = url;
|
||||
console.log("wikimap.set_active_url", url);
|
||||
this.active_url = url;
|
||||
if (this.loaded) {
|
||||
var page = this.wiki.get_page(this.active_url);
|
||||
if (page) {
|
||||
// console.log("calling replaceState", page.title);
|
||||
window.history.replaceState (null, null, "#"+this.wiki.escapeTitle(page.title));
|
||||
// window.location.hash = this.wiki.escapeTitle(page.title);
|
||||
this.set_active_page(page);
|
||||
} else {
|
||||
console.log("wikimap: set_active_url: NO PAGE FOR", url);
|
||||
@@ -5378,9 +5415,12 @@ var app = (function (exports) {
|
||||
// console.log("page is already the active page", page, this.active_page);
|
||||
return;
|
||||
}
|
||||
|
||||
// window.location.hash = this.wiki.escapeTitle(page.title);
|
||||
// window.history.pushState ({pagetitle: page.title}, page.title, "/m/"+this.wiki.escapeTitle(page.title));
|
||||
// cleanup old
|
||||
if (this.active_page) {
|
||||
this.active_page.fx = undefined;
|
||||
this.active_page.fy = undefined;
|
||||
this.active_page.active = false;
|
||||
// deactivate linked links/nodes
|
||||
this.linked_nodes_set_active(this.active_page, false);
|
||||
@@ -5421,10 +5461,10 @@ var app = (function (exports) {
|
||||
// LOAD/ENSURE PAGE LINKS
|
||||
var links_out = await page.get_links();
|
||||
links_out = links_out.filter(p => (!p.redirect && p.ns == 0));
|
||||
console.log("links_out", links_out);
|
||||
// console.log("links_out", links_out);
|
||||
var links_in = await page.get_linkshere();
|
||||
links_in = links_in.filter(p => (!p.redirect && p.ns == 0));
|
||||
console.log("links_in", links_in);
|
||||
// console.log("links_in", links_in);
|
||||
links_out.forEach(p => {
|
||||
this.ensure_link(page, p).wiki = true;
|
||||
});
|
||||
@@ -5435,12 +5475,19 @@ var app = (function (exports) {
|
||||
}
|
||||
|
||||
this.active_page = page;
|
||||
// console.log("fixing active page", this.active_page);
|
||||
if (this.active_page.x === undefined) {
|
||||
this.active_page.x = this.width/2;
|
||||
this.active_page.y = this.height/2;
|
||||
}
|
||||
this.active_page.fx = this.active_page.x;
|
||||
this.active_page.fy = this.active_page.y;
|
||||
this.active_page.active = true;
|
||||
this.linked_nodes_set_active(this.active_page, true);
|
||||
|
||||
setTimeout(() => {
|
||||
this.centerOnItem(page, 1000);
|
||||
}, 1000);
|
||||
//setTimeout(() => {
|
||||
this.centerOnItem(page, 1000);
|
||||
//}, 1000);
|
||||
|
||||
this.events.emit("page", this.active_page);
|
||||
var data = {nodes: this.get_nodes(), links: values(this.all_links_by_key)};
|
||||
@@ -5497,7 +5544,7 @@ var app = (function (exports) {
|
||||
}
|
||||
|
||||
update_graph (graph) {
|
||||
console.log("UPDATE GRAPH", graph.nodes.length, graph.links.length);
|
||||
// console.log("UPDATE GRAPH", graph.nodes.length, graph.links.length);
|
||||
var link = this.linksg.selectAll("line")
|
||||
.data(graph.links, d => { return this.link_key(d.source.title, d.target.title) });
|
||||
var link_enter = link.enter()
|
||||
@@ -5528,11 +5575,15 @@ var app = (function (exports) {
|
||||
})
|
||||
.on("mouseover", function (d) {
|
||||
// console.log("mouseover", this);
|
||||
// d.mouse = true;
|
||||
select(this).classed("mouse", true);
|
||||
// that.update_nodes();
|
||||
})
|
||||
.on("mouseout", function (d) {
|
||||
// console.log("mouseout", this);
|
||||
// d.mouse = false;
|
||||
select(this).classed("mouse", false);
|
||||
// that.update_nodes();
|
||||
})
|
||||
.call(drag()
|
||||
.on("start", this.dragstarted.bind(this))
|
||||
@@ -5603,13 +5654,14 @@ var app = (function (exports) {
|
||||
update_nodes () {
|
||||
var nodes = this.nodesg.selectAll("g.page");
|
||||
// console.log("update_nodes", nodes.size());
|
||||
nodes.classed("mouse", d=>d.mouse);
|
||||
nodes.classed("active", d=>d.active);
|
||||
nodes.classed("active2", d=>d.active2);
|
||||
nodes.classed("highlight", d=>d.highlight);
|
||||
nodes.sort((a, b) => {
|
||||
// console.log("sort", a, b);
|
||||
var x = a.active ? 10 : (a.active2 ? 5 : 0),
|
||||
y = b.active ? 10 : (b.active2 ? 5 : 0);
|
||||
var x = a.mouse ? 10 : (a.active ? 8 : (a.active2 ? 5 : 0)),
|
||||
y = b.mouse ? 10 : (b.active ? 8 : (b.active2 ? 5 : 0));
|
||||
return x - y;
|
||||
});
|
||||
var links = this.linksg.selectAll("line");
|
||||
@@ -5641,20 +5693,24 @@ var app = (function (exports) {
|
||||
centerOnItem(item, duration) {
|
||||
var bounds = this.svg.node().getBoundingClientRect();
|
||||
var curt = transform(this.rect.node());
|
||||
console.log("centerOnItem", this.zoom_level, "item", item);
|
||||
// console.log("centerOnItem", this.zoom_level, "item", item);
|
||||
var zoom_level = this.zoom_level ? this.zoom_level : curt.k;
|
||||
if (item && item.x !== undefined) {
|
||||
var transform$1 = function () {
|
||||
return identity$1
|
||||
this.zoom.translateTo(duration ? this.rect.transition().duration(duration) : this.rect, item.x, item.y);
|
||||
// this.zoom.translateTo(this.rect, item.x, item.y);
|
||||
/*
|
||||
var transform = function () {
|
||||
return zoomIdentity
|
||||
.translate(bounds.width / 2, bounds.height / 2)
|
||||
.scale(zoom_level)
|
||||
.translate(-item.x, -item.y);
|
||||
};
|
||||
if (duration) {
|
||||
this.rect.transition().duration(duration).call(this.zoom.transform, transform$1);
|
||||
this.rect.transition().duration(duration).call(this.zoom.transform, transform);
|
||||
} else {
|
||||
this.rect.call(this.zoom.transform, transform$1);
|
||||
this.rect.call(this.zoom.transform, transform);
|
||||
}
|
||||
*/
|
||||
} else {
|
||||
console.log("NO ITEM");
|
||||
var transform$1 = function () {
|
||||
|
||||
Reference in New Issue
Block a user