User:Grandiosarceus/Embed DocStoc.js

/* Author: Jesús Martínez Novo "Ciencia Al Poder" License: http://www.gnu.org/copyleft/gpl.html GNU General Public Licence 2.0 or later Use on a page: View the doc You can modify the width, height and href to fit the width, height and location of the movie. */ function playDocstoc{ var divs = document.getElementById('bodyContent').getElementsByTagName('div'); var dsobjcode = ''; if (window.ActiveXObject){ // IE		dsobjcode += ''; }else{ dsobjcode += ''; }	dsobjcode += ' Download the required FlashPlayer Plug-in to view the doc. ';	for (var i = 0; i < divs.length; i++){ if ((' Docstoc ').indexOf(' '+divs[i].className+' ') != -1){ try{ var dsdiv = divs[i]; var width = dsdiv.style.width.replace('px',''); var height = dsdiv.style.width.replace('px',''); var src = dsdiv.getElementsByTagName('a')[0].href; var doc = ''; var mem = ''; if (src.indexOf('?') < 0) continue; var qsparam = src.substring(src.indexOf('?')+1,src.length).split('&'); for (var i=0; i < qsparam.length; i++){ var parg = qsparam[i].split('='); if (parg[0] == 'doc_id') doc = parg[1]; if (parg[0] == 'mem_id') mem = parg[1]; }				var movie = dsobjcode.replace(/\{width\}/g,width).replace(/\{height\}/g,height).replace(/\{src\}/g,src).replace(/\{doc\}/g,doc).replace(/\{mem\}/g,mem); dsdiv.innerHTML = movie; }catch(e){}; }	} } addOnloadHook(playDocstoc); /* */