1/* globals Backbone, _ */ 2 3var bit = bit || {}; 4 5bit.fluctuation = (function ($) { 6 "use strict"; 7 var Model = Backbone.Model.extend({ 8 defaults: function () { 9 return { 10 isin: '', 11 name: '', 12 link: '', 13 lastprice: '', 14 percentualchange: '' 15 }; 16 }, 17 initialize: function () { 18 } 19 }), 20 21 Collection = Backbone.Collection.extend({ 22 model: Model 23 24 }), 25 26 ViewUpward = Backbone.View.extend({ 27 up: $('#fluctuationUpward'), 28 tagName: 'tr', 29 initialize: function () { 30 var _thisView = this; 31 this.template = _.template('<tr> <td colspan="2"> <a href="<%= link %>" onClick="pushGA4event_t2_hp(\'intro_hp\',\'up_and_down\',\'<%= name.toLowerCase().replaceAll(\' \', \'_\') %>\');" class="m-intro__link"><%= name %></a> </td> <td colspan="1" class="m-fluctuation__row--right"> <a href="<%= link %>" onClick="pushGA4event_t2_hp(\'intro_hp\',\'up_and_down\',\'<%= name.toLowerCase().replaceAll(\' \', \'_\') %>\');"><span class="m-intro__value--bal"><%= parseFloat(lastprice) %></span></a> </td> <td colspan="1" class="m-fluctuation__row--right"> <a href="<%= link %>" onClick="pushGA4event_t2_hp(\'intro_hp\',\'up_and_down\',\'<%= name.toLowerCase().replaceAll(\' \', \'_\') %>\');"><span class="m-intro__fluctuation--<%=alternateGreenRedClass(percentualchange)%>--bal"><% if (percentualchange >= 0) { %>+<% } %><%= formatDecimals(percentualchange) %>%</span></a> </td> </tr>'); 32 this.collection.fetch({url: bit.init.flux.rise}).done(function () { 33 _thisView.render(); 34 }); 35 }, 36 render: function () { 37 var that = this; 38 if (this.collection.length===0) { 39 $("#upwardNoContent").show(); 40 } else { 41 this.collection.each(function (model) { 42 $(that.up).append(that.template(model.attributes)); 43 }); 44 } 45 return this; 46 } 47 }), 48 49 ViewDownward = Backbone.View.extend({ 50 down: $('#fluctuationDownward'), 51 tagName: 'tr', 52 initialize: function () { 53 var _thisView = this; 54 this.template = _.template('<tr> <td colspan="2"> <a href="<%= link %>" onClick="pushGA4event_t2_hp(\'intro_hp\',\'up_and_down\',\'<%= name.toLowerCase().replaceAll(\' \', \'_\') %>\');" class="m-intro__link"><%= name %></a> </td> <td colspan="1" class="m-fluctuation__row--right"> <a href="<%= link %>" onClick="pushGA4event_t2_hp(\'intro_hp\',\'up_and_down\',\'<%= name.toLowerCase().replaceAll(\' \', \'_\') %>\');"><span class="m-intro__value--bal"><%= parseFloat(lastprice) %></span></a> </td> <td colspan="1" class="m-fluctuation__row--right"> <a href="<%= link %>" onClick="pushGA4event_t2_hp(\'intro_hp\',\'up_and_down\',\'<%= name.toLowerCase().replaceAll(\' \', \'_\') %>\');"><span class="m-intro__fluctuation--<%=alternateGreenRedClass(percentualchange)%>--bal"><% if (percentualchange >= 0) { %>+<% } %><%= formatDecimals(percentualchange) %>%</span></a> </td> </tr>'); 55 this.collection.fetch({url: bit.init.flux.fall}).done(function () { 56 _thisView.render(); 57 }); 58 }, 59 render: function () { 60 var that = this; 61 if (this.collection.length===0) { 62 $("#downwardNoContent").show(); 63 } else { 64 this.collection.each(function (model) { 65 $(that.down).append(that.template(model.attributes)); 66 }); 67 } 68 return this; 69 } 70 }), 71 72 initialize = function () { 73 $("#upwardNoContent").hide(); 74 $("#downwardNoContent").hide(); 75 var viewUp, viewDw, 76 fluctuationUp = new Collection(), 77 fluctuationDw = new Collection(); 78 viewUp = new ViewUpward({collection: fluctuationUp}); 79 viewDw = new ViewDownward({collection: fluctuationDw}); 80 return { up : viewUp, down : viewDw}; 81 }; 82 return { 83 Collection: Collection, 84 ViewUpward: ViewUpward, 85 ViewDownward: ViewDownward, 86 initialize: initialize 87 }; 88 89})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.