// ==UserScript== // @name SGW Fixer - Dev // @namespace https://greasyfork.org // @include https://sellers.shopgoodwill.com/sellers/newAuctionItem-catsel.asp* // @include https://sellers.shopgoodwill.com/sellers/reviewItem-label.asp* // @include https://sellers.shopgoodwill.com/sellers/reviewItem-label.asp?state=2 // @include http://localhost/sgw.html // @version 6.2.0.2 // @description Implements numerous improvements to the functionality of the Shopgoodwill seller site. // @grant none // @require https://greasyfork.org/scripts/10208-gm-api-script/code/GM%20API%20script.js?version=54964 // @require https://greasyfork.org/scripts/19381-sgw-shelves-cats/code/SGW%20Shelves%20%20Cats.user.js?version=126258 // @downloadURL none // ==/UserScript== $('*[name]').not('[id]').each(function(){ $(this).attr('id', $(this).attr('name')); }); window.addEventListener ("message", receiveMessage, false); var url = document.URL; function receiveMessage (event) { var messageJSON; try { messageJSON = JSON.parse (event.data); } catch (zError) { // Do nothing } var safeValue = JSON.stringify(messageJSON); if (typeof(messageJSON['lastLocation'])!== "undefined") { GM_setValue("lastLocation", safeValue); } else { GM_setValue("storedPresets", safeValue); } } if (url == "https://sellers.shopgoodwill.com/sellers/reviewItem-label.asp?state=2") { var myLastLoc = JSON.parse(GM_getValue("lastLocation", "")); if (typeof myLastLoc !== "undefined") { $('a:contains("Add")').before("Location: " + myLastLoc['lastLocation'] + "
"); $('p').first().before("

" + myLastLoc['lastTitle'] + "

"); GM_deleteValue("lastLocation"); } } if (GM_getValue("lastLocation")) { myLastLoc = JSON.parse(GM_getValue("lastLocation", "")); // console.log(url + ": Last location stored as " + myLastLoc['lastLocation']); // console.log(url + ": Last title: " + myLastLoc['lastTitle']) } // The name as listed is what the script looks for at the top of the page, as in "Welcome Firstname Lastname". // (Any piece of that is fine: "John L", "John Linnell", and "hn Lin" would all pick out John Linnell) // "buttonLock" : "yes" causes the shipping buttons to have a lock over them for that user // "unlockY" : [number] is an optional argument that allows you to set the height of the unlock button (with icon): a larger number makes the // button lower on the page var posters = { "Alicia V" : { "name" : "Alicia", "delay" : 1, }, "Hetal S" : { "name" : "Hetal", "duration" : 4, "delay" : 1, }, "Jacob L" : { "name" : "Jacob", "skip" : "allow", "CM" : "yes", "delay" : 0, "duration" : 4, "debug" : true, }, "Jackie C" : { "name" : "Jackie", "CM" : "yes", "delay" : 0, "duration" : 4, }, "Jeff H" : { "name" : "Jeff", "skip" : "allow", "CM" : "BIN", "delay" : 0, "duration" : 4, "debug" : true, }, "Jeremy J" : { "name" : "Jeremy", "skip" : "allow", "duration" : 4, "CM" : "yes", "delay" : 0, "debug" : true, }, "Jessica G" : { "name" : "Jessica", "delay" : 1, }, "Joanne H" : { "name" : "Joanne", "delay" : 1, }, "Kathy O" : { "name" : "Kathy", "skip" : "allow", "delay" : 0, "duration" : 4, }, "Nick Q" : { "name" : "Nick", "delay" : 0, }, "Phalada X" : { "name" : "Phalada", "skip" : "allow", "CM" : "yes", "delay" : 0, "duration" : 4, }, "Peter N" : { "name" : "Peter", "delay" : 1, }, "Phillip S" : { "name" : "Phillip", "delay" : 0, }, "Poppy P" : { "name" : "Poppy", "delay" : 1, "debug" : true, }, "Tanya K" : { "name" : "Tanya", "delay" : 0, }, "Thomas L Butler" : { "name" : "Tom", "delay" : 0, }, "Valerie W" : { "name" : "Valerie", "duration" : 4, "skip" : "allow", "CM" : "yes", "delay" : 0, "debug" : true, }, } var thisPoster = ""; var posterDelay = 0; $.each(posters, function(name, info) { //working 10/27 re = new RegExp(name,"gi"); if(re.exec($(".smtext").html())) { thisPoster = name.replace(/ /gi,""); console.log(thisPoster); } }); var presetTypes = { "Store" : "", "Shipping Weight" : "", "Display Weight" : "", "Location" : "", "Duration" : "", "Ship Charge" : "", "Ship Type" : "", // ^^^ general, guitar, art, lot, long, Media <---- note the capital M! "Ship in own box/between cardboard" : "", // ^^^ yes for yes, any other value defaults to no "Dimension 1" : "", "Dimension 2" : "", "Dimension 3" : "", "Skip" : "", "Owner" : "", } $('body').append(''); if (GM_getValue("storedPresets")) { var presets = JSON.parse (GM_getValue("storedPresets")); if (!presets.hasOwnProperty('Owner') || presets['Owner'] != thisPoster) { if(presets['Skip'] == 'skip') { // console.log('Skip==skip'); $("head").append(""); } else { } presets = { "Store" : "", "Shipping Weight" : "", "Display Weight" : "", "Location" : "", "Duration" : "", "Ship Charge" : "", "Ship Type" : "", // ^^^ general, guitar, art, lot, long, Media <---- note the capital M! "Ship in own box/between cardboard" : "", // ^^^ yes for yes, any other value defaults to no "Dimension 1" : "", "Dimension 2" : "", "Dimension 3" : "", "Skip" : "", "Owner" : thisPoster, }; } else { if (!presets.hasOwnProperty('Duration')) { presets['Duration'] = ""; } else { } if(presets['Skip'] == 'skip') { $("head").append(""); } else { // console.log('Skip!=skip'); } } } else { var presets = { "Store" : "", "Shipping Weight" : "", "Display Weight" : "", "Location" : "", "Duration" : "", "Ship Charge" : "", "Ship Type" : "", // ^^^ general, guitar, art, lot, long, Media <---- note the capital M! "Ship in own box/between cardboard" : "", // ^^^ yes for yes, any other value defaults to no "Dimension 1" : "", "Dimension 2" : "", "Dimension 3" : "", "Skip" : "", "Owner" : thisPoster, }; } var myPresets = ""; var presetBox = "
"; $('p:contains("photos are uploaded")').after(presetBox); $.each(presetTypes, function(key, value){ var myVal = presets[key]; if (myVal && myVal.length) { myPresets += "
" + key + ": " + myVal + "
"; } key2 = "" + key + "" if (key == 'Ship Type') { key2 += " (guitar, art, long, media, clothing, pickup)"; } else if (key == "Ship in own box/between cardboard") { key2 = "Own box/cardboard: (yes or blank/no)"; } key2 += ": "; $('#presetBox').append("" + key2 + "
"); }); $('#presetInputOwner').hide(); if (myPresets.length) { myPresets = "
Presets:
" + myPresets + "

