Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
- var sections = [[],[],[],[],[],[],[],[],[],[],[],[]]; // temp array to hold all of the month data
- jQuery('#shopp .variations li label').each(function()
- {
- var c = jQuery(this).text();
- c = c.trim();
- var index = months.indexOf(c.split(" ")[0]);
- var s = {};
- s.name = jQuery("input:radio", this).attr("name");
- s.month = c.split(" ")[0];
- s.fullDate = c;
- s.value = jQuery("input:radio", this).attr("value");
- sections[index].push(s);
- });
- var len = sections.length - 1;
- for ( var i = len; i >= 0; i-- )
- {
- if( !sections[i].length )
- {
- sections.splice( i, 1 );
- }
- }
- // create new html
- var newStuff='<div id="accordion">';
- for ( var i = 0; i < sections.length; i++ )
- {
- newStuff += ( '<h3>' + sections[i][0].month + '</h3>' );
- newStuff += '<div>';
- for ( var j = 0; j < sections[i].length; j++ )
- {
- newStuff += '<label>';
- newStuff += '<input type="radio" name="' + sections[i][j].name + '" value="' + sections[i][j].value + '" />';
- newStuff += sections[i][j].fullDate;
- newStuff += '</label>';
- }
- newStuff += '</div>';
- }
- newStuff += '</div>';
- //jQuery("#sidebar_course_dates").html(newStuff);
- jQuery('#accordion').accordion();
- });
- String.prototype.trim = function ()
- {
- return this.replace(/^\s*/, "").replace(/\s*jQuery/, "");
- }
Add Comment
Please, Sign In to add comment