2 'jquery', 'knockout', 'text!./metar.html'
3 ], function(jquery, ko, htmlString) {
5 function ViewModel(params) {
6 var NO_METAR = "no METAR";
7 self.scrolledMetar = ko.observable("");
9 self.metar = ko.observable(NO_METAR);
10 self.valid = ko.observable(false).extend({ fgprop: 'metar-valid' });
11 self.valid.subscribe(function(newValue) {
13 if( false == newValue ) {
18 jquery.get('/json/environment/metar/data', null, function(data) {
20 self.metar(data.value);
26 self.longTimeout = 1500;
27 self.shortTimeout = 50;
29 function scrollText ( id ){
30 if( id != self.timerId )
33 var t = self.metar() + " " + self.metar();
34 var a = self.textStart;
35 var b = a+self.textLength;
36 self.scrolledMetar( t.substring(a,b) );
37 var timeout = t.charAt(a) == ' ' ? self.longTimeout : self.shortTimeout;
38 if( ++a >= self.metar().length )
41 setTimeout(function() { scrollText(id); }, timeout );
44 scrollText( ++self.timerId );
47 ViewModel.prototype.dispose = function() {
51 // Return component definition
53 viewModel : ViewModel,