Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(634)

Side by Side Diff: sky/examples/stocks/companylist.sky

Issue 950073002: Make the stocks app slightly prettier. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | sky/examples/stocks/stock.sky » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <script> 1 <script>
2 import "dart:math";
3
2 // Snapshot from http://www.nasdaq.com/screening/company-list.aspx 4 // Snapshot from http://www.nasdaq.com/screening/company-list.aspx
3 // Fetched 2/23/2014. 5 // Fetched 2/23/2014.
4 // "Symbol","Name","LastSale","MarketCap","IPOyear","Sector","industry","Summary Quote", 6 // "Symbol","Name","LastSale","MarketCap","IPOyear","Sector","industry","Summary Quote",
5 final List<List<String>> _kCompanyList = [ 7 final List<List<String>> _kCompanyList = [
6 ["TFSC","1347 Capital Corp.","9.43","\$56.09M","2014","Finance","Business Serv ices","http://www.nasdaq.com/symbol/tfsc"], 8 ["TFSC","1347 Capital Corp.","9.43","\$56.09M","2014","Finance","Business Serv ices","http://www.nasdaq.com/symbol/tfsc"],
7 ["TFSCR","1347 Capital Corp.","0.37","n/a","2014","Finance","Business Services ","http://www.nasdaq.com/symbol/tfscr"], 9 ["TFSCR","1347 Capital Corp.","0.37","n/a","2014","Finance","Business Services ","http://www.nasdaq.com/symbol/tfscr"],
8 ["TFSCU","1347 Capital Corp.","9.97","\$41.67M","2014","n/a","n/a","http://www .nasdaq.com/symbol/tfscu"], 10 ["TFSCU","1347 Capital Corp.","9.97","\$41.67M","2014","n/a","n/a","http://www .nasdaq.com/symbol/tfscu"],
9 ["TFSCW","1347 Capital Corp.","0.2","n/a","2014","Finance","Business Services" ,"http://www.nasdaq.com/symbol/tfscw"], 11 ["TFSCW","1347 Capital Corp.","0.2","n/a","2014","Finance","Business Services" ,"http://www.nasdaq.com/symbol/tfscw"],
10 ["PIH","1347 Property Insurance Holdings, Inc.","7.66","\$48.7M","2014","Finan ce","Property-Casualty Insurers","http://www.nasdaq.com/symbol/pih"], 12 ["PIH","1347 Property Insurance Holdings, Inc.","7.66","\$48.7M","2014","Finan ce","Property-Casualty Insurers","http://www.nasdaq.com/symbol/pih"],
11 ["FLWS","1-800 FLOWERS.COM, Inc.","10.32","\$667.78M","1999","Consumer Service s","Other Specialty Stores","http://www.nasdaq.com/symbol/flws"], 13 ["FLWS","1-800 FLOWERS.COM, Inc.","10.32","\$667.78M","1999","Consumer Service s","Other Specialty Stores","http://www.nasdaq.com/symbol/flws"],
(...skipping 2954 matching lines...) Expand 10 before | Expand all | Expand 10 after
2966 ["ZU","zulily, inc.","14.4","\$1.8B","2013","Consumer Services","Catalog/Speci alty Distribution","http://www.nasdaq.com/symbol/zu"], 2968 ["ZU","zulily, inc.","14.4","\$1.8B","2013","Consumer Services","Catalog/Speci alty Distribution","http://www.nasdaq.com/symbol/zu"],
2967 ["ZUMZ","Zumiez Inc.","38.77","\$1.13B","2005","Consumer Services","Clothing/S hoe/Accessory Stores","http://www.nasdaq.com/symbol/zumz"], 2969 ["ZUMZ","Zumiez Inc.","38.77","\$1.13B","2005","Consumer Services","Clothing/S hoe/Accessory Stores","http://www.nasdaq.com/symbol/zumz"],
2968 ["ZNGA","Zynga Inc.","2.32","\$2.09B","2011","Technology","EDP Services","http ://www.nasdaq.com/symbol/znga"], 2970 ["ZNGA","Zynga Inc.","2.32","\$2.09B","2011","Technology","EDP Services","http ://www.nasdaq.com/symbol/znga"],
2969 ]; 2971 ];
2970 2972
2971 class Stock { 2973 class Stock {
2972 String symbol; 2974 String symbol;
2973 String name; 2975 String name;
2974 double lastSale; 2976 double lastSale;
2975 String marketCap; 2977 String marketCap;
2978 double percentChange;
2976 2979
2977 Stock(this.symbol, this.name, this.lastSale, this.marketCap); 2980 Stock(this.symbol, this.name, this.lastSale, this.marketCap);
2978 2981
2979 Stock.fromFields(List<String> fields) { 2982 Stock.fromFields(List<String> fields) {
2980 // FIXME: This class should only have static data, not lastSale, etc. 2983 // FIXME: This class should only have static data, not lastSale, etc.
2981 // "Symbol","Name","LastSale","MarketCap","IPOyear","Sector","industry","Sum mary Quote", 2984 // "Symbol","Name","LastSale","MarketCap","IPOyear","Sector","industry","Sum mary Quote",
2982 lastSale = 0.0; 2985 lastSale = 0.0;
2983 try{ 2986 try{
2984 lastSale = double.parse(fields[2]); 2987 lastSale = double.parse(fields[2]);
2985 } catch(_) {} 2988 } catch(_) {}
2986 symbol = fields[0]; 2989 symbol = fields[0];
2987 name = fields[1]; 2990 name = fields[1];
2988 marketCap = fields[4]; 2991 marketCap = fields[4];
2992 var rng = new Random();
2993 percentChange = (rng.nextDouble() * 20) - 10;
2989 } 2994 }
2990 } 2995 }
2991 2996
2992 class StockOracle { 2997 class StockOracle {
2993 List<Stock> stocks; 2998 List<Stock> stocks;
2994 2999
2995 StockOracle(this.stocks); 3000 StockOracle(this.stocks);
2996 3001
2997 StockOracle.fromCompanyList(List<List<String>> list) { 3002 StockOracle.fromCompanyList(List<List<String>> list) {
2998 stocks = list.map((fields) => new Stock.fromFields(fields)).toList(); 3003 stocks = list.map((fields) => new Stock.fromFields(fields)).toList();
2999 } 3004 }
3000 3005
3001 Stock lookupBySymbol(String symbol) { 3006 Stock lookupBySymbol(String symbol) {
3002 this.stocks.forEach((stock) { 3007 this.stocks.forEach((stock) {
3003 if (stock.symbol == symbol) 3008 if (stock.symbol == symbol)
3004 return stock; 3009 return stock;
3005 }); 3010 });
3006 return null; 3011 return null;
3007 } 3012 }
3008 } 3013 }
3009 3014
3010 final StockOracle oracle = new StockOracle.fromCompanyList(_kCompanyList); 3015 final StockOracle oracle = new StockOracle.fromCompanyList(_kCompanyList);
3011 3016
3012 </script> 3017 </script>
OLDNEW
« no previous file with comments | « no previous file | sky/examples/stocks/stock.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698