"; $('#presetBox').before(myPresets); $('#myPresets').data("data", presets); } if(myPresets['Ship Type'] == "media") { myPresets['Ship Type'] = "Media"; } $('#presetBox').append("
Update presets"); $('#presetBox').after("
Edit presets"); $('#presetLocation').attr('id', 'tempLoc'); $('#tempLoc').after(""); $('#tempLoc').remove(); $('#presetLocation').append(""); $.each(jsondata2, function(shelfIndex, shelfArray){ $('#presetLocation').append(""); }); $('#presetStore').attr('id', 'tempStore'); $('#tempStore').after($('#itemsellerstore').clone().attr('id', 'presetStore')); $('#tempStore').remove(); $('#presetStore').prepend(""); if(url == "https://sellers.shopgoodwill.com/sellers/newAuctionItem-catsel.asp?clear=yes") { // Hides form if photos are not uploaded // the return URL from the photo uploader is: // https://sellers.shopgoodwill.com/sellers/newauctionitem-catsel.asp?btnSubmit=Return+to+item+entry $('#form1').hide(); } else { $('#presetBoxButton').parent().append("

Gallery:

"); } $("#form1").append(""); $("#form1").append(""); var button1 = "
'); $('#itemShippingPrice').before('
'); $('#itemShipMethod').before('
'); $('#itemShipMethod').after("

" + button1 + "Unlock shipping method" + button2 + "
"); } var currentDur = $('#itemDuration').val(); var cmAllow = "no"; var cmBIN = "no"; $('#itemDuration').replaceWith(""); $("#itemStartOffset, #itemstarttime, #itemDuration, #itemEndTime, #itemShipMethod, #itemShippingPrice, #itemNoCombineShipping, #itemAutoInsurance").attr('tabindex', "-1"); $("#WebWizRTE, #itemDescription").height(700); $("#WebWizRTE, #itemDescription").width(810); $("#s1").attr("size", 100); $("strong:contains('Item Title')").prepend("
"); $("#itemTitle").attr("maxlength",50); $("#itemTitle").removeAttr('onkeypress').removeAttr('onkeyup'); $('#myCounter').html(50); //UGH, SHOPGOODWILL $('font:contains("Numbers and decimal point")').after("

" + button1 + "Unlock shipping charge" + button2 + "
"); $('strong:contains("Private Description")').hide(); $('#itemSellerInfo').hide(); $('p:contains("optimization")').hide(); var html = $('#form1 > table > tbody > tr:eq(1) > td:eq(1)')[0]; var html2 = $('#form1 > table:eq(1) > tbody > tr > td')[0]; html2.innerHTML = html2.innerHTML.replace(/You will be advised[\s\S]*place your listing[\s\S]*will be assessed[\s\S]*in the next screen\./g,""); $("p:contains('Make sure you know')").hide(); $("p:contains('Please review the')").hide(); $("p:contains('read shopgoodwill')").hide(); $("hr").hide(); $('p:contains("Starting Bid")').addClass("bidStartDurBox"); $('p:contains("Auction Duration")').addClass("bidStartDurBox").after("

"); $('p:contains("Auction Duration")').after("Starting bid, start time, duration
") $('#bidStartDurBoxButton').after("Buy now price"); $('.bidStartDurBox').hide(); $('#itemStartOffset').attr("id", "itemStartOffset"); $('#itemstarttime').attr("id", "itemstarttime"); $('#itemDuration').attr("id", "itemDuration"); // Cyber Monday buttons /* now = new Date(); currentDate = now.getDate(); cyberMondayStart = 20; daysTillCMStart = cyberMondayStart - currentDate; cyberMonday = 30; daysTillCM = cyberMonday - currentDate; if (cmAllow == "yes") { $('#BINBoxShowButton').after("

