Skip to content

Commit

Permalink
Fixit
Browse files Browse the repository at this point in the history
  • Loading branch information
ploubser committed Oct 25, 2010
1 parent 99c7059 commit 869f402
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions vendor/plugins/bernard_gauge/lib/gauge_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class GaugeController < ApplicationController
def redraw_gauge
div = ""
value = ""
if params[:id] =~/item(\d+)/
div = "con#{$1}"
end

@parameters = {}
params[:parameters].split(";").each do |p|
tmp = p.split(/:/, 2)
@parameters[tmp[0]] = tmp[1]
end

unless @parameters["remote"] == "true"
tmp = File.open(@parameters["path"], 'r')
value = tmp.gets()
else
Net::HTTP.start(@parameters["url"]) do |http|
resp = http.get("/#{@parameters["path"]}")
value = resp.body
end
end

render :update do |page|
page << "redrawGauge(#{value}, '#{div}')"
end
end
end

0 comments on commit 869f402

Please sign in to comment.