-
Notifications
You must be signed in to change notification settings - Fork 0
/
transient-table.js
224 lines (214 loc) · 8.87 KB
/
transient-table.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
function showSpecCSV() {
document.getElementById('speccsv').style.display = 'block';
parent.resizeWindowToContents();
}
function eSN(name, filename, stem, quantities, bibcode) {
var value =
'{\n' +
'\t"' + name + '":{\n' +
'\t\t"name":"' + name + '",\n';
if (bibcode !== undefined) {
value +=
'\t\t"sources":[\n' +
'\t\t\t{\n' +
'\t\t\t\t"bibcode":"' + bibcode + '"\n' +
'\t\t\t}\n' +
'\t\t],\n';
}
value +=
'\t\t"alias":[\n' +
'\t\t\t{\n' +
'\t\t\t\t"value":"' + name + '"\n' +
'\t\t\t}\n' +
'\t\t]';
if (quantities !== undefined) {
for (var i = 0; i < quantities.length; i++) {
if (quantities[i][1] == '') continue;
value +=
',\n\t\t"' + quantities[i][0] + '":[\n' +
'\t\t\t{\n' +
'\t\t\t\t"value":"' + quantities[i][1] + '"\n' +
'\t\t\t}\n' +
'\t\t]';
}
}
value +=
'\n\t}\n' +
'}';
value = encodeURIComponent(value);
var instructions = 'PLEASE READ: Welcome to the new JSON page for ' + name + '! Before editing this file, please look at our JSON schema [https://github.com/astrocatalogs/supernovae/blob/master/SCHEMA.md]. Please replace this message with your own comments before committing.'
var win = window.open('https://github.com/astrocatalogs/' + stem + '-internal/new/master/?filename=' +
encodeURIComponent(filename) + '.json&value=' + value + '&description=' + instructions, '_blank')
win.focus();
}
function markSame(name1, name2, edit, catalog) {
var filename = name1.replace("/", "_") + '.json';
var codemessage = '';
if (edit === "true") {
codemessage += '### IMPORTANT: A FILE FOR THIS EVENT ALREADY EXISTS IN THE REPOSITORY.\n';
codemessage += '### Due to limitations of the GitHub URL interface, you must copy the contents\n';
codemessage += '### of this file into the existing JSON file for this event in order to edit it\n';
codemessage += '### The location of the file to paste into is located at:\n';
codemessage += '### https://github.com/astrocatalogs/' + catalog + '-internal/edit/master/' + encodeURIComponent(filename) + '\n';
codemessage += '### COMMITTING THE FILE ON THIS PAGE WILL RESULT IN A "FILE ALREADY EXISTS" ERROR.\n';
codemessage += '### Delete all lines preceded by a # before committing any changes to the file\n';
codemessage += '### located at the above URL.\n';
} else {
codemessage = '';
}
var value = encodeURIComponent(
codemessage +
'{\n' +
'\t"' + name1 + '":{\n' +
'\t\t"name":"' + name1 + '",\n' +
'\t\t"alias":[\n' +
'\t\t\t{\n' +
'\t\t\t\t"value":"' + name1 + '"\n' +
'\t\t\t},\n' +
'\t\t\t{\n' +
'\t\t\t\t"value":"' + name2 + '"\n' +
'\t\t\t}\n' +
'\t\t]\n' +
'\t}\n' +
'}')
var instructions = encodeURIComponent('Events ' + name1 + ' and ' + name2 + ' marked as being the same via OSC duplicate finder.');
var win = window.open('https://github.com/astrocatalogs/' + catalog + '-internal/new/master/?filename=' +
encodeURIComponent(filename) + '&value=' + value + '&message=' + instructions, '_blank')
win.focus();
}
function markDiff(name1, name2, edit, catalog) {
var filename = name1.replace("/", "_") + '.json';
var codemessage = '';
if (edit === "true") {
codemessage += '### IMPORTANT: A FILE FOR THIS EVENT ALREADY EXISTS IN THE REPOSITORY.\n';
codemessage += '### Due to limitations of the GitHub URL interface, you must copy the contents\n';
codemessage += '### of this file into the existing JSON file for this event in order to edit it\n';
codemessage += '### The location of the file to paste into is located at:\n';
codemessage += '### https://github.com/astrocatalogs/' + catalog + '-internal/edit/master/' + encodeURIComponent(filename) + '\n';
codemessage += '### COMMITTING THE FILE ON THIS PAGE WILL RESULT IN A "FILE ALREADY EXISTS" ERROR.\n';
codemessage += '### Delete all lines preceded by a # before committing any changes to the file\n';
codemessage += '### located at the above URL.\n';
} else {
codemessage = '';
}
var value = encodeURIComponent(
codemessage +
'{\n' +
'\t"' + name1 + '":{\n' +
'\t\t"name":"' + name1 + '",\n' +
'\t\t"distinctfrom":[\n' +
'\t\t\t{\n' +
'\t\t\t\t"value":"' + name2 + '"\n' +
'\t\t\t}\n' +
'\t\t]\n' +
'\t}\n' +
'}')
var instructions = encodeURIComponent('Events ' + name1 + ' and ' + name2 + ' marked as being distinct from one another via OSC duplicate finder.');
var win = window.open('https://github.com/astrocatalogs/' + catalog + '-internal/new/master/?filename=' +
encodeURIComponent(filename) + '&value=' + value + '&message=' + instructions, '_blank')
win.focus();
}
function lookupSimbad(query) {
var win = window.open('http://simbad.u-strasbg.fr/simbad/sim-basic?Ident=' + query, '_blank');
win.focus();
}
function lookupTns(query) {
var win = window.open('https://wis-tns.weizmann.ac.il/object/' + query, '_blank');
win.focus();
}
function markError(name, quantity, sourcekind, source, edit, catalog) {
var filename = name.replace("/", "_") + '.json';
var sks = sourcekind.split(',');
var sis = source.split(',');
var sourcestring = '';
for (i = 0; i < sks.length; i++) {
sourcestring +=
'\t\t\t{\n' +
'\t\t\t\t"value":"' + sis[i] + '",\n' +
'\t\t\t\t"kind":"' + sks[i] + '",\n' +
'\t\t\t\t"extra":"' + quantity + '"\n' +
'\t\t\t}' + ((i == sks.length - 1) ? '' : ',') + '\n';
}
var codemessage = '';
if (edit === "true") {
codemessage += '### IMPORTANT: A FILE FOR THIS EVENT ALREADY EXISTS IN THE REPOSITORY.\n';
codemessage += '### Due to limitations of the GitHub URL interface, you must copy the contents\n';
codemessage += '### of this file into the existing JSON file for this event in order to edit it\n';
codemessage += '### The location of the file to paste into is located at:\n';
codemessage += '### https://github.com/astrocatalogs/' + catalog + '-internal/edit/master/' + encodeURIComponent(filename) + '\n';
codemessage += '### COMMITTING THE FILE ON THIS PAGE WILL RESULT IN A "FILE ALREADY EXISTS" ERROR.\n';
codemessage += '### Delete all lines preceded by a # before committing any changes to the file\n';
codemessage += '### located at the above URL.\n';
} else {
codemessage = '';
}
var value = encodeURIComponent(
codemessage +
'{\n' +
'\t"' + name + '":{\n' +
'\t\t"name":"' + name + '",\n' +
'\t\t"errors":[\n' +
sourcestring +
'\t\t]\n' +
'\t}\n' +
'}');
var instructions = encodeURIComponent(name + '\'s ' + quantity + ' from ' + source + ' marked as being erroneous.');
var win = window.open('https://github.com/astrocatalogs/' + catalog + '-internal/new/master/?filename=' +
encodeURIComponent(filename) + '&value=' + value + '&message=' + instructions, '_blank');
win.focus();
}
function addQuantity(name, quantity, edit, catalog) {
var filename = name.replace("/", "_") + '.json';
var codemessage = '';
if (edit === "true") {
codemessage += '### IMPORTANT: A FILE FOR THIS EVENT ALREADY EXISTS IN THE REPOSITORY.\n';
codemessage += '### Due to limitations of the GitHub URL interface, you must copy the contents\n';
codemessage += '### of this file into the existing JSON file for this event in order to edit it\n';
codemessage += '### The location of the file to paste into is located at:\n';
codemessage += '### https://github.com/astrocatalogs/' + catalog + '-internal/edit/master/' + encodeURIComponent(filename) + '\n';
codemessage += '### COMMITTING THE FILE ON THIS PAGE WILL RESULT IN A "FILE ALREADY EXISTS" ERROR.\n';
codemessage += '### Delete all lines preceded by a # before committing any changes to the file\n';
codemessage += '### located at the above URL.\n';
} else {
codemessage = '';
}
var value = encodeURIComponent(
codemessage +
'{\n' +
'\t"' + name + '":{\n' +
'\t\t"name":"' + name + '",\n' +
'\t\t"sources":[\n' +
'\t\t\t{\n' +
'\t\t\t\t"bibcode":"### BIBCODE FOR NEW VALUE ###"\n' +
'\t\t\t}\n' +
'\t\t],\n' +
'\t\t"' + quantity + '":[\n' +
'\t\t\t{\n' +
'\t\t\t\t"value":"### NEW VALUE ###",\n' +
'\t\t\t\t"e_value":"### ERROR IN VALUE (if applicable) ###",\n' +
'\t\t\t\t"u_value":"### VALUE\'S UNIT (if applicable) ###"\n' +
'\t\t\t}\n' +
'\t\t]\n' +
'\t}\n' +
'}');
var instructions = encodeURIComponent('"' + quantity + '" added to ' + name + '.');
var win = window.open('https://github.com/astrocatalogs/' + catalog + '-internal/new/master/?filename=' +
encodeURIComponent(filename) + '&value=' + value + '&message=' + instructions, '_blank');
win.focus();
}
function googleNames(names) {
var namearr = names.split(',');
for (var i = 0; i < namearr.length; i++) {
if (namearr[i].startsWith('SN') && !isNaN(parseFloat(namearr[i].slice(2,6)))) {
namearr[i] = namearr[i].replace('SN', '');
}
if (namearr[i].startsWith('AT') && !isNaN(parseFloat(namearr[i].slice(2,6)))) {
namearr[i] = namearr[i].replace('AT', '');
}
}
namearr = jQuery.grep(namearr, function(v, k){
return jQuery.inArray(v, namearr) === k;
});
var win = window.open('https://www.google.com/#q=' + encodeURIComponent(namearr.join(" ")), '_blank')
win.focus();
}