Cyber Monday"); if (daysTillCMStart > 0) { /// $('#cyberMondayDurButton').after(" Cyber Monday (pre-post)"); } if (cmBIN == "yes") { $('#cyberMondayDurButton').after(" Cyber Monday BIN"); } } */ html.innerHTML = html.innerHTML.replace("onblur", "alt"); html.innerHTML = html.innerHTML.replace(/
/g,""); html.innerHTML = html.innerHTML.replace(/pounds((.|\n)*)oversized packages\./g,""); html.innerHTML = html.innerHTML.replace(/Shipping Charge allows((.|\n)*)United States\./g,""); $('b:contains("Set the Shipping Charge")').hide(); html.innerHTML = html.innerHTML.replace(/to use the default shipper's rate calculator\./g,""); html.innerHTML = html.innerHTML.replace(/This is the number((.|\n)*)become active\./g,""); html.innerHTML = html.innerHTML.replace(/This is the number((.|\n)*)will end\./g,""); $('font:contains("UPS dimensional weight calculator click")').hide(); html.innerHTML = html.innerHTML.replace(/Select this option to change the shipping method from your default method\./g,""); html.innerHTML = html.innerHTML.replace(/One line((.|\n)*)find your item\.|You may use((.|\n)*)do not use HTML\.|For |Dutch auctions((.|\n)*)selling a single set\.|This is the price((.|\n)*)and commas \(','\)|Bid increment is((.|\n)*)each bid\.|Reserve Price is((.|\n)*)Reserve Price!|Buy Now allows((.|\n)*)Buy Now!/g, ""); html.innerHTML = html.innerHTML.replace(/Item Quantity((.|\n)*)itemQuantity" size="3" value="1">/g, ""); html.innerHTML = html.innerHTML.replace(/per item((.|\n)*): 3\.00/g, ""); html.innerHTML = html.innerHTML.replace(/Bid Increment((.|\n)*)10\.00/g, "Bid increment:
Reserve price:
Buy now price: (leave at 0 to not have buy-it-now as an option)"); // html.innerHTML = html.innerHTML.replace(//g, ""); // html.innerHTML = html.innerHTML.replace(//g, ""); // $("input[name='itemTitle']").attr("required", true); html.innerHTML = html.innerHTML.replace(/Box Selection((.|\n)*)willing to ship your item\./g, "") html.innerHTML = html.innerHTML.replace(/Handling Charge((.|\n)*)final item selling price\)\./g, ""); // html.innerHTML = html.innerHTML.replace(//g, ""); html.innerHTML = html.innerHTML.replace(//g, ""); html.innerHTML = html.innerHTML.replace(/Example: 1<\/i>/g, ""); html.innerHTML = html.innerHTML.replace(/here<\/a>/g, "here"); html.innerHTML = html.innerHTML.replace(/here<\/a>/g, "here"); html.innerHTML = html.innerHTML.replace(/"); html.innerHTML = html.innerHTML.replace(/"); html.innerHTML = html.innerHTML.replace(/"); html.innerHTML = html.innerHTML.replace(/"); html.innerHTML = html.innerHTML.replace(/"); html.innerHTML = html.innerHTML.replace(//g, ""); html.innerHTML = html.innerHTML.replace(/USPS Only/g, 'Post Office Only'); html2.innerHTML = html2.innerHTML.replace(/Press ((.|\n)*) to start over\./g, ""); html2.innerHTML = html2.innerHTML.replace(//g, ""); html2.innerHTML = html2.innerHTML.replace(/Press to((.|\n)*)start over./g, ""); html2.innerHTML = html2.innerHTML.replace(//g, ""); $('p:contains("Auction Gallery")').replaceWith('
Auction Gallery: ($7.95 charge)
Checking this box causes the auction to appear in the gallery on the site\'s front page.
Please make sure the photos are square, either by adding white space using Paint, or by cropping them with Croppola.

'); $('td:contains("Featured Auction")').replaceWith('Featured Auction: ($4.95 charge)
This adds the item to the Featured Auctions in its category.
Photos can be used as-is.
'); html.innerHTML = html.innerHTML.replace(/Select this((.|\n)*)other items\./g, "Select this option if the buyer of this item should not be allowed to combine this item with shipment of other items."); html.innerHTML = html.innerHTML.replace(/Select this option if you'd like to have((.|\n)*)in order\./g, " Select this option if you'd like to have the system automatically apply the appropriate insurance amount, based on the items current price. In the case of multiple items in the shipment, insurance is calculated on the value of all items in order."); $('#itemIsStock').parent().hide(); $('#itemDescription').parent().after("

Step 3 - Shipping
"); $('#step3Header').after($('#shipCalcContainer')); $('p:contains(\"Seller Store\")').before("
Step 4 - Store and location
"); $('font:contains(\"Step 1\")').html("Step 1 - Images and presets"); $('strong:contains(\"Step 2\")').html("Step 2 - Item information"); $('b:contains("Item Shipment Combining"), #itemNoCombineShipping, #itemNoCombineShippingText, b:contains("Auto Include Insurance"), #itemAutoInsurance, #itemAutoInsuranceText').addClass('hiddenCheckboxes'); //$('.hiddenCheckboxes').insertAfter($('#noteToShipping').parent()); $('.hiddenCheckboxes').each(function(){ $('#form1').append($(this)); }) $('b:contains("Item Shipment Combining"), #itemNoCombineShipping, #itemNoCombineShippingText').wrapAll(""); $('b:contains("Auto Include Insurance"), #itemAutoInsurance, #itemAutoInsuranceText').wrapAll(""); //$('.hiddenCheckboxes').hide(); $('br + br + br').remove(); var debug = false; $.each(posters, function(name, info) { //here2 re = new RegExp(name,"gi"); if(re.exec($(".smtext").html())) { if (info["buttonLock"] == "yes") { var unlockY = 1535; if (info["unlockY"]) { unlockY = info["unlockY"]; } $('.shippingOptions').before('
'); $('.shippingOptions').before('
'); } if (info['skip'] && info['skip'] == 'allow') { } else { $('#presetInputSkip').hide(); } if (info['CM'] == 'yes' || info['CM'] == 'BIN') { cmAllow = "yes"; if (info['CM'] == 'BIN') { cmBIN = "yes"; } } if (info['debug'] == true) { debug = true; } if (info['duration']) { $('#itemDuration').attr('value', info['duration']); // Suck it, javascript. Why do I have to use attr() for this?! Why won't val() freaking work?! God, I hate you. } delay = info['delay']; if (delay > 0) { var d = new Date(); var today = d.getDay(); if ((today + delay) == 6) { delay += 2; } else if ((today + delay) == 7) { delay += 3; } $('#itemStartOffset').val(delay); $('#itemstarttime').val('14:00'); } $("body").append(""); } }); $('p:contains("Description"), strong:contains("Title"), font:contains("characters remaining"), strong:contains("Category"), #s1').addClass('section2'); $('#shipCalcContainer, font:contains("leave at"), .shippingOptions, font:contains("Shipping Charge"), span:contains("Unlock shipping"), b:contains("Shipping"), #shipMethodLock, #itemShipMethod, b:contains("Item Shipment"), input[name="itemNoCombineShipping"], #itemNoCombineShippingText, b:contains("Insurance"), #itemAutoInsurance, #itemAutoInsuranceText').not(':not(:visible)').addClass('section3'); $('#form1').append(""); $('#form1').append(""); $('#itemShipMethod option[value=\"3\"]').text('Post Office'); $("#itemSellerInfo").after("Note to shipping:

"); var sgwTimeouts = window.setTimeout(function(){ // console.dir(presets); presetCount = $('.presetSpan').length; if (presetCount <= 1) { $('#myPresets').hide(); } function processPresets(presets){ function checkPreset(presets, key) { if (typeof presets[key] != 'undefined' && presets[key].length > 0) { return true; } else { return false; } } if (checkPreset(presets, 'Dimension 1')) { $('#dim1').val(presets['Dimension 1']); } else { } if (checkPreset(presets, 'Dimension 2')) { $('#dim2').val(presets['Dimension 2']); } if (checkPreset(presets, 'Dimension 3')) { $('#dim3').val(presets['Dimension 3']); } if (checkPreset(presets, 'Display Weight')) { $('#actualWeight').val(presets['Display Weight']); $('#itemDisplayWeight').val(presets['Display Weight']); } if (checkPreset(presets, 'Duration')) { $('#itemDuration').val(presets['Duration']); } if (checkPreset(presets, 'Location')) { $('#itemSellerInventoryLocationID').val(presets['Location']); } if (checkPreset(presets, 'Ship Charge')) { $('#itemShippingPrice').val(presets['Ship Charge']); dummyWeight(); shippingMethod('USPS'); } if (checkPreset(presets, 'Ship Type')) { shipType = presets['Ship Type'].toLowerCase(); if(shipType == 'media') { if ($('#actualWeight').val().length < 1) { weightPrompt(); } doMedia($('#actualWeight').val()); } else if (shipType == 'clothing') { if ($('#actualWeight').val().length < 1) { weightPrompt(); } calculateUSPS($('#actualWeight').val()); } else if (shipType == 'guitar' || shipType == 'art' || shipType == 'long') { $('#currentShipCalcType').val(shipType); $('#calc-'+shipType).css('background-color', '#AAA'); } } if (checkPreset(presets, 'Ship in own box/between cardboard') && presets['Ship in own box/between cardboard'].toLowerCase() == 'yes') { $('#ownBox:visible:enabled').prop('checked', true); } if (checkPreset(presets, 'Shipping Weight')) { $('#itemWeight').val(presets['Shipping Weight']); } if (checkPreset(presets, 'Skip') && $('#docready3').length < 1) { $("head").append(""); } if (checkPreset(presets, 'Store')) { $('#itemsellerstore').val(presets['Store']); } } processPresets(presets); $('#itemTitle').bind('keyup', function(){ $("#myCounter").html(50-$('#itemTitle').val().length); }); $('td:contains(\"Item information\")').click(function(){ $('.section2').toggle(); }); $('div:contains(\"Step 3 - Shipping\")').click(function(){ $('.section3').toggle(); $('br+br').toggle(); $('p:empty').toggle(); }); $('#itemGallery').bind('change', function(){ if ($('#itemGallery:checked').length > 0) { $('#galleryCB2').prop('checked', true); now = new Date(); currentDate = now.getDate(); currentWeekDay = now.getDay(); // 0 == Sunday; therefore 7 == Saturday; therefore daysTillSaturday = 6 - currentWeekDay; (7 inclusive, but we want not inclusive) daysTillSaturday = 6 - currentWeekDay; daysInMonth = [31,28,31,30,31,30,31,31,30,31,30,31]; daysThisMonth = daysInMonth[now.getMonth()]; // This gives us the end of the month. var suggestedDuration; // We want to know is if the next Saturday is the end of the period... but there's no programmatic way to tell that. Crap. if (daysTillSaturday <= 3) { suggestedDuration = daysTillSaturday + 7; } else { suggestedDuration = 7; } duration = prompt(' Auction duration?\n(Note: if it\'s close to the end of the period,\n you may want to do a shorter auction!)\n\n (Minimum 4, maximum 15)\n\n', suggestedDuration); $('#itemDuration').val(Math.min(Math.max(duration,4),15)); } else { $('#galleryCB2').prop('checked', false); } }); $('#submit1').bind('click', function(e){ e.preventDefault(); var submitForm = true; var itemDescription = ''; if (typeof $('#WebWizRTE').contents()[0]['body']['innerText'] != 'undefined') { itemDescription = $('#WebWizRTE').contents()[0]['body']['innerText'].replace(/(?:\r\n|\r|\n)/g, ''); if (itemDescription.length < 10) { alert('Please enter a description!'); submitForm = false; } } var myCat = $('#s1').val(); while ($('#itemTitle').val().length < 1) { $('#itemTitle').val(prompt('Item title?')); } if ($('#itemWeight').val().length < 1) { if ($('#currentShipCalcType').val() == 'USPS') { while ($('#itemWeight').val().length < 1) { var weight = prompt("Item's weight?"); $('#itemWeight').val(weight); $('#itemDisplayWeight').val(weight); } } else if ($('#currentShipCalcType').val() == 'pickup') { $('#itemWeight').val(150); } else { alert('Please enter shipping information!'); $('.calcInput:empty').first().focus(); submitForm = false; } } while ($('#itemDisplayWeight').val().length < 1) { $('#itemDisplayWeight').val(prompt('Item\'s actual weight?')); } while ($('#itemsellerstore').val() == '') { var store = prompt('Store number?'); if (store == '999') { store = '999 - Mixed Locations'; } $('#itemsellerstore').val(store); } while ($('#itemSellerInventoryLocationID').val().length < 1) { $('#itemSellerInventoryLocationID').val(prompt('Location?')); } if (submitForm === true) { if ($('#itemsellerstore').val() == '999') { $('#itemsellerstore').val('999 - Mixed Locations'); } var shipString = '{{'; if ($('#Clothing').css('background-color') == 'rgb(170, 170, 170)') { shipString += 'clth:'+$('#actualWeight').val()+'#'; if ($('#itemShipMethod').val() == 2) { shipString += '/' + $('#dim1').val() + 'x' + $('#dim2').val() + 'x' + $('#dim3').val(); } } else if ($('#Media').css('background-color') == 'rgb(170, 170, 170)') { shipString += 'mdia:'+$('#actualWeight').val()+'#'; } else { if ($('#currentShipCalcType').val() == 'general') { shipString += 'gen:'; } else if ($('#currentShipCalcType').val() == 'guitar') { shipString += 'guit:'; } else if ($('#currentShipCalcType').val() == 'art') { shipString += 'art:'; } else if ($('#currentShipCalcType').val() == 'long') { shipString += 'long:'; } shipString += $('#actualWeight').val() + '#'; if ($('#dim1').val().length > 0 && $('#dim2').val().length > 0 && $('#dim3').val().length > 0) { shipString += '/' + $('#dim1').val() + 'x' + $('#dim2').val() + 'x' + $('#dim3').val(); } } shipString += '}}'; shipString += '
Original location: ' + $('#itemSellerInventoryLocationID').val(); console.log(shipString); if ($('#noteToShipping').val().length > 0) { // $('#itemSellerInfo').val($('#itemSellerInfo').val()+'

Note from ' + $('#posterName').html() + ': ' + $('#noteToShipping').val()); shipString += '

Note from ' + $('#posterName').html() + ': ' + $('#noteToShipping').val(); } $('#itemSellerInfo').val(shipString); combineCheck(); var myLoc = $('#itemSellerInventoryLocationID').val(); var myTitle = $('input[name=\"itemTitle\"]').val(); saveLocation = JSON.stringify({'lastLocation': myLoc, 'lastTitle': myTitle}); window.postMessage (saveLocation, '*'); $('#form1').submit(); } }); function combineCheck(){ var noCombine = false; var myWeight = $('#itemWeight').val(); if (myWeight >= 20) { noCombine = true; } else { // console.log('weight<=20'); var myCat = $('#s1').val(); var badCats = ['Paintings', 'Prints', 'Strings', 'Brass', 'Formalwear', 'Outerwear', 'Wedding > Dresses', 'Lamps', 'Dinnerware', 'Sewing Machines', 'Typewriters', 'Receivers', 'Turntables', 'Dinnerware']; $.each(badCats, function(index, category){ if (myCat.indexOf(category) >= 0) { noCombine = true; } }); // console.log('...'); if (noCombine == false) { // console.log('noCombine==false'); var myDescription = ''; if (typeof $('#WebWizRTE').contents()[0]['body']['innerText'] != 'undefined') { var myDescription = $('#WebWizRTE').contents()[0]['body']['innerText'].replace(/(?:\r\n|\r|\n)/g, '').toLowerCase(); } var myTitle = $('#itemTitle').val().toLowerCase(); var badWords = ['Framed', 'Saxophone', 'Guitar', 'Keyboard', 'Trombone', 'Telescope', 'Saxophone', 'Lamp', 'Snowboard', 'Skateboard', 'Glass', 'Crystal', 'Cast iron', 'Tool', 'Drum', 'Sewing machine', 'Typewriter', 'Printer', 'Desktop', 'Receiver', 'Turntable', 'Monitor']; console.log(myDescription); console.log(myTitle); $.each(badWords, function(index, word){ word = word.toLowerCase(); if (myDescription.indexOf(word) >= 0 || myTitle.indexOf(word) >= 0) { noCombine = true; console.log('y:'+word); } else { console.log('n:'+word); } }); if (noCombine == false && (myCat.indexOf('Speaker') || myTitle.indexOf('speaker') || myDescription.indexOf('speaker')) && myWeight > 5) { noCombine = true; } } } if (noCombine == true) { $('#itemNoCombineShipping').prop('checked', true); } else { $('#itemNoCombineShipping').removeProp('checked'); } } function dummyWeight() { if ($('#itemWeight').val().length < 1) { $('#itemWeight').val(1); } if ($('#itemDisplayWeight').val().length < 1) { $('#itemDisplayWeight').val(1); } } $('.upsButton').bind('click', function(){ useSuggestion('UPS'); }); $('.uspsButton').bind('click', function(){ useSuggestion('USPS'); }); $('.pickupOnlyButton').bind('click', function(){ useSuggestion('pickup'); }); function buttonClickAnimate(button) { button.css('background-color', '#AAA').animate({ 'background-color' : '#EEE', }, 500); } function weightPrompt() { var displayWeight = Math.ceil($('#addPounds').html()); while ($('#actualWeight').val().length < 1) { var actualWeight = prompt('Item\'s actual weight?'); actualWeight = actualWeight.replace(/[^\d.-]/g,''); $('#actualWeight').val(actualWeight); displayWeight += Math.ceil(actualWeight); $('#calc-'+$('#currentShipCalcType').val()).trigger("click"); } $('#itemDisplayWeight').val(displayWeight); } $('#calc-media').bind('click', function(){ buttonClickAnimate($(this)); $('#Media') .trigger('click'); }); $('#calc-clothing').bind('click', function(){ buttonClickAnimate($(this)); weightPrompt(); var weight = parseFloat($('#actualWeight').val()); $('#itemDisplayWeight').val(weight); calculateUSPS(weight); }); function calculateUSPS(weight) { if (weight >= 3) { $('#UPS').trigger('click'); } else { if (weight < .56) { charge = 2.99; } else if (weight < 1) { charge = 3.99; } else if (weight < 2) { charge = 6.99; } else { charge = 8.99; } $('#itemShippingPrice').val(charge); shippingMethod('USPS'); } } $('.shipCharge').bind('click', function(){ $('.shipType').css('background-color', '#EEE'); $(this).css('background-color', '#AAA'); var thisBox = $(this).text(); var boxData = $('#boxDefinitions').data()[thisBox]; weightPrompt(); if (thisBox == 'Media') { doMedia($('#actualWeight').val()); } else if (thisBox == 'Clothing' || thisBox == 'Small&light') { $('#calc-clothing').trigger('click'); } else if (boxData['method'] == 'USPS') { $('#itemDisplayWeight').val($('#actualWeight').val()); $('#itemWeight').val($('#actualWeight').val()); $('#itemShippingPrice').val(boxData['price']); $('#shipTypeNote') == thisBox; } else if (boxData['method'] == 'UPS') { $('#itemDisplayWeight').val($('#actualWeight').val()); realWeight = Math.ceil($('#actualWeight').val())+Math.ceil($('#addInches').html()); if (realWeight > boxData['weight']) { $('#itemWeight').val(realWeight); } else { $('#itemWeight').val(boxData['weight']); } $('#shipTypeNote') == boxData['note']; } if (boxData['method'].length > 0) { // console.log('.shipCharge():'+boxData['method']); shippingMethod(boxData['method']); } }); function useSuggestion(type) { buttonClickAnimate($('.'+type+'Button:visible')); if (type == 'pickupOnly') { type = 'pickup'; } // console.log('useSuggestion():'+type); shippingMethod(type); weightPrompt(); $('#itemDisplayWeight').val($('#actualWeight').val()); if (type == 'UPS') { $('#itemWeight').val($('#shipCalcShippingWeight').html()); } else if (type == 'USPS') { $('#itemWeight').val($('#actualWeight').val()); $('#itemShippingPrice').val($('#uspsSuggPrice').html()); } else if (type == 'pickup') { $('#itemWeight').val(150); } } $('#UPS').bind('click', function(){ weightPrompt(); dimList = [$('#dim1').val(), $('#dim2').val(), $('#dim3').val()]; $.each(dimList, function(index, dim){ index+=1; while (dim.length < 1) { dim = prompt('Dimension ' + index); $('#dim'+index).val(dim); } }); $('#calc-'+$('#currentShipCalcType').val()).trigger('click'); if($('.upsButton:visible').length > 0) { useSuggestion('UPS'); } else { useSuggestion('pickup'); } }); $('#pickupOnly').bind('click', function(){ weightPrompt(); shippingMethod('pickup'); }); function shippingMethod(method) { // console.log('shippingMethod() '+method); $('#UPS, #pickup').css('background-color', '#EEE'); $('#itemShipMethod > option').removeAttr('selected'); if (method == 'UPS') { $('#itemShipMethod').val(2); $('#itemAutoInsurance').removeProp('checked'); $('#itemShippingPrice').val(0); $('#UPS').css('background-color', '#AAA'); } else if (method =='pickup') { // console.log('a'); $('#itemShipMethod').val(0); $('#itemAutoInsurance').removeProp('checked'); $('#itemShippingPrice').val(0); $('#itemWeight').val(150); $('#pickupOnly').css('background-color', '#AAA'); } else if (method == 'USPS') { // console.log('???'); $('#itemShipMethod').val(3); $('#itemAutoInsurance').prop('checked', true); $('#itemWeight').val(Math.ceil($('#actualWeight').val()) + Math.ceil($('#addPounds').html())); } } function getCharge(myWeight) { console.log('getCharge:'+myWeight); if (myWeight <= 3) { return '3.99'; } else if (myWeight <= 6) { return '5.99'; } else if (myWeight <= 10) { return '7.99'; } else if (myWeight <= 13) { return '8.99'; } else if (myWeight <= 15) { return '9.99'; } else if (myWeight <= 19) { return '11.99'; } else if (myWeight <= 25) { return '15.99'; } else if (myWeight <= 27) { return '16.99'; } else if (myWeight <= 29) { return '17.99'; } else if (myWeight <= 31) { return '18.99'; } else if (myWeight <= 33) { return '19.99'; } else if (myWeight <= 35) { return '20.99'; } else if (myWeight <= 37) { return '21.99'; } else if (myWeight <= 39) { return '22.99'; } else if (myWeight <= 41) { return '23.99'; } else if (myWeight <= 43) { return '24.99'; } else if (myWeight <= 45) { return '25.99'; } else if (myWeight <= 47) { return '26.99'; } else if (myWeight <= 49) { return '27.99'; } else if (myWeight <= 51) { return '28.99'; } else if (myWeight <= 53) { return '29.99'; } else if (myWeight <= 55) { return '30.99'; } else if (myWeight <= 57) { return '31.99'; } else if (myWeight <= 59) { return '32.99'; } else if (myWeight <= 61) { return '33.99'; } else if (myWeight <= 63) { return '34.99'; } else if (myWeight <= 65) { return '35.99'; } else if (myWeight <= 67) { return '36.99'; } else if (myWeight <= 68) { return '37.99'; } else if (myWeight <= 69) { return '38.99'; } else if (myWeight <= 70) { return '39.99'; } } function doMedia(weight) { console.log('media:'+weight); var myCharge; if (weight < 50) { myCharge = getCharge(weight); } else if (weight < 70) { myCharge = 2 * getCharge(weight/2); } else { if (weight <= 140) { weight /= 2; myCharge = 2.25 * getCharge(weight); } else if (weight <= 210) { weight /= 3; myCharge = 3.5 * getCharge(weight); } myCharge = (Math.ceil(myCharge) - .01) } $('#itemDisplayWeight').val(weight); $('#itemWeight').val(weight); $('#itemShippingPrice').val(myCharge); $('#shipTypeNote').val('Media'); shippingMethod('USPS'); } }, 1100); if (debug === true) { $('body').append("
Debug
"); $('#debugContainer').css({ 'position' : 'absolute', 'top' : '100px', 'right' : '10px', }); $('#debugBox').bind('click', function(){ if ($('#debugBox:checked').length>0) { if ($('#debugOptionsContainer').length <= 0) { $('#form1, #noCombineShippingContainer, #autoInsuranceContainer').show(); $('#noCombineShippingContainer, #autoInsuranceContainer').wrapAll("
"); $('#itemLength').parent().parent().appendTo($('#debugOptionsContainer')).show(); $('#itemShipLength').parent().parent().appendTo($('#debugOptionsContainer')).show(); $('#debugOptionsContainer span, #debugOptionsContainer br').remove(); } else { $('#debugOptionsContainer').show(); } } else { $('#debugOptionsContainer').hide(); } }); } $('#incrementReserveBox').parent().parent().hide(); $('#UPS').css('background-color', "#AAA"); // End