Skip to content

Commit

Permalink
wip of audience feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
binford2k committed Nov 7, 2013
1 parent c74dd45 commit 99a30dc
Show file tree
Hide file tree
Showing 8 changed files with 185 additions and 16 deletions.
26 changes: 23 additions & 3 deletions lib/showoff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,7 @@ def valid_cookie
@logger.warn "Open sockets: #{settings.sockets.size}"
end
ws.onmessage do |data|
begin
control = JSON.parse(data)

@logger.info "#{control.inspect}"
Expand Down Expand Up @@ -912,10 +913,28 @@ def valid_cookie
when 'position'
ws.send( { 'current' => @@current }.to_json )

when 'feedback'
slide = control['slide']
rating = control['rating']
feedback = control['feedback']

File.open("feedback.json", "w+") do |f|
data = JSON.load(f) || Hash.new

data[slide] ||= Array.new
data[slide] << { :rating => rating, :feedback => feedback }
f.write data.to_json
end


else
@logger.debug "Unknown message <#{control['message']}> received."
@logger.warn "Unknown message <#{control['message']}> received."
@logger.warn control.inspect
end

rescue Exception => e
@logger.warn "Hah! Shit blew up: #{e}"
end
end
ws.onclose do
@logger.warn("websocket closed")
Expand Down Expand Up @@ -968,8 +987,9 @@ def valid_cookie

at_exit do
if defined?(@@counter)
viewstats = File.new("viewstats.json", "w")
viewstats.write @@counter.to_json
File.open("viewstats.json", "w") do |f|
f.write @@counter.to_json
end
end
end
end
Binary file added public/css/fast.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/css/grippy-close.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/css/grippy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
77 changes: 72 additions & 5 deletions public/css/showoff.css
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,14 @@ pre { margin: 1em 40px; padding: .25em; }
.offscreen { position:absolute; top:0; left:-9999px; overflow:hidden; }
#debugInfo { margin-left: 30px; }
#notesInfo { margin-left: 30px; display: none }
#debugFilename {
position: absolute;
bottom: 5px;
right: 10px;
font-size: 12px;
#slideFilename {
position: absolute;
right: 5px;
bottom: 0px;
height: 23px;
padding-left: 10px;
background: #ccc;
z-index: 2147483647;
}
#preshow { display: none; }
/* define the screen blocking view */
Expand All @@ -221,6 +224,63 @@ pre { margin: 1em 40px; padding: .25em; }
font-weight: bold;
}


#sidebarWrapper {
float: left;
height: 100%;
position: fixed;
background-color: #dfdfdf;
opacity: 0.98;
z-index: 2147483647; /* max, see http://www.puidokas.com/max-z-index/ */
}

#sidebar {
height: 100%;
width: 200px;
background: transparent url(grippy-close.png) no-repeat right center;
display: none;
}

#sidebarHandle {
height: 100%;
width: 9px;
background: transparent url(grippy.png) no-repeat center;
}

div.sidebarRow {
text-align: center;
border-bottom: 2px inset #ccc;
margin: 5px 0;
padding: 5px 0;
}

#sidebarWrapper h4 {
text-align: left;
margin-left: 3px;
}
#sidebar span.buttonWrapper {
height: 60px;
width: 85px;
padding: 5px;
display: inline-block;
}
#sidebar span.buttonWrapper button {
margin: 44px auto 0 auto;
}

#sidebar span.buttonWrapper.slow {
background: transparent url(slow.png) no-repeat center top;
}

#sidebar span.buttonWrapper.fast {
background: transparent url(fast.png) no-repeat center top;
}

#sidebar textarea {
height: 85px;
width: 85%;
}

.fg-menu-container {
z-index: 2147483647; /* max, see http://www.puidokas.com/max-z-index/ */
}
Expand Down Expand Up @@ -593,6 +653,13 @@ body#stats {
font-size: 70%;
}

#sidebarWrapper,
#sidebar,
#sidebarHandle {
display:none,

}

#preso, .slide {
border: 1px solid #999;
}
Expand Down
Binary file added public/css/slow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 60 additions & 7 deletions public/js/showoff.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ var shiftKeyActive = false
var query
var slideStartTime = new Date().getTime()

var questionPrompt = 'Ask a question...'
var feedbackPrompt = 'Why?...'

var loadSlidesBool
var loadSlidesPrefix

Expand Down Expand Up @@ -61,6 +64,35 @@ function setupPreso(load_slides, prefix) {
// Better would be dynamic calculations, but this is enough for now.
$(window).resize(function(){location.reload();});

$("#sidebarWrapper").hover(
function() {
$('#sidebar').show();
document.onkeydown = null;
document.onkeyup = null;
},
function() {
$('#sidebar').hide();
document.onkeydown = keyDown;
document.onkeyup = keyUp;
}
);

$("#paceSlow").click(function() { sendPace('slow'); });
$("#paceFast").click(function() { sendPace('fast'); });
$("#askQuestion").click(function() { askQuestion( $("textarea#question").val()) });
$("#sendFeedback").click(function() {
sendFeedback($( "input:radio[name=rating]:checked" ).val(), $("textarea#feedback").val())
});

$("textarea#question").val(questionPrompt);
$("textarea#feedback").val(feedbackPrompt);
$("textarea#question").focus(function() { clearIf($(this), questionPrompt) });
$("textarea#feedback").focus(function() { clearIf($(this), feedbackPrompt) });

$('.slide .content').each(function(index) {
$(this).prepend('<div id="slideFilename">' + $(this).attr('ref') + '</div>');
});

// Open up our control socket
ws = new WebSocket('ws://' + location.host + '/control');
ws.onopen = function() { console.log('control socket opened'); };
Expand Down Expand Up @@ -250,6 +282,9 @@ function showSlide(back_step, updatepv) {

var ret = setCurrentNotes();

var fileName = currentSlide.children().first().attr('ref');
$('#slideFilename').text(fileName);

// Update presenter view, if we spawned one
if (updatepv && 'presenterView' in window) {
var pv = window.presenterView;
Expand Down Expand Up @@ -321,13 +356,34 @@ function showIncremental(incr)
}
}

function clearIf(elem, val) {
console.log(elem.val());
console.log(val);
if(elem.val() == val ) { elem.val(''); }
}

function parseMessage(data) {
var command = JSON.parse(data);

if ("current" in command) { follow(command["current"]); }

}

function sendPace(pace) {
ws.send(JSON.stringify({ message: 'pace', pace: pace}));
}

function askQuestion(question) {
ws.send(JSON.stringify({ message: 'question', question: question}));
$("textarea#question").val(questionPrompt);
}

function sendFeedback(rating, feedback) {
var slide = $("#slideFilename").text();
ws.send(JSON.stringify({ message: 'feedback', rating: rating, feedback: feedback, slide: slide}));
$("textarea#feedback").val(feedbackPrompt);
}

function track() {
if (mode.track) {
var slideEndTime = new Date().getTime();
Expand Down Expand Up @@ -396,14 +452,11 @@ function nextStep(updatepv)
function doDebugStuff()
{
if (debugMode) {
$('#debugInfo').show()
$('.slide .content').each(function(index) {
$(this).prepend('<div id="debugFilename">' + $(this).attr('ref') + '</div>');
});
debug('debug mode on')
$('#debugInfo').show();
$('#slideFilename').show();
} else {
$('#debugInfo').hide()
$('.content #debugFilename').remove()
$('#debugInfo').hide();
$('#slideFilename').hide();
}
}

Expand Down
31 changes: 30 additions & 1 deletion views/index.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,34 @@
<a tabindex="1" href="#search-engines" class="fg-button fg-button-icon-right ui-widget ui-state-default ui-corner-all" id="stylemenu"><span class="ui-icon ui-icon-triangle-1-s"></span>styles</a>
<div id="stylepicker" class="hidden"></div>

<div id="sidebarWrapper">
<div id="sidebar">
<h3>Feedback</h3>
<div class="sidebarRow">
<h4>The presenter should...</h4>
<span class="buttonWrapper slow"><button id="paceSlow">Slow Down</button></span>
<span class="buttonWrapper fast"><button id="paceFast">Speed Up</button></span>
</div>
<div class="sidebarRow">
<textarea id="question"></textarea>
<button id="askQuestion">Ask a Question</button>
</div>
<div class="sidebarRow">
<h4>This slide is...</h4>
Terrible
<input type="radio" name="rating" value="1"></input>
<input type="radio" name="rating" value="2"></input>
<input type="radio" name="rating" value="3"></input>
<input type="radio" name="rating" value="4"></input>
<input type="radio" name="rating" value="5"></input>
Awesome
<textarea id="feedback"></textarea>
<button id="sendFeedback">Send Feedback</button>
</div>
</div>
<div id="sidebarHandle"></div>
</div>

<div id="help">
<table>
<tr><td class="key">z, ?</td><td>toggle help (this)</td></tr>
Expand All @@ -36,12 +64,13 @@
<input type="submit" onClick="nextStep();" value="next"/>
</div>

<div id="preso">loading presentation...</div>
<div id="preso"><center>loading presentation...</center></div>
<div id="footer">
<span id="followMode"></span>
<span id="slideInfo"></span>
<span id="debugInfo"></span>
<span id="notesInfo"></span>
<span id="slideFilename"></span>
</div>

<div id="slides" class="offscreen" <%= 'style="display:none;"' if @slides %>>
Expand Down

0 comments on commit 99a30dc

Please sign in to comment.