Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //##layne## shipping js
- $(document).ready(function () {
- $("input[name='postcode']").keyup(function(){
- var tmptxt=$(this).val();
- $(this).val(tmptxt.replace(/\D|^0/g,''));
- if(tmptxt.length > 4){
- $(this).val(tmptxt.substring(-1,4));
- }
- }).bind("paste",function(){
- var tmptxt=$(this).val();
- $(this).val(tmptxt.replace(/\D|^0/g,''));
- if(tmptxt.length > 4){
- $(this).val(tmptxt.substring(-1,4));
- }
- }).css("ime-mode", "disabled");
- $("input[name='postcode'], #postcode").each(function (index,e) {
- $(this).after('<input name="suburb" type="hidden">');
- var cache = {};
- $(e).autocomplete({
- source: function(request, response ) {
- var postcode = request.term;
- if ( postcode in cache ) {
- response( $.map( cache[ postcode ], function( item ) {
- return {
- label: item.label,
- value:item.value,
- suburb:item.suburb,
- }
- }));
- return;
- }
- $.ajax({
- url: 'index.php?route=information/dealers/suburb',
- dataType: "json",
- data:{
- postcode: request.term,
- },
- success: function( data ) {
- cache[ postcode ] = data;
- response( $.map( data, function( item ) {
- return {
- label: item.label,
- value:item.value,
- suburb:item.suburb,
- }
- }));
- }
- });
- },
- minLength: 3,
- select: function( event, ui ) {
- $("#search_dealer input[name='suburb']").val(ui.item.suburb);
- getDealers(ui.item.value, ui.item.suburb);
- }
- });
- });
- function getDealers(postcode,suburb){
- var postcode = postcode ? postcode : $("#search_dealer input[name='postcode']").val();
- var suburb = suburb ? suburb : $("#search_dealer input[name='suburb']").val();
- /*
- var weight = $("#shipping input[name='weight']").val();
- var length = $("#shipping input[name='length']").val();
- var width = $("#shipping input[name='width']").val();
- var height = $("#shipping input[name='height']").val();
- */
- $.post(
- "index.php?route=information/dealers/query",
- {postcode:postcode, suburb:suburb},
- function(result){
- $("#result").html(result);
- }
- );
- createMaps();
- }
- function createMaps(){
- var map = new google.maps.Map(document.getElementById("map"), {
- center: new google.maps.LatLng(-37.814107, 144.963280),
- zoom: 13,
- mapTypeId: 'roadmap'
- });
- var infoWindow = new google.maps.InfoWindow;
- // Change this depending on the name of your PHP file
- // downloadUrl("catalog/controller/information/dealers.php", function(query) {
- /*
- if (window.XMLHttpRequest)
- {// code for IE7+, Firefox, Chrome, Opera, Safari
- xmlhttp=new XMLHttpRequest();
- }
- else
- {// code for IE6, IE5
- xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
- }
- xmlhttp.open("GET","catalog/view/javascript/data.xml",false);
- xmlhttp.send();
- xmlDoc=xmlhttp.responseXML;
- //alert(xmlDoc.documentElement.tagName)
- alert(xmlDoc);
- */
- /*
- var xmlDoc=loadXMLDoc("data.xml");
- alert(xmlDoc);
- */
- /*
- var error = "";
- var file = "data.xml";
- try //Internet Explorer
- {
- xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
- xmlDoc.async=false;
- xmlDoc.load(file);
- }
- catch(e)
- {
- //alert("1");
- try //Firefox, Mozilla, Opera, etc.
- {
- xmlDoc=document.implementation.createDocument("","",null);
- xmlDoc.async=false;
- xmlDoc.load(file);
- }
- catch(e)
- {
- try //Google Chrome
- {
- //alert("2");
- var xmlhttp = new window.XMLHttpRequest();
- xmlhttp.open("GET","data.xml",false);
- xmlhttp.send(null);
- //alert(xmlhttp.getResponseHeader("Content-Length"));
- //alert("3");
- //alert(xmlhttp.readyState);
- //alert(xmlhttp.getAllResponseHeaders());
- xmlDoc = xmlhttp.responseXML.documentElement;
- }
- catch(e)
- {
- error=e.message;
- //alert(error);
- }
- }
- }
- */
- //downloadUrl("data.xml", function(data) {
- downloadUrl("http://www.goskitz.com.au/index.php?route=information/dealers", function(data) {
- //downloadUrl("http://www.goskitz.com.au/catalog/view/javascript/data.xml", function(data) {
- // alert("1");
- var xml = data.responseXML;
- // alert("2");
- //var xml = parseXml(data);
- //alert(xml);
- var markers = xml.documentElement.getElementsByTagName("marker");
- //alert(markers);
- //alert("3");
- //alert("length is : "+ markers.length);
- for (var i = 0; i < markers.length; i++) {
- alert("ssas");
- var name = markers[i].getAttribute("name");
- var address = markers[i].getAttribute("address");
- var point = new google.maps.LatLng(
- parseFloat(markers[i].getAttribute("lat")),
- parseFloat(markers[i].getAttribute("lng")));
- var html = "<b>" + name + "</b> <br/>" + address;
- var icon = 'http://labs.google.com/ridefinder/images/mm_20_blue.png';
- var marker = new google.maps.Marker({
- map: map,
- position: point,
- icon: icon.icon
- });
- bindInfoWindow(marker, map, infoWindow, html);
- }
- });
- }
- function bindInfoWindow(marker, map, infoWindow, html) {
- google.maps.event.addListener(marker, 'click', function() {
- infoWindow.setContent(html);
- infoWindow.open(map, marker);
- });
- }
- function downloadUrl(url, callback) {
- var request = window.ActiveXObject ?
- new ActiveXObject('Microsoft.XMLHTTP') :
- new XMLHttpRequest;
- request.onreadystatechange = function() {
- if (request.readyState == 4) {
- request.onreadystatechange = doNothing;
- callback(request, request.status);
- }
- };
- //alert(url);
- request.open('GET', url, true);
- request.send(null);
- //alert(request.responseText);
- //alert(request);
- //alert(request.getAllResponseHeaders());
- }
- function parseXml(str) {
- if (window.ActiveXObject) {
- var doc = new ActiveXObject('Microsoft.XMLDOM');
- doc.loadXML(str);
- return doc;
- } else if (window.DOMParser) {
- return (new DOMParser).parseFromString(str, 'text/xml');
- }
- }
- function doNothing() {}
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement