forked from gtk-rs/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaypen.js
1 lines (1 loc) · 833 Bytes
/
playpen.js
1
document.addEventListener('DOMContentLoaded',function(){'use strict';if(!window.playgroundUrl){return;}var featureRegexp=new RegExp('^\s*#!\\[feature\\(\.*?\\)\\]');var elements=document.querySelectorAll('pre.rust-example-rendered');Array.prototype.forEach.call(elements,function(el){el.onmouseover=function(e){if(el.contains(e.relatedTarget)){return;}var a=document.createElement('a');a.setAttribute('class','test-arrow');a.textContent='Run';var code=el.previousElementSibling.textContent;var channel='';if(featureRegexp.test(code)){channel='&version=nightly';}a.setAttribute('href',window.playgroundUrl+'?code='+encodeURIComponent(code)+channel);a.setAttribute('target','_blank');el.appendChild(a);};el.onmouseout=function(e){if(el.contains(e.relatedTarget)){return;}el.removeChild(el.querySelectorAll('a.test-arrow')[0]);};});});