Moved JavaScript to its own file
[quandoparte] / application / resources / harmattan / qml / StationListPage.js
1 var view = undefined
2
3 function loadStation(name)
4 {
5     var component = Qt.createComponent("StationPage.qml");
6     if (component.status == Component.Ready) {
7         view = component.createObject(stationListPage)
8         stationListPage.stationView = view
9         pageStack.push(view)
10         view.html = "<h1>Loading station " + name + "</h1><p>Lorem ipsum</p>"
11         provider.stationSchedule(name)
12     }
13     else
14         console.log('Cannot load component: ' + component.errorString());
15 }
16
17 function highlightSearch(s)
18 {
19     // TODO compile RegExp on change, or find a way to cleanly use
20     // stationListProxyModel.filterRegExp
21     if (searchField.text.length) {
22         var r = new RegExp(searchField.text, 'i')
23         var match = r.exec(s)
24         return s.replace(r, '<span style="text-decoration:underline">' +
25                          match + '</span>')
26     } else {
27         return s
28     }
29 }
30