Skip to content

Commit 939a557

Browse files
committed
Converter demo: Update to use the new refresh method in listview, along with some small tunings.
1 parent 1cbdc76 commit 939a557

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

experiments/converter/application.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,24 @@
11
$(function() {
22
var symbols = {
33
"USD": "$",
4-
"EUR": "",
5-
"GBP": "£",
4+
"EUR": "€",
5+
"GBP": "£",
66
"Miles": "m",
77
"Kilometer": "km",
88
"inch": "\"",
99
"centimeter": "cm"
1010
};
1111

1212
function list() {
13-
var ul = $( "#conversions" ).empty()
14-
.filter( ":mobile-page" ).page( "destroy" )
15-
.end(),
16-
ulEdit = $( "#edit-conversions" ).empty()
17-
.filter( ":mobile-page" ).page( "destroy" )
18-
.end();
13+
var ul = $( "#conversions" ).empty(),
14+
ulEdit = $( "#edit-conversions" ).empty();
1915
$.each( all, function( index, conversion ) {
2016
// if last update was less then a minute ago, don't update
2117
if ( conversion.type === "currency" && !conversion.rate || conversion.updated && conversion.updated + 60000 < +new Date) {
2218
var self = conversion;
2319
var url = "http://query.yahooapis.com/v1/public/yql?q=select%20rate%2Cname%20from%20csv%20where%20url%3D'http%3A%2F%2Fdownload.finance.yahoo.com%2Fd%2Fquotes%3Fs%3D" + conversion.from + conversion.to + "%253DX%26f%3Dl1n'%20and%20columns%3D'rate%2Cname'&format=json&diagnostics=true&callback=?";
2420
$.getJSON( url, function( result ) {
2521
self.rate = parseFloat( result.query.results.row.rate );
26-
// TODO trigger a custom event instead of keyup?
2722
$( "#term" ).keyup();
2823
self.updated = +new Date;
2924
conversions.store();
@@ -36,8 +31,7 @@ $(function() {
3631
symbols: symbols
3732
}).appendTo( ulEdit );
3833
});
39-
ul.page();
40-
// TODO trigger a custom event instead of keyup?
34+
ul.add(ulEdit).listview("refresh");
4135
$( "#term" ).keyup();
4236
}
4337
var all = conversions.all();

experiments/converter/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ <h1>Currency converter</h1>
4141
</form>
4242
</div>
4343
<div data-role="content">
44-
<ul id="++conversions" data-role="listview" data-theme="a">
44+
<ul id="conversions" data-role="listview" data-theme="a">
4545
<li>
4646
<p class="currency-from">$ <span class="unit">USD</span></p>
4747
<p class="currency-to ui-li-aside">&euro; <span id="USDEUR" class="rate">NaN</span> <span class="unit">EUR</span></p>

experiments/converter/storage.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ var defaults = [
55
type: "currency",
66
from: "USD",
77
to: "EUR"
8+
},
9+
{
10+
type: "currency",
11+
from: "GBP",
12+
to: "EUR"
813
}
914
// TODO add back in as defaults once its possible to add other conversions, not just currencies
1015
/*,

0 commit comments

Comments
 (0)