Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function CostSort(sortType) {
- var table = ($('#purchasetable').children().toArray());
- var tablelength = table.length;
- var pricing = new Promise(function(resolve, reject) {
- var pricearr = [];
- var tablelength = table.length;
- for (var i = 0; i < tablelength; i++) {
- var price = parseFloat(($($(table[i]).children()[4]).text()).replace('$', ''));
- pricearr.push({
- id: ($($(table)[i]).attr('id')),
- price: (price)
- });
- }
- resolve (pricearr);
- });
- pricing.then((prices) => {
- if (sortType === "hightolow") {
- var highsort = (prices).sort(function(a, b) { return b.price - a.price });
- var tablesort = new Promise(function(resolve, reject) {
- var highhtml = [];
- for (var x = 0; x < highsort.length; x++) {
- var itemhtml = "<tr id='" + highsort[x].id + "' onclick=submitid(" +
- parseFloat(((highsort[x].id).replace('#', ''))) + ")>" +
- $($('#purchasetable').find('#' + highsort[x].id)).html() +
- "</tr>";
- highhtml.push(itemhtml);
- }
- resolve (highhtml);
- });
- tablesort.then((html) => {
- var sorting = new Promise(function(resolve, reject) {
- var sorted = html;
- $('#purchasetable').empty();
- resolve (sorted);
- });
- sorting.then((sorted) => {
- for (var z = 0; z < sorted.length; z++) {
- $('#purchasetable').append(sorted[z]);
- }
- });
- });
- } else if (sortType === "lowtohigh") {
- var lowsort = (prices).sort(function(a, b) { return a.price - b.price });
- var tablesort = new Promise(function(resolve, reject) {
- var lowhtml = [];
- for (var x = 0; x < lowsort.length; x++) {
- var itemhtml = "<tr id='" + lowsort[x].id + "' onclick=submitid(" +
- parseFloat(((lowsort[x].id).replace('#', ''))) + ")>" +
- $($('#purchasetable').find('#' + lowsort[x].id)).html() +
- "</tr>";
- lowhtml.push(itemhtml);
- }
- resolve (lowhtml);
- });
- tablesort.then((html) => {
- var sorting = new Promise(function(resolve, reject) {
- var sorted = html;
- $('#purchasetable').empty();
- resolve (sorted);
- });
- sorting.then((sorted) => {
- for (var z = 0; z < sorted.length; z++) {
- $('#purchasetable').append(sorted[z]);
- }
- });
- });
- }
- });
- }
- function ProfitSort(sortType) {
- var table = ($('#purchasetable').children().toArray());
- var tablelength = table.length;
- var pricing = new Promise(function(resolve, reject) {
- var pricearr = [];
- var tablelength = table.length;
- for (var i = 0; i < tablelength; i++) {
- var price = parseFloat(($($(table[i]).children()[6]).text()).replace('$', ''));
- if (Boolean(price) === true) {
- pricearr.push({
- id: ($($(table)[i]).attr('id')),
- price: (price)
- });
- }
- }
- resolve (pricearr);
- });
- pricing.then((prices) => {
- if (sortType === "hightolow") {
- var highsort = (prices).sort(function(a, b) { return b.price - a.price });
- var tablesort = new Promise(function(resolve, reject) {
- var highhtml = [];
- for (var x = 0; x < highsort.length; x++) {
- var itemhtml = "<tr id='" + highsort[x].id + "' onclick=submitid(" +
- parseFloat(((highsort[x].id).replace('#', ''))) + ")>" +
- $($('#purchasetable').find('#' + highsort[x].id)).html() +
- "</tr>";
- highhtml.push(itemhtml);
- }
- resolve (highhtml);
- });
- tablesort.then((html) => {
- var sorting = new Promise(function(resolve, reject) {
- var sorted = html;
- $('#purchasetable').empty();
- resolve (sorted);
- });
- sorting.then((sorted) => {
- for (var z = 0; z < sorted.length; z++) {
- $('#purchasetable').append(sorted[z]);
- }
- });
- });
- } else if (sortType === "lowtohigh") {
- var lowsort = (prices).sort(function(a, b) { return a.price - b.price });
- var tablesort = new Promise(function(resolve, reject) {
- var lowhtml = [];
- for (var x = 0; x < lowsort.length; x++) {
- var itemhtml = "<tr id='" + lowsort[x].id + "' onclick=submitid(" +
- parseFloat(((lowsort[x].id).replace('#', ''))) + ")>" +
- $($('#purchasetable').find('#' + lowsort[x].id)).html() +
- "</tr>";
- lowhtml.push(itemhtml);
- }
- resolve (lowhtml);
- });
- tablesort.then((html) => {
- var sorting = new Promise(function(resolve, reject) {
- var sorted = html;
- $('#purchasetable').empty();
- resolve (sorted);
- });
- sorting.then((sorted) => {
- for (var z = 0; z < sorted.length; z++) {
- $('#purchasetable').append(sorted[z]);
- }
- });
- });
- }
- });
- }
- function ProfitSort(sortType) {
- var table = ($('#purchasetable').children().toArray());
- var tablelength = table.length;
- var pricing = new Promise(function(resolve, reject) {
- var pricearr = [];
- var tablelength = table.length;
- for (var i = 0; i < tablelength; i++) {
- var price = parseFloat(($($(table[i]).children()[6]).text()).replace('$', ''));
- if (Boolean(price) === true) {
- pricearr.push({
- id: ($($(table)[i]).attr('id')),
- price: (price)
- });
- }
- }
- resolve (pricearr);
- });
- pricing.then((prices) => {
- if (sortType === "hightolow") {
- var highsort = (prices).sort(function(a, b) { return b.price - a.price });
- var tablesort = new Promise(function(resolve, reject) {
- var highhtml = [];
- for (var x = 0; x < highsort.length; x++) {
- var itemhtml = "<tr id='" + highsort[x].id + "' onclick=submitid(" +
- parseFloat(((highsort[x].id).replace('#', ''))) + ")>" +
- $($('#purchasetable').find('#' + highsort[x].id)).html() +
- "</tr>";
- highhtml.push(itemhtml);
- }
- resolve (highhtml);
- });
- tablesort.then((html) => {
- var sorting = new Promise(function(resolve, reject) {
- var sorted = html;
- $('#purchasetable').empty();
- resolve (sorted);
- });
- sorting.then((sorted) => {
- for (var z = 0; z < sorted.length; z++) {
- $('#purchasetable').append(sorted[z]);
- }
- });
- });
- } else if (sortType === "lowtohigh") {
- var lowsort = (prices).sort(function(a, b) { return a.price - b.price });
- var tablesort = new Promise(function(resolve, reject) {
- var lowhtml = [];
- for (var x = 0; x < lowsort.length; x++) {
- var itemhtml = "<tr id='" + lowsort[x].id + "' onclick=submitid(" +
- parseFloat(((lowsort[x].id).replace('#', ''))) + ")>" +
- $($('#purchasetable').find('#' + lowsort[x].id)).html() +
- "</tr>";
- lowhtml.push(itemhtml);
- }
- resolve (lowhtml);
- });
- tablesort.then((html) => {
- var sorting = new Promise(function(resolve, reject) {
- var sorted = html;
- $('#purchasetable').empty();
- resolve (sorted);
- });
- sorting.then((sorted) => {
- for (var z = 0; z < sorted.length; z++) {
- $('#purchasetable').append(sorted[z]);
- }
- });
- });
- }
- });
- }
- function SaleSort(sortType) {
- var table = ($('#purchasetable').children().toArray());
- var tablelength = table.length;
- var pricing = new Promise(function(resolve, reject) {
- var pricearr = [];
- var tablelength = table.length;
- for (var i = 0; i < tablelength; i++) {
- var price = parseFloat(($($(table[i]).children()[5]).text()).replace('$', ''));
- if (Boolean(price) === true) {
- pricearr.push({
- id: ($($(table)[i]).attr('id')),
- price: (price)
- });
- }
- }
- resolve (pricearr);
- });
- pricing.then((prices) => {
- if (sortType === "hightolow") {
- var highsort = (prices).sort(function(a, b) { return b.price - a.price });
- var tablesort = new Promise(function(resolve, reject) {
- var highhtml = [];
- for (var x = 0; x < highsort.length; x++) {
- var itemhtml = "<tr id='" + highsort[x].id + "' onclick=submitid(" +
- parseFloat(((highsort[x].id).replace('#', ''))) + ")>" +
- $($('#purchasetable').find('#' + highsort[x].id)).html() +
- "</tr>";
- highhtml.push(itemhtml);
- }
- resolve (highhtml);
- });
- tablesort.then((html) => {
- var sorting = new Promise(function(resolve, reject) {
- var sorted = html;
- $('#purchasetable').empty();
- resolve (sorted);
- });
- sorting.then((sorted) => {
- for (var z = 0; z < sorted.length; z++) {
- $('#purchasetable').append(sorted[z]);
- }
- });
- });
- } else if (sortType === "lowtohigh") {
- var lowsort = (prices).sort(function(a, b) { return a.price - b.price });
- var tablesort = new Promise(function(resolve, reject) {
- var lowhtml = [];
- for (var x = 0; x < lowsort.length; x++) {
- var itemhtml = "<tr id='" + lowsort[x].id + "' onclick=submitid(" +
- parseFloat(((lowsort[x].id).replace('#', ''))) + ")>" +
- $($('#purchasetable').find('#' + lowsort[x].id)).html() +
- "</tr>";
- lowhtml.push(itemhtml);
- }
- resolve (lowhtml);
- });
- tablesort.then((html) => {
- var sorting = new Promise(function(resolve, reject) {
- var sorted = html;
- $('#purchasetable').empty();
- resolve (sorted);
- });
- sorting.then((sorted) => {
- for (var z = 0; z < sorted.length; z++) {
- $('#purchasetable').append(sorted[z]);
- }
- });
- });
- }
- });
- }
- function WearSort(sortType) {
- var table = ($('#purchasetable').children().toArray());
- var tablelength = table.length;
- var pricing = new Promise(function(resolve, reject) {
- var pricearr = [];
- var tablelength = table.length;
- for (var i = 0; i < tablelength; i++) {
- var price = parseFloat($($(table[i]).children()[2]).text());
- if (Boolean(price) === true) {
- pricearr.push({
- id: ($($(table)[i]).attr('id')),
- price: (price)
- });
- }
- }
- resolve (pricearr);
- });
- pricing.then((prices) => {
- if (sortType === "hightolow") {
- var highsort = (prices).sort(function(a, b) { return b.price - a.price });
- var tablesort = new Promise(function(resolve, reject) {
- var highhtml = [];
- for (var x = 0; x < highsort.length; x++) {
- var itemhtml = "<tr id='" + highsort[x].id + "' onclick=submitid(" +
- parseFloat(((highsort[x].id).replace('#', ''))) + ")>" +
- $($('#purchasetable').find('#' + highsort[x].id)).html() +
- "</tr>";
- highhtml.push(itemhtml);
- }
- resolve (highhtml);
- });
- tablesort.then((html) => {
- var sorting = new Promise(function(resolve, reject) {
- var sorted = html;
- $('#purchasetable').empty();
- resolve (sorted);
- });
- sorting.then((sorted) => {
- for (var z = 0; z < sorted.length; z++) {
- $('#purchasetable').append(sorted[z]);
- }
- });
- });
- } else if (sortType === "lowtohigh") {
- var lowsort = (prices).sort(function(a, b) { return a.price - b.price });
- var tablesort = new Promise(function(resolve, reject) {
- var lowhtml = [];
- for (var x = 0; x < lowsort.length; x++) {
- var itemhtml = "<tr id='" + lowsort[x].id + "' onclick=submitid(" +
- parseFloat(((lowsort[x].id).replace('#', ''))) + ")>" +
- $($('#purchasetable').find('#' + lowsort[x].id)).html() +
- "</tr>";
- lowhtml.push(itemhtml);
- }
- resolve (lowhtml);
- });
- tablesort.then((html) => {
- var sorting = new Promise(function(resolve, reject) {
- var sorted = html;
- $('#purchasetable').empty();
- resolve (sorted);
- });
- sorting.then((sorted) => {
- for (var z = 0; z < sorted.length; z++) {
- $('#purchasetable').append(sorted[z]);
- }
- });
- });
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement