Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
<script type="text/javascript"> var map; var gdir; var geocoder = null; var addressMarker; function sendForm(elem, lang){ obkt = { from : { ob : elem.fromAddress_text, val : elem.fromAddress_text.value }, to : { ob : elem.toAddress_text, val : elem.toAddress_text.value }, trip : { ob : elem.trip, val : elem.trip.value }, trip1 : { ob : elem.trip1, val : elem.trip1.value }, trip2 : { ob : elem.trip2, val : elem.trip2.value }, car : { ob : elem.car, val : elem.car.value}, monitor : { ob : elem.monitor, val : elem.monitor.value } } $(obkt).each(function(){ if ($(this).val) { $(this.ob).addClass("error"); } }); if ( ( !obkt.from.val ) || ( !obkt.to.val) ){ errorshow("One of more parametrs values are not set, please set and try again!"); } else { setDirections(obkt.from.val, obkt.to.val, lang) } } function prep(id){ if (( !Drupal.settings.locat ) && (id == "from")) { return Drupal.settings.locat.from } if (( !Drupal.settings.locat ) && (id == "to")){ return Drupal.settings.locat.to } } else {jQuery.extend(Drupal.settings, { "basePath": "/", "page": "routecalc", "lang": "en" }); if( id == "from" ){ return Drupal.t("@start",trans) } if( id == "to"){ return Drupal.t("@endt",trans) } } } function initialize() { if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById("map_canvas")); map.addControl(new GSmallMapControl()); map.enableScrollWheelZoom(); map.setMapType(G_NORMAL_MAP); gdir = new GDirections(map, document.getElementById("directions")); GEvent.addListener(gdir, "addoverlay", onGDirectionsLoad); GEvent.addListener(gdir, "error", handleErrors); setDirections(prep("from"), prep("to"), Drupal.t("@la",trans)); } } function setDirections(fromAddress, toAddress, locale) { gdir.locale fromAddress +=",Ma"; toAddress +=",Ma"; gdir.load("from: " + fromAddress + " to: " + toAddress,{ "locale": locale }); } function handleErrors(){ if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS) errorshow("<p>Unfortunately, the system can not find the desired value, Possible reasons:</p><p>1. The specified point is located outside the state Masachussets.</p><p>2. Google map system is not known to the requested location.</p>"); else if (gdir.getStatus().code == G_GEO_SERVER_ERROR) errorshow("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code); else if (gdir.getStatus().code == G_GEO_MISSING_QUERY) errorshow("Your request contains an empty field direction.\n Error code: " + gdir.getStatus().code); else if (gdir.getStatus().code == G_GEOgetIcon().image_BAD_KEY) errorshow("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code); else if (gdir.getStatus().code == G_GEO_BAD_REQUEST) errorshow("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code); else errorshow("An unknown error occurred."); } function convert_mile(metr){ mile = (metr/parseInt("1609,344")); mile = mile.toFixed(1); return mile; } function addinput(e) { text = $(e).parent("li").attr('val') if ( $(e).parent("li").hasClass("autocom from") ){ $("#fromAddress").val(text); $("div.autocomplete").remove(); } if ( $(e).parent("li").hasClass("autocom to") ){ $("#toAddress").val(text); $("div.autocomplete").remove(); } } function onGDirectionsLoad(){ if ( $("#geo-error").length !== 0 ){ $("#geo-error").remove(); } var metr = gdir.getDistance().meters; var direct = ""; direct += "<div id=distance>'.$rast.'"+ convert_mile(metr) +" '.$mil.' ( "+ metr/parseInt(1000) +" '.$km.')</div>"; direct += "<div id=price></div>"; $("div[jsvalues=\"$routeId:$index;$Route:$AllRoutes[$index]\"]").empty().append(direct); var trip = $("#trip input:radio:checked").val(); var from = gdir.B.Placemark[0].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName var fromall = $("#fromAddress").val(); var to = gdir.B.Placemark[1].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName var toall = $("#toAddress").val(); var monitor = $("#monitor:checked").length; var time1 = $("#trip1 input:radio:checked").val(); var time2 = $("#trip2 input:radio:checked").val(); var car = $("#car option:selected").val(); $("#p_submit input").removeAttr("disabled"); $.post("/routecalc/price",{"from":from,"to":to, "trip":trip, "monitor":monitor, "time1":time1, "time2":time2, "car":car, "miles": convert_mile(metr) }, function(data) { if ( data.otvet != null ){ $("#price").html("<span>Price: <b>"+data.otvet+"<b>$<span>"); if ( data.otvet != 0 ) { if (metr != 0){ $("#price").after('<input id="adcart" type="submit" value="Add to Cart" />'); $("#adcart").click(function(){ $(this).attr("disabled","disabled"); $.post("/routecalc/addcart",{"from":from,"to":to,"fromall":fromall,"toall":toall,"trip":trip,"monitor":monitor,"time1":time1, "time2":time2, "car":car, "miles": convert_mile(metr), price: data.otvet }, function(d,suc){ if (suc == "success"){ if ( $("#cart").length == 0 ){ $("#p_submit").after("<div id='cart'><div id='trips'>Trips:"+d.trips+"</div><div id='allpr'>Price:"+d.allprice+" $<p><a href='/routecalc/addcart'>"+Drupal.settings.t.сheckout+"</a></p></div></div>"); } else { $("#cart").empty().append("<div id='trips'>Trips:"+d.trips+"</div><div id='allpr'>Price:"+d.allprice+" $<p><a href='/routecalc/addcart'>сheckout</a></p></div>"); } $("#adcart").removeAttr("disabled"); } },"json"); }); } } } },"json"); } function errorshow(err){ $("#geo-error").remove(); $("#directions").before('<div id="geo-error">'+err+'</div>'); } </script>
This paste will be private.
From the Design Piracy series on my blog: