Jump to content

User:Frietjes/docsandboxtestcaseslinks.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Frietjes (talk | contribs) at 15:35, 8 September 2014. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// Adds [sandbox] and [testcases] to the documentation links
// Clicking on [sandbox] and [testcases] will view those respective pages
//
var span_element = document.getElementById('doc_editlinks');
if(span_element.innerHTML.search(/\[<a[^<>]*>view<\/a>\]/g) >= 0) {
  var view_link = span_element.innerHTML.replace(/^.*(\[<a[^<>]*>view<\/a>\]).*$/, '$1');
  var sandbox_link = view_link.replace(/("[^"]*\/)doc(?:\/[^"]*|)(")/g, '$1/sandbox$2');
  sandbox_link = sandbox_link.replace(/>view</, '>sandbox<');
  var testcases_link = view_link.replace(/("[^"]*\/)doc(?:\/[^"]*|)(")/g, '$1/testcases$2');
  testcases_link = testcases_link.replace(/>view</, '>testcases<');
  span_element.innerHTML = span_element.innerHTML + ' ' + sandbox_link + ' ' + testcases_link;
}