Commit 2002fae9 authored by Luke Macken's avatar Luke Macken

First attempt at using jQuery Sparklines.

alert(jQuery('body').html()) looks good, but none of our DOM changes
are reflected in the widget.
parent 5769d6a7
This diff is collapsed.
This diff is collapsed.
...@@ -276,6 +276,16 @@ class PyrasiteWindow(Gtk.Window): ...@@ -276,6 +276,16 @@ class PyrasiteWindow(Gtk.Window):
io = p.get_io_counters() io = p.get_io_counters()
self.info_html = """ self.info_html = """
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<head>
<style> <style>
body {font: normal 12px/150%% Arial, Helvetica, sans-serif;} body {font: normal 12px/150%% Arial, Helvetica, sans-serif;}
.grid table { border-collapse: collapse; text-align: left; width: 100%%; } .grid table { border-collapse: collapse; text-align: left; width: 100%%; }
...@@ -290,9 +300,14 @@ class PyrasiteWindow(Gtk.Window): ...@@ -290,9 +300,14 @@ class PyrasiteWindow(Gtk.Window):
.grid table tbody .alt td { background: #E1EEf4; color: #00557F; } .grid table tbody .alt td { background: #E1EEf4; color: #00557F; }
.grid table tbody td:first-child { border: none; } .grid table tbody td:first-child { border: none; }
</style> </style>
</head>
<body>
<h2>%(title)s</h2> <h2>%(title)s</h2>
<ul> <ul>
Sparkline:
<span id="cpu_graph" class="cpu_graph">Loading</span>
<br/>
<li><b>CPU:</b> %(cpu)0.2f%% (%(cpu_user)s user, %(cpu_sys)s system)</li> <li><b>CPU:</b> %(cpu)0.2f%% (%(cpu_user)s user, %(cpu_sys)s system)</li>
<li><b>Memory:</b> %(mem)0.2f%% (%(mem_rss)s RSS, %(mem_vms)s VMS)</li> <li><b>Memory:</b> %(mem)0.2f%% (%(mem_rss)s RSS, %(mem_vms)s VMS)</li>
<li><b>Read count:</b> %(read_count)s</li> <li><b>Read count:</b> %(read_count)s</li>
...@@ -372,6 +387,8 @@ class PyrasiteWindow(Gtk.Window): ...@@ -372,6 +387,8 @@ class PyrasiteWindow(Gtk.Window):
thread.user_time, thread.system_time) thread.user_time, thread.system_time)
self.info_html += "</tbody></table></div>" self.info_html += "</tbody></table></div>"
self.info_html += "</body></html>"
self.info_view.load_string(self.info_html, "text/html", "utf-8", '#') self.info_view.load_string(self.info_html, "text/html", "utf-8", '#')
# The Details tab # The Details tab
...@@ -397,6 +414,27 @@ class PyrasiteWindow(Gtk.Window): ...@@ -397,6 +414,27 @@ class PyrasiteWindow(Gtk.Window):
self.details_view.load_string(self.details_html, "text/html", "utf-8", '#') self.details_view.load_string(self.details_html, "text/html", "utf-8", '#')
def test():
# Inject jQuery
jquery = file('jquery-1.7.1.min.js')
self.details_view.execute_script(jquery.read())
jquery.close()
# Inject Sparkline
sparkline = file('jquery.sparkline.min.js')
self.details_view.execute_script(sparkline.read())
sparkline.close()
# FIXME: alert works, sparkline does not...
self.details_view.execute_script("""
jQuery(document).ready(function() {
jQuery('#cpu_graph').sparkline();
alert('FOO');
});
""")
GObject.timeout_add(500, test)
def update_progress(self, fraction, text=None): def update_progress(self, fraction, text=None):
if text: if text:
self.progress.set_text(text + '...') self.progress.set_text(text + '...')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment