<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>views/practice_xml.erb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -23,5 +23,9 @@ helpers do
     s.to_s.gsub(/[&amp;&quot;&gt;&lt;]/,'')
   end
   
+  def xml_child_int(xml,child_name)
+    xml.at(child_name).inner_text.to_i
+  end
+  
   alias :h :html_escape
 end
\ No newline at end of file</diff>
      <filename>helpers.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,7 +4,8 @@
   &lt;data_type&gt;csv&lt;/data_type&gt;
   &lt;background&gt;
     &lt;alpha&gt;90&lt;/alpha&gt;
-    &lt;border_alpha&gt;10&lt;/border_alpha&gt;
+    &lt;border_color&gt;000000&lt;/border_color&gt;
+    &lt;border_alpha&gt;100&lt;/border_alpha&gt;
   &lt;/background&gt;
   &lt;plot_area&gt;
     &lt;margins&gt;</diff>
      <filename>public/chart_1_settings.xml</filename>
    </modified>
    <modified>
      <diff>@@ -4,7 +4,8 @@
   &lt;data_type&gt;csv&lt;/data_type&gt;
   &lt;background&gt;
     &lt;alpha&gt;90&lt;/alpha&gt;
-    &lt;border_alpha&gt;10&lt;/border_alpha&gt;
+    &lt;border_color&gt;000000&lt;/border_color&gt;
+    &lt;border_alpha&gt;100&lt;/border_alpha&gt;  
   &lt;/background&gt;
   &lt;plot_area&gt;
     &lt;margins&gt;</diff>
      <filename>public/chart_2_settings.xml</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,7 @@
 body {
-	font-family: Arial, Helvetica, Verdana;
+	font-family:  'Century Gothic', Arial, Helvetica, Verdana;
+	margin: 0px;
+	background-color: #F1EBB9;
 }
 
 #left {
@@ -11,23 +13,75 @@ body {
 	margin-left: 440px;
 }
 
+#content {
+	margin: 10px;
+}
+
+/* Menu / Topbar stuff */
+
+#menu {
+	background-color: #52121C;
+	color: white;
+	margin: 0px;
+}
+
+#menu ul {
+	margin-top: 16px;
+	padding-right: 80px;
+	float: right;
+}
+
+#menu li {
+	display: inline;
+	margin-right: 12px;
+	padding: 7px 7px 12px 7px;
+}
+
+#menu li a, #menu li a:visited {
+	color: white;
+	text-decoration: none;
+}
+
+#menu li.selected a {
+	color: black;
+}
+
+#menu li.selected {
+	background-color: #F1EBB9;
+	color: black;
+	-moz-border-radius-topright: 12px;
+	-webkit-border-top-right-radius: 12px;
+	-moz-border-radius-topleft: 12px;
+	-webkit-border-top-left-radius: 12px;
+}
+
+#title {
+	font-size: 26px;
+	padding: 6px;
+}
+
+/* End menu stuff */
+
 table.classic {
-	width: 600px;
 	border: 1px solid black;
 	border-collapse: collapse;
 	font-size: x-small;
 	text-align: right;
 }
 
-.header {
+th {
 	background-color: black;
 	color: white;
 	text-align: center;
-	font-size: medium;
+	font-weight: normal;
 }
 
-.footer {
+#footer {
 	font-size: x-small;	
+	text-align: center;
+	clear: both;
+	margin-top: 12px;
+	padding: 8px;
 }
 
 .error {</diff>
      <filename>public/style.css</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,9 @@
 require 'rubygems'
 require 'sinatra'
 require 'andand'
+require 'hpricot'
+require 'lib/math_statistics'
+require 'activesupport'
 
 get '/' do
   erb :index
@@ -40,4 +43,67 @@ post '/' do
   erb :index
 end
 
+get '/practice_xml' do
+  erb :practice_xml
+end
+
+post '/practice_xml' do
+  data = Hpricot::XML(params[:data])
+  # Look for the name of the GP (the andand keeps it working when nothing is found)
+  @track_title = (data/:track_name).inner_text + ' ( ' + (data/:track_country_name).inner_text + ' )' 
+  
+  @sections = {}
+  1.upto(3) { |x| @sections[x] = (data/:&quot;time_#{x}&quot;).collect {|t| t.inner_text.to_f } }
+  total = @sections.collect { |s| s.last.median }.sum
+  @section_weight = @sections.collect { |s| s.last.median / total.to_f }
+  
+  # setup data init
+  @setup_data = {}
+  PARTS = [['front_wing','steer'],['rear_wing','grip'],['suspension'],['gears']]
+  
+  # put drp stuff in an easy array
+  # drp_data[lap_nr][skill_id]
+  # skills are:
+  SKILLS = %w{feedback_dqp acceleration braking top_speed kerb_use racing_line}
+  @drp_data = []
+  
+  # get the data from each lap
+  (data/:laps/:data).each do |lap| 
+    lap_nr = xml_child_int(lap,'lapnr')
+    @drp_data[lap_nr-1] ||= []
+    1.upto(3) do |section|
+      PARTS.each do |part|
+        # initialize arrays
+        @setup_data[part.first] ||= {}
+        @setup_data[part.first][section] ||= {}
+        @setup_data[part.first][section]['min'] ||= [0]
+        @setup_data[part.first][section]['max'] ||= [100]
+        # fill the arrays with minima and maxima
+        @setup_data[part.first][section]['min'] &lt;&lt; xml_child_int(lap,part.first) if xml_child_int(lap,&quot;feedback_#{part.last}_#{section}&quot;) == 1
+        @setup_data[part.first][section]['max'] &lt;&lt; xml_child_int(lap,part.first) if xml_child_int(lap,&quot;feedback_#{part.last}_#{section}&quot;) == -1
+      
+      end # part
+    end # section
+    SKILLS.each_index do |skill_id|
+      @drp_data[lap_nr-1][skill_id] = xml_child_int(lap,SKILLS[skill_id])
+    end
+  end # laps
+
+  # get the minima and maxima
+  PARTS.each do |part|
+    avgs = {}
+    1.upto(3) do |section|
+      # fill the arrays with minima and maxima
+      @setup_data[part.first][section]['min'] = @setup_data[part.first][section]['min'].max
+      @setup_data[part.first][section]['max'] = @setup_data[part.first][section]['max'].min
+      @setup_data[part.first][section]['avg'] = (@setup_data[part.first][section]['min'] + @setup_data[part.first][section]['max'])/2.to_f
+      avgs[section] = @setup_data[part.first][section]['avg']
+    end
+    @setup_data[part.first]['weighted_avg'] = avgs.collect { |section,avg| avg*@section_weight[section-1] }.sum
+  end 
+  
+
+  erb :practice_xml
+end
+
 require 'helpers.rb'
\ No newline at end of file</diff>
      <filename>sinatra_app.rb</filename>
    </modified>
    <modified>
      <diff>@@ -10,10 +10,6 @@
 			&lt;input type=&quot;submit&quot; /&gt;
 		&lt;/p&gt;
 	&lt;/form&gt;
-	&lt;p class=&quot;footer&quot;&gt;
-		OpenSource Software. &lt;a href=&quot;http://github.com/andruby/f1time-tools&quot;&gt;Sourcecode&lt;/a&gt; - 
-		&lt;a href=&quot;http://www.andrewsblog.org&quot;&gt;Andrewsblog&lt;/a&gt;
-	&lt;/p&gt;
 	&lt;% if @csv_for_chart_1 %&gt;
 		&lt;script type=&quot;text/javascript&quot; src=&quot;amline/swfobject.js&quot;&gt;&lt;/script&gt;
 		&lt;div id=&quot;chart_1&quot;&gt;You need to upgrade your Flash Player&lt;/div&gt;</diff>
      <filename>views/index.erb</filename>
    </modified>
    <modified>
      <diff>@@ -6,13 +6,24 @@
 		&lt;title&gt;Andrew's F1Time Tools&lt;/title&gt;
 	&lt;/head&gt;
 	&lt;body&gt;
-		&lt;h1&gt;Andrew's F1Time lap data extractor&lt;/h1&gt;
+	  &lt;div id=&quot;menu&quot;&gt;
+	    &lt;ul&gt;
+ 	     &lt;li&lt;%= ' class=&quot;selected&quot;' if request.path_info == '/' %&gt;&gt;&lt;a href=&quot;/&quot;&gt;lap data extractor&lt;/a&gt;&lt;/li&gt;
+ 	     &lt;li&lt;%= ' class=&quot;selected&quot;' if request.path_info == '/practice_xml' %&gt;&gt;&lt;a href=&quot;/practice_xml&quot;&gt;practice xml parser&lt;/a&gt;&lt;/li&gt;
+ 	   &lt;/ul&gt;
+	    &lt;div id=&quot;title&quot;&gt;Andrew's F1Time Tools&lt;/div&gt;
+	  &lt;/div&gt;
 		
 		&lt;% if @error %&gt;
 			&lt;div class=&quot;error&quot;&gt;&lt;%= @error %&gt;&lt;/div&gt;
 		&lt;% end %&gt;
 		
-		&lt;%= yield %&gt;
+		&lt;div id=&quot;content&quot;&gt;&lt;%= yield %&gt;&lt;/div&gt;
+		
+		&lt;div id=&quot;footer&quot;&gt;
+  		OpenSource Software. &lt;a href=&quot;http://github.com/andruby/f1time-tools&quot;&gt;Sourcecode&lt;/a&gt; - 
+  		&lt;a href=&quot;http://www.andrewsblog.org&quot;&gt;Andrewsblog&lt;/a&gt;
+		&lt;/div&gt;
 		
 		&lt;!-- Google Analytics Code --&gt;
 		&lt;script type=&quot;text/javascript&quot;&gt;</diff>
      <filename>views/layout.erb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>d85184e94a21b157458f927b275018e4ff399626</id>
    </parent>
  </parents>
  <author>
    <name>Andrew Fecheyr Lippens</name>
    <email>andrew@bedesign.be</email>
  </author>
  <url>http://github.com/andruby/f1time-tools/commit/06d7b12660727194c1b079b921fc8e622b2d1d81</url>
  <id>06d7b12660727194c1b079b921fc8e622b2d1d81</id>
  <committed-date>2009-04-23T18:54:03-07:00</committed-date>
  <authored-date>2009-04-23T18:54:03-07:00</authored-date>
  <message>New layout and added a xml parser for practice data</message>
  <tree>a39ececf2f04d359fa2e7a3100fcd47e5105f578</tree>
  <committer>
    <name>Andrew Fecheyr Lippens</name>
    <email>andrew@bedesign.be</email>
  </committer>
</commit>
