<?php
/**
* generate javascript to get page content and post to taggingmanager
*
* @author hide@address.com
* @version 1.0.1
* @package TaggingManager
*/
$root_path = './';
include_once($root_path.'config.php');
?>
(function() {
function getSel()
{
var txt = '';
if (window.getSelection)
{
txt = window.getSelection();
}
else if (document.getSelection)
{
txt = document.getSelection();
}
else if (document.selection)
{
txt = document.selection.createRange().text;
}
else return txt;
return txt;
}
function getdocumentcode(obj)
{
var code = "";
if (obj.document.childNodes.length > 1){
code = obj.document.lastChild.innerHTML;
}
if (!code && obj.document.childNodes.length == 1){
code = obj.document.childNodes[0].innerHTML;
}
if (!code){
code = obj.document.body.innerHTML;
}
if (code){
code = '<html>' + code + '</html>';
}
return code;
}
try {
var documentcode = getdocumentcode(window);
var snipset = getSel();
var elm = document.createElement("div");
elm.id = "filter";
with(elm.style){position="absolute";top=0;left=0;width="1600px";height="1200px";backgroundColor="#eeeeee";opacity=.6;zindex=8888;};
document.body.appendChild(elm);
// data - form
var formelm = document.createElement('form');
var elm1 = document.createElement('input');
var elm2 = document.createElement('input');
var elm3 = document.createElement('textarea');
var elm4 = document.createElement('input');
// title
elm1.name = "t";
elm1.value = document.title;
// url
elm2.name = "u";
elm2.value = location.href;
// body
elm3.name = "b";
elm3.appendChild(document.createTextNode(documentcode));
// snipset
elm4.name = "x";
elm4.value = getSel();
// form
formelm.appendChild(elm1);
formelm.appendChild(elm2);
formelm.appendChild(elm3);
formelm.appendChild(elm4);
formelm.style.display = 'none';
try{
document.body.appendChild(formelm);
}catch(e){
document.appendChild(formelm);
}
// submit
var chr = document.charset;
formelm.action = "<? echo $location; ?>/filter.php";
formelm.method = "POST";
formelm.acceptCharset = "utf-8";
document.charset = "utf-8";
formelm.submit();
// close
document.charset = chr;
}catch(err){
document.location="<? echo $location; ?>/filter.php?url="+location.href;
}
})();