1function citation_tool(url, cite_id) { 2 // Modal part 3 $('#citation_modal_table tbody').empty(); 4 var modal = document.getElementById('citation-tool'); 5 var span = document.getElementById("close-citation"); 6 modal.classList.add("modal"); 7 setTimeout(function(){ 8 modal.style.display = "block"; 9 }, 200) 10 11 span.onclick = function() { 12 modal.style.display = "none"; 13 $(".article_option").remove(); 14 $(".article").remove(); 15 $(".cite-submenu").remove(); 16 } 17 window.onclick = function(event) { 18 if (event.target == modal) { 19 modal.style.display = "none"; 20 $(".article_option").remove(); 21 $(".article").remove(); 22 $(".cite-submenu").remove(); 23 } 24 } 25 26 // Process location 27 var this_site = parse_url_long(url); 28 var highlight_main = false; 29 if (window.location.pathname==='/') { 30 highlight_main = true 31 } 32 33 // AJAX to create citation list 34 var dropdown_articles = document.getElementById("dropdown_articles"); 35 var article_list = document.getElementById("article_list"); 36 var env = url.split('//')[1].split('/')[0]; 37 var main_ref_id = []; 38 var cit_request = new XMLHttpRequest(); 39 var domains = ["gpcrdb.org", "gproteindb.org", "arrestindb.org", "biasedsignalingatlas.org"]; 40 var filter_for = false; 41 let cite_id_missing = typeof cite_id === "undefined"; 42 if ((cite_id_missing && env==="gpcrdb.org") || cite_id==="cite_gpcrdb") { 43 filter_for = "gpcrdb"; 44 } 45 if ((cite_id_missing && env==="gproteindb.org") || cite_id==="cite_gproteindb") { 46 filter_for = "gproteindb"; 47 } 48 if ((cite_id_missing && env==="arrestindb.org") || cite_id==="cite_arrestindb") { 49 filter_for = "arrestindb"; 50 } 51 if ((cite_id_missing && env==="biasedsignalingatlas.org") || cite_id==="cite_biasedsignalingatlas") { 52 filter_for = "biasedsignalingatlas"; 53 } 54 // Use the current origin; previous splitting logic was fragile (e.g. "http:" + "/citations"). 55 cit_request.open('GET', window.location.origin + '/citations'); 56 cit_request.onload = function() { 57 if (cit_request.status < 200 || cit_request.status >= 300) { 58 console.warn("Citations request failed:", cit_request.status, cit_request.responseText); 59 return; 60 } 61 let data = []; 62 try { 63 data = JSON.parse(cit_request.responseText); 64 } catch (e) { 65 console.warn("Citations response was not valid JSON:", e, cit_request.responseText); 66 return; 67 } 68 for (let i = 0; i < data.length; i++) { 69 var link = ""; 70 if (!domains.includes(env)) { 71 link = "/" + data[i][0].split("//")[1].split("/").slice(1).join("/"); 72 } 73 else { 74 link = data[i][0]; 75 } 76 if (link[link.length-1]==='/') { 77 link = link.substring(0, link.length-1); 78 } 79 if (link==='/GPCR-Gprotein_Mutations.xlsx') { 80 link = 'https://files.gpcrdb.org/GPCR-Gprotein_Mutations.xlsx' 81 } 82 else if (link==='/mutations.html#mutation-data-submission') { 83 link = 'https://docs.gpcrdb.org/mutations.html#mutation-data-submission' 84 } 85 if ($('a[href="'+link+'"]').first().parent().parent().parent().first().hasClass('dropdown-submenu')) { 86 data[i].push($('a[href="'+link+'"]').first().parent().parent().parent().parent().parent().first().find(">:first-child").text().trim()); 87 } 88 else { 89 if (link==="/protein/ste2_yeast") { 90 data[i].push("GPCRdb"); 91 } 92 else { 93 data[i].push($('a[href="'+link+'"]').first().parent().parent().parent().first().find(">:first-child").text().trim()); 94 } 95 } 96 } 97 // Create HTML once per call 98 var articles = {}; 99 var tags = []; 100 for (let i = 0; i < data.length; i++) { 101 if (data[i][11]==='') { 102 continue; 103 } 104 if (filter_for==="gpcrdb" && data[i][11]!=="GPCRdb") { 105 continue; 106 } 107 else if (filter_for==="gproteindb" && data[i][11]!=="GproteinDb" && data[i][7]===2022) { 108 continue; 109 } 110 else if (filter_for==="arrestindb" && data[i][11]!=="ArrestinDb") { 111 continue; 112 } 113 else if (filter_for==="biasedsignalingatlas" && data[i][11]!=="Biased Signaling Atlas") { 114 continue; 115 } 116 else if (filter_for==="arrestindb" && data[i][11]==="ArrestinDb") { 117 data[i][5] = "The arrestin database, ArrestinDb"; 118 data[i][6] = "Jimmy Caroli, Gáspár Pándy-Szekeres, Alexander S. Hauser, György M. Keserű, Albert J. Kooistra and David E. Gloriam"; 119 data[i][7] = 2022; 120 data[i][8] = ""; 121 data[i][9] = "Manuscript"; 122 data[i][10] = ""; 123 } 124 else if (filter_for==="biasedsignalingatlas" && data[i][11]==="Biased Signaling Atlas") { 125 data[i][5] = "A community Biased Signaling Atlas"; 126 data[i][6] = "Jimmy Caroli, Alibek Mamyrbekov, Kasper Harpsøe, Sahar Gardizi, Linda Dörries, Eshan Ghosh, Alexander S. Hauser, Albert J. Kooistra, and David E. Gloriam"; 127 data[i][7] = 2023; 128 data[i][8] = "19, 531â535"; 129 data[i][9] = "Nature Chemical Biology"; 130 data[i][10] = "https://doi.org/10.1038/s41589-023-01292-8"; 131 } 132 var site = parse_url_long(data[i][0]); 133 tags.push(site); 134 // Dropdown menus 135 var a_sub, submenu, submenu_ul; 136 if (document.getElementById(data[i][11])===null) { 137 submenu = document.createElement("li"); 138 submenu.setAttribute("id", data[i][11]); 139 submenu.classList.add("dropdown-submenu"); 140 submenu.classList.add("cite-submenu"); 141 a_sub = document.createElement("a"); 142 a_sub.innerHTML = data[i][11]; 143 a_sub.setAttribute('tabindex', '0'); 144 submenu.appendChild(a_sub); 145 submenu_ul = document.createElement("ul"); 146 submenu_ul.classList.add('dropdown-menu'); 147 submenu_ul.classList.add('dropdown-auto-overflow') 148 submenu.appendChild(submenu_ul); 149 } 150 else { 151 submenu = document.getElementById(data[i][11]) 152 submenu_ul = submenu.getElementsByTagName('ul')[0]; 153 } 154 155 // Dropdown options 156 var option = document.createElement("li"); 157 var option_link = document.createElement("a"); 158 option_link.innerHTML = data[i][4]; 159 option_link.classList.add("article_option"); 160 option.appendChild(option_link); 161 option.setAttribute("id", site.replace('#', '_').replace('.', '_')); 162 option.setAttribute("role", "button"); 163 164 if (site===this_site) { 165 option.setAttribute("selected", "selected"); 166 $('#page_select_button').html(data[i][4]); 167 } 168 169 submenu_ul.appendChild(option); 170 dropdown_articles.appendChild(submenu); 171 172 // Reformat data 173 if (!(data[i][5] in articles)) { 174 articles[data[i][5]] = {'tools':{}}; 175 articles[data[i][5]]['tools'][site] = option.innerHTML; 176 articles[data[i][5]]['main'] = data[i][3]; 177 articles[data[i][5]]['authors'] = data[i][6]; 178 articles[data[i][5]]['year'] = data[i][7]; 179 articles[data[i][5]]['reference'] = data[i][8]; 180 articles[data[i][5]]['journal'] = data[i][9]; 181 articles[data[i][5]]['doi'] = data[i][10]; 182 articles[data[i][5]]['menu'] = data[i][11]; 183 if (data[i][3] === "GPCRdb" || data[i][3] === "GproteinDb") { 184 main_ref_id.push(site); 185 } 186 } 187 else { 188 articles[data[i][5]]['tools'][site] = option.innerHTML; 189 if (data[i][3]=="GPCRdb" || data[i][3]=="GproteinDb") { 190 main_ref_id.push(site); 191 } 192 } 193 } 194 195 // Create HTML 196 for (var key in articles) { 197 var main_ref = false 198 var entry = document.createElement("ul"); 199 entry.setAttribute("id", articles[key]['doi']); 200 var entry_holder = document.createElement("div"); 201 var tools_list = document.createElement("div"); 202 // Loop through tools list to add them with ID 203 var selected = false;
204 for (var tool_key in articles[key]['tools']) { 205 if (tool_key===this_site) { 206 selected = true; 207 } 208 var tool = document.createElement("div"); 209 tool.innerHTML = articles[key]['tools'][tool_key].bold(); 210 tool.setAttribute("id", tool_key.replace('#', '_').replace('.', '_')+'_tag'); 211 tool.style.display = 'none'; 212 tools_list.appendChild(tool); 213 // var separator = document.createElement("div"); 214 // separator.innerHTML = '\u00A0•\u00A0'; 215 // separator.style.display = 'inline-block'; 216 // tools_list.appendChild(separator); 217 if (main_ref_id.includes(tool_key)) { 218 main_ref = true; 219 } 220 } 221 // tools_list.removeChild(tools_list.lastChild); 222 tools_list.style.display = 'block'; 223 224 var ref = document.createElement("div"); 225 var p = document.createElement("p"); 226 var d1 = document.createElement("div"); 227 var d2 = document.createElement("div"); 228 var d3 = document.createElement("div"); 229 d1.innerHTML = key; 230 d2.innerHTML = articles[key]['authors']; 231 232 // Link 233 var a = document.createElement("a"); 234 a.innerHTML = articles[key]['journal'].italics() + ", " + articles[key]['year'] + ", " + articles[key]['reference']; 235 a.title = key; 236 a.href = "https://doi.org/"+articles[key]['doi']; 237 a.target = "_blank"; 238 d3.appendChild(a); 239 p.appendChild(d1); 240 p.appendChild(d2); 241 p.appendChild(d3); 242 ref.appendChild(p); 243 ref.style.display = 'block'; 244 245 entry_holder.appendChild(tools_list); 246 entry_holder.appendChild(ref); 247 entry.appendChild(entry_holder); 248 entry.classList.add('article'); 249 if (selected) { 250 entry.classList.add('highlight_reference'); 251 } 252 if (main_ref) { 253 var main_ref_list = document.getElementById("main_reference"); 254 255 main_ref_list.appendChild(entry); 256 } 257 else { 258 article_list.appendChild(entry); 259 } 260 } 261 if (env=="gproteindb.org") { 262 main_ref_id = main_ref_id[0]; 263 } 264 else { 265 main_ref_id = main_ref_id[1]; 266 } 267 /*var color = "#BE00BE"; 268 if (filter_for==="gproteindb") { 269 color = "#F46615"; 270 } 271 else if (filter_for==="arrestindb") { 272 color = "#55AE35"; 273 } 274 $(".article").first().css("border-top","4px solid "+color);*/ 275 // $(".article").eq(1).css("border-top","4px solid #BE00BE"); 276 if (highlight_main || $('.highlight_reference').length==0) { 277 highlight_article(main_ref_id); 278 $('#dropdown_articles option#'+main_ref_id).attr('selected', 'selected'); 279 } 280 }; 281 cit_request.send(); 282} 283 284function highlight_article(key) { 285 $('.highlight_reference').removeClass('highlight_reference'); 286 $('#'+key+'_tag').parent().parent().parent().addClass('highlight_reference'); 287} 288 289function parse_url(url) { 290 var url_split = url.split('/'); 291 if (url_split[url_split.length-1]==="") { 292 var this_site = url_split[url_split.length-2]; 293 if (this_site==='targetselection') { 294 this_site = url_split[url_split.length-3]+'-'+this_site; 295 } 296 } 297 else { 298 var this_site = url_split[url_split.length-1]; 299 if (this_site==='targetselection') { 300 this_site = url_split[url_split.length-2]+'-'+this_site; 301 } 302 } 303 return this_site 304} 305 306function parse_url_long(url) { 307 var url_split = url.split('/'); 308 if (url_split[url_split.length-1]==="") { 309 if (url_split.length>5) { 310 return url_split[3]+"-"+url_split[4]; 311 } 312 else { 313 return url_split[3]; 314 } 315 } 316 else if (url_split.length===4) { 317 return url_split[3]; 318 } 319 else { 320 return url_split[3]+"-"+url_split[4]; 321 } 322} 323 324function toggle_widget() { 325 $("#ref_widget").animate({width: "toggle"}); 326 if ($("#widget_chevron").hasClass("glyphicon glyphicon-chevron-left")) { 327 $("#widget_chevron").removeClass("glyphicon glyphicon-chevron-left"); 328 $("#widget_chevron").addClass("glyphicon glyphicon-chevron-right"); 329 $("#widget_infosign").show(); 330 } 331 else { 332 $("#widget_chevron").removeClass("glyphicon glyphicon-chevron-right"); 333 $("#widget_chevron").addClass("glyphicon glyphicon-chevron-left"); 334 $("#widget_infosign").hide(); 335 setTimeout(function() { 336 $("#ref_widget").animate({width: "toggle"}); 337 $("#widget_chevron").removeClass("glyphicon glyphicon-chevron-left"); 338 $("#widget_chevron").addClass("glyphicon glyphicon-chevron-right"); 339 $("#widget_infosign").show(); 340 }, 8000) 341 } 342} 343 344async function check_for_video(url) { 345 var this_site = parse_url_long(url); 346 var cit_request = new XMLHttpRequest(); 347 cit_request.open('GET', window.location.origin + '/citations'); 348 cit_request.onload = function() { 349 if (cit_request.status < 200 || cit_request.status >= 300) { 350 return; 351 } 352 let data = []; 353 try { 354 data = JSON.parse(cit_request.responseText); 355 } catch (e) { 356 return; 357 } 358 var video = false;
359 for (i = 0; i < data.length; i++) { 360 var site = parse_url_long(data[i][0]); 361 if (site===this_site && data[i][1]!=null) { 362 video = data[i][1]; 363 $('#icon_video').attr('href', video); 364 $('#icon_video').css('display','inline'); 365 } 366 } 367 } 368 cit_request.send(); 369}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.