<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[12847] CalendarServer/trunk/calendarserver/webadmin/work.xhtml</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/12847">12847</a></dd>
<dt>Author</dt> <dd>wsanchez@apple.com</dd>
<dt>Date</dt> <dd>2014-03-07 13:34:28 -0800 (Fri, 07 Mar 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>refactor a bit</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunkcalendarserverwebadminworkxhtml">CalendarServer/trunk/calendarserver/webadmin/work.xhtml</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunkcalendarserverwebadminworkxhtml"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/calendarserver/webadmin/work.xhtml (12846 => 12847)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/calendarserver/webadmin/work.xhtml        2014-03-07 21:00:13 UTC (rev 12846)
+++ CalendarServer/trunk/calendarserver/webadmin/work.xhtml        2014-03-07 21:34:28 UTC (rev 12847)
</span><span class="lines">@@ -57,6 +57,8 @@
</span><span class="cx"> <script>
</span><span class="cx"> //<![CDATA[
</span><span class="cx">
</span><ins>+ var debug = false;
+
</ins><span class="cx"> var workTypeDescriptions = {
</span><span class="cx"> // Scheduling
</span><span class="cx"> "SCHEDULE_ORGANIZER_WORK": "Schedule Organizer",
</span><span class="lines">@@ -90,7 +92,7 @@
</span><span class="cx"> "FIND_MIN_VALID_REVISION_WORK": "Revision Cleanup: Find Minimum",
</span><span class="cx"> };
</span><span class="cx">
</span><del>- var jobItemAttributeDescriptions = {
</del><ins>+ var jobAttributeDescriptions = {
</ins><span class="cx"> "jobID": "Job ID",
</span><span class="cx"> "priority": "Job Priority",
</span><span class="cx"> "notBefore": "Not Before",
</span><span class="lines">@@ -107,6 +109,7 @@
</span><span class="cx"> "work_attendee": "Attendee",
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+
</ins><span class="cx"> // Function to return keys from an object in order, followed by keys
</span><span class="cx"> // from another which were not in the first.
</span><span class="cx"> // We use this in case we get a JSON dictionary with keys that haven't
</span><span class="lines">@@ -127,14 +130,9 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- var debug = false;
</del><span class="cx">
</span><span class="cx"> var maxSeen = 30;
</span><span class="cx">
</span><del>- var eventSource;
- var itemTypeEventListener;
- var itemTypeEventListenerWorkType;
-
</del><span class="cx"> function drawChart(data) {
</span><span class="cx"> var items = [];
</span><span class="cx">
</span><span class="lines">@@ -261,7 +259,7 @@
</span><span class="cx"> "transform",
</span><span class="cx"> function(i) { return "translate(" + xInset + "," + yLocation(i.description) + ")"; }
</span><span class="cx"> )
</span><del>- .attr("onclick", function(i) { return 'showDetails("' + i.name + '");'; })
</del><ins>+ .attr("onclick", function(i) { return 'showJobDetails("' + i.name + '");'; })
</ins><span class="cx"> ;
</span><span class="cx">
</span><span class="cx"> // Exit bars selection
</span><span class="lines">@@ -297,7 +295,8 @@
</span><span class="cx"> inner.exit().remove();
</span><span class="cx"> }
</span><span class="cx">
</span><del>- function initChart() {
</del><ins>+
+ function initChart() {
</ins><span class="cx"> var data = {};
</span><span class="cx">
</span><span class="cx"> for (var key in workTypeDescriptions) {
</span><span class="lines">@@ -307,6 +306,9 @@
</span><span class="cx"> drawChart(data);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+
+ var eventSource;
+
</ins><span class="cx"> function registerForEvents() {
</span><span class="cx"> eventSource = new EventSource("./events");
</span><span class="cx">
</span><span class="lines">@@ -322,7 +324,11 @@
</span><span class="cx"> );
</span><span class="cx"> }
</span><span class="cx">
</span><del>- function showDetails(workType) {
</del><ins>+
+ var itemTypeEventListener;
+ var itemTypeEventListenerWorkType;
+
+ function showJobDetails(workType) {
</ins><span class="cx"> var debuggingContainer = document.getElementById("debug");
</span><span class="cx">
</span><span class="cx"> if (debug) {
</span><span class="lines">@@ -370,59 +376,67 @@
</span><span class="cx"> eventDebug.innerHTML = e.data;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- // Reset the rows; we're going to refill the table below
- detailsBody.innerHTML = "";
-
</del><span class="cx"> var jobItems = JSON.parse(e.data);
</span><span class="cx">
</span><del>- function addCellToRow(row, tag, text) {
- var cell = document.createElement(tag);
- var content = document.createTextNode(text);
- cell.appendChild(content);
- row.appendChild(cell);
- }
</del><ins>+ drawJobDetails(jobItems, detailsTable, detailsCaption, detailsHeader, detailsBody);
+ }
</ins><span class="cx">
</span><del>- for (var i in jobItems) {
- var jobItem = jobItems[i]; // OMG JavaScript is so stupid.
</del><ins>+ eventSource.addEventListener(workType, itemTypeEventListener)
+ }
</ins><span class="cx">
</span><del>- // Unhide the table
- detailsTable.style.display = "block";
-
- var attributes = keysInKindOfKnownOrder(jobItemAttributeDescriptions, jobItem);
</del><span class="cx">
</span><del>- // Add the table headers if they aren't already there
- if (detailsHeader.innerHTML == "") {
- var row = document.createElement("tr");
</del><ins>+ function drawJobDetails(jobItems, detailsTable, detailsCaption, detailsHeader, detailsBody) {
+ // Reset the rows; we're going to refill the table below
+ detailsBody.innerHTML = "";
</ins><span class="cx">
</span><del>- for (var i in attributes) {
- var attribute = attributes[i]; // OMG JavaScript, wow you so dumb
- attributeDescription = valueOrKey(jobItemAttributeDescriptions, attribute)
</del><ins>+ for (var i in jobItems) {
+ var jobItem = jobItems[i]; // OMG JavaScript is so stupid.
</ins><span class="cx">
</span><del>- addCellToRow(row, "th", attributeDescription)
- }
</del><ins>+ // Unhide the table
+ detailsTable.style.display = "block";
+
+ var attributes = keysInKindOfKnownOrder(jobAttributeDescriptions, jobItem);
</ins><span class="cx">
</span><del>- detailsHeader.appendChild(row);
- }
-
- // Add a table row for this job item
</del><ins>+ // Add the table headers if they aren't already there
+ if (detailsHeader.innerHTML == "") {
</ins><span class="cx"> var row = document.createElement("tr");
</span><span class="cx">
</span><span class="cx"> for (var i in attributes) {
</span><del>- var attribute = attributes[i]; // OMG JavaScript the lameness
</del><ins>+ var attribute = attributes[i]; // OMG JavaScript, wow you so dumb
+ attributeDescription = valueOrKey(jobAttributeDescriptions, attribute)
</ins><span class="cx">
</span><del>- var value = jobItem[attribute]
- if (value === null) { value = ""; }
-
- addCellToRow(row, "td", value)
</del><ins>+ addCellToRow(row, "th", attributeDescription)
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- detailsBody.appendChild(row);
</del><ins>+ detailsHeader.appendChild(row);
</ins><span class="cx"> }
</span><ins>+
+ // Add a table row for this job item
+ var row = document.createElement("tr");
+
+ for (var i in attributes) {
+ var attribute = attributes[i]; // OMG JavaScript the lameness
+
+ var value = jobItem[attribute]
+ if (value === null) { value = ""; }
+
+ addCellToRow(row, "td", value)
+ }
+
+ detailsBody.appendChild(row);
</ins><span class="cx"> }
</span><ins>+ }
</ins><span class="cx">
</span><del>- eventSource.addEventListener(workType, itemTypeEventListener)
</del><ins>+
+ function addCellToRow(row, tag, text) {
+ var cell = document.createElement(tag);
+ var content = document.createTextNode(text);
+
+ cell.appendChild(content);
+ row.appendChild(cell);
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+
</ins><span class="cx"> window.onload = function() {
</span><span class="cx"> initChart();
</span><span class="cx"> registerForEvents();
</span></span></pre>
</div>
</div>
</body>
</html>