Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
cmt [2013/05/08 12:06] awfcmt [2013/05/09 13:03] awf
Line 1: Line 1:
 Notes on CMT Notes on CMT
  
-Link to translate URLs to links.  Add this to your browser toolbar.+Link to translate URLs to links.  Navigate to a page with URLs in it, then execute this in your browser's debug console. 
 + 
 +(On IE, press F12, select the "Console" tab, and paste in the code below.) 
 +<code> 
 +function replace_urls() { 
 +  n = document.getElementsByTagName('b'); 
 +  for(i = 0; i < n.length; ++i) { 
 +    if (n[i].innerText.match('URL:')) { 
 +      text = n[i].nextSibling; 
 +      url = text.wholeText.replace(/\s+/,''); 
 +      n[i].innerHTML = '<b>URL</b> (<'+'a target="_blank" href="' + url + '">link<'+'/a>):'; 
 +    } 
 +  } 
 +
 +replace_urls()</code> 
 +And this one zaps the links too 
 +<code> 
 +  n = document.getElementsByTagName('b'); 
 +  for(i = 0; i < n.length; ++i) { 
 +    if (n[i].innerText.match('URL:')) { 
 +      text = n[i].nextSibling; 
 +      url = text.wholeText.replace(/\s+/,''); 
 +      n[i].innerHTML = 'URL (<'+'a target="_blank" href="' + url + '">link<'+'/a>):'; 
 +      n[i].nextSibling.replaceNode(document.createElement('div')); 
 +    } 
 +  } 
 +</code>
 <html> <html>
 <script> <script>
 function replace_urls() { function replace_urls() {
-n = document.getElementsByTagName('b'); +  n = document.getElementsByTagName('b'); 
-for(i = 0; i < n.length; ++i) { +  for(i = 0; i < n.length; ++i) { 
-  if (n[i].innerText.match('URL:')) { +    if (n[i].innerText.match('URL:')) { 
-     text = n[i].nextSibling; +      text = n[i].nextSibling; 
- url = text.wholeText.replace(/\s+/,''); +      url = text.wholeText.replace(/\s+/,''); 
- nn = document.createElement('div'); +      nn = document.createElement('div'); 
- nn.innerHTML = '<'+'a target="_blank" href="' + url + '">Link<'+'/a>'; +      nn.innerHTML = '<b>URL</b> (<'+'a target="_blank" href="' + url + '">link<'+'/a>):'; 
- text.replaceNode(nn); +      n[i].replaceNode(nn); 
-     +    
-}+  }
 } }
 +
 </script> </script>
-<button onclick='javascript:replace_urls()'>replace</button>+<button onclick='javascript:replace_urls()'>TEST</button>
  
 <div> <div>
Line 24: Line 51:
 </html> </html>
  
 +~~DISCUSSION~~
  
cmt.txt · Last modified: 2021/04/13 13:50 by awf
CC Attribution 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0