I changed fixtures sorting from "entry number" to "by date"
-
Hello again !
I hacked a new function via the soccer info widget jquery code.
Thhis was pretty hard, cause the initial datas arent sorted to dates.It replaces the entries “by date”, not “by list-number” as it was.
That means i can filter for example MAX_AGE: 0, Wich only shows all games from today, or filter MAX_AGE: 1, wich shows all games from today and tomorrow, and so on.If someone is interessted in this function, here is the code of my js:
hack = { // heute = 0, morgen = 1, übermorgen = 2 MAX_AGE: 1, age: function(date) { var from = parseInt(moment(date,"dddd, DD MMMM YYYY, HH:mm", 'de').startOf('day').format('X')); var to = parseInt(moment().startOf('day').format('X')); return parseInt(( from - to ) / 86400); }, do: function(cb) { var dates = jQuery('.sifixtures td.date'); for (var i=0;i<dates.length;i++) { var to_remove = []; console.log(dates[i].innerHTML + " -- " + this.age(dates[i].innerHTML)); if(this.age(dates[i].innerHTML) > this.MAX_AGE) { var node = dates[i].parentNode; var next = node.nextElementSibling; var child_count = node.parentNode.childElementCount; to_remove.push(node); node = next; for(var x=0;x<child_count;x++) { if(node && node.className == 'date') break; if(node) to_remove.push(node); if(node) node = node.nextElementSibling; } } for(var a=0;a<to_remove.length;a++) to_remove[a].remove(); this.show_empty(); } }, show_empty: function() { var nodes = jQuery('.sifixtures>table>tbody'); for (var i=0;i<nodes.length;i++) { if(nodes[i].childElementCount == 0) { nodes[i].parentNode.parentNode.innerHTML='<p style="text-align:center;font-size:14px;">Keine Spiele</p>'; } } } } jQuery(function(){ hack.do(); });
- The topic ‘I changed fixtures sorting from "entry number" to "by date"’ is closed to new replies.