cvs: pearweb /public_html/javascript peardev_map.js popmap.js showmap.js

From: Date: Mon, 11 Dec 2006 21:02:56 +0000
Subject: cvs: pearweb /public_html/javascript peardev_map.js popmap.js showmap.js
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-core+get-5249@lists.php.net to get a copy of this message
arnaud Mon Dec 11 21:02:56 2006 UTC Added files: /pearweb/public_html/javascript peardev_map.js popmap.js showmap.js Log: adding javascript files for the pear developers maps

http://cvs.php.net/viewvc.cgi/pearweb/public_html/javascript/peardev_map.js?view=markup&rev=1.1 Index: pearweb/public_html/javascript/peardev_map.js +++ pearweb/public_html/javascript/peardev_map.js var map = document.getElementById('peardev_map'); if (map) { var gmapped = GMap2(document.getElementById('peardev_map')); } // {{{ var baseIcon /** * The base icon created with * google's help ;-) */ var baseIcon = new GIcon(); baseIcon.iconSize = new GSize(20, 20); baseIcon.shadowSize = new GSize(37, 34); baseIcon.iconAnchor = new GPoint(0, 0); baseIcon.infoWindowAnchor = new GPoint(9, 2); baseIcon.infoShadowAnchor = new GPoint(18, 25); // }}} // {{{ public function createMarker /** * Create a marker * * This function creates a marker with the * picture in pngs/dev.png. It creates * a new marker, then return the *object* * marker. * * @todo Change the icon.image variable to the * pearweb installation (s/pearweb/pear.php.net/g) * * @access public * @param float point The point to place the marker * * @param string textvalue The text to display for a user * in the window above the marker * when the marker is clicked on. * * @return object marker The new marker with it's position * properties, etc. */ function createMarker(point, textvalue) { var icon = new GIcon(baseIcon); icon.image = 'http://pear.php.net/pngs/dev.png'; var marker = new GMarker(point, icon); GEvent.addListener(marker, 'click', function() { marker.openInfoWindowHtml(textvalue); }); return marker; } // }}} // {{{ public function showFullMap /** * Show the full map * * This function will take the points * set by the map/index.php script * process them, make the gmap, attach * it to the peardev_map div, and display * on the page. * * @access public */ function showfullmap() { if (GBrowserIsCompatible()) { if (!gmapped) { var gmapped = new GMap2(document.getElementById('peardev_map')); } gmapped.addControl(new GLargeMapControl()); gmapped.addControl(new GMapTypeControl()); gmapped.setCenter (new GLatLng(37.4419, -122.1419), 3); for (var i = 0; i < points.length; i++) { /** * The html in the marker */ var peardevdesc = "User: " + points[i][2] + "<br />"; peardevdesc += "Page: " + points[i][3] + "<br />"; peardevdesc += "Email: " + points[i][4] + "<br />"; var newpoint = new GLatLng(points[i][0], points[i][1]); gmapped.addOverlay(createMarker(newpoint, peardevdesc)); } } } // }}} http://cvs.php.net/viewvc.cgi/pearweb/public_html/javascript/popmap.js?view=markup&rev=1.1 Index: pearweb/public_html/javascript/popmap.js +++ pearweb/public_html/javascript/popmap.js // {{{ Disclaimer /** * @author: David Coallier <davidc@php.net> * @package pearweb * @version $Id: popmap.js,v 1.1 2006/12/11 21:02:55 arnaud Exp $ */ // }}} // {{{ Browsers detection. var IE = navigator.userAgent.indexOf("MSIE") != -1; var Opera = navigator.userAgent.indexOf("Opera") != -1; var Mozilla = navigator.userAgent.indexOf("Mozilla") != -1; var Safari = navigator.userAgent.indexOf("Safari") != -1; // }}} // {{{ Compatibility /** * Compatibility with elder browsers. */ if (!String.fromCharCode) { String.prototype.fromCharCode = function(code) { var h = code.toString(16); if (h.length == 1) { h = '0' + h; } return unescape('%' + h); } } if (!String.charCodeAt) { String.prototype.charCodeAt = function(str) { for (i = 1, h; i < 256; i++) { if (String.fromCharCode(i) == str.charAt(i)) { return i; } } } } // http://www.crockford.com/javascript/remedial.html if (!Array.splice) { Array.prototype.splice = function(s, d) { var max = Math.max, min = Math.min, a = [], // The return value array e, // element i = max(arguments.length - 2, 0), // insert count k = 0, l = this.length, n, // new length v, // delta x; // shift count s = s || 0; if (s < 0) { s += l; } s = max(min(s, l), 0); // start point d = max(min(typeof d == 'number' ? d : l, l - s), 0); // delete count v = i - d; n = l + v; while (k < d) { e = this[s + k]; if (!e) { a[k] = e; } k += 1; } x = l - s - d; if (v < 0) { k = s + i; while (x) { this[k] = this[k - v]; k += 1; x -= 1; } this.length = n; } else if (v > 0) { k = 1; while (x) { this[n - k] = this[l - k]; k += 1; x -= 1; } } for (k = 0; k < i; ++k) { this[s + k] = arguments[k + 2]; } return a; } } if (!Array.push) { Array.prototype.push = function() { for (var i = 0, startLength = this.length; i < arguments.length; i++) { this[startLength + i] = arguments[i]; } return this.length; } } if (!Array.pop) { Array.prototype.pop = function() { return this.splice(this.length - 1, 1)[0]; } } // }}} // {{{ variables var matchCounter = new Array(); // }}} // {{{ Anonymous class pearweb // Configuration: var pearweb = {}; // }}} // {{{ pearweb functions // {{{ function pearweb /** * Onload function.. this starts everything up once the page has finished loading */ pearweb.pearweb = function() { pearweb.create_map_div(); }; // {{{ function display_map /** * Display the map */ pearweb.display_map = function (e) { //ad_data = pearweb.get_ad_data(keyword); eventX = IE ? event.clientX : e.clientX eventY = IE ? event.clientY : e.clientY popup = document.getElementById('pearweb_map'); var content = ''; var left = IE ? eventX + document.body.scrollLeft : e.pageX - window.pageXOffset; var top = IE ? document.body.scrollTop : e.pageY - window.pageYOffset; var maxY = IE ? document.body.clientHeight : window.innerHeight; var maxX = IE ? document.body.clientWidth : window.innerWidth; var maxDivWidth = new Number('410'); var maxDivHeight = new Number('410'); if (IE) { if (eventY <= (maxDivHeight)) { top = top; } else { if ((maxY/(top)) < 0.3) { top -= maxDivHeight; } else { top -= maxDivHeight; } } if ((left + maxDivWidth) > maxX) { left = ((maxX-maxDivWidth)-30); } else { if ((maxX < (left+maxDivWidth)) && (maxX < 410)) { left = ((maxX-maxDivWidth) / 2); } } top = top - maxDivHeight; } else { if ((top + maxDivHeight) > maxY) { top = (maxY-maxDivHeight)-10; } if ((left + maxDivWidth) > maxX) { left = ((maxX - maxDivWidth)-30); } else { if ( (maxX < (left+maxDivWidth)) && (maxX < 480)) { left = ( ( maxX - maxDivWidth) / 2); } } } var position = IE ? "absolute" : "fixed"; var html = '<div class="header" style="background-color: #babdb6; text-align: right; border: 1px solid black;width: 410px; height: 350px;'; //html += ' display:inline; '; html += 'position:' + position + '; left:'+left+'px; top:'+top+'px;">'; html += '<table width="100%" height="5%">'; html += ' <tr><td style="text-position: left;">Double click to choose location<a href="#" style="background-color: gray; color: white;" onclick="pearweb.hide_div();">[X]</a></td></tr>'; html += '</table><div id="map" class="map" style="width: 100%; height: 95%">\n'; html += '</div>'; html += '<div id="message"></div>'; html += '</div>'; popup.innerHTML = html; if (window.opera) { popup.style.position="absolute"; } popup.style.visibility="visible"; popup.style.display=""; }; // }}} // {{{ function hide_ad /** * Hide the ad */ pearweb.hide_ad = function(delay) { if(delay) { hide_timer = setInterval('pearweb.hide_div();',delay); } else { pearweb.hide_div(); } }; // }}} // {{{ function hide_div pearweb.hide_div = function() { if (window.opera) { popup.style.position="fixed"; } popup = document.getElementById('pearweb_map'); popup.style.visibility="hidden"; popup.display = 'none'; GUnload(); }; // }}} // {{{ function create_map_div pearweb.create_map_div = function() { var div = document.createElement('div'); div.setAttribute('id', 'pearweb_map'); div.setAttribute('style', 'position:absolute;visibility:hidden;'); document.body.appendChild(div); }; // }}} // {{{ window events handling // Trigger the highlight using the onload handler. if (window.attachEvent) { window.attachEvent('onload', pearweb.pearweb); } else if (window.addEventListener) { window.addEventListener('load', pearweb.pearweb, true); } else { var __onload = window.onload; window.onload = function() { pearweb.pearweb(); __onload(); }; } // }}} http://cvs.php.net/viewvc.cgi/pearweb/public_html/javascript/showmap.js?view=markup&rev=1.1 Index: pearweb/public_html/javascript/showmap.js +++ pearweb/public_html/javascript/showmap.js function showmap() { if (GBrowserIsCompatible()) { if (!map) { var map = new GMap2(document.getElementById("map")); } GEvent.addListener(map, "dblclick", function() { var center = map.getCenter(); var latitude = center.y.toFixed(10); var longitude = center.x.toFixed(10); document.getElementById("latitude").value = latitude; document.getElementById('longitude').value = longitude; pearweb.hide_div(); }); map.addControl(new GSmallMapControl()); map.addControl(new GMapTypeControl()); lat = document.getElementById('latitude').value; lng = document.getElementById('longitude').value; if (lat.length > 5 && lng.length > 5) { var point = new GLatLng(lat, lng); var icon = new GIcon(); icon.image = 'http://pear.php.net/gifs/pearpoint.gif'; icon.iconSize = new GSize(15, 20); icon.shadowSize = new GSize(25, 30); icon.iconAnchor = new GPoint(0, 0); map.setCenter(point, 1); map.addOverlay(new GMarker(point, icon)); } else { map.setCenter(new GLatLng(37.4419, -122.1419), 1); } } }
« previous php.pear.core (#5249) next »