#!/bin/env python
# -*- coding: utf-8 -*-
+from mod_python import apache
import feedparser
-import urllib
import pprint
import re
-from mod_python import apache
+import urllib
def req_pre(req):
<html>
<head>
<title>HyperFrontend RSS feed input</title>
+ <script src="sel.js"></script>
</head>
<body>
+ Selecteer iets en klik de link<br />
+ <button onclick="javascript:f_wie()">Wie</button>
+ <button onclick="javascript:f_wat()">Wat</button>
+ <button onclick="javascript:f_wan()">Wanneer</button>
""")
req.write('\tLoading "{}" as "{}"<br />\n'.format(url, name))
feed = feedparser.parse(url)
channel = feed.feed
- req.write('\t<table border="1">\n')
- req.write('\t\t<tr><th>Title</th><th>...</th></tr>\n')
+ req.write('\t<table border="1" id="htab">\n')
+ req.write('\t\t<tr><th>Title</th><th>Summary</th><th>...</th></tr>\n')
for i in feed.entries:
- req.write('\t\t<tr><td>{}</td><td>...</td></tr>\n'.
- format(i['title'].encode('ascii', 'xmlcharrefreplace')))
-
- req.write('\t</table>\n')
+ req.write('\t\t<tr><td>{}</td><td>{}</td><td>...</td></tr>\n'.
+ format(i['title'].encode('ascii', 'xmlcharrefreplace'),
+ i['summary'].encode('ascii', 'xmlcharrefreplace')))
+ req.write('\t</table>\n<br />')
+ for k, v in feed.entries[0].iteritems():
+ req.write('{}: {}<br />\n'.format(k, v))
def handler(req):
--- /dev/null
+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;
+ }
+ }
+ return html;
+}
+
+function stylizeHighlightedString()
+{
+ var range = window.getSelection().getRangeAt(0);
+ var selectionContents = range.extractContents();
+ var span = document.createElement("span");
+ span.appendChild(selectionContents);
+ span.setAttribute("class","uiWebviewHighlight");
+
+ span.style.backgroundColor = "red";
+ span.style.color = "white";
+
+ range.insertNode(span);
+}
+
+function f_wan() {
+ console.log("wanneer")
+ console.log(getSelectionHtml());
+ stylizeHighlightedString()
+}
+
+function f_wie() {
+ console.log("wie")
+ console.log(getSelectionHtml());
+}
+
+function f_wat() {
+ console.log("wat")
+ console.log(getSelectionHtml());
+}
+
+
+window.onload = function() {
+ var box = document.getElementById('htab');
+ box.addEventListener('contextmenu', function(e) {
+ console.log(getSelectionHtml());
+ });
+}
+
+