Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jQuery(document).ready(function () {
- function setCookie(name, value) {
- var exp = new Date();
- exp.setTime(exp.getTime() + (1000 * 60 * 60 * 24 * 30));
- document.cookie = name + "=" + escape(value) + "; path=/" + ((exp == null) ? "" : "; expires=" + exp.toGMTString());
- }
- function getCookie(name) {
- var dc = document.cookie;
- var cname = name + "=";
- if (dc.length > 0) {
- begin = dc.indexOf(cname);
- if (begin != -1) {
- begin += cname.length;
- end = dc.indexOf(";", begin);
- if (end == -1) end = dc.length;
- return unescape(dc.substring(begin, end));
- }
- }
- return null;
- }
- var select = jQuery('<form id="ordering" method="POST" action="">' +
- 'Ordina per: <select name="order">' +
- '<option value="date_recorded">data</option>' +
- '<option value="favourites">preferenze</option>' +
- '<option value="comments">commenti</option>' +
- '</select><select name="sort">' +
- '<option value="DESC">▼</option>' +
- '<option value="ASC">▲</option>' +
- '</select>' +
- '<input type="submit" value="✓" />' +
- '</form>');
- //il tasto viene aggiunto a fianco a INFO e RSS
- select.appendTo(jQuery('#content>div>ul:eq(1)'));
- var order = getCookie('order');
- var sort = getCookie('sort');
- if (order){
- setCookie('order', order);
- select.children('select:eq(0)').val(order);
- }else{
- setCookie('order', 'date_recorded');
- }
- if (sort){
- setCookie('sort', sort);
- select.children('select:eq(1)').val(sort);
- }else{
- setCookie('sort', 'DESC');
- }
- select.submit(function(){
- jQuery(this).children('select').each(function(){
- var theSelect = jQuery(this);
- setCookie(theSelect.attr("name"), theSelect.val());
- });
- window.location.reload();
- return false;
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement