Skip to content

Commit

Permalink
updates to rapid scan
Browse files Browse the repository at this point in the history
  • Loading branch information
atruskie committed Mar 28, 2013
1 parent a60d2c2 commit 2e1b4c5
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 25 deletions.
21 changes: 19 additions & 2 deletions app/assets/javascripts/angular/controllers/experiments.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@
"notes",
"extraInstructions",
"imageLink",
"show"
"show",
"downloaded"

]
);
Expand Down Expand Up @@ -338,6 +339,21 @@
}
});

$scope.totalDownloaded = 0;
$scope.downloading = function() {
var total = 0;
// angular.forEach($scope.stepResults.flashes, function(value, index) {
// if(value.downloaded === true) {
// total += 1;
// }
// });

return $("#step_"+$scope.bigScope.step +" img").toArray().every(function(value) {return value.complete});

$scope.totalDownloaded = total;
return total;
};

$scope.showInstructions = true;
$scope.showDoneButton = false;
$scope.start = function () {
Expand Down Expand Up @@ -523,7 +539,8 @@
show: false,
detected: null,
hits: [],
pauses: []
pauses: [],
downloaded: null
}
);
}
Expand Down
34 changes: 33 additions & 1 deletion app/assets/javascripts/angular/directives/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@


return {
restict: 'A',
restrict: 'A',
link: function radioInputType(scope, element, attr) {
// make the name unique, if not defined
if (baw.angularCopies.isUndefined(attr.name)) {
Expand Down Expand Up @@ -599,6 +599,38 @@
}
});

bawds.directive('bawImageLoaded',['$timeout', '$parse', function($timeout, $parse) {
return {
restrict: 'A',
link: function(scope, elements, attr) {
var element = elements[0];
if (element.nodeName !== "IMG") {
throw 'Cannot put ngAudio element on an element that is not a <audio />';
}

var getter = $parse(attr.bawImageLoaded);
var assigner = getter.assign;

assigner(scope, element.complete);

element.onload = function() {
assigner(scope, element.complete);
};

function checkLater() {
$timeout(function(){
assigner(scope, element.complete);

//if (element.complete) {
checkLater();
//}
}, 1000);
}

}
}
}]);

