+var selection;
var mouse_x = 0;
var mouse_y = 0;
var mouse_left = false;
}
function init(a, w) {
+ console.log(a)
var b = document.createElement("DIV");
b.id = "contextmenu";
if (!w) var w = 120;
b.style.width = w + "px";
- var c = '<div style="position:relative;left:1px;top:-1px;">';
+ var c = '<div style="position:relative;left:5px;top:-4px;">';
c += a;
c += '</div>';
+ console.log(c)
b.innerHTML = c;
b.style.position = "absolute";
b.style.left = "0px";
}
function mouseUp(e) {
- selection = getSelectionHtml()
+ var curselection = window.getSelection().getRangeAt(0);
+ if (curselection.endOffset - curselection.startOffset > 0)
+ selection = curselection;
+ console.log(selection)
if (e.which == 1) document.getElementById("contextmenu").style.visibility = "hidden";
else if (e.which == 3) mouse_right = false
}
document.getElementById("contextmenu").style.left = mouse_x + "px";
document.getElementById("contextmenu").style.top = mouse_y + "px";
document.getElementById("contextmenu").style.visibility = "visible"
- console.log(selection)
}
}
-function getSelectionHtml() {
- var html = "";
- if (typeof window.getSelection != "undefined") {
- var sel = window.getSelection();
- if (sel.rangeCount) {
- var container = document.createElement("div");
- for (var i = 0, len = sel.rangeCount; i < len; ++i) {
- container.appendChild(sel.getRangeAt(i).cloneContents());
- }
- html = container.innerHTML;
- }
- } else if (typeof document.selection != "undefined") {
- if (document.selection.type == "Text") {
- html = document.selection.createRange().htmlText;
+
+function stylizeHighlightedString(range, col)
+{
+ var selectionContents = range.extractContents();
+ var span = document.createElement("span");
+ span.appendChild(selectionContents);
+ span.setAttribute("class","uiWebviewHighlight");
+ span.style.backgroundColor = col;
+ span.style.color = "white";
+ range.insertNode(span);
+}
+
+function f_wanneer() {
+ stylizeHighlightedString(selection, "red")
+}
+
+function f_wat() {
+ stylizeHighlightedString(selection, "green")
+}
+
+function f_waar() {
+ stylizeHighlightedString(selection, "blue")
+}
+
+function post_all() {
+ var xmlhttp = new XMLHttpRequest();
+ xmlhttp.onreadystatechange=function()
+ {
+ if (xmlhttp.readyState==4)
+ {
+ document.write(xmlhttp.responseText);
}
}
- return html;
+ var params = "content="+encodeURIComponent(document.getElementsByTagName("table")[0].innerHTML);
+ xmlhttp.open("POST", "hyper.py", true);
+ xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ xmlhttp.setRequestHeader("Content-length", params.length);
+ xmlhttp.send(params);
}
<html>
<head>
<title>HyperFrontend RSS feed input</title>
- <script src="sel.js"></script>
+ <script src="contextmenu_o.js"></script>
<style type="text/css">
a:link {color: #000000 ; text-decoration: none; font-family: Verdana;font-size:8pt;}
a:visited {color: #0c2b86 ; text-decoration: none; font-family: Verdana;font-size:8pt;}
<body>
Selecteer iets en klik de link<br />
<button style="color:blue" onclick="javascript:f_waar()">Waar</button>
- <button style="color:green" onclick="javascript:f_wie()">Wie</button>
+ <button style="color:green" onclick="javascript:f_wat()">Wie</button>
<button style="color:red" onclick="javascript:f_wanneer()">Wanneer</button>
-<script language="javascript" type="text/javascript" src="contextmenu_o.js"></script>
<div style="position:absolute;left:12px;width:500px;"></div>
<script language="javascript" type="text/javascript">
var content='<b>Categorize</b><br />';
content+=' <a href="#" onclick="javascript:f_waar()">Waar</a><br />';
- content+=' <a href="#" onclick="javascript:f_wat()">Wat</a><br />';
+ content+=' <a href="#" onclick="javascript:f_wat()">Wat</a>';
content+=' <a href="#" onclick="javascript:f_wanneer()>Wanneer</a><br />';
+ content+=' Test 123';
init(content,120);
</script>
""")
def req_post(req):
req.write("""\
+ <button onclick="javascript:post_all()" method="post" target="_blank">Submit</button>
</body>
</html>
""")
for k, v in feed.entries[0].iteritems():
req.write('{}: {}<br />\n'.format(k, v))
-
def handler(req):
- req_pre(req)
- args = dict(filter(lambda x: x[1],
- map(lambda x: x.split('='),
- req.__getattribute__('args').split('&'))))
- if 'url' not in args and 'name' not in args:
- req.write('Something went wrong, empty fields?<br />')
- req.write('<a href="index.html">back</a>')
+ if req.method == "POST":
+ raise Exception("POSTEDDDD")
else:
- feed2html(req, args['url'], args['name'])
- req_post(req)
- return apache.OK
+ req_pre(req)
+ args = dict(filter(lambda x: x[1],
+ map(lambda x: x.split('='),
+ req.__getattribute__('args').split('&'))))
+ if 'url' not in args and 'name' not in args:
+ req.write('Something went wrong, empty fields?<br />')
+ req.write('<a href="index.html">back</a>')
+ else:
+ feed2html(req, args['url'], args['name'])
+ req_post(req)
+ return apache.OK