mise a jours post wikithon winterschool 2024
This commit is contained in:
5555
dist/app.00.js
vendored
Normal file
5555
dist/app.00.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
150
dist/app.js
vendored
150
dist/app.js
vendored
@@ -4375,6 +4375,137 @@ var app = (function (exports) {
|
||||
return force;
|
||||
}
|
||||
|
||||
function forceCollide(radius){
|
||||
var nodes,
|
||||
radii,
|
||||
random,
|
||||
strength = 1,
|
||||
iterations = 1;
|
||||
|
||||
if (typeof radius !== "function") radius = constant(radius == null ? 1 : +radius);
|
||||
|
||||
function force() {
|
||||
var i, n = nodes.length,
|
||||
tree,
|
||||
node,
|
||||
xi,
|
||||
yi,
|
||||
ri,
|
||||
ri2;
|
||||
|
||||
for (var k = 0; k < iterations; ++k) {
|
||||
tree = quadtree(nodes, x, y).visitAfter(prepare);
|
||||
for (i = 0; i < n; ++i) {
|
||||
node = nodes[i];
|
||||
ri = radii[node.index], ri2 = ri * ri;
|
||||
xi = node.x + node.vx;
|
||||
yi = node.y + node.vy;
|
||||
tree.visit(apply);
|
||||
}
|
||||
}
|
||||
|
||||
function apply(quad, x0, y0, x1, y1) {
|
||||
var data = quad.data, rj = quad.r, r = ri + rj;
|
||||
if (data) {
|
||||
if (data.index > node.index) {
|
||||
var x = xi - data.x - data.vx,
|
||||
y = yi - data.y - data.vy,
|
||||
l = x * x + y * y;
|
||||
if (l < r * r) {
|
||||
if (x === 0) x = jiggle(random), l += x * x;
|
||||
if (y === 0) y = jiggle(random), l += y * y;
|
||||
l = (r - (l = Math.sqrt(l))) / l * strength;
|
||||
node.vx += (x *= l) * (r = (rj *= rj) / (ri2 + rj));
|
||||
node.vy += (y *= l) * r;
|
||||
data.vx -= x * (r = 1 - r);
|
||||
data.vy -= y * r;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
return x0 > xi + r || x1 < xi - r || y0 > yi + r || y1 < yi - r;
|
||||
}
|
||||
}
|
||||
|
||||
function prepare(quad) {
|
||||
if (quad.data) return quad.r = radii[quad.data.index];
|
||||
for (var i = quad.r = 0; i < 4; ++i) {
|
||||
if (quad[i] && quad[i].r > quad.r) {
|
||||
quad.r = quad[i].r;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function initialize() {
|
||||
if (!nodes) return;
|
||||
var i, n = nodes.length, node;
|
||||
radii = new Array(n);
|
||||
for (i = 0; i < n; ++i) node = nodes[i], radii[node.index] = +radius(node, i, nodes);
|
||||
}
|
||||
|
||||
force.initialize = function(_nodes, _random) {
|
||||
nodes = _nodes;
|
||||
random = _random;
|
||||
initialize();
|
||||
};
|
||||
|
||||
force.iterations = function(_) {
|
||||
return arguments.length ? (iterations = +_, force) : iterations;
|
||||
};
|
||||
|
||||
force.strength = function(_) {
|
||||
return arguments.length ? (strength = +_, force) : strength;
|
||||
};
|
||||
|
||||
force.radius = function(_) {
|
||||
return arguments.length ? (radius = typeof _ === "function" ? _ : constant(+_), initialize(), force) : radius;
|
||||
};
|
||||
|
||||
return force;
|
||||
}
|
||||
|
||||
function forceCenter(x, y) {
|
||||
var nodes, strength = 1;
|
||||
|
||||
if (x == null) x = 0;
|
||||
if (y == null) y = 0;
|
||||
|
||||
function force() {
|
||||
var i,
|
||||
n = nodes.length,
|
||||
node,
|
||||
sx = 0,
|
||||
sy = 0;
|
||||
|
||||
for (i = 0; i < n; ++i) {
|
||||
node = nodes[i], sx += node.x, sy += node.y;
|
||||
}
|
||||
|
||||
for (sx = (sx / n - x) * strength, sy = (sy / n - y) * strength, i = 0; i < n; ++i) {
|
||||
node = nodes[i], node.x -= sx, node.y -= sy;
|
||||
}
|
||||
}
|
||||
|
||||
force.initialize = function(_) {
|
||||
nodes = _;
|
||||
};
|
||||
|
||||
force.x = function(_) {
|
||||
return arguments.length ? (x = +_, force) : x;
|
||||
};
|
||||
|
||||
force.y = function(_) {
|
||||
return arguments.length ? (y = +_, force) : y;
|
||||
};
|
||||
|
||||
force.strength = function(_) {
|
||||
return arguments.length ? (strength = +_, force) : strength;
|
||||
};
|
||||
|
||||
return force;
|
||||
|
||||
}
|
||||
|
||||
function forceRadial(radius, x, y) {
|
||||
var nodes,
|
||||
strength = constant$4(0.1),
|
||||
@@ -5204,9 +5335,13 @@ var app = (function (exports) {
|
||||
this.simulation = forceSimulation()
|
||||
//.velocityDecay(0.1)
|
||||
.force("link", forceLink().id(d => d.title))
|
||||
.force("charge", forceManyBody())
|
||||
.force("radial", forceRadial(180, width/2, height/2));
|
||||
// .force("center", forceCenter(width / 2, height / 2));
|
||||
.force("charge", forceManyBody().strength(-50))
|
||||
.force("radial", forceRadial(1, width/-4, height/-4))
|
||||
.force("center", forceCenter(width / 2, height / 2.5))
|
||||
.force("collide", forceCollide().radius(20));
|
||||
|
||||
|
||||
|
||||
|
||||
this.all_links_by_key = {};
|
||||
}
|
||||
@@ -5219,7 +5354,8 @@ var app = (function (exports) {
|
||||
for (let i=0, l=this.symbols.length; i<l; i++) {
|
||||
let sym = this.symbols[i];
|
||||
if (sym.key === "default") {
|
||||
let page = this.wiki.get_page_by_title("Special:AllPages");
|
||||
//let page = this.wiki.get_page_by_title("Special:AllPages");
|
||||
let page = this.wiki.get_page_by_title("Bienvenue_<65>_l'erg");
|
||||
sym.page = page;
|
||||
} else {
|
||||
let cat = this.wiki.get_page_by_title(this.categorylabel+":"+sym.key);
|
||||
@@ -5305,8 +5441,8 @@ var app = (function (exports) {
|
||||
});
|
||||
|
||||
this.rect = this.svg.append("rect")
|
||||
.attr("width", 1000)
|
||||
.attr("height", 1000)
|
||||
.attr("width", "50%")
|
||||
.attr("height", "50%")
|
||||
.style("fill", "none");
|
||||
if (!mobilecheck()) {
|
||||
this.rect.style("pointer-events", "all")
|
||||
@@ -5428,7 +5564,7 @@ var app = (function (exports) {
|
||||
}
|
||||
|
||||
async set_active_page (page) {
|
||||
console.log("wikimap: set_active_page:", page.title);
|
||||
console.log("wikimap: set_active_page:", page);
|
||||
if (page === this.active_page) {
|
||||
// console.log("page is already the active page", page, this.active_page);
|
||||
return;
|
||||
|
||||
127
dist/index.00.js
vendored
Normal file
127
dist/index.00.js
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
// custom_scroller_menu(
|
||||
// document.scrollingElement,
|
||||
// document.getElementById("menubar"),
|
||||
// document.getElementById("debug"));
|
||||
|
||||
var svg = document.querySelector("#svg"),
|
||||
iframe = document.querySelector("iframe#wikiframe"),
|
||||
cats = document.querySelector("#cats"),
|
||||
cats_contents = document.querySelector("#cats .body"),
|
||||
cats_thumb = document.querySelector("#cats .thumb"),
|
||||
allcatscb = document.querySelector("input#allcats"),
|
||||
historycb = document.querySelector("input#history"),
|
||||
current_title = null,
|
||||
loaded = false,
|
||||
wikibaseurl,
|
||||
wikibasepat;
|
||||
|
||||
|
||||
window.addEventListener("resize", resize);
|
||||
function resize() {
|
||||
var w = window,
|
||||
d = document,
|
||||
e = d.documentElement,
|
||||
g = d.getElementsByTagName('body')[0],
|
||||
x = w.innerWidth || e.clientWidth || g.clientWidth,
|
||||
y = w.innerHeight|| e.clientHeight|| g.clientHeight;
|
||||
svg.setAttribute("width", x);
|
||||
svg.setAttribute("height", y);
|
||||
//console.log("resize", x, y);
|
||||
}
|
||||
resize();
|
||||
|
||||
// console.log("mediawikiapi", mediawikiapi);
|
||||
var symbols = {
|
||||
"Orientations": "symbols.svg#Orientations",
|
||||
"Ateliers pluridisciplinaires": "symbols.svg#Ateliers_pluridisciplinaires",
|
||||
"Cours de soutien à l'orientation": "symbols.svg#Cours_de_soutien_a_l'orientation",
|
||||
"Cours de soutien spécifique": "symbols.svg#Cours_de_soutien_specifique",
|
||||
"Cours techniques": "symbols.svg#Cours_techniques",
|
||||
"Cours théoriques": "symbols.svg#Cours_theoriques",
|
||||
"Enseignants": "symbols.svg#Enseignants",
|
||||
"default": "symbols.svg#Main"
|
||||
};
|
||||
var map = new app.Map(symbols);
|
||||
|
||||
map.init_svg("#svg");
|
||||
async function doload () {
|
||||
console.log("loading map");
|
||||
await map.load_json("data/sitemap.json");
|
||||
// console.log("loading categories");
|
||||
// await map.load_cats("cats.json", cats_contents);
|
||||
console.log("LOADED!");
|
||||
loaded = true;
|
||||
if (current_title) {
|
||||
map.set_active_title(current_title);
|
||||
}
|
||||
}
|
||||
|
||||
map.on("page", function (title) {
|
||||
console.log("map.page", title);
|
||||
var url = wiki_title_to_url(title);
|
||||
iframe.src = url;
|
||||
})
|
||||
// async function doload() {
|
||||
// map.set_active_node(startpage.value);
|
||||
// }
|
||||
|
||||
function strip_fragment (href) {
|
||||
var spos = href.indexOf("#");
|
||||
if (spos >= 0) {
|
||||
return href.substr(0, href.indexOf("#"))
|
||||
}
|
||||
return href;
|
||||
}
|
||||
function url_to_wiki_title (href) {
|
||||
href = strip_fragment(href);
|
||||
var m = wikibasepat.exec(href);
|
||||
if (m !== null) {
|
||||
return decodeURI(m[1]).replace(/_/g, " ");
|
||||
}
|
||||
console.log("m", m);
|
||||
}
|
||||
function wiki_title_to_url (title) {
|
||||
return wikibaseurl+encodeURI(title.replace(/ /g, "_"));
|
||||
}
|
||||
window.addEventListener("DOMContentLoaded", doload);
|
||||
function strip_title_from_wiki_url (url) {
|
||||
return url.substr(0, url.lastIndexOf("/")+1);
|
||||
}
|
||||
iframe.addEventListener("load", function () {
|
||||
var href = strip_fragment(iframe.contentWindow.location.href);
|
||||
if (!wikibaseurl) {
|
||||
wikibaseurl = strip_title_from_wiki_url(href);
|
||||
wikibasepat = new RegExp(wikibaseurl+"(.+)");
|
||||
}
|
||||
console.log("iframe loaded", href);
|
||||
var title = url_to_wiki_title(href);
|
||||
console.log("title", title);
|
||||
if (title) {
|
||||
current_title = title;
|
||||
if (loaded) {
|
||||
map.set_active_title(title);
|
||||
}
|
||||
}
|
||||
// attempt to map url to wiki page title and update the map if it is one
|
||||
|
||||
});
|
||||
|
||||
cats_thumb.addEventListener("click", function () {
|
||||
cats.classList.toggle("expanded");
|
||||
});
|
||||
// allcats checkbox
|
||||
// match current state & respond to change events
|
||||
// console.log("setting checked to", cats.classList.contains("showall"))
|
||||
allcatscb.checked = cats.classList.contains("showall");
|
||||
allcatscb.addEventListener("change", function () {
|
||||
// console.log("allcats", allcatscb);
|
||||
if (allcatscb.checked) {
|
||||
cats.classList.add("showall")
|
||||
} else {
|
||||
cats.classList.remove("showall")
|
||||
}
|
||||
})
|
||||
historycb.addEventListener("change", function () {
|
||||
// console.log("history", historycb.checked);
|
||||
map.set_show_history(historycb.checked);
|
||||
})
|
||||
2
dist/index.js
vendored
2
dist/index.js
vendored
@@ -7,7 +7,7 @@ var svg = document.querySelector("#svg"),
|
||||
svg: "#svg",
|
||||
categorylabel: "Catégorie",
|
||||
categorydiv: "#cats .body",
|
||||
zoom: 2.0
|
||||
zoom: 3.0
|
||||
}),
|
||||
zoom_in = document.querySelector(".leaflet-control-zoom-in"),
|
||||
zoom_out = document.querySelector(".leaflet-control-zoom-out"),
|
||||
|
||||
Reference in New Issue
Block a user