-
Notifications
You must be signed in to change notification settings - Fork 12
/
web-payments-common.js
170 lines (168 loc) · 5.12 KB
/
web-payments-common.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/* Web Payments Community Group common spec JavaScript */
var webpayments = {
// Add to the respecConfig preProcess config array
preProcess: {
apply: function(c) {
// process the document before anything else is done
var refs = document.querySelectorAll('adef') ;
for (var i = 0; i < refs.length; i++) {
var item = refs[i];
var p = item.parentNode ;
var con = item.innerHTML ;
var sp = document.createElement( 'dfn' ) ;
var tit = item.getAttribute('title') ;
if (!tit) {
tit = con;
}
sp.className = 'adef' ;
sp.title=tit ;
sp.innerHTML = con ;
p.replaceChild(sp, item) ;
}
refs = document.querySelectorAll('aref') ;
for (var i = 0; i < refs.length; i++) {
var item = refs[i];
var p = item.parentNode ;
var con = item.innerHTML ;
var sp = document.createElement( 'a' ) ;
sp.className = 'aref' ;
sp.setAttribute('title', con);
sp.innerHTML = '@'+con ;
p.replaceChild(sp, item) ;
}
// local datatype references
refs = document.querySelectorAll('ldtref') ;
for (var i = 0; i < refs.length; i++) {
var item = refs[i];
if (!item) continue ;
var p = item.parentNode ;
var con = item.innerHTML ;
var ref = item.getAttribute('title') ;
if (!ref) {
ref = item.textContent ;
}
if (ref) {
ref = ref.replace(/\n/g, '_') ;
ref = ref.replace(/\s+/g, '_') ;
}
var sp = document.createElement( 'a' ) ;
sp.className = 'datatype';
sp.title = ref ;
sp.innerHTML = con ;
p.replaceChild(sp, item) ;
}
// external datatype references
refs = document.querySelectorAll('dtref') ;
for (var i = 0; i < refs.length; i++) {
var item = refs[i];
if (!item) continue ;
var p = item.parentNode ;
var con = item.innerHTML ;
var ref = item.getAttribute('title') ;
if (!ref) {
ref = item.textContent ;
}
if (ref) {
ref = ref.replace(/\n/g, '_') ;
ref = ref.replace(/\s+/g, '_') ;
}
var sp = document.createElement( 'a' ) ;
sp.className = 'externalDFN';
sp.title = ref ;
sp.innerHTML = con ;
p.replaceChild(sp, item) ;
}
// now do terms
refs = document.querySelectorAll('tdef') ;
for (var i = 0; i < refs.length; i++) {
var item = refs[i];
if (!item) continue ;
var p = item.parentNode ;
var con = item.innerHTML ;
var ref = item.getAttribute('title') ;
if (!ref) {
ref = item.textContent ;
}
if (ref) {
ref = ref.replace(/\n/g, '_') ;
ref = ref.replace(/\s+/g, '_') ;
}
var sp = document.createElement( 'dfn' ) ;
sp.title = ref ;
sp.innerHTML = con ;
p.replaceChild(sp, item) ;
}
// now term references
refs = document.querySelectorAll('tref') ;
for (var i = 0; i < refs.length; i++) {
var item = refs[i];
if (!item) continue ;
var p = item.parentNode ;
var con = item.innerHTML ;
var ref = item.getAttribute('title') ;
if (!ref) {
ref = item.textContent ;
}
if (ref) {
ref = ref.replace(/\n/g, '_') ;
ref = ref.replace(/\s+/g, '_') ;
}
var sp = document.createElement( 'a' ) ;
var id = item.textContent ;
sp.className = 'tref' ;
sp.title = ref ;
sp.innerHTML = con ;
p.replaceChild(sp, item) ;
}
}
},
// Add as the respecConfig localBiblio variable
// Extend or override global respec references
localBiblio: {
"REST": {
title: "Architectural Styles and the Design of Network-based Software Architectures",
date: "2000",
href: "http://www.ics.uci.edu/~fielding/pubs/dissertation/",
authors: [
"Fielding, Roy Thomas"
],
publisher: "University of California, Irvine."
},
"SECURE-MESSAGING": {
title: "Secure Messaging",
href: "https://web-payments.org/specs/source/secure-messaging",
authors: [
"Manu Sporny"
],
etal: true,
// FIXME: add CG-DRAFT status and publisher support to respec
status: "unofficial",
publisher: "Web Payments Community Group"
},
"RDF-DATASET-NORMALIZATION" :{
title: "RDF Dataset Normalization",
href: "http://json-ld.github.io/normalization/spec/",
authors: [
"Dave Longley"
],
status: "unofficial",
publisher: "Credentials Community Group"
},
"SECURITY-VOCABULARY" :{
title: "Security Vocabulary",
href: "https://web-payments.org/specs/source/vocabs/security.html",
authors: [
"Manu Sporny", "Dave Longley"
],
status: "unofficial",
publisher: "Web Payments Community Group"
},
// aliases to known references
"HTTP-SIGNATURES": {
aliasOf: "http-signatures"
},
"JSON-PATCH": {
aliasOf: "json-patch"
}
}
};