This repository has been archived by the owner on Jun 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
netpincer_sortbydeliverydate.js
62 lines (59 loc) · 1.9 KB
/
netpincer_sortbydeliverydate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
function loadScript(url, callback) {
var head = document.getElementsByTagName("head")[0];
var script = document.createElement("script");
script.src = url;
var done = false;
script.onload = script.onreadystatechange = function() {
if( !done && (!this.readyState ||
this.readyState == "loaded" ||
this.readyState == "complete") ) {
done = true;
callback();
// Handle memory leak in IE
script.onload = script.onreadystatechange = null;
head.removeChild( script );
}
};
head.appendChild(script);
}
loadScript("http://code.jquery.com/jquery-latest.js", function() {
// a <table>-ok, es a szallitasi idok, meg az id-k hogy menjenek a szurok
var tables=[], d_times=[], ids=[];
// alap xpath a szallitokhoz
base = 'form:has(table) > table';
// kiszedjuk a szallitasi idoket, es a table-oket
jQuery(base).each(function(i) {
// a problemas scriptek kiszedese
tables[i] = jQuery(this).
html().
replace(/\<script\>[\s\S]+?\<\/script\>/g, '');
d_times[i] = parseInt(
jQuery(this).
find('tbody > tr > td > table > tbody > tr > td > a > b').
html().
replace(/.*?\(([\d]+) perc\)/,'$1')
);
ids[i] = jQuery(this).attr('id');
});
// rendezes
for (i = 0;i < (tables.length-1); i++) {
for (j = i+1; j < tables.length; j++) {
if (d_times[j] < d_times[i]) {
tmp = tables[i]; tables[i] = tables[j]; tables[j] = tmp;
tmp2 = d_times[i]; d_times[i] = d_times[j]; d_times[j] = tmp2;
tmp3 = ids[i]; ids[i] = ids[j]; ids[j] = tmp3;
}
}
}
// visszarak!
jQuery(base).each(function(i) {
jQuery(this).
replaceWith(
'<table id="' +
ids[i] +
'" class="cat-table" cellspacing="0">' +
tables[i] +
'</table>'
);
});
});