 Chromium Code Reviews
 Chromium Code Reviews Issue 1926683002:
  docserver: Load JS async defer since it really isn't required and it was blocking the loading of th…  (Closed) 
  Base URL: https://skia.googlesource.com/buildbot@master
    
  
    Issue 1926683002:
  docserver: Load JS async defer since it really isn't required and it was blocking the loading of th…  (Closed) 
  Base URL: https://skia.googlesource.com/buildbot@master| OLD | NEW | 
|---|---|
| (Empty) | |
| 1 sk.DomReady.then(function() { | |
| 2 prettyPrint(); | |
| 3 | |
| 4 // Open the side drawer with the navigation menu. | |
| 5 $$$('button').addEventListener('click', function(e) { | |
| 6 $$$('#drawer').classList.add('opened'); | |
| 7 e.stopPropagation(); | |
| 8 }); | |
| 9 | |
| 10 // Close the side drawer. | |
| 11 $$$('body').addEventListener('click', function() { | |
| 12 $$$('#drawer').classList.remove('opened'); | |
| 13 }); | |
| 14 | |
| 15 // highlightNav highlights where we are in the navigation. | |
| 16 var highlightNav = function() { | |
| 17 $$('#drawer li a').forEach(function(e) { | |
| 18 if (e.dataset.path == window.location.pathname) { | |
| 19 e.classList.add('selected'); | |
| 20 $$$('title').innerText = e.innerText; | |
| 21 } else { | |
| 22 e.classList.remove('selected'); | |
| 23 } | |
| 24 }); | |
| 25 } | |
| 26 | |
| 27 // Shortcut the links and handle them via XHR, that way we only | |
| 28 // pay the loading time once, yet still retain full URLs. | |
| 29 $$('#drawer li a').forEach(function(e) { | |
| 30 e.addEventListener('click', function(e) { | |
| 31 // Preserve query parameters as we navigate. | |
| 32 var q = window.location.search; | |
| 33 var url = e.target.dataset.path; | |
| 34 if (q != "") { | |
| 35 url += q; | |
| 36 } | |
| 37 sk.get('/_'+url).then(function(content) { | |
| 38 window.history.pushState(null, null, url); | |
| 39 highlightNav(); | |
| 40 $$$('html #content').innerHTML = content; | |
| 41 $$$('html #page').scrollIntoView(); | |
| 42 prettyPrint(); | |
| 43 }); | |
| 44 e.preventDefault(); | |
| 45 }); | |
| 46 }); | |
| 47 | |
| 48 highlightNav(); | |
| 49 }); | |
| 50 | |
| 51 (function() { | |
| 52 var cx = '009791159600898516779:8-nlv0iznho'; | |
| 53 var gcse = document.createElement('script'); | |
| 54 gcse.type = 'text/javascript'; | |
| 55 gcse.async = true; | |
| 56 gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + | |
| 57 '//cse.google.com/cse.js?cx=' + cx; | |
| 58 var s = document.getElementsByTagName('script')[0]; | |
| 
dogben
2016/04/27 17:10:31
Is this referring to the script element that you r
 
jcgregorio
2016/04/27 17:17:30
No, this is just code that says add this new scrip
 | |
| 59 s.parentNode.insertBefore(gcse, s); | |
| 60 })(); | |
| OLD | NEW |