Subversion Repositories cheapmusic

Rev

Rev 43 | Rev 47 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 43 Rev 46
Line 103... Line 103...
103
    });
103
    });
104
    $('[data-toggle="tooltip"]').tooltip({trigger : 'hover'});
104
    $('[data-toggle="tooltip"]').tooltip({trigger : 'hover'});
105
    $('[data-toggle2="tooltip"]').tooltip({trigger : 'hover'});
105
    $('[data-toggle2="tooltip"]').tooltip({trigger : 'hover'});
106
}
106
}
107
 
107
 
-
 
108
// number of discogs entries per page according to screen size
108
function paginationPerPage() {
109
function paginationPerPage() {
109
    width = $( document ).width();
110
    width = $( document ).width();
110
    if (width < 576){
111
    if (width < 576){
111
        return 1;    
112
        return 1;    
112
    } else if (width < 768){
113
    } else if (width < 768){
Line 117... Line 118...
117
        return 4;    
118
        return 4;    
118
    } else {
119
    } else {
119
        return 6;    
120
        return 6;    
120
    }
121
    }
121
}
122
}
-
 
123
 
-
 
124
// sort table by column
-
 
125
function sortTable(table, col, colType) {
-
 
126
    var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0;
-
 
127
    table = document.getElementById(table);
-
 
128
    switching = true;
-
 
129
    // Set the sorting direction to ascending:
-
 
130
    dir = "asc";
-
 
131
    /* Make a loop that will continue until no switching has been done: */
-
 
132
    while (switching) {
-
 
133
        // Start by saying: no switching is done:
-
 
134
        switching = false;
-
 
135
        rows = table.rows;
-
 
136
        /* Loop through all table rows (except the first, which contains table headers): */
-
 
137
        for (i = 1; i < (rows.length - 1); i++) {
-
 
138
            // Start by saying there should be no switching:
-
 
139
            shouldSwitch = false;
-
 
140
            /* Get the two elements you want to compare, one from current row and one from the next: */
-
 
141
            x = rows[i].getElementsByTagName("TD")[col];
-
 
142
            y = rows[i + 1].getElementsByTagName("TD")[col];
-
 
143
            /* Check if the two rows should switch place, based on the direction, asc or desc: */
-
 
144
            if (dir == "asc") {
-
 
145
                if (colType == 'numeric') {
-
 
146
                    if (Number(x.innerHTML) > Number(y.innerHTML.toLowerCase)) {
-
 
147
                        // If so, mark as a switch and break the loop:
-
 
148
                        shouldSwitch = true;
-
 
149
                        break;
-
 
150
                    }
-
 
151
                } else /* if (colType == 'text') */ {
-
 
152
                    if (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()) {
-
 
153
                        // If so, mark as a switch and break the loop:
-
 
154
                        shouldSwitch = true;
-
 
155
                        break;
-
 
156
                    }
-
 
157
                }
-
 
158
            } else if (dir == "desc") {
-
 
159
                if (colType == 'numeric') {
-
 
160
                    if (Number(x.innerHTML) < Number(y.innerHTML)) {
-
 
161
                        // If so, mark as a switch and break the loop:
-
 
162
                        shouldSwitch = true;
-
 
163
                        break;
-
 
164
                    }
-
 
165
                } else /* if (colType == 'text') */ {
-
 
166
                    if (x.innerHTML.toLowerCase() < y.innerHTML.toLowerCase()) {
-
 
167
                        // If so, mark as a switch and break the loop:
-
 
168
                        shouldSwitch = true;
-
 
169
                        break;
-
 
170
                    }
-
 
171
                }
-
 
172
            }
-
 
173
        }
-
 
174
        if (shouldSwitch) {
-
 
175
            /* If a switch has been marked, make the switch and mark that a switch has been done: */
-
 
176
            rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
-
 
177
            switching = true;
-
 
178
            // Each time a switch is done, increase this count by 1:
-
 
179
            switchcount++;
-
 
180
        } else {
-
 
181
            /* If no switching has been done AND the direction is "asc", set the direction to "desc" and run the while loop again. */
-
 
182
            if (switchcount == 0 && dir == "asc") {
-
 
183
                dir = "desc";
-
 
184
                switching = true;
-
 
185
            }
-
 
186
        }
-
 
187
    }
-
 
188
}
-
 
189