From: Mart Lubbers Date: Tue, 6 May 2014 20:01:53 +0000 (+0200) Subject: js stuff X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=b736cd98e8e3c3bb6a9db6082d1e6e9fcb937283;p=bsc-thesis1415.git js stuff --- diff --git a/program/hypfront/hyper.py b/program/hypfront/hyper.py index e773f86..bcf521e 100644 --- a/program/hypfront/hyper.py +++ b/program/hypfront/hyper.py @@ -1,11 +1,11 @@ #!/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): @@ -16,8 +16,13 @@ def req_pre(req): HyperFrontend RSS feed input + + Selecteer iets en klik de link
+ + + """) @@ -34,13 +39,15 @@ def feed2html(req, url, name): req.write('\tLoading "{}" as "{}"
\n'.format(url, name)) feed = feedparser.parse(url) channel = feed.feed - req.write('\t\n') - req.write('\t\t\n') + req.write('\t
Title...
\n') + req.write('\t\t\n') for i in feed.entries: - req.write('\t\t\n'. - format(i['title'].encode('ascii', 'xmlcharrefreplace'))) - - req.write('\t
TitleSummary...
{}...
\n') + req.write('\t\t{}{}...\n'. + format(i['title'].encode('ascii', 'xmlcharrefreplace'), + i['summary'].encode('ascii', 'xmlcharrefreplace'))) + req.write('\t\n
') + for k, v in feed.entries[0].iteritems(): + req.write('{}: {}
\n'.format(k, v)) def handler(req): diff --git a/program/hypfront/sel.js b/program/hypfront/sel.js new file mode 100644 index 0000000..1cd90a7 --- /dev/null +++ b/program/hypfront/sel.js @@ -0,0 +1,58 @@ +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()); + }); +} + +