@@ -66,12 +66,19 @@ function test_py_import(line) {
6666
6767
6868// test if URL exists
69- // slow??
70- function UrlExists ( url ) {
69+ // make sure it's asynchronous otherwise hangs!
70+ function check_URL_add_link ( url , cell ) {
7171 var http = new XMLHttpRequest ( ) ;
72- http . open ( 'HEAD' , url , false ) ;
72+ http . open ( 'HEAD' , url ) ;
73+ http . onreadystatechange = function ( ) {
74+ if ( this . readyState == 4 ) {
75+ if ( this . status != 404 ) {
76+ var srcText = "   <a href=\"" + url + "\" style=\"text-decoration:underline;\">[goto src]</a>" ;
77+ cell . innerHTML = cell . innerHTML . concat ( srcText ) ;
78+ }
79+ }
80+ } ;
7381 http . send ( ) ;
74- return http . status != 404 ;
7582}
7683
7784
@@ -117,18 +124,20 @@ for (var i = 0; i < rows.length; ++i) {
117124 // we add in a tag to go to the src file instead
118125 // THIS ASSUMES THE FILE IS IN /src/ DIRECTORY
119126 // but what if it is in /plugins???
120- // brutal way atm to tell if it's .cpp or .cc. Need github API here!
121127 var srcPath = link . replace ( "interface" , "src" ) ;
122128 var cppSrc = srcPath . replace ( ".h" , ".cpp" ) ;
123129 var ccSrc = srcPath . replace ( ".h" , ".cc" ) ;
124- if ( UrlExists ( cppSrc ) )
125- srcPath = cppSrc ;
126- else if ( UrlExists ( ccSrc ) )
127- srcPath = ccSrc ;
128- if ( srcPath != link . replace ( "interface" , "src" ) ) {
129- var srcText = "   <a href=\"" + srcPath + "\" style=\"text-decoration:underline;\">[goto src]</a>" ;
130- cell . innerHTML = cell . innerHTML . concat ( srcText ) ;
131- }
130+ check_URL_add_link ( cppSrc , cell ) ;
131+ check_URL_add_link ( ccSrc , cell ) ;
132+ // console.log(a);
133+ // if (check_URL_add_link(cppSrc))
134+ // srcPath = cppSrc;
135+ // else if (check_URL_add_link(ccSrc))
136+ // srcPath = ccSrc;
137+ // if (srcPath != link.replace("interface", "src")) {
138+ // var srcText = "   <a href=\""+srcPath+"\" style=\"text-decoration:underline;\">[goto src]</a>";
139+ // cell.innerHTML = cell.innerHTML.concat(srcText);
140+ // }
132141 }
133142
134143 // tests for python imports/fragments
0 commit comments