mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-05-03 12:24:46 +00:00
Converter demo: Update to use the new refresh method in listview, along with some small tunings.
This commit is contained in:
parent
1cbdc76d08
commit
939a557d67
3 changed files with 11 additions and 12 deletions
|
|
@ -1,8 +1,8 @@
|
|||
$(function() {
|
||||
var symbols = {
|
||||
"USD": "$",
|
||||
"EUR": "€",
|
||||
"GBP": "£",
|
||||
"EUR": "€",
|
||||
"GBP": "£",
|
||||
"Miles": "m",
|
||||
"Kilometer": "km",
|
||||
"inch": "\"",
|
||||
|
|
@ -10,12 +10,8 @@ $(function() {
|
|||
};
|
||||
|
||||
function list() {
|
||||
var ul = $( "#conversions" ).empty()
|
||||
.filter( ":mobile-page" ).page( "destroy" )
|
||||
.end(),
|
||||
ulEdit = $( "#edit-conversions" ).empty()
|
||||
.filter( ":mobile-page" ).page( "destroy" )
|
||||
.end();
|
||||
var ul = $( "#conversions" ).empty(),
|
||||
ulEdit = $( "#edit-conversions" ).empty();
|
||||
$.each( all, function( index, conversion ) {
|
||||
// if last update was less then a minute ago, don't update
|
||||
if ( conversion.type === "currency" && !conversion.rate || conversion.updated && conversion.updated + 60000 < +new Date) {
|
||||
|
|
@ -23,7 +19,6 @@ $(function() {
|
|||
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=?";
|
||||
$.getJSON( url, function( result ) {
|
||||
self.rate = parseFloat( result.query.results.row.rate );
|
||||
// TODO trigger a custom event instead of keyup?
|
||||
$( "#term" ).keyup();
|
||||
self.updated = +new Date;
|
||||
conversions.store();
|
||||
|
|
@ -36,8 +31,7 @@ $(function() {
|
|||
symbols: symbols
|
||||
}).appendTo( ulEdit );
|
||||
});
|
||||
ul.page();
|
||||
// TODO trigger a custom event instead of keyup?
|
||||
ul.add(ulEdit).listview("refresh");
|
||||
$( "#term" ).keyup();
|
||||
}
|
||||
var all = conversions.all();
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
</form>
|
||||
</div>
|
||||
<div data-role="content">
|
||||
<ul id="++conversions" data-role="listview" data-theme="a">
|
||||
<ul id="conversions" data-role="listview" data-theme="a">
|
||||
<li>
|
||||
<p class="currency-from">$ <span class="unit">USD</span></p>
|
||||
<p class="currency-to ui-li-aside">€ <span id="USDEUR" class="rate">NaN</span> <span class="unit">EUR</span></p>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,11 @@ var defaults = [
|
|||
type: "currency",
|
||||
from: "USD",
|
||||
to: "EUR"
|
||||
},
|
||||
{
|
||||
type: "currency",
|
||||
from: "GBP",
|
||||
to: "EUR"
|
||||
}
|
||||
// TODO add back in as defaults once its possible to add other conversions, not just currencies
|
||||
/*,
|
||||
|
|
|
|||
Loading…
Reference in a new issue