Permalink
Browse files

Linking stuff up

  • Loading branch information...
1 parent fb051d9 commit 9fe3f0e88ed00c050665d516ba185ef6b1c2025f @feross committed Nov 6, 2011
Showing with 47 additions and 39 deletions.
  1. +1 −0 .gitignore
  2. +4 −0 mainwindow.cpp
  3. +2 −34 resources/index.html
  4. +27 −2 resources/js/script.js
  5. +13 −3 resources/js/stories/request.js
View
@@ -5,5 +5,6 @@ fireflock
*.o
moc_fireflock.cpp
moc_mainwindow.cpp
+moc_backendthread.cpp
qrc_fireflock.cpp
Makefile
View
@@ -4,6 +4,7 @@
#include <QWebFrame>
#include <QWebElementCollection>
#include <QNetworkDiskCache>
+#include <QWebSettings>
class UserAgentWebPage : public QWebPage {
QString userAgentForUrl(const QUrl &url ) const {
@@ -36,6 +37,9 @@ MainWin::MainWin(QWidget * parent) : QWebView(parent)
// qrc:// URLs refer to resources. See fireflock.qrc
QUrl startURL = QUrl("qrc:/index.html");
+ // disable same origin
+ page()->settings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true);
+
// Load web content now!
setUrl(startURL);
}
View
@@ -44,39 +44,7 @@
<h1>Anon User 1</h1>
<div class="stories">
- <a href="http://cnn.com" target="_blank" class="story clearfix">
- <img class="favicon" src="img/favicon.gif">
- <span class="desc">Visited <b>Greek prime minister set to form new government - CNN.com</b>.</span>
- </a>
- <a href="#" class="story clearfix">
- <img class="favicon" src="img/favicon.gif">
- <span class="desc">Visited <b>Greek prime minister set to form new government - CNN.com</b>.</span>
- </a>
- <a href="#" class="story clearfix">
- <img class="favicon" src="img/favicon.gif">
- <span class="desc">Visited <b>Greek prime minister set to form new government - CNN.com</b>.</span>
- </a>
- <a href="#" class="story clearfix">
- <img class="favicon" src="img/favicon.gif">
- <span class="desc">Visited <b>Greek prime minister set to form new government - CNN.com</b>.</span>
- </a>
- <a href="#" class="story clearfix">
- <img class="favicon" src="img/favicon.gif">
- <span class="desc">Visited <b>Greek prime minister set to form new government - CNN.com</b>.</span>
- </a>
- <a href="#" class="story clearfix">
- <img class="favicon" src="img/favicon.gif">
- <span class="desc">Visited <b>Greek prime minister set to form new government - CNN.com</b>.</span>
- </a>
- <a href="#" class="story clearfix">
- <img class="favicon" src="img/favicon.gif">
- <span class="desc">Visited <b>Greek prime minister set to form new government - CNN.com</b>.</span>
- </a>
- <a href="#" class="story clearfix">
- <img class="favicon" src="img/favicon.gif">
- <span class="desc">Visited <b>Greek prime minister set to form new government - CNN.com</b>.</span>
- </a>
- <a href="#" class="story clearfix">
+ <a href="http://cnn.com" class="story clearfix">
<img class="favicon" src="img/favicon.gif">
<span class="desc">Visited <b>Greek prime minister set to form new government - CNN.com</b>.</span>
</a>
@@ -99,7 +67,7 @@
<script src="js/identifyUser.js"></script>
<script src="js/plugins.js"></script>
- <script src="js/users.js"></script>
+ <script src="js/users.js"></script>
<script src="js/script.js"></script>
</body>
@@ -8,6 +8,8 @@ window.Client = {
requestMap: {},
handlePacket: function(data) {
+ $('body').append($('<div>').text(data));
+
if (typeof data == "string") {
data = $.parseJSON(data);
}
@@ -48,8 +50,6 @@ window.Client = {
},
renderStory: function(userIndex, storyData) {
- log(storyData);
- log(userIndex);
if ($("#user"+userIndex).length == 0) {
this.addUser(userIndex);
}
@@ -93,13 +93,38 @@ $(function() {
});
function sim() {
+<<<<<<< HEAD
var testPacket = {"type":"request", "path":"/home.php", "userIP":"127.0.0.1", "hostname":"www.nikilster.com"};
var testPacket2 = {"type":"request", "path":"/watch?v=RF9PFJI_t5I&feature=feedrec_grec_index", "userIP":"100.0.0.1", "hostname":"www.youtube.com"};
var testPacket3 = {"type":"response", "path":"/watch?v=RF9PFJI_t5I&feature=feedrec_grec_index", "userIP":"100.0.0.1", "hostname":"www.facebook.com", "body":"<div><a class='headerTinymanName' href='test'>Nikil Viswanathan</a></div>"};
+=======
+ var testPacket = {"isResponse":false,"serverIP":"87.238.50.204:80","userIP":"10.32.142.68:53598","method":"GET","path":"/4.7-snapshot/qwebsettings.html","query":"","host":"doc.qt.nokia.com","cookies":"__switchTo5x=7; __unam=f59ceff-133752ee443-5b04aad3-2; __utma=262969676.49335727.1320514537.1320518103.1320520985.3; __utmc=262969676; __utmz=262969676.1320520985.3.3.utmcsr=blog.qt.nokia.com|utmccn=(referral)|utmcmd=referral|utmcct=/2010/06/03/qt-is-going-over-the-top-to-bring-online-video-to-connected-tvs/; __utma=15568163.1687546187.1320514529.1320543628.1320547915.6; __utmb=15568163.7.10.1320547915; __utmc=15568163; __utmz=15568163.1320547915.6.4.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided)","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.106 Safari/535.2"}
+>>>>>>> Linking stuff up
Client.handlePacket(testPacket);
+<<<<<<< HEAD
Client.handlePacket(testPacket);
Client.handlePacket(testPacket);
Client.handlePacket(testPacket);
Client.handlePacket(testPacket);
+<<<<<<< HEAD
+}
+=======
+
+ // $.get('sample.log', function(data){
+ // var pkts = data.split('\n');
+ // log("Loaded "+pkts.length+" packets...");
+ // var i = 0;
+ // setInterval(function(){
+ // var pkt = $.trim(pkts[i]);
+ // i++;
+ // //ignore empty lines
+ // if(pkt.length == 0)
+ // return;
+ // Client.handlePacket(pkt);
+ // }, 1000);
+ // });
+=======
+>>>>>>> Linking stuff up
}
+>>>>>>> Linking stuff up
@@ -4,16 +4,26 @@ var requestStory = {
//Applies to requests
appliesToPacket: function(packet){
- return packet['type'] == "request";
+ return packet['isResponse'] == false &&
+ packet['method'] == 'GET' &&
+ packet['path'].indexOf('.css') == -1 &&
+ packet['path'].indexOf('.js') == -1;
},
//Just return the url and time
renderStory: function(packet){
- var url = packet['hostname'] + packet['path'];
+ var url = 'http://' + packet['hostname'] + packet['path'];
var now = new Date();
var timeStr = now.getHours() + ":" + now.getMinutes();
- var desc = "Visited <b>Greek prime minister set to form new SDJKHJKLSDHKJLFH - CNN.com</b>.";
+ $.load(url, function(data) {
+ var dom = $('<div>').html(data);
+ var title = dom.find('title').text();
+ });
+
+ alert(title);
+
+ var desc = title;
return {
href: url,
favicon: "img/favicon.gif",

0 comments on commit 9fe3f0e

Please sign in to comment.