// ==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.6 // @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?upDate=20160624b // @require https://greasyfork.org/scripts/13969-sgw-fixer-users/code/SGW%20Fixer%20-%20Users.js?upDate=20160719 // @downloadURL none // ==/UserScript== $('*[name]').not('[id]').each(function(){ $(this).attr('id', $(this).attr('name')); }); window.addEventListener ("message", receiveMessage, false); var url = document.URL; var premium = false; var baseDuration = 0; 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", "")); } // 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 thisPoster = ""; var myPosterName = ""; 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,""); myPosterName = name; 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 { } } } 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(); } $('#itemTitle').parent().parent().prepend("
Listing upgrades
"); $('#listingUpgrades').append("Gallery ($8) "); $('#listingUpgrades').append("Feature ($5) "); $('#listingUpgrades').append("Premium item "); $("#form1").append(""); $("#form1").append(""); var button1 = "
'); $('#itemShippingPrice').before('
'); $('#itemShipMethod').before('
'); $('#itemShipMethod').after("

" + button1 + "Unlock shipping method" + button2 + "
"); } var currentDur = $('#itemDuration').val(); if (url != "https://sellers.shopgoodwill.com/sellers/newauctionitem-catsel.asp?btnSubmit=Return+to+item+entry") { $('#itemDuration').replaceWith(""); } var cmAllow = "no"; var cmBIN = "no"; $("#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(/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(/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)); }) // butts $('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').val(info['duration']); } 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(){ 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); $('#galleryCB2').bind('click', function(){ $("#itemGallery").trigger("click"); }); $('#featureCB2').bind('click', function(){ $("#itemFeatured").trigger("click"); }); $('#premiumItem').bind('click', function(){ if ($('#premiumItem:checked').length > 0) { premiumItem(true); } else { premiumItem(false); } }); function premiumItem(willBePremium) { $('#premiumItem').prop('checked', willBePremium); if (baseDuration == 0) { baseDuration = $('#itemDuration').val(); } if (willBePremium) { now = new Date(); currentDate = now.getDate(); itemStartDay = now.getDay(); itemStartDay += ($('#itemStartOffset').val()*1); // if it's not starting today... // console.log('Item starts on day ' + itemStartDay%7); var itemDuration = 10 - (itemStartDay%7); // This gets you the number of days from the start day until the FOLLOWING Wednesday - Wednesday of the next week // console.log(nextWednesday); if (Math.floor(Math.random() * 2) == 1) { itemDuration += 1; // based on a coin flip, end on the Wednesday or add a 1 and end on the Thursday } $('#itemDuration').val(itemDuration); } else { $('#itemDuration').val(baseDuration); $('#galleryCB2, #featureCB2, #itemGallery, #itemFeatured').prop('checked', false).removeProp('disabled'); } } $('#itemTitle').bind('keyup', function(){ $("#myCounter").html(50-$('#itemTitle').val().length); }); /* $('td:contains(\"Item information\")').click(function(){ $('.section2').toggle(); // windowshades }); $('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); $('#featureCB2, #itemFeatured').prop('checked', false).prop('disabled', true); $('#premiumItem').prop('disabled', true); premiumItem(true); } else { $('#galleryCB2').prop('checked', false); $('#featureCB2, #itemFeatured, #premiumItem').removeProp('disabled'); premiumItem(false); } }); $('#itemFeatured').bind('change', function(){ if ($('#itemFeatured:checked').length > 0) { $('#featureCB2').prop('checked', true); $('#premiumItem').prop('disabled', true); premiumItem(true); } else { $('#featureCB2').prop('checked', false); $('#premiumItem').removeProp('disabled'); premiumItem(false); } }); $('#submit1').bind('click', function(e){ e.preventDefault(); if ($('.shipCalcInput:focus'). length < 1) { 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 = 'OLoc: ' + $('#itemSellerInventoryLocationID').val()+"
"; 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(); } } if ($('#ownBox:checked').length > 0) { shipString += ':ownBox'; } shipString += '}}'; if ($('#currentShippingNote').length > 0) { if ($('#currentShippingNote').val().length > 0) { shipString+= '

' + $('#currentShippingNote').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()).substring(0,200); } // .substring() here so that the note doesn't exceed 200 characters, ballsing up the post if ($('#premiumItem:checked').length > 0) { shipString += '|P'; } $('#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(); } } else { if ($('#dim1').val().length && $('#dim2').val().length && $('#dim3').val().length) { if ($('#currentShipCalcType').val().length) { $('.useButton:visible').first().trigger('click'); } else { $('#calc-general').trigger('click'); } } else { var switched = false; $('.shipCalcInput').each(function(){ if ($(this).val().length < 1 && switched == false) { $(this).focus(); switched = true; } }); } } }); /* $('#submit1').after("
check
"); $('#checkCombine').bind('click', function(){ combineCheck(); });*/ function combineCheck(){ console.log('dsf'); var noCombine = false; var myWeight = $('#itemWeight').val(); if (myWeight >= 20) { noCombine = true; } else { 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('badCat: ' + category); } }); if (noCombine == false) { var myDescription = ''; if (typeof $('#WebWizRTE').contents()[0]['body']['innerText'] != 'undefined') { var myDesc = $('#WebWizRTE').contents()[0]['body']['innerText'].replace(/(?:\r\n|\r|\n)/g, '').toLowerCase(); var re = new RegExp(".+?(?=check out our other)"); var match = myDesc.match(re); myDescription = match[0]; } 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('badWord: '+word); } else { } }); if (noCombine == false && (myCat.indexOf('Speaker') || myTitle.indexOf('speaker') || myDescription.indexOf('speaker')) && myWeight > 5) { noCombine = true; console.log('badWeight (speaker)'); } } } 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) { $('.useButton').css({'background-color' : '#cce0ff'}); button.css({'background-color' : darken(button.css('background-color'), .1)}) } function darken(color, modifier) { var parts = color.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/); delete(parts[0]); for (var i = 1; i <= 3; ++i) { parts[i] = Math.min(Math.ceil(parts[i]*(1-modifier)), 255); } return 'rgb(' + parts[1] + ',' + parts[2] + ',' + parts[3] + ')'; } function darkenElement(element, modifier) { var bgColor = element.css('background-color'); dark = darken(bgColor, modifier); darker = darken(bgColor, modifier*2); console.log(dark); console.log(darker); element.css({'background-color' : darker, /*'border-color' : borderColor*/}).animate({ 'background-color' : dark, }, 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(){ $('.fakeButton').css({'background-color' : '#eee'}); buttonClickAnimate($(this)); $('#Media') .trigger('click'); }); $('#calc-clothing').bind('click', function(){ $('.fakeButton').css({'background-color' : '#eee'}); 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) { var buttonAnimateString = '.' + type; if (type == 'pickup') { buttonAnimateString += 'Only'; } buttonAnimateString += 'Button:visible' buttonClickAnimate($(buttonAnimateString)); if (type == 'pickupOnly') { type = 'pickup'; } 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) { $('#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') { $('#itemShipMethod').val(0); $('#itemAutoInsurance').removeProp('checked'); $('#itemShippingPrice').val(0); $('#itemWeight').val(150); $('#pickupOnly').css('background-color', '#AAA'); } else if (method == 'USPS') { $('#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'); } var gallery = false; $('b:contains("Uploaded Files")').parent().parent().siblings().each(function(){ if($(this).children().first().text().indexOf(' Cropped') >= 0) { gallery = true; } }); if (gallery) { $('#galleryCB2').trigger('click'); } }, 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