bawds.directive('bawInjectTransformers', function () {
return {
restrict: 'A',
Expand Down
11 changes: 7 additions & 4 deletions app/assets/templates/rapid_scanning_experiment.html
Original file line number Diff line number Diff line change
Expand Up @@ -424,17 +424,20 @@ <h4>{{stepResults.name}}, exposure <em>{{stepResults.speed.speed}}</em>s</h4>
<span ng-bind-html-unsafe="stepResults.speed.notes"> </span>
</p>

<p>
<p ng-show="downloading() < stepResults.flashes.length" >
The expriment is downloading, please wait: <progress value="{{downloading()}}" max="{{stepResults.flashes.length}}"></progress></p>
<p ng-show="downloading() == stepResults.flashes.length">

The test will start immediately after you press the button below - get ready.
</p>
</div>
<button ng-click="start()">I understand the instructions, let's go</button>
<button ng-disabled="downloading()" ng-click="start()">I understand the instructions, let's go</button>
</div>

<div style="height:600px; vertical-align: middle;" ng-show="!showInstructions"
ui-keydown="{'17-ctrl':'hit($event)', '16-shift':'hit($event)', 'left':'hit($event)', 'right':'hit($event)', 'space': 'pauseOrResume($event)'}"
tabindex="1" id="experimentKeyPressDiv">
<div ng-repeat="step in bigScope.spec.experimentSteps" ng-show="bigScope.step == $index + 1">
<div id="{{'step_' +($index + 1)}}" ng-repeat="step in bigScope.spec.experimentSteps" ng-show="bigScope.step == $index + 1">
<div class="header">
<h4>{{stepResults.name}}, exposure {{stepResults.speed.speed}}s</h4>
{{stepResults.extraInstructions}}
Expand Down Expand Up @@ -476,7 +479,7 @@ <h4>{{stepResults.name}}, exposure {{stepResults.speed.speed}}s</h4>
</div>
<img class="spectrogramImage" ng-show="countDown == 0"
ng-style="{width: SPECTROGRAM_WIDTH + 'px'}"
ng-src="{{segment.imageLink}}">
ng-src="{{segment.imageLink}}" > <!-- baw-image-loaded="segment.downloaded"-->

<div>
<span style="float:left">Starting time: <span class="relative-chunk-time hint--bottom">{{ft(segment.start)}}</span></span>
Expand Down
38 changes: 22 additions & 16 deletions public/experiment_assets/rapid_scan.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@
"name": "Koala flashcards - Set A",
"type": "flashing",
"segments" : [
{
"audioId": "230FA545-DCC9-46AC-B87F-1F9AD5C3DEC3",
"startTime": 0,
"endTime": 240
}
{"audioId": "C41C8E9D-5D6A-458D-A6DB-81929D2C9DD2", "startTime": 0 , "endTime": 120},
{"audioId": "0E86CDB0-68CD-4F43-BCDD-C0B36469809F", "startTime": 0 , "endTime": 120},
{"audioId": "427C85E3-11AA-482B-8C39-2BC7BC3F3352", "startTime": 0 , "endTime": 240},
{"audioId": "DE1063BB-01E6-4C56-882C-98E084F14EA0", "startTime": 0 , "endTime": 240},
{"audioId": "567B993D-0439-484C-BE7F-DD8A7C6688F3", "startTime": 0 , "endTime": 120},
{"audioId": "BEDA5E61-81E8-4F53-A195-D5964F3000CF", "startTime": 0 , "endTime": 240},
{"audioId": "81770AF6-5017-4A83-A365-6A9742F487CC", "startTime": 0 , "endTime": 240}
],
"compression": 1,
"speed": "random",
Expand All @@ -64,11 +66,14 @@
"name": "Koala flashcards - Set B",
"type": "flashing",
"segments" : [
{
"audioId": "230FA545-DCC9-46AC-B87F-1F9AD5C3DEC3",
"startTime": 0,
"endTime": 240
}
{"audioId": "146C15AC-D201-49C3-9B2B-BC7C76181AB1", "startTime": 0 , "endTime": 120},
{"audioId": "230FA545-DCC9-46AC-B87F-1F9AD5C3DEC3", "startTime": 0 , "endTime": 240},
{"audioId": "76A04D45-05AC-4A4B-B8F1-FFFDE8FC99A6", "startTime": 33120 , "endTime": 33360},
{"audioId": "0C226A73-25D2-4A95-BF9B-0FD66BD76BF4", "startTime": 0 , "endTime": 120},
{"audioId": "E7DBBD4E-6B82-4719-BD8C-79D2AB14B921", "startTime": 0 , "endTime": 120},
{"audioId": "3654723B-6E93-438B-8127-DDB7239B1E83", "startTime": 0 , "endTime": 240},
{"audioId": "AE8DE97E-CEA4-4D53-9BAC-1C687CA66D43", "startTime": 0 , "endTime": 120},
{"audioId": "B1BFAA13-2F35-469E-9FEA-D9D1847A4B29", "startTime": 0 , "endTime": 120}
],
"compression": 1,
"speed": "random",
Expand All @@ -82,11 +87,12 @@
"name": "Koala flashcards - Set C",
"type": "flashing",
"segments" : [
{
"audioId": "230FA545-DCC9-46AC-B87F-1F9AD5C3DEC3",
"startTime": 0,
"endTime": 240
}
{"audioId": "E8E34C43-A67F-4DFC-B368-F8265A78C898", "startTime": 0 , "endTime": 240},
{"audioId": "01331441-AD7D-4DC6-8982-D526E04BAF5D", "startTime": 0 , "endTime": 240},
{"audioId": "8B6A019F-5828-4FBC-8037-D42AA8D3FA05", "startTime": 0 , "endTime": 240},
{"audioId": "4BCA2B53-828F-4552-ABA3-7029F33D9703", "startTime": 0 , "endTime": 120},
{"audioId": "88635FDB-A13A-4F22-8E08-CF5736F24207", "startTime": 0 , "endTime": 240},
{"audioId": "DF6D35CC-9009-46C1-921A-7FB22D9D24C4", "startTime": 0 , "endTime": 240}
],
"compression": 1,
"speed": "random",
Expand All @@ -97,4 +103,4 @@
],
"experimentResultsPostUri": "/experiments",
"surveyLink": "http://survey.qut.edu.au/f/176572/2045/"
}
}
4 changes: 2 additions & 2 deletions public/experiment_assets/rapid_scan_counts.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
]
},
"6B": {
"count": 7,
"count": 8,
"speedCode": 6,
"dataSetCode": "B",
"speeds": [
Expand Down Expand Up @@ -210,7 +210,7 @@
]
},
"3C": {
"count": 7,
"count": 8,
"speedCode": 3,
"dataSetCode": "C",
"speeds": [
Expand Down

0 comments on commit 2e1b4c5

Please sign in to comment.