forked from w3c/vc-use-cases
-
Notifications
You must be signed in to change notification settings - Fork 0
/
refs.js
50 lines (41 loc) · 1.6 KB
/
refs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* globals respecConfig, $, localRoleInfo, roleInfo, require */
/* exported linkCrossReferences, restrictReferences, fixIncludes */
// add a handler to come in after all the definitions are resolved
//
require(["core/pubsubhub"], function( respecEvents ) {
respecEvents.sub('end', function(message) {
var needs = {} ;
if (message === 'core/link-to-dfn') {
$.each(document.querySelectorAll("udef"), function(i, item) {
var container = item.parentNode;
var content = item.innerHTML;
var sp = document.createElement("span");
var title = item.getAttribute("title");
if (!title) {
title = content;
}
var name = title.replace(/ .*$/, '');
name = name.replace(/\./, "_");
var id = "uneed_" + name;
sp.id = id;
sp.className = "userneed-name";
sp.title = title;
sp.innerHTML = content;
container.replaceChild(sp, item);
needs[id] = content;
});
$("uref").each(function() {
var p = this.parentNode;
var item = this.innerHTML;
var id = item.replace(/\./, "_");
id = "uneed_"+id;
if (needs[id]) {
var ref = document.createElement("a");
ref.href = "#"+id;
ref.innerHTML = needs[id];
p.replaceChild(ref, this);
}
});
}
});
});