from:http://www.pittss.lv/jquery/gomap/solutions.php

jquery.gomap-1.3.3.js:

  1. /**
  2. * jQuery goMap
  3. *
  4. * @url http://www.pittss.lv/jquery/gomap/
  5. * @author Jevgenijs Shtrauss <pittss@gmail.com>
  6. * @version 1.3.3 2014.11.27
  7. * This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
  8. */
  9.  
  10. (function($) {
  11. var geocoder = new google.maps.Geocoder();
  12.  
  13. function MyOverlay(map) { this.setMap(map); };
  14. MyOverlay.prototype = new google.maps.OverlayView();
  15. MyOverlay.prototype.onAdd = function() { };
  16. MyOverlay.prototype.onRemove = function() { };
  17. MyOverlay.prototype.draw = function() { };
  18.  
  19. $.goMap = {};
  20.  
  21. $.fn.goMap = function(options) {
  22. return this.each(function() {
  23. var goMap = $(this).data('goMap');
  24. if(!goMap) {
  25. var goMapBase = $.extend(true, {}, $.goMapBase);
  26. $(this).data('goMap', goMapBase.init(this, options));
  27. $.goMap = goMapBase;
  28. }
  29. else {
  30. $.goMap = goMap;
  31. }
  32. });
  33. };
  34.  
  35. $.goMapBase = {
  36. defaults: {
  37. address: '', // Street, City, Country
  38. latitude: 56.9,
  39. longitude: 24.1,
  40. zoom: 4,
  41. delay: 200,
  42. hideByClick: true,
  43. oneInfoWindow: true,
  44. prefixId: 'gomarker',
  45. polyId: 'gopoly',
  46. groupId: 'gogroup',
  47. navigationControl: true, // Show or hide navigation control
  48. navigationControlOptions: {
  49. position: 'TOP_LEFT', // TOP, TOP_LEFT, TOP_RIGHT, BOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT, LEFT, RIGHT
  50. style: 'DEFAULT' // DEFAULT, SMALL, LARGE
  51. },
  52. mapTypeControl: true, // Show or hide map control
  53. mapTypeControlOptions: {
  54. position: 'TOP_RIGHT', // TOP, TOP_LEFT, TOP_RIGHT, BOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT, LEFT, RIGHT
  55. style: 'DEFAULT'// DEFAULT, DROPDOWN_MENU, HORIZONTAL_BAR
  56. },
  57. scaleControl: false, // Show or hide scale
  58. scrollwheel: true, // Mouse scroll whell
  59. directions: false,
  60. directionsResult: null,
  61. disableDoubleClickZoom: false,
  62. streetViewControl: false,
  63. markers: [],
  64. overlays: [],
  65. polyline: {
  66. color: '#FF0000',
  67. opacity: 1.0,
  68. weight: 2
  69. },
  70. polygon: {
  71. color: '#FF0000',
  72. opacity: 1.0,
  73. weight: 2,
  74. fillColor: '#FF0000',
  75. fillOpacity: 0.2
  76. },
  77. circle: {
  78. color: '#FF0000',
  79. opacity: 1.0,
  80. weight: 2,
  81. fillColor: '#FF0000',
  82. fillOpacity: 0.2
  83. },
  84. rectangle: {
  85. color: '#FF0000',
  86. opacity: 1.0,
  87. weight: 2,
  88. fillColor: '#FF0000',
  89. fillOpacity: 0.2
  90. },
  91. maptype: 'HYBRID', // Map type - HYBRID, ROADMAP, SATELLITE, TERRAIN
  92. html_prepend: '<div class="gomapMarker">',
  93. html_append: '</div>',
  94. addMarker: false
  95. },
  96. map: null,
  97. count: 0,
  98. markers: [],
  99. polylines: [],
  100. polygons: [],
  101. circles: [],
  102. rectangles: [],
  103. tmpMarkers: [],
  104. geoMarkers: [],
  105. lockGeocode: false,
  106. bounds: null,
  107. overlays: null,
  108. overlay: null,
  109. mapId: null,
  110. plId: null,
  111. pgId: null,
  112. cId: null,
  113. rId: null,
  114. opts: null,
  115. centerLatLng: null,
  116.  
  117. init: function(el, options) {
  118. var opts = $.extend(true, {}, $.goMapBase.defaults, options);
  119. this.mapId = $(el);
  120. this.opts = opts;
  121.  
  122. if (opts.address)
  123. this.geocode({address: opts.address, center: true});
  124. // else if (opts.latitude != $.goMapBase.defaults.latitude && opts.longitude != $.goMapBase.defaults.longitude)
  125. // this.centerLatLng = new google.maps.LatLng(opts.latitude, opts.longitude);
  126. else if ($.isArray(opts.markers) && opts.markers.length > 0) {
  127. if (opts.markers[0].address)
  128. this.geocode({address: opts.markers[0].address, center: true});
  129. else
  130. this.centerLatLng = new google.maps.LatLng(opts.markers[0].latitude, opts.markers[0].longitude);
  131. }
  132. else
  133. this.centerLatLng = new google.maps.LatLng(opts.latitude, opts.longitude);
  134.  
  135. var myOptions = {
  136. center: this.centerLatLng,
  137. disableDoubleClickZoom: opts.disableDoubleClickZoom,
  138. mapTypeControl: opts.mapTypeControl,
  139. streetViewControl: opts.streetViewControl,
  140. mapTypeControlOptions: {
  141. position: google.maps.ControlPosition[opts.mapTypeControlOptions.position.toUpperCase()],
  142. style: google.maps.MapTypeControlStyle[opts.mapTypeControlOptions.style.toUpperCase()]
  143. },
  144. mapTypeId: google.maps.MapTypeId[opts.maptype.toUpperCase()],
  145. panControl: opts.navigationControl,
  146. zoomControl: opts.navigationControl,
  147. panControlOptions: {
  148. position: google.maps.ControlPosition[opts.navigationControlOptions.position.toUpperCase()]
  149. },
  150. zoomControlOptions: {
  151. position: google.maps.ControlPosition[opts.navigationControlOptions.position.toUpperCase()],
  152. style: google.maps.ZoomControlStyle[opts.navigationControlOptions.style.toUpperCase()]
  153. },
  154. scaleControl: opts.scaleControl,
  155. scrollwheel: opts.scrollwheel,
  156. zoom: opts.zoom
  157. };
  158.  
  159. this.map = new google.maps.Map(el, myOptions);
  160. this.overlay = new MyOverlay(this.map);
  161.  
  162. this.overlays = {
  163. polyline: { id: 'plId', array: 'polylines', create: 'createPolyline' },
  164. polygon: { id: 'pgId', array: 'polygons', create: 'createPolygon' },
  165. circle: { id: 'cId', array: 'circles', create: 'createCircle' },
  166. rectangle: { id: 'rId', array: 'rectangles', create: 'createRectangle' }
  167. };
  168.  
  169. this.plId = $('<div style="display:none;"/>').appendTo(this.mapId);
  170. this.pgId = $('<div style="display:none;"/>').appendTo(this.mapId);
  171. this.cId = $('<div style="display:none;"/>').appendTo(this.mapId);
  172. this.rId = $('<div style="display:none;"/>').appendTo(this.mapId);
  173.  
  174. for (var j = 0, l = opts.markers.length; j < l; j++)
  175. this.createMarker(opts.markers[j]);
  176.  
  177. for (var j = 0, l = opts.overlays.length; j < l; j++)
  178. this[this.overlays[opts.overlays[j].type].create](opts.overlays[j]);
  179.  
  180. var goMap = this;
  181. if (opts.addMarker == true || opts.addMarker == 'multi') {
  182. google.maps.event.addListener(goMap.map, 'click', function(event) {
  183. var options = {
  184. position: event.latLng,
  185. draggable: true
  186. };
  187.  
  188. var marker = goMap.createMarker(options);
  189.  
  190. google.maps.event.addListener(marker, 'dblclick', function(event) {
  191. marker.setMap(null);
  192. goMap.removeMarker(marker.id);
  193. });
  194.  
  195. });
  196. }
  197. else if (opts.addMarker == 'single') {
  198. google.maps.event.addListener(goMap.map, 'click', function(event) {
  199. if(!goMap.singleMarker) {
  200. var options = {
  201. position: event.latLng,
  202. draggable: true
  203. };
  204.  
  205. var marker = goMap.createMarker(options);
  206. goMap.singleMarker = true;
  207.  
  208. google.maps.event.addListener(marker, 'dblclick', function(event) {
  209. marker.setMap(null);
  210. goMap.removeMarker(marker.id);
  211. goMap.singleMarker = false;
  212. });
  213. }
  214. });
  215. }
  216. delete opts.markers;
  217. delete opts.overlays;
  218.  
  219. return this;
  220. },
  221.  
  222. ready: function(f) {
  223. google.maps.event.addListenerOnce(this.map, 'bounds_changed', function() {
  224. return f();
  225. });
  226. },
  227.  
  228. geocode: function(address, options) {
  229. var goMap = this;
  230. setTimeout(function() {
  231. geocoder.geocode({'address': address.address}, function(results, status) {
  232. if (status == google.maps.GeocoderStatus.OK && address.center)
  233. goMap.map.setCenter(results[0].geometry.location);
  234.  
  235. if (status == google.maps.GeocoderStatus.OK && options && options.markerId)
  236. options.markerId.setPosition(results[0].geometry.location);
  237.  
  238. else if (status == google.maps.GeocoderStatus.OK && options) {
  239. if(goMap.lockGeocode) {
  240. goMap.lockGeocode = false;
  241. options.position = results[0].geometry.location;
  242. options.geocode = true;
  243. goMap.createMarker(options);
  244. }
  245. }
  246. else if(status == google.maps.GeocoderStatus.OVER_QUERY_LIMIT) {
  247. goMap.geocode(address, options);
  248. }
  249. });
  250. }, this.opts.delay);
  251. },
  252.  
  253. geoMarker: function() {
  254. if(this.geoMarkers.length > 0 && !this.lockGeocode) {
  255. this.lockGeocode = true;
  256. var current = this.geoMarkers.splice(0, 1);
  257. this.geocode({address:current[0].address}, current[0]);
  258. }
  259. else if(this.lockGeocode) {
  260. var goMap = this;
  261. setTimeout(function() {
  262. goMap.geoMarker();
  263. }, this.opts.delay);
  264. }
  265. },
  266.  
  267. setMap: function(options) {
  268. delete options.mapTypeId;
  269.  
  270. if (options.address) {
  271. this.geocode({address: options.address, center: true});
  272. delete options.address;
  273. }
  274. else if (options.latitude && options.longitude) {
  275. options.center = new google.maps.LatLng(options.latitude, options.longitude);
  276. delete options.longitude;
  277. delete options.latitude;
  278. }
  279.  
  280. if(options.mapTypeControlOptions && options.mapTypeControlOptions.position)
  281. options.mapTypeControlOptions.position = google.maps.ControlPosition[options.mapTypeControlOptions.position.toUpperCase()];
  282.  
  283. if(options.mapTypeControlOptions && options.mapTypeControlOptions.style)
  284. options.mapTypeControlOptions.style = google.maps.MapTypeControlStyle[options.mapTypeControlOptions.style.toUpperCase()];
  285.  
  286. if(typeof options.navigationControl !== 'undefined') {
  287. options.panControl = options.navigationControl;
  288. options.zoomControl = options.navigationControl;
  289. }
  290.  
  291. if(options.navigationControlOptions && options.navigationControlOptions.position) {
  292. options.panControlOptions = {position: google.maps.ControlPosition[options.navigationControlOptions.position.toUpperCase()]};
  293. options.zoomControlOptions = {position: google.maps.ControlPosition[options.navigationControlOptions.position.toUpperCase()]};
  294. }
  295.  
  296. if(options.navigationControlOptions && options.navigationControlOptions.style) {
  297. if(typeof options.zoomControlOptions === 'undefined')
  298. options.zoomControlOptions = {style: google.maps.ZoomControlStyle[options.navigationControlOptions.style.toUpperCase()]};
  299. else
  300. options.zoomControlOptions.style = google.maps.ZoomControlStyle[options.navigationControlOptions.style.toUpperCase()];
  301. }
  302. this.map.setOptions(options);
  303. },
  304.  
  305. getMap: function() {
  306. return this.map;
  307. },
  308.  
  309. createListener: function(type, event, data) {
  310. var target;
  311.  
  312. if(typeof type != 'object')
  313. type = {type:type};
  314.  
  315. if(type.type == 'map')
  316. target = this.map;
  317. else if(type.type == 'marker' && type.marker)
  318. target = $(this.mapId).data(type.marker);
  319. else if(type.type == 'info' && type.marker)
  320. target = $(this.mapId).data(type.marker + 'info');
  321.  
  322. if(target)
  323. return google.maps.event.addListener(target, event, data);
  324. else if((type.type == 'marker' || type.type == 'info') && this.getMarkerCount() != this.getTmpMarkerCount())
  325. var goMap = this;
  326. setTimeout(function() {
  327. goMap.createListener(type, event, data);
  328. }, this.opts.delay);
  329. },
  330.  
  331. removeListener: function(listener) {
  332. google.maps.event.removeListener(listener);
  333. },
  334.  
  335. setInfoWindow: function(marker, html) {
  336. var goMap = this;
  337. html.content = goMap.opts.html_prepend + html.content + goMap.opts.html_append;
  338. var infowindow = new google.maps.InfoWindow(html);
  339. infowindow.show = false;
  340.  
  341. $(goMap.mapId).data(marker.id + 'info',infowindow);
  342.  
  343. if (html.popup) {
  344. goMap.openWindow(infowindow, marker, html);
  345. infowindow.show = true;
  346. }
  347.  
  348. google.maps.event.addListener(marker, 'click', function() {
  349. if (infowindow.show && goMap.opts.hideByClick) {
  350. infowindow.close();
  351. infowindow.show = false;
  352. }
  353. else {
  354. goMap.openWindow(infowindow, marker, html);
  355. infowindow.show = true;
  356. }
  357. });
  358. },
  359.  
  360. openWindow: function(infowindow, marker, html) {
  361. var goMap = this;
  362. if(this.opts.oneInfoWindow)
  363. this.clearInfo();
  364.  
  365. if (html.ajax) {
  366. infowindow.open(this.map, marker);
  367. $.ajax({
  368. url: html.ajax,
  369. success: function(html) {
  370. infowindow.setContent(goMap.opts.html_prepend + html + goMap.opts.html_append);
  371. }
  372. });
  373. }
  374. else if (html.id) {
  375. infowindow.setContent(goMap.opts.html_prepend + $(html.id).html() + goMap.opts.html_append);
  376. infowindow.open(this.map, marker);
  377. }
  378. else
  379. infowindow.open(this.map, marker);
  380. },
  381.  
  382. setInfo: function(id, text) {
  383. var info = $(this.mapId).data(id + 'info');
  384.  
  385. if(typeof text == 'object')
  386. info.setOptions(goMap.opts.html_prepend + text + goMap.opts.html_append);
  387. else
  388. info.setContent(goMap.opts.html_prepend + text + goMap.opts.html_append);
  389. },
  390.  
  391. getInfo: function(id, hideDiv) {
  392. var info = $(this.mapId).data(id + 'info').getContent();
  393. if(hideDiv)
  394. return $(info).html();
  395. else
  396. return info;
  397. },
  398.  
  399. clearInfo: function() {
  400. for (var i = 0, l = this.markers.length; i < l; i++) {
  401. var info = $(this.mapId).data(this.markers[i] + 'info');
  402. if(info) {
  403. info.close();
  404. info.show = false;
  405. }
  406. }
  407. },
  408.  
  409. fitBounds: function(type, markers) {
  410. var goMap = this;
  411. if(this.getMarkerCount() != this.getTmpMarkerCount())
  412. setTimeout(function() {
  413. goMap.fitBounds(type, markers);
  414. }, this.opts.delay);
  415. else {
  416. this.bounds = new google.maps.LatLngBounds();
  417.  
  418. if(!type || (type && type == 'all')) {
  419. for (var i = 0, l = this.markers.length; i < l; i++) {
  420. this.bounds.extend($(this.mapId).data(this.markers[i]).position);
  421. }
  422. }
  423. else if (type && type == 'visible') {
  424. for (var i = 0, l = this.markers.length; i < l; i++) {
  425. if(this.getVisibleMarker(this.markers[i]))
  426. this.bounds.extend($(this.mapId).data(this.markers[i]).position);
  427. }
  428.  
  429. }
  430. else if (type && type == 'markers' && $.isArray(markers)) {
  431. for (var i = 0, l = markers.length; i < l; i++) {
  432. this.bounds.extend($(this.mapId).data(markers[i]).position);
  433. }
  434. }
  435. this.map.fitBounds(this.bounds);
  436. }
  437. },
  438.  
  439. getBounds: function() {
  440. return this.map.getBounds();
  441. },
  442.  
  443. createPolyline: function(poly) {
  444. poly.type = 'polyline';
  445. return this.createOverlay(poly);
  446. },
  447.  
  448. createPolygon: function(poly) {
  449. poly.type = 'polygon';
  450. return this.createOverlay(poly);
  451. },
  452.  
  453. createCircle: function(poly) {
  454. poly.type = 'circle';
  455. return this.createOverlay(poly);
  456. },
  457.  
  458. createRectangle: function(poly) {
  459. poly.type = 'rectangle';
  460. return this.createOverlay(poly);
  461. },
  462.  
  463. createOverlay: function(poly) {
  464. var overlay = [];
  465. if (!poly.id) {
  466. this.count++;
  467. poly.id = this.opts.polyId + this.count;
  468. }
  469. switch(poly.type) {
  470. case 'polyline':
  471. if (poly.coords.length > 0) {
  472. for (var j = 0, l = poly.coords.length; j < l; j++)
  473. overlay.push(new google.maps.LatLng(poly.coords[j].latitude, poly.coords[j].longitude));
  474.  
  475. overlay = new google.maps.Polyline({
  476. map: this.map,
  477. path: overlay,
  478. strokeColor: poly.color ? poly.color : this.opts.polyline.color,
  479. strokeOpacity: poly.opacity ? poly.opacity : this.opts.polyline.opacity,
  480. strokeWeight: poly.weight ? poly.weight : this.opts.polyline.weight
  481. });
  482. }
  483. else
  484. return false;
  485. break;
  486. case 'polygon':
  487. if (poly.coords.length > 0) {
  488. for (var j = 0, l = poly.coords.length; j < l; j++)
  489. overlay.push(new google.maps.LatLng(poly.coords[j].latitude, poly.coords[j].longitude));
  490.  
  491. overlay = new google.maps.Polygon({
  492. map: this.map,
  493. path: overlay,
  494. strokeColor: poly.color ? poly.color : this.opts.polygon.color,
  495. strokeOpacity: poly.opacity ? poly.opacity : this.opts.polygon.opacity,
  496. strokeWeight: poly.weight ? poly.weight : this.opts.polygon.weight,
  497. fillColor: poly.fillColor ? poly.fillColor : this.opts.polygon.fillColor,
  498. fillOpacity: poly.fillOpacity ? poly.fillOpacity : this.opts.polygon.fillOpacity
  499. });
  500. }
  501. else
  502. return false;
  503. break;
  504. case 'circle':
  505. overlay = new google.maps.Circle({
  506. map: this.map,
  507. center: new google.maps.LatLng(poly.latitude, poly.longitude),
  508. radius: poly.radius,
  509. strokeColor: poly.color ? poly.color : this.opts.circle.color,
  510. strokeOpacity: poly.opacity ? poly.opacity : this.opts.circle.opacity,
  511. strokeWeight: poly.weight ? poly.weight : this.opts.circle.weight,
  512. fillColor: poly.fillColor ? poly.fillColor : this.opts.circle.fillColor,
  513. fillOpacity: poly.fillOpacity ? poly.fillOpacity : this.opts.circle.fillOpacity
  514. });
  515. break;
  516. case 'rectangle':
  517. overlay = new google.maps.Rectangle({
  518. map: this.map,
  519. bounds: new google.maps.LatLngBounds(new google.maps.LatLng(poly.sw.latitude, poly.sw.longitude), new google.maps.LatLng(poly.ne.latitude, poly.ne.longitude)),
  520. strokeColor: poly.color ? poly.color : this.opts.circle.color,
  521. strokeOpacity: poly.opacity ? poly.opacity : this.opts.circle.opacity,
  522. strokeWeight: poly.weight ? poly.weight : this.opts.circle.weight,
  523. fillColor: poly.fillColor ? poly.fillColor : this.opts.circle.fillColor,
  524. fillOpacity: poly.fillOpacity ? poly.fillOpacity : this.opts.circle.fillOpacity
  525. });
  526. break;
  527. default:
  528. return false;
  529. break;
  530. }
  531. this.addOverlay(poly, overlay);
  532. return overlay;
  533. },
  534.  
  535. addOverlay: function(poly, overlay) {
  536. $(this[this.overlays[poly.type].id]).data(poly.id, overlay);
  537. this[this.overlays[poly.type].array].push(poly.id);
  538. },
  539.  
  540. setOverlay: function(type, overlay, options) {
  541. overlay = $(this[this.overlays[type].id]).data(overlay);
  542.  
  543. if (options.coords && options.coords.length > 0) {
  544. var array = [];
  545. for (var j = 0, l = options.coords.length; j < l; j++)
  546. array.push(new google.maps.LatLng(options.coords[j].latitude, options.coords[j].longitude));
  547.  
  548. options.path = array;
  549. delete options.coords;
  550. }
  551. else if (options.ne && options.sw) {
  552. options.bounds = new google.maps.LatLngBounds(new google.maps.LatLng(options.sw.latitude, options.sw.longitude), new google.maps.LatLng(options.ne.latitude, options.ne.longitude));
  553. delete options.ne;
  554. delete options.sw;
  555. }
  556. else if (options.latitude && options.longitude) {
  557.  
  558. options.center = new google.maps.LatLng(options.latitude, options.longitude);
  559. delete options.latitude;
  560. delete options.longitude;
  561. }
  562. overlay.setOptions(options);
  563. },
  564.  
  565. showHideOverlay: function(type, overlay, display) {
  566. if(typeof display === 'undefined') {
  567. if(this.getVisibleOverlay(type, overlay))
  568. display = false;
  569. else
  570. display = true;
  571. }
  572.  
  573. if(display)
  574. $(this[this.overlays[type].id]).data(overlay).setMap(this.map);
  575. else
  576. $(this[this.overlays[type].id]).data(overlay).setMap(null);
  577. },
  578.  
  579. getVisibleOverlay: function(type, overlay) {
  580. if($(this[this.overlays[type].id]).data(overlay).getMap())
  581. return true;
  582. else
  583. return false;
  584. },
  585.  
  586. getOverlaysCount: function(type) {
  587. return this[this.overlays[type].array].length;
  588. },
  589.  
  590. removeOverlay: function(type, overlay) {
  591. var index = $.inArray(overlay, this[this.overlays[type].array]), current;
  592. if (index > -1) {
  593. current = this[this.overlays[type].array].splice(index, 1);
  594. var markerId = current[0];
  595. $(this[this.overlays[type].id]).data(markerId).setMap(null);
  596. $(this[this.overlays[type].id]).removeData(markerId);
  597.  
  598. return true;
  599. }
  600. return false;
  601. },
  602.  
  603. clearOverlays: function(type) {
  604. for (var i = 0, l = this[this.overlays[type].array].length; i < l; i++) {
  605. var markerId = this[this.overlays[type].array][i];
  606. $(this[this.overlays[type].id]).data(markerId).setMap(null);
  607. $(this[this.overlays[type].id]).removeData(markerId);
  608. }
  609. this[this.overlays[type].array] = [];
  610. },
  611.  
  612. showHideMarker: function(marker, display) {
  613. if(typeof display === 'undefined') {
  614. if(this.getVisibleMarker(marker)) {
  615. $(this.mapId).data(marker).setVisible(false);
  616. var info = $(this.mapId).data(marker + 'info');
  617. if(info && info.show) {
  618. info.close();
  619. info.show = false;
  620. }
  621. }
  622. else
  623. $(this.mapId).data(marker).setVisible(true);
  624. }
  625. else
  626. $(this.mapId).data(marker).setVisible(display);
  627. },
  628.  
  629. showHideMarkerByGroup: function(group, display) {
  630. for (var i = 0, l = this.markers.length; i < l; i++) {
  631. var markerId = this.markers[i];
  632. var marker = $(this.mapId).data(markerId);
  633. if(marker.group == group) {
  634. if(typeof display === 'undefined') {
  635. if(this.getVisibleMarker(markerId)) {
  636. marker.setVisible(false);
  637. var info = $(this.mapId).data(markerId + 'info');
  638. if(info && info.show) {
  639. info.close();
  640. info.show = false;
  641. }
  642. }
  643. else
  644. marker.setVisible(true);
  645. }
  646. else
  647. marker.setVisible(display);
  648. }
  649. }
  650. },
  651.  
  652. getVisibleMarker: function(marker) {
  653. return $(this.mapId).data(marker).getVisible();
  654. },
  655.  
  656. getMarkerCount: function() {
  657. return this.markers.length;
  658. },
  659.  
  660. getTmpMarkerCount: function() {
  661. return this.tmpMarkers.length;
  662. },
  663.  
  664. getVisibleMarkerCount: function() {
  665. return this.getMarkers('visiblesInMap').length;
  666. },
  667.  
  668. getMarkerByGroupCount: function(group) {
  669. return this.getMarkers('group', group).length;
  670. },
  671.  
  672. getMarkers: function(type, name) {
  673. var array = [];
  674. switch(type) {
  675. case "json":
  676. for (var i = 0, l = this.markers.length; i < l; i++) {
  677. var temp = "'" + i + "': '" + $(this.mapId).data(this.markers[i]).getPosition().toUrlValue() + "'";
  678. array.push(temp);
  679. }
  680. array = "{'markers':{" + array.join(",") + "}}";
  681. break;
  682. case "data":
  683. for (var i = 0, l = this.markers.length; i < l; i++) {
  684. var temp = "marker[" + i + "]=" + $(this.mapId).data(this.markers[i]).getPosition().toUrlValue();
  685. array.push(temp);
  686. }
  687. array = array.join("&");
  688. break;
  689. case "visiblesInBounds":
  690. for (var i = 0, l = this.markers.length; i < l; i++) {
  691. if (this.isVisible($(this.mapId).data(this.markers[i]).getPosition()))
  692. array.push(this.markers[i]);
  693. }
  694. break;
  695. case "visiblesInMap":
  696. for (var i = 0, l = this.markers.length; i < l; i++) {
  697. if(this.getVisibleMarker(this.markers[i]))
  698. array.push(this.markers[i]);
  699. }
  700. break;
  701. case "group":
  702. if(name)
  703. for (var i = 0, l = this.markers.length; i < l; i++) {
  704. if($(this.mapId).data(this.markers[i]).group == name)
  705. array.push(this.markers[i]);
  706. }
  707. break;
  708. case "markers":
  709. for (var i = 0, l = this.markers.length; i < l; i++) {
  710. var temp = $(this.mapId).data(this.markers[i]);
  711. array.push(temp);
  712. }
  713. break;
  714. default:
  715. for (var i = 0, l = this.markers.length; i < l; i++) {
  716. var temp = $(this.mapId).data(this.markers[i]).getPosition().toUrlValue();
  717. array.push(temp);
  718. }
  719. break;
  720. }
  721. return array;
  722. },
  723.  
  724. getVisibleMarkers: function() {
  725. return this.getMarkers('visiblesInBounds');
  726. },
  727.  
  728. createMarker: function(marker) {
  729. if (!marker.geocode) {
  730. this.count++;
  731. if (!marker.id)
  732. marker.id = this.opts.prefixId + this.count;
  733. this.tmpMarkers.push(marker.id);
  734. }
  735. if (marker.address && !marker.geocode) {
  736. this.geoMarkers.push(marker);
  737. this.geoMarker();
  738. }
  739. else if (marker.latitude && marker.longitude || marker.position) {
  740. var options = { map:this.map };
  741. options.id = marker.id;
  742. options.group = marker.group ? marker.group : this.opts.groupId;
  743. options.zIndex = marker.zIndex ? marker.zIndex : 0;
  744. options.zIndexOrg = marker.zIndexOrg ? marker.zIndexOrg : 0;
  745.  
  746. if (marker.visible == false)
  747. options.visible = marker.visible;
  748.  
  749. if (marker.title)
  750. options.title = marker.title;
  751.  
  752. if (marker.draggable)
  753. options.draggable = marker.draggable;
  754.  
  755. if (marker.icon && marker.icon.image) {
  756. options.icon = marker.icon.image;
  757. if (marker.icon.shadow)
  758. options.shadow = marker.icon.shadow;
  759. }
  760. else if (marker.icon)
  761. options.icon = marker.icon;
  762.  
  763. else if (this.opts.icon && this.opts.icon.image) {
  764. options.icon = this.opts.icon.image;
  765. if (this.opts.icon.shadow)
  766. options.shadow = this.opts.icon.shadow;
  767. }
  768. else if (this.opts.icon)
  769. options.icon = this.opts.icon;
  770.  
  771. options.position = marker.position ? marker.position : new google.maps.LatLng(marker.latitude, marker.longitude);
  772.  
  773. var cmarker = new google.maps.Marker(options);
  774.  
  775. if (marker.html) {
  776. if (!marker.html.content && !marker.html.ajax && !marker.html.id)
  777. marker.html = { content:marker.html };
  778. else if (!marker.html.content)
  779. marker.html.content = null;
  780.  
  781. this.setInfoWindow(cmarker, marker.html);
  782. }
  783. this.addMarker(cmarker);
  784. return cmarker;
  785. }
  786. },
  787.  
  788. addMarker: function(marker) {
  789. $(this.mapId).data(marker.id, marker);
  790. this.markers.push(marker.id);
  791. },
  792.  
  793. setMarker: function(marker, options) {
  794. var tmarker = $(this.mapId).data(marker);
  795.  
  796. delete options.id;
  797. delete options.visible;
  798.  
  799. if(options.icon) {
  800. var toption = options.icon;
  801. delete options.icon;
  802.  
  803. if(toption && toption == 'default') {
  804. if (this.opts.icon && this.opts.icon.image) {
  805. options.icon = this.opts.icon.image;
  806. if (this.opts.icon.shadow)
  807. options.shadow = this.opts.icon.shadow;
  808. }
  809. else if (this.opts.icon)
  810. options.icon = this.opts.icon;
  811. }
  812. else if(toption && toption.image) {
  813. options.icon = toption.image;
  814. if (toption.shadow)
  815. options.shadow = toption.shadow;
  816. }
  817. else if (toption)
  818. options.icon = toption;
  819. }
  820.  
  821. if (options.address) {
  822. this.geocode({address: options.address}, {markerId:tmarker});
  823. delete options.address;
  824. delete options.latitude;
  825. delete options.longitude;
  826. delete options.position;
  827. }
  828. else if (options.latitude && options.longitude || options.position) {
  829. if (!options.position)
  830. options.position = new google.maps.LatLng(options.latitude, options.longitude);
  831. }
  832. tmarker.setOptions(options);
  833. },
  834.  
  835. removeMarker: function(marker) {
  836. var index = $.inArray(marker, this.markers), current;
  837. if (index > -1) {
  838. this.tmpMarkers.splice(index,1);
  839. current = this.markers.splice(index,1);
  840. var markerId = current[0];
  841. var marker = $(this.mapId).data(markerId);
  842. var info = $(this.mapId).data(markerId + 'info');
  843.  
  844. marker.setVisible(false);
  845. marker.setMap(null);
  846. $(this.mapId).removeData(markerId);
  847.  
  848. if(info) {
  849. info.close();
  850. info.show = false;
  851. $(this.mapId).removeData(markerId + 'info');
  852. }
  853. return true;
  854. }
  855. return false;
  856. },
  857.  
  858. clearMarkers: function() {
  859. for (var i = 0, l = this.markers.length; i < l; i++) {
  860. var markerId = this.markers[i];
  861. var marker = $(this.mapId).data(markerId);
  862. var info = $(this.mapId).data(markerId + 'info');
  863.  
  864. marker.setVisible(false);
  865. marker.setMap(null);
  866. $(this.mapId).removeData(markerId);
  867.  
  868. if(info) {
  869. info.close();
  870. info.show = false;
  871. $(this.mapId).removeData(markerId + 'info');
  872. }
  873. }
  874. this.singleMarker = false;
  875. this.lockGeocode = false;
  876. this.markers = [];
  877. this.tmpMarkers = [];
  878. this.geoMarkers = [];
  879. },
  880.  
  881. isVisible: function(latlng) {
  882. return this.map.getBounds().contains(latlng);
  883. }
  884. }
  885. })(jQuery);

  jquery.dump.js:

/**
* jquery.dump.js
* @author Torkild Dyvik Olsen
* @version 1.0
*
* A simple debug function to gather information about an object.
* Returns a nested tree with information.
*
*/
(function($) { $.fn.dump = function() {
return $.dump(this);
} $.dump = function(object) {
var recursion = function(obj, level) {
if(!level) level = 0;
var dump = '', p = '';
for(i = 0; i < level; i++) p += "\t"; t = type(obj);
switch(t) {
case "string":
return '"' + obj + '"';
break;
case "number":
return obj.toString();
break;
case "boolean":
return obj ? 'true' : 'false';
case "date":
return "Date: " + obj.toLocaleString();
case "array":
dump += 'Array ( \n';
$.each(obj, function(k,v) {
dump += p +'\t' + k + ' => ' + recursion(v, level + 1) + '\n';
});
dump += p + ')';
break;
case "object":
dump += 'Object { \n';
$.each(obj, function(k,v) {
dump += p + '\t' + k + ': ' + recursion(v, level + 1) + '\n';
});
dump += p + '}';
break;
case "jquery":
dump += 'jQuery Object { \n';
$.each(obj, function(k,v) {
dump += p + '\t' + k + ' = ' + recursion(v, level + 1) + '\n';
});
dump += p + '}';
break;
case "regexp":
return "RegExp: " + obj.toString();
case "error":
return obj.toString();
case "document":
case "domelement":
dump += 'DOMElement [ \n'
+ p + '\tnodeName: ' + obj.nodeName + '\n'
+ p + '\tnodeValue: ' + obj.nodeValue + '\n'
+ p + '\tinnerHTML: [ \n';
$.each(obj.childNodes, function(k,v) {
if(k < 1) var r = 0;
if(type(v) == "string") {
if(v.textContent.match(/[^\s]/)) {
dump += p + '\t\t' + (k - (r||0)) + ' = String: ' + trim(v.textContent) + '\n';
} else {
r--;
}
} else {
dump += p + '\t\t' + (k - (r||0)) + ' = ' + recursion(v, level + 2) + '\n';
}
});
dump += p + '\t]\n'
+ p + ']';
break;
case "function":
var match = obj.toString().match(/^(.*)\(([^\)]*)\)/im);
match[1] = trim(match[1].replace(new RegExp("[\\s]+", "g"), " "));
match[2] = trim(match[2].replace(new RegExp("[\\s]+", "g"), " "));
return match[1] + "(" + match[2] + ")";
case "window":
default:
dump += 'N/A: ' + t;
break;
} return dump;
} var type = function(obj) {
var type = typeof(obj); if(type != "object") {
return type;
} switch(obj) {
case null:
return 'null';
case window:
return 'window';
case document:
return 'document';
case window.event:
return 'event';
default:
break;
} if(obj.jquery) {
return 'jquery';
} switch(obj.constructor) {
case Array:
return 'array';
case Boolean:
return 'boolean';
case Date:
return 'date';
case Object:
return 'object';
case RegExp:
return 'regexp';
case ReferenceError:
case Error:
return 'error';
case null:
default:
break;
} switch(obj.nodeType) {
case 1:
return 'domelement';
case 3:
return 'string';
case null:
default:
break;
} return 'Unknown';
} return recursion(object);
} function trim(str) {
return ltrim(rtrim(str));
} function ltrim(str) {
return str.replace(new RegExp("^[\\s]+", "g"), "");
} function rtrim(str) {
return str.replace(new RegExp("[\\s]+$", "g"), "");
} })(jQuery);

  jquery.chili-2.2.js

/*
===============================================================================
Chili is the jQuery code highlighter plugin
...............................................................................
LICENSE: http://www.opensource.org/licenses/mit-license.php
WEBSITE: http://noteslog.com/chili/ Copyright 2008 / Andrea Ercolino
===============================================================================
*/ ( function($) { ChiliBook = { //implied global version: "2.2" // 2008-07-06 // options -------------------------------------------------------------------- , automatic: true
, automaticSelector: "code" , lineNumbers: !true , codeLanguage: function( el ) {
var recipeName = $( el ).attr( "class" );
return recipeName ? recipeName : '';
} , recipeLoading: true
, recipeFolder: "" // used like: recipeFolder + recipeName + '.js' // IE and FF convert   to " ", Safari and Opera do not
, replaceSpace: " "
, replaceTab: "    "
, replaceNewLine: " <br/>" , selectionStyle: [ "position:absolute; z-index:3000; overflow:scroll;"
, "width:16em;"
, "height:9em;"
, "border:1px solid gray;"
, "padding:15px;"
, "background-color:yellow;"
].join( ' ' ) // ------------------------------------------------------------- end of options , defaultReplacement: '<span class="$0">$$</span>' // TODO: make this an option again
, recipes: {} //repository
, queue: {} //registry , unique: function() {
return (new Date()).valueOf();
}
}; $.fn.chili = function( options ) {
var book = $.extend( {}, ChiliBook, options || {} ); function cook( ingredients, recipe, blockName ) { function prepareBlock( recipe, blockName ) {
var steps = [];
for( var stepName in recipe[ blockName ] ) {
steps.push( prepareStep( recipe, blockName, stepName ) );
}
return steps;
} // prepareBlock function prepareStep( recipe, blockName, stepName ) {
var step = recipe[ blockName ][ stepName ];
var exp = ( typeof step._match == "string" ) ? step._match : step._match.source;
return {
recipe: recipe
, blockName: blockName
, stepName: stepName
, exp: "(" + exp + ")"
, length: 1 // add 1 to account for the newly added parentheses
+ (exp // count number of submatches in here
.replace( /\\./g, "%" ) // disable any escaped character
.replace( /\[.*?\]/g, "%" ) // disable any character class
.match( /\((?!\?)/g ) // match any open parenthesis, not followed by a ?
|| [] // make sure it is an empty array if there are no matches
).length // get the number of matches
, replacement: step._replace ? step._replace : book.defaultReplacement
};
} // prepareStep function knowHow( steps ) {
var prevLength = 1;
var exps = [];
for (var i = 0; i < steps.length; i++) {
var exp = steps[ i ].exp;
// adjust backreferences
exp = exp.replace( /\\\\|\\(\d+)/g, function( m, aNum ) {
return !aNum ? m : "\\" + ( prevLength + 1 + parseInt( aNum, 10 ) );
} );
exps.push( exp );
prevLength += steps[ i ].length;
}
var prolog = '((?:\\s|\\S)*?)';
var epilog = '((?:\\s|\\S)+)';
var source = '(?:' + exps.join( "|" ) + ')';
source = prolog + source + '|' + epilog;
return new RegExp( source, recipe._case ? "g" : "gi" );
} // knowHow function escapeHTML( str ) {
return str.replace( /&/g, "&" ).replace( /</g, "<" );
} // escapeHTML function replaceSpaces( str ) {
return str.replace( / +/g, function( spaces ) {
return spaces.replace( / /g, replaceSpace );
} );
} // replaceSpaces function filter( str ) {
str = escapeHTML( str );
if( replaceSpace ) {
str = replaceSpaces( str );
}
return str;
} // filter function applyRecipe( subject, recipe ) {
return cook( subject, recipe );
} // applyRecipe function applyBlock( subject, recipe, blockName ) {
return cook( subject, recipe, blockName );
} // applyBlock function applyStep( subject, recipe, blockName, stepName ) {
var replaceSpace = book.replaceSpace; var step = prepareStep( recipe, blockName, stepName );
var steps = [step]; var perfect = subject.replace( knowHow( steps ), function() {
return chef.apply( { steps: steps }, arguments );
} );
return perfect;
} // applyStep function applyModule( subject, module, context ) {
if( ! module ) {
return filter( subject );
} var sub = module.split( '/' );
var recipeName = '';
var blockName = '';
var stepName = '';
switch( sub.length ) {
case 1:
recipeName = sub[0];
break;
case 2:
recipeName = sub[0]; blockName = sub[1];
break;
case 3:
recipeName = sub[0]; blockName = sub[1]; stepName = sub[2];
break;
default:
return filter( subject );
} function getRecipe( recipeName ) {
var path = getPath( recipeName );
var recipe = book.recipes[ path ];
if( ! recipe ) {
throw {msg:"recipe not available"};
}
return recipe;
} try {
var recipe;
if ( '' == stepName ) {
if ( '' == blockName ) {
if ( '' == recipeName ) {
//nothing to do
}
else { // ( '' != recipeName )
recipe = getRecipe( recipeName );
return applyRecipe( subject, recipe );
}
}
else { // ( '' != blockName )
if( '' == recipeName ) {
recipe = context.recipe;
}
else {
recipe = getRecipe( recipeName );
}
if( ! (blockName in recipe) ) {
return filter( subject );
}
return applyBlock( subject, recipe, blockName );
}
}
else { // ( '' != stepName )
if( '' == recipeName ) {
recipe = context.recipe;
}
else {
recipe = getRecipe( recipeName );
}
if( '' == blockName ) {
blockName = context.blockName;
}
if( ! (blockName in recipe) ) {
return filter( subject );
}
if( ! (stepName in recipe[blockName]) ) {
return filter( subject );
}
return applyStep( subject, recipe, blockName, stepName );
}
}
catch( e ) {
if (e.msg && e.msg == "recipe not available") {
var cue = 'chili_' + book.unique();
if( book.recipeLoading ) {
var path = getPath( recipeName );
if( ! book.queue[ path ] ) {
/* this is a new recipe to download */
try {
book.queue[ path ] = [ {cue: cue, subject: subject, module: module, context: context} ];
$.getJSON( path, function( recipeLoaded ) {
book.recipes[ path ] = recipeLoaded;
var q = book.queue[ path ];
for( var i = 0, iTop = q.length; i < iTop; i++ ) {
var replacement = applyModule( q[ i ].subject, q[ i ].module, q[ i ].context );
if( book.replaceTab ) {
replacement = replacement.replace( /\t/g, book.replaceTab );
}
if( book.replaceNewLine ) {
replacement = replacement.replace( /\n/g, book.replaceNewLine );
}
$( '#' + q[ i ].cue ).replaceWith( replacement );
}
} );
}
catch( recipeNotAvailable ) {
alert( "the recipe for '" + recipeName + "' was not found in '" + path + "'" );
}
}
else {
/* not a new recipe, so just enqueue this element */
book.queue[ path ].push( {cue: cue, subject: subject, module: module, context: context} );
}
return '<span id="' + cue + '">' + filter( subject ) + '</span>';
}
return filter( subject );
}
else {
return filter( subject );
}
}
} // applyModule function addPrefix( prefix, replacement ) {
var aux = replacement.replace( /(<span\s+class\s*=\s*(["']))((?:(?!__)\w)+\2\s*>)/ig, "$1" + prefix + "__$3" );
return aux;
} // addPrefix function chef() {
if (! arguments[ 0 ]) {
return '';
}
var steps = this.steps;
var i = 0; // iterate steps
var j = 2; // iterate chef's arguments
var prolog = arguments[ 1 ];
var epilog = arguments[ arguments.length - 3 ];
if (! epilog) {
var step;
while( step = steps[ i++ ] ) {
var aux = arguments; // this unmasks chef's arguments inside the next function
if( aux[ j ] ) {
var replacement = '';
if( $.isFunction( step.replacement ) ) {
var matches = []; //Array.slice.call( aux, j, step.length );
for (var k = 0, kTop = step.length; k < kTop; k++) {
matches.push( aux[ j + k ] );
}
matches.push( aux[ aux.length - 2 ] );
matches.push( aux[ aux.length - 1 ] );
replacement = step.replacement
.apply( {
x: function() {
var subject = arguments[0];
var module = arguments[1];
var context = {
recipe: step.recipe
, blockName: step.blockName
};
return applyModule( subject, module, context );
}
}, matches );
}
else { //we expect step.replacement to be a string
replacement = step.replacement
.replace( /(\\\$)|(?:\$\$)|(?:\$(\d+))/g, function( m, escaped, K ) {
if( escaped ) { /* \$ */
return "$";
}
else if( !K ) { /* $$ */
return filter( aux[ j ] );
}
else if( K == "0" ) { /* $0 */
return step.stepName;
}
else { /* $K */
return filter( aux[ j + parseInt( K, 10 ) ] );
}
} );
}
replacement = addPrefix( step.recipe._name, replacement );
return filter( prolog ) + replacement;
}
else {
j+= step.length;
}
}
}
else {
return filter( epilog );
}
} // chef if( ! blockName ) {
blockName = '_main';
checkSpices( recipe );
}
if( ! (blockName in recipe) ) {
return filter( ingredients );
}
var replaceSpace = book.replaceSpace;
var steps = prepareBlock( recipe, blockName );
var kh = knowHow( steps );
var perfect = ingredients.replace( kh, function() {
return chef.apply( { steps: steps }, arguments );
} );
return perfect; } // cook function loadStylesheetInline( sourceCode ) {
if( document.createElement ) {
var e = document.createElement( "style" );
e.type = "text/css";
if( e.styleSheet ) { // IE
e.styleSheet.cssText = sourceCode;
}
else {
var t = document.createTextNode( sourceCode );
e.appendChild( t );
}
document.getElementsByTagName( "head" )[0].appendChild( e );
}
} // loadStylesheetInline function checkSpices( recipe ) {
var name = recipe._name;
if( ! book.queue[ name ] ) { var content = ['/* Chili -- ' + name + ' */'];
for (var blockName in recipe) {
if( blockName.search( /^_(?!main\b)/ ) < 0 ) {
for (var stepName in recipe[ blockName ]) {
var step = recipe[ blockName ][ stepName ];
if( '_style' in step ) {
if( step[ '_style' ].constructor == String ) {
content.push( '.' + name + '__' + stepName + ' { ' + step[ '_style' ] + ' }' );
}
else {
for (var className in step[ '_style' ]) {
content.push( '.' + name + '__' + className + ' { ' + step[ '_style' ][ className ] + ' }' );
}
}
}
}
}
}
content = content.join('\n'); loadStylesheetInline( content ); book.queue[ name ] = true;
}
} // checkSpices function askDish( el ) {
var recipeName = book.codeLanguage( el );
if( '' != recipeName ) {
var path = getPath( recipeName );
if( book.recipeLoading ) {
/* dynamic setups come here */
if( ! book.queue[ path ] ) {
/* this is a new recipe to download */
try {
book.queue[ path ] = [ el ];
$.getJSON( path, function( recipeLoaded ) {
book.recipes[ path ] = recipeLoaded;
var q = book.queue[ path ];
for( var i = 0, iTop = q.length; i < iTop; i++ ) {
makeDish( q[ i ], path );
}
} );
}
catch( recipeNotAvailable ) {
alert( "the recipe for '" + recipeName + "' was not found in '" + path + "'" );
}
}
else {
/* not a new recipe, so just enqueue this element */
book.queue[ path ].push( el );
}
/* a recipe could have been already downloaded */
makeDish( el, path );
}
else {
/* static setups come here */
makeDish( el, path );
}
}
} // askDish function makeDish( el, recipePath ) {
var recipe = book.recipes[ recipePath ];
if( ! recipe ) {
return;
}
var $el = $( el );
var ingredients = $el.text();
if( ! ingredients ) {
return;
} //fix for msie: \r (13) is used instead of \n (10)
//fix for opera: \r\n is used instead of \n
ingredients = ingredients.replace(/\r\n?/g, "\n"); //reverse fix for safari: msie, mozilla and opera render the initial \n
if( $el.parent().is('pre') ) {
/*
if( ! $.browser.safari ) {
ingredients = ingredients.replace(/^\n/g, "");
}
*/
} var dish = cook( ingredients, recipe ); // all happens here if( book.replaceTab ) {
dish = dish.replace( /\t/g, book.replaceTab );
}
if( book.replaceNewLine ) {
dish = dish.replace( /\n/g, book.replaceNewLine );
} el.innerHTML = dish; //much faster than $el.html( dish );
//tried also the function replaceHtml from http://blog.stevenlevithan.com/archives/faster-than-innerhtml
//but it was not faster nor without sideffects (it was not possible to count spans into el) //opera and safari select PRE text correctly
/*
if( $.browser.msie || $.browser.mozilla ) {
enableSelectionHelper( el );
}
*/
var $that = $el.parent();
var classes = $that.attr( 'class' );
var ln = /ln-(\d+)-([\w][\w\-]*)|ln-(\d+)|ln-/.exec( classes );
if( ln ) {
addLineNumbers( el );
var start = 0;
if( ln[1] ) {
start = parseInt( ln[1], 10 );
var $pieces = $( '.ln-' + ln[1] + '-' + ln[2] );
var pos = $pieces.index( $that[0] );
$pieces.slice( 0, pos ).each( function() {
start += $( this ).find( 'li' ).length;
} );
}
else if( ln[3] ) {
start = parseInt( ln[3], 10 );
}
else {
start = 1;
}
$el.find( 'ol' )[0].start = start;
$('body').width( $('body').width() - 1 ).width( $('body').width() + 1 );
}
else if( book.lineNumbers ) {
addLineNumbers( el );
} } // makeDish function enableSelectionHelper( el ) {
return false; //disable the selection helper
var element = null;
$( el )
.parents()
.filter( "pre" )
.bind( "mousedown", function() {
element = this;
if( $.browser.msie ) {
document.selection.empty();
}
else {
window.getSelection().removeAllRanges();
}
} )
.bind( "mouseup", function( event ) {
if( element && (element == this) ) {
element = null;
var selected = '';
if( $.browser.msie ) {
selected = document.selection.createRange().htmlText;
if( '' == selected ) {
return;
}
selected = preserveNewLines( selected );
var container_tag = '<textarea style="STYLE">';
}
else {
selected = window.getSelection().toString(); //opera doesn't select new lines
if( '' == selected ) {
return;
}
selected = selected
.replace( /\r/g, '' )
.replace( /^# ?/g, '' )
.replace( /\n# ?/g, '\n' )
;
var container_tag = '<pre style="STYLE">';
}
var $container = $( container_tag.replace( /\bSTYLE\b/, ChiliBook.selectionStyle ) )
.appendTo( 'body' )
.text( selected )
.attr( 'id', 'chili_selection' )
.click( function() { $(this).remove(); } )
;
var top = event.pageY - Math.round( $container.height() / 2 ) + "px";
var left = event.pageX - Math.round( $container.width() / 2 ) + "px";
$container.css( { top: top, left: left } );
if( $.browser.msie ) {
// window.clipboardData.setData( 'Text', selected ); //I couldn't find anything similar for Mozilla
$container[0].focus();
$container[0].select();
}
else {
var s = window.getSelection();
s.removeAllRanges();
var r = document.createRange();
r.selectNodeContents( $container[0] );
s.addRange( r );
}
}
} )
;
} // enableSelectionHelper function getPath( recipeName ) {
return book.recipeFolder + recipeName + ".js";
} // getPath function getSelectedText() {
var text = '';
if( $.browser.msie ) {
text = document.selection.createRange().htmlText;
}
else {
text = window.getSelection().toString();
}
return text;
} // getSelectedText function preserveNewLines( html ) {
do {
var newline_flag = ChiliBook.unique();
}
while( html.indexOf( newline_flag ) > -1 );
var text = '';
if (/<br/i.test(html) || /<li/i.test(html)) {
if (/<br/i.test(html)) {
html = html.replace( /\<br[^>]*?\>/ig, newline_flag );
}
else if (/<li/i.test(html)) {
html = html.replace( /<ol[^>]*?>|<\/ol>|<li[^>]*?>/ig, '' ).replace( /<\/li>/ig, newline_flag );
}
var el = $( '<pre>' ).appendTo( 'body' ).hide()[0];
el.innerHTML = html;
text = $( el ).text().replace( new RegExp( newline_flag, "g" ), '\r\n' );
$( el ).remove();
}
return text;
} // preserveNewLines function addLineNumbers( el ) { function makeListItem1( not_last_line, not_last, last, open ) {
var close = open ? '</span>' : '';
var aux = '';
if( not_last_line ) {
aux = '<li>' + open + not_last + close + '</li>';
}
else if( last ) {
aux = '<li>' + open + last + close + '</li>';
}
return aux;
} // makeListItem1 function makeListItem2( not_last_line, not_last, last, prev_li ) {
var aux = '';
if( prev_li ) {
aux = prev_li;
}
else {
aux = makeListItem1( not_last_line, not_last, last, '' )
}
return aux;
} // makeListItem2 var html = $( el ).html();
var br = /<br>/.test(html) ? '<br>' : '<BR>';
var empty_line = '<li>' + book.replaceSpace + '</li>';
var list_items = html
//extract newlines at the beginning of a span
.replace( /(<span [^>]+>)((?:(?: |\xA0)<br>)+)(.*?)(<\/span>)/ig, '$2$1$3$4' ) // I don't know why <span .*?> does not work here
//transform newlines inside of a span
.replace( /(.*?)(<span .*?>)(.*?)(?:<\/span>(?: |\xA0)<br>|<\/span>)/ig, // but here it does
function( all, before, open, content ) {
if (/<br>/i.test(content)) {
var pieces = before.split( br );
var lastPiece = pieces.pop();
before = pieces.join( br );
var aux = (before ? before + br : '') //+ replace1( lastPiece + content, open );
+ (lastPiece + content).replace( /((.*?)(?: |\xA0)<br>)|(.*)/ig,
function( tmp, not_last_line, not_last, last ) {
var aux2 = makeListItem1( not_last_line, not_last, last, open );
return aux2;
}
);
return aux;
}
else {
return all;
}
}
)
//transform newlines outside of a span
.replace( /(<li>.*?<\/li>)|((.*?)(?: |\xA0)<br>)|(.+)/ig,
function( tmp, prev_li, not_last_line, not_last, last ) {
var aux2 = makeListItem2( not_last_line, not_last, last, prev_li );
return aux2;
}
)
//fix empty lines for Opera
.replace( /<li><\/li>/ig, empty_line )
; el.innerHTML = '<ol>' + list_items + '</ol>';
} // addLineNumbers function revealChars( tmp ) {
return $
.map( tmp.split(''),
function(n, i) {
return ' ' + n + ' ' + n.charCodeAt( 0 ) + ' ';
} )
.join(' ');
} // revealChars //-----------------------------------------------------------------------------
// the coloring starts here
this
.each( function() {
var $this = $( this );
$this.trigger( 'chili.before_coloring' );
askDish( this );
$this.trigger( 'chili.after_coloring' );
} ); return this;
//-----------------------------------------------------------------------------
}; //main
$( function() { if( ChiliBook.automatic ) {
$( ChiliBook.automaticSelector ).chili();
} } ); } ) ( jQuery );

  recipes.js

/*
===============================================================================
Chili is the jQuery code highlighter plugin
...............................................................................
LICENSE: http://www.opensource.org/licenses/mit-license.php
WEBSITE: http://noteslog.com/chili/ Copyright 2008 / Andrea Ercolino
===============================================================================
*/ ChiliBook.recipeLoading = false; ChiliBook.recipes[ "php.js" ] =
/* ----------------------------------------------------------------------------
* this recipe uses a little trick for highlighting php code
* 1: replace each php snippet with a placeholder
* 2: highlight html without php and php snippets apart
* 3: replace each placeholder with its highlighted php snippet
*
* the trick is not perfect only if the html without php is broken
* however, in such a case many highlighters get fooled but Chili does not
*
* ---
* this recipe has been adapted for working with Safari
* in fact, Safari cannot match more than 101236 characters with a lazy star
* --------------------------------------------------------------------------*/
{
_name: "php"
, _case: true
, _main: {
all: {
_match: /[\w\W]*/
, _replace: function( all ) {
var placeholder = String.fromCharCode(0);
var blocks = [];
var that = this;
var no_php_1 = all.replace( /<\?[^?]*\?+(?:[^>][^?]*\?+)*>/g, function( block ) {
blocks.push( that.x( block, '/block/php_1' ) );
return placeholder;
} );
var no_php_2 = no_php_1.replace( /^[^?]*\?+(?:[^>][^?]*\?+)*>|<\?[\w\W]*$/g, function( block ) {
blocks.push( that.x( block, '/block/php_2' ) );
return placeholder;
} );
if( blocks.length ) {
var html = this.x( no_php_2, 'html' );
var count = 0;
return html.replace( new RegExp( placeholder, "g" ), function() {
return blocks[ count++ ];
} );
}
else {
return this.x( all, '/php' );
}
}
}
}
, block: {
php_1: { // --- <? +++ ?> ---
_match: /(<\?(?:php\b)?)([^?]*\?+(?:[^>][^?]*\?+)*>)/
, _replace: function( all, open, content ) {
return "<span class='start'>" + this.x( open ) + "</span>"
+ this.x( content.replace( /\?>$/, '' ), '/php' )
+ "<span class='end'>" + this.x( '?>' ) + "</span>";
}
, _style: {
start: "color: red; font-weight: bold"
, end: "color: red;"
}
}
, php_2: { // +++ ?> --- <? +++
_match: /([^?]*\?+(?:[^>][^?]*\?+)*>)|(<\?(?:php\b)?)([\w\W]*)/
, _replace: function( all, content, open2, content2 ) {
if( open2 ) {
return "<span class='start'>" + this.x( open2 ) + "</span>"
+ this.x( content2, '/php' );
}
else {
return this.x( content.replace( /\?>$/, '' ), '/php' )
+ "<span class='end'>" + this.x( '?>' ) + "</span>";
}
}
, _style: {
start: "color: red; font-weight: bold"
, end: "color: red;"
}
}
}
, php: {
mlcom: {
_match: /\/\*[^*]*\*+([^\/][^*]*\*+)*\//
, _style: "color: gray;"
}
, com: {
_match: /(?:\/\/.*)|(?:[^\\]\#.*)/
, _style: "color: green;"
}
, string1: {
_match: /\'[^\'\\]*(?:\\.[^\'\\]*)*\'/
, _style: "color: purple;"
}
, string2: {
_match: /\"[^\"\\]*(?:\\.[^\"\\]*)*\"/
, _style: "color: fuchsia;"
}
, value: {
_match: /\b(?:[Nn][Uu][Ll][Ll]|[Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee])\b/
, _style: "color: gray; font-weight: bold;"
}
, number: {
_match: /\b[+-]?(\d*\.?\d+|\d+\.?\d*)([eE][+-]?\d+)?\b/
, _style: "color: red;"
}
, const1: {
_match: /\b(?:DEFAULT_INCLUDE_PATH|E_(?:ALL|CO(?:MPILE_(?:ERROR|WARNING)|RE_(?:ERROR|WARNING))|ERROR|NOTICE|PARSE|STRICT|USER_(?:ERROR|NOTICE|WARNING)|WARNING)|P(?:EAR_(?:EXTENSION_DIR|INSTALL_DIR)|HP_(?:BINDIR|CONFIG_FILE_(?:PATH|SCAN_DIR)|DATADIR|E(?:OL|XTENSION_DIR)|INT_(?:MAX|SIZE)|L(?:IBDIR|OCALSTATEDIR)|O(?:S|UTPUT_HANDLER_(?:CONT|END|START))|PREFIX|S(?:API|HLIB_SUFFIX|YSCONFDIR)|VERSION))|__COMPILER_HALT_OFFSET__)\b/
, _style: "color: red;"
}
, const2: {
_match: /\b(?:A(?:B(?:DAY_(?:1|2|3|4|5|6|7)|MON_(?:1(?:0|1|2|)|2|3|4|5|6|7|8|9))|LT_DIGITS|M_STR|SSERT_(?:ACTIVE|BAIL|CALLBACK|QUIET_EVAL|WARNING))|C(?:ASE_(?:LOWER|UPPER)|HAR_MAX|O(?:DESET|NNECTION_(?:ABORTED|NORMAL|TIMEOUT)|UNT_(?:NORMAL|RECURSIVE))|R(?:EDITS_(?:ALL|DOCS|FULLPAGE|G(?:ENERAL|ROUP)|MODULES|QA|SAPI)|NCYSTR|YPT_(?:BLOWFISH|EXT_DES|MD5|S(?:ALT_LENGTH|TD_DES)))|URRENCY_SYMBOL)|D(?:AY_(?:1|2|3|4|5|6|7)|ECIMAL_POINT|IRECTORY_SEPARATOR|_(?:FMT|T_FMT))|E(?:NT_(?:COMPAT|NOQUOTES|QUOTES)|RA(?:_(?:D_(?:FMT|T_FMT)|T_FMT|YEAR)|)|XTR_(?:IF_EXISTS|OVERWRITE|PREFIX_(?:ALL|I(?:F_EXISTS|NVALID)|SAME)|SKIP))|FRAC_DIGITS|GROUPING|HTML_(?:ENTITIES|SPECIALCHARS)|IN(?:FO_(?:ALL|C(?:ONFIGURATION|REDITS)|ENVIRONMENT|GENERAL|LICENSE|MODULES|VARIABLES)|I_(?:ALL|PERDIR|SYSTEM|USER)|T_(?:CURR_SYMBOL|FRAC_DIGITS))|L(?:C_(?:ALL|C(?:OLLATE|TYPE)|M(?:ESSAGES|ONETARY)|NUMERIC|TIME)|O(?:CK_(?:EX|NB|SH|UN)|G_(?:A(?:LERT|UTH(?:PRIV|))|C(?:ONS|R(?:IT|ON))|D(?:AEMON|EBUG)|E(?:MERG|RR)|INFO|KERN|L(?:OCAL(?:0|1|2|3|4|5|6|7)|PR)|MAIL|N(?:DELAY|EWS|O(?:TICE|WAIT))|ODELAY|P(?:ERROR|ID)|SYSLOG|U(?:SER|UCP)|WARNING)))|M(?:ON_(?:1(?:0|1|2|)|2|3|4|5|6|7|8|9|DECIMAL_POINT|GROUPING|THOUSANDS_SEP)|_(?:1_PI|2_(?:PI|SQRTPI)|E|L(?:N(?:10|2)|OG(?:10E|2E))|PI(?:_(?:2|4)|)|SQRT(?:1_2|2)))|N(?:EGATIVE_SIGN|O(?:EXPR|STR)|_(?:CS_PRECEDES|S(?:EP_BY_SPACE|IGN_POSN)))|P(?:ATH(?:INFO_(?:BASENAME|DIRNAME|EXTENSION)|_SEPARATOR)|M_STR|OSITIVE_SIGN|_(?:CS_PRECEDES|S(?:EP_BY_SPACE|IGN_POSN)))|RADIXCHAR|S(?:EEK_(?:CUR|END|SET)|ORT_(?:ASC|DESC|NUMERIC|REGULAR|STRING)|TR_PAD_(?:BOTH|LEFT|RIGHT))|T(?:HOUS(?:ANDS_SEP|EP)|_FMT(?:_AMPM|))|YES(?:EXPR|STR))\b/
, _style: "color: red;"
}
, global: {
_match: /(?:\$GLOBALS|\$_COOKIE|\$_ENV|\$_FILES|\$_GET|\$_POST|\$_REQUEST|\$_SERVER|\$_SESSION|\$php_errormsg)\b/
, _style: "color: red;"
}
, keyword: {
_match: /\b(?:__CLASS__|__FILE__|__FUNCTION__|__LINE__|__METHOD__|abstract|and|array|as|break|case|catch|cfunction|class|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|eval|exception|exit|extends|extends|final|for|foreach|function|global|if|implements|include|include_once|interface|isset|list|new|old_function|or|php_user_filter|print|private|protected|public|require|require_once|return|static|switch|this|throw|try|unset|use|var|while|xor)\b/
, _style: "color: navy; font-weight: bold;"
}
, variable: {
_match: /\$(\w+)/
, _replace: '<span class="keyword">$</span><span class="variable">$1</span>'
, _style: "color: #4040c2;"
}
, heredoc: {
_match: /(\<\<\<\s*)(\w+)((?:(?!\2).*\n)+)(\2)\b/
, _replace: '<span class="keyword">$1</span><span class="string1">$2</span><span class="string2">$3</span><span class="string1">$4</span>'
}
}
} ChiliBook.recipes[ "html.js" ] =
{
_name: 'html'
, _case: false
, _main: {
doctype: {
_match: /<!DOCTYPE\b[\w\W]*?>/
, _style: "color: #CC6600;"
}
, ie_style: {
_match: /(<!--\[[^\]]*\]>)([\w\W]*?)(<!\[[^\]]*\]-->)/
, _replace: function( all, open, content, close ) {
return "<span class='ie_style'>" + this.x( open ) + "</span>"
+ this.x( content, '//style' )
+ "<span class='ie_style'>" + this.x( close ) + "</span>";
}
, _style: "color: DarkSlateGray; font-weight: bold;"
}
, comment: {
_match: /<!--[\w\W]*?-->/
, _style: "color: #4040c2;"
}
, script: {
_match: /(<script\s+[^>]*>)([\w\W]*?)(<\/script\s*>)/
, _replace: function( all, open, content, close ) {
return this.x( open, '//tag_start' )
+ this.x( content, 'js' )
+ this.x( close, '//tag_end' );
}
}
, style: {
_match: /(<style\s+[^>]*>)([\w\W]*?)(<\/style\s*>)/
, _replace: function( all, open, content, close ) {
return this.x( open, '//tag_start' )
+ this.x( content, 'css' )
+ this.x( close, '//tag_end' );
}
}
// matches a starting tag of an element (with attrs)
// like "<div ... >" or "<img ... />"
, tag_start: {
_match: /(<\w+)((?:[?%]>|[\w\W])*?)(\/>|>)/
, _replace: function( all, open, content, close ) {
return "<span class='tag_start'>" + this.x( open ) + "</span>"
+ this.x( content, '/tag_attrs' )
+ "<span class='tag_start'>" + this.x( close ) + "</span>";
}
, _style: "color: navy; font-weight: bold;"
}
// matches an ending tag
// like "</div>"
, tag_end: {
_match: /<\/\w+\s*>|\/>/
, _style: "color: navy;"
}
, entity: {
_match: /&\w+?;/
, _style: "color: blue;"
}
}
, tag_attrs: {
// matches a name/value pair
attr: {
// before in $1, name in $2, between in $3, value in $4
_match: /(\W*?)([\w-]+)(\s*=\s*)((?:\'[^\']*(?:\\.[^\']*)*\')|(?:\"[^\"]*(?:\\.[^\"]*)*\"))/
, _replace: "$1<span class='attr_name'>$2</span>$3<span class='attr_value'>$4</span>"
, _style: { attr_name: "color: green;", attr_value: "color: maroon;" }
}
}
}; ChiliBook.recipes[ "js.js" ] =
{
_name: 'js'
, _case: true
, _main: {
ml_comment: {
_match: /\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\//
, _style: 'color: gray;'
}
, sl_comment: {
_match: /\/\/.*/
, _style: 'color: green;'
}
, string: {
_match: /(?:\'[^\'\\\n]*(?:\\.[^\'\\\n]*)*\')|(?:\"[^\"\\\n]*(?:\\.[^\"\\\n]*)*\")/
, _style: 'color: teal;'
}
, num: {
_match: /\b[+-]?(?:\d*\.?\d+|\d+\.?\d*)(?:[eE][+-]?\d+)?\b/
, _style: 'color: red;'
}
, reg_not: { //this prevents "a / b / c" to be interpreted as a reg_exp
_match: /(?:\w+\s*)\/[^\/\\\n]*(?:\\.[^\/\\\n]*)*\/[gim]*(?:\s*\w+)/
, _replace: function( all ) {
return this.x( all, '//num' );
}
}
, reg_exp: {
_match: /\/[^\/\\\n]*(?:\\.[^\/\\\n]*)*\/[gim]*/
, _style: 'color: maroon;'
}
, brace: {
_match: /[\{\}]/
, _style: 'color: red; font-weight: bold;'
}
, statement: {
_match: /\b(with|while|var|try|throw|switch|return|if|for|finally|else|do|default|continue|const|catch|case|break)\b/
, _style: 'color: navy; font-weight: bold;'
}
, error: {
_match: /\b(URIError|TypeError|SyntaxError|ReferenceError|RangeError|EvalError|Error)\b/
, _style: 'color: Coral;'
}
, object: {
_match: /\b(String|RegExp|Object|Number|Math|Function|Date|Boolean|Array)\b/
, _style: 'color: DeepPink;'
}
, property: {
_match: /\b(undefined|arguments|NaN|Infinity)\b/
, _style: 'color: Purple; font-weight: bold;'
}
, 'function': {
_match: /\b(parseInt|parseFloat|isNaN|isFinite|eval|encodeURIComponent|encodeURI|decodeURIComponent|decodeURI)\b/
, _style: 'color: olive;'
}
, operator: {
_match: /\b(void|typeof|this|new|instanceof|in|function|delete)\b/
, _style: 'color: RoyalBlue; font-weight: bold;'
}
, liveconnect: {
_match: /\b(sun|netscape|java|Packages|JavaPackage|JavaObject|JavaClass|JavaArray|JSObject|JSException)\b/
, _style: 'text-decoration: overline;'
}
}
}; ChiliBook.recipes[ "css.js" ] =
{
_name: 'css'
, _case: true
, _main: {
comment: {
_match: /\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\//
, _style: "color: olive;"
}
, directive: {
_match: /@\w+/
, _style: "color: fuchsia;"
}
, url: {
_match: /\b(url\s*\()([^)]+)(\))/
, _replace: "<span class='url'>$1</span>$2<span class='url'>$3</span>"
, _style: "color: fuchsia;"
}
, block: {
_match: /\{([\w\W]*?)\}/
, _replace: function( all, pairs ) {
return '{' + this.x( pairs, '/definition' ) + '}';
}
}
, 'class': {
_match: /\.\w+/
, _style: "color: #CC0066; font-weight: bold;"
}
, id: {
_match: /#\w+/
, _style: "color: IndianRed; font-weight: bold;"
}
, pseudo: {
_match: /:\w+/
, _style: "color: #CC9900;"
}
, element: {
_match: /\w+/
, _style: "color: Purple; font-weight: bold;"
}
}
, definition: {
comment: {
_match: /\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\//
}
, property: {
_match: /\b(?:zoom|z-index|writing-mode|word-wrap|word-spacing|word-break|width|widows|white-space|volume|voice-family|visibility|vertical-align|unicode-bidi|top|text-underline-position|text-transform|text-shadow|text-overflow|text-kashida-space|text-justify|text-indent|text-decoration|text-autospace|text-align-last|text-align|table-layout|stress|speech-rate|speak-punctuation|speak-numeral|speak-header|speak|size|scrollbar-track-color|scrollbar-shadow-color|scrollbar-highlight-color|scrollbar-face-color|scrollbar-dark-shadow-color|scrollbar-base-color|scrollbar-arrow-color|scrollbar-3d-light-color|ruby-position|ruby-overhang|ruby-align|right|richness|quotes|position|play-during|pitch-range|pitch|pause-before|pause-after|pause|page-break-inside|page-break-before|page-break-after|page|padding-top|padding-right|padding-left|padding-bottom|padding|overflow-Y|overflow-X|overflow|outline-width|outline-style|outline-color|outline|orphans|min-width|min-height|max-width|max-height|marks|marker-offset|margin-top|margin-right|margin-left|margin-bottom|margin|list-style-type|list-style-position|list-style-image|list-style|line-height|line-break|letter-spacing|left|layout-grid-type|layout-grid-mode|layout-grid-line|layout-grid-char-spacing|layout-grid-char|layout-grid|layout-flow|layer-background-image|layer-background-color|include-source|ime-mode|height|font-weight|font-variant|font-style|font-stretch|font-size-adjust|font-size|font-family|font|float|filter|empty-cells|elevation|display|direction|cursor|cue-before|cue-after|cue|counter-reset|counter-increment|content|color|clip|clear|caption-side|bottom|border-width|border-top-width|border-top-style|border-top-color|border-top|border-style|border-spacing|border-right-width|border-right-style|border-right-color|border-right|border-left-width|border-left-style|border-left-color|border-left|border-color|border-collapse|border-bottom-width|border-bottom-style|border-bottom-color|border-bottom|border|behavior|background-repeat|background-position-y|background-position-x|background-position|background-image|background-color|background-attachment|background|azimuth|accelerator)\s*:/
, _style: "color: #330066;"
}
, special: {
_match: /\b(?:-use-link-source|-set-link-source|-replace|-moz-user-select|-moz-user-modify|-moz-user-input|-moz-user-focus|-moz-outline-width|-moz-outline-style|-moz-outline-color|-moz-outline|-moz-opacity|-moz-border-top-colors|-moz-border-right-colors|-moz-border-radius-topright|-moz-border-radius-topleft|-moz-border-radius-bottomright|-moz-border-radius-bottomleft|-moz-border-radius|-moz-border-left-colors|-moz-border-bottom-colors|-moz-binding)\s*:/
, _style: "color: #330066; text-decoration: underline;"
}
, url: {
_match: /\b(url\s*\()([^)]+)(\))/
, _replace: "<span class='url'>$1</span>$2<span class='url'>$3</span>"
}
, value: {
_match: /\b(?:xx-small|xx-large|x-soft|x-small|x-slow|x-low|x-loud|x-large|x-high|x-fast|wider|wait|w-resize|visible|url|uppercase|upper-roman|upper-latin|upper-alpha|underline|ultra-expanded|ultra-condensed|tv|tty|transparent|top|thin|thick|text-top|text-bottom|table-row-group|table-row|table-header-group|table-footer-group|table-column-group|table-column|table-cell|table-caption|sw-resize|super|sub|status-bar|static|square|spell-out|speech|solid|soft|smaller|small-caption|small-caps|small|slower|slow|silent|show|separate|semi-expanded|semi-condensed|se-resize|scroll|screen|s-resize|run-in|rtl|rightwards|right-side|right|ridge|rgb|repeat-y|repeat-x|repeat|relative|projection|print|pre|portrait|pointer|overline|outside|outset|open-quote|once|oblique|nw-resize|nowrap|normal|none|no-repeat|no-open-quote|no-close-quote|ne-resize|narrower|n-resize|move|mix|middle|message-box|medium|marker|ltr|lowercase|lower-roman|lower-latin|lower-greek|lower-alpha|lower|low|loud|local|list-item|line-through|lighter|level|leftwards|left-side|left|larger|large|landscape|justify|italic|invert|inside|inset|inline-table|inline|icon|higher|high|hide|hidden|help|hebrew|handheld|groove|format|fixed|faster|fast|far-right|far-left|fantasy|extra-expanded|extra-condensed|expanded|embossed|embed|e-resize|double|dotted|disc|digits|default|decimal-leading-zero|decimal|dashed|cursive|crosshair|cross|crop|counters|counter|continuous|condensed|compact|collapse|code|close-quote|circle|center-right|center-left|center|caption|capitalize|braille|bottom|both|bolder|bold|block|blink|bidi-override|below|behind|baseline|avoid|auto|aural|attr|armenian|always|all|absolute|above)\b/
, _style: "color: #3366FF;"
}
, string: {
_match: /(?:\'[^\'\\\n]*(?:\\.[^\'\\\n]*)*\')|(?:\"[^\"\\\n]*(?:\\.[^\"\\\n]*)*\")/
, _style: "color: teal;"
}
, number: {
_match: /(?:\b[+-]?(?:\d*\.?\d+|\d+\.?\d*))(?:%|(?:(?:px|pt|em|)\b))/
, _style: "color: red;"
}
, color : {
_match: /(?:\#[a-fA-F0-9]{3,6})|\b(?:yellow|white|teal|silver|red|purple|olive|navy|maroon|lime|green|gray|fuchsia|blue|black|aqua|YellowGreen|Yellow|WhiteSmoke|White|Wheat|Violet|Turquoise|Tomato|Thistle|Teal|Tan|SteelBlue|SpringGreen|Snow|SlateGrey|SlateGray|SlateBlue|SkyBlue|Silver|Sienna|SeaShell|SeaGreen|SandyBrown|Salmon|SaddleBrown|RoyalBlue|RosyBrown|Red|Purple|PowderBlue|Plum|Pink|Peru|PeachPuff|PapayaWhip|PaleVioletRed|PaleTurquoise|PaleGreen|PaleGoldenRod|Orchid|OrangeRed|Orange|OliveDrab|Olive|OldLace|Navy|NavajoWhite|Moccasin|MistyRose|MintCream|MidnightBlue|MediumVioletRed|MediumTurquoise|MediumSpringGreen|MediumSlateBlue|MediumSeaGreen|MediumPurple|MediumOrchid|MediumBlue|MediumAquaMarine|Maroon|Magenta|Linen|LimeGreen|Lime|LightYellow|LightSteelBlue|LightSlateGrey|LightSlateGray|LightSkyBlue|LightSeaGreen|LightSalmon|LightPink|LightGrey|LightGreen|LightGray|LightGoldenRodYellow|LightCyan|LightCoral|LightBlue|LemonChiffon|LawnGreen|LavenderBlush|Lavender|Khaki|Ivory|Indigo|IndianRed|HotPink|HoneyDew|Grey|GreenYellow|Green|Gray|GoldenRod|Gold|GhostWhite|Gainsboro|Fuchsia|ForestGreen|FloralWhite|FireBrick|DodgerBlue|DimGrey|DimGray|DeepSkyBlue|DeepPink|Darkorange|DarkViolet|DarkTurquoise|DarkSlateGrey|DarkSlateGray|DarkSlateBlue|DarkSeaGreen|DarkSalmon|DarkRed|DarkOrchid|DarkOliveGreen|DarkMagenta|DarkKhaki|DarkGrey|DarkGreen|DarkGray|DarkGoldenRod|DarkCyan|DarkBlue|Cyan|Crimson|Cornsilk|CornflowerBlue|Coral|Chocolate|Chartreuse|CadetBlue|BurlyWood|Brown|BlueViolet|Blue|BlanchedAlmond|Black|Bisque|Beige|Azure|Aquamarine|Aqua|AntiqueWhite|AliceBlue)\b/
, _style: "color: green;"
}
}
};

  

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Search / goMap</title>
<link type="text/css" href="../main.css" rel="stylesheet" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="../js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../js/jquery.gomap-1.3.3.js"></script>
<script type="text/javascript" src="../js/jquery.dump.js"></script>
<script type="text/javascript" src="../js/jquery.chili-2.2.js"></script>
<script type="text/javascript" src="../js/recipes.js"></script>
<script type="text/javascript">
$(function() {
var lat = 56.946536;
var lon = 24.10485;
var zoom = 8; $("#map").goMap({
scaleControl: true,
maptype: 'ROADMAP',
streetViewControl: false,
zoom: zoom,
markers: [{
id: 'address',
latitude: lat,
longitude: lon,
draggable: true
}]
}); // $("#message").appendTo('#dialogMap').show(); $.goMap.createListener({type:'marker', marker:'address'}, 'position_changed', function() {
$("#latlon").val($($.goMap.mapId).data('address').getPosition().toUrlValue());
}); $("#search_map").click(function() {
if($("#map_address").val() == "")
alert("Address is empty!")
else {
var _address = $.goMap.createListener({type:'marker', marker:'address'}, 'position_changed', function() {
$.goMap.fitBounds();
$.goMap.removeListener(_address);
$.goMap.setMap({zoom:17});
}); $.goMap.setMarker('address', {address:$("#map_address").val()});
}
return false;
}); });
</script>
<style>
.gomapMarker {
width:30px;
height:200px;
display:block;
}
</style>
</head>
<body>
<div id="wrap">
<div id="header">
<div id="logo"><h1><b>$.goMap()</b> / search</h1> google maps jQuery plugn</div>
<div id="menu">
<a href="../solutions.php">→ Back</a>
</div>
</div>
<div id="content">
<b>$.goMap()</b> is <a href="http://www.jquery.com/">jQuery</a> plugin useing <a href="http://code.google.com/apis/maps/documentation/javascript/">Google Maps v3</a>.
<h3>Simple example</h3>
<input type="text" name="map_address" value="" id="map_address" /> <input type="button" name="search_map" value="Search" id="search_map" />
<br/>
<input type="text" name="latlon" value="" id="latlon" readonly/>
<br/>
<style>
em, .map, #map2 {
width:100%;
margin:0 auto;
height:400px;
display:block;
}
</style>
<br/>
<div id="map"></div> <div id="footer">pittss © / contacts: pittss@gmail.com</div>
</div>
</div>
</body>
</html>

  

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>group / goMap</title>
<link type="text/css" href="../main.css" rel="stylesheet" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="../js/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="../js/jquery.gomap-1.3.1.js"></script>
<script type="text/javascript" src="../js/jquery.dump.js"></script>
<script type="text/javascript" src="../js/jquery.chili-2.2.js"></script>
<script type="text/javascript" src="../js/recipes.js"></script>
<script type="text/javascript">
$(function() { $("#map").goMap({
icon: '../img/apartment.png'
}); $.goMap.ready(function() {
var bounds = $.goMap.getBounds();
var southWest = bounds.getSouthWest();
var northEast = bounds.getNorthEast();
var lngSpan = northEast.lng() - southWest.lng();
var latSpan = northEast.lat() - southWest.lat(); for (var i = 0; i < 60; i++) { var group = 'g1';
var icon = 'http://www.google.com/intl/en_ALL/mapfiles/marker_green'+String.fromCharCode(i + 65)+'.png'; if(i > 50) {
group = 'g4';
icon = 'http://www.google.com/intl/en_ALL/mapfiles/marker_black'+String.fromCharCode((i-50) + 65)+'.png';
}
else if(i > 40) {
group = 'g3';
icon = 'http://www.google.com/intl/en_ALL/mapfiles/marker_orange'+String.fromCharCode((i-40) + 65)+'.png';
}
else if(i > 20) {
group = 'g2';
icon = 'http://www.google.com/intl/en_ALL/mapfiles/marker'+String.fromCharCode((i-20) + 65)+'.png';
} $.goMap.createMarker({
latitude: southWest.lat() + latSpan * Math.random(),
longitude: southWest.lng() + lngSpan * Math.random(),
group: group,
icon: icon });
} }); $("#group").change(function() {
var group = $(this).val(); if(group == 'all')
for (var i in $.goMap.markers) {
$.goMap.showHideMarker($.goMap.markers[i], true);
}
else {
for (var i in $.goMap.markers) {
$.goMap.showHideMarker($.goMap.markers[i], false);
} $.goMap.showHideMarkerByGroup(group, true);
} }); $("#count1").click(function(){
$("#map").goMap();
alert($.goMap.getMarkerCount());
}); });
</script>
</head>
<body>
<div id="wrap">
<div id="header">
<div id="logo"><h1><b>$.goMap()</b> / group</h1> google maps jQuery plugn</div>
<div id="menu">
<a href="../solutions.php">→ Back</a>
</div>
</div>
<div id="content">
<b>$.goMap()</b> is <a href="http://www.jquery.com/">jQuery v1.5</a> plugin useing <a href="http://code.google.com/apis/maps/documentation/javascript/">Google Maps v3</a>.
<h3>Simple example</h3>
<br/>
<style>
em, .map, #map2 {
width:100%;
margin:0 auto;
height:400px;
display:block;
}
</style>
<br/>
<select id="group">
<option value="all">Show all markers</option>
<option value="g1">Show only group "g1"</option>
<option value="g2">Show only group "g2"</option>
<option value="g3">Show only group "g3"</option>
<option value="g4">Show only group "g4"</option>
</select>
<input type="button" name="count1" value="count markers" id="count1" />
<div id="map"></div> <div id="footer">pittss © <?=date("Y");?> / contacts: pittss@gmail.com</div>
</div>
</div>
</body>
</html>

  

javascript: jquery.gomap-1.3.3.js的更多相关文章

  1. JavaScript、jQuery、HTML5、Node.js实例大全-读书笔记3

    技术很多,例子很多,只好慢慢学,慢慢实践!!现在学的这本书是[JavaScript实战----JavaScript.jQuery.HTML5.Node.js实例大全] JavaScript.jQuer ...

  2. JavaScript、jQuery、HTML5、Node.js实例大全-读书笔记2

    技术很多,例子很多,只好慢慢学,慢慢实践!!现在学的这本书是[JavaScript实战----JavaScript.jQuery.HTML5.Node.js实例大全] JavaScript.jQuer ...

  3. JavaScript、jQuery、HTML5、Node.js实例大全-读书笔记1

    技术很多,例子很多,只好慢慢学,慢慢实践!!现在学的这本书是[JavaScript实战----JavaScript.jQuery.HTML5.Node.js实例大全] 第 3 章 用 JavaScri ...

  4. Handlebars的基本用法 Handlebars.js使用介绍 http://handlebarsjs.com/ Handlebars.js 模板引擎 javascript/jquery模板引擎——Handlebars初体验 handlebars.js 入门(1) 作为一名前端的你,必须掌握的模板引擎:Handlebars 前端数据模板handlebars与jquery整

    Handlebars的基本用法 使用Handlebars,你可以轻松创建语义化模板,Mustache模板和Handlebars是兼容的,所以你可以将Mustache导入Handlebars以使用 Ha ...

  5. 【JavaScript框架封装】使用原生js封装的类似于JQuery的框架及核心源码分享(多文件版本)

    这个版本的JQuery是对上一个版本的JQuery,使用了require.js进行了二次封装,基本上把前面的每一个框架封装成为一个单独的模块,最终的目录结构如下: 由于代码量和目录比较多,这个封装好的 ...

  6. JavaScript jQuery 中定义数组与操作及jquery数组操作

    首先给大家介绍javascript jquery中定义数组与操作的相关知识,具体内容如下所示: 1.认识数组 数组就是某类数据的集合,数据类型可以是整型.字符串.甚至是对象Javascript不支持多 ...

  7. 用JavaScript动态加载CSS和JS文件

    本文转载自:http://www.cnblogs.com/xiaochaohuashengmi/archive/2011/11/14/2248451.html 今天项目中需要用到动态加载 CSS 文件 ...

  8. 在线运行Javascript,Jquery,HTML,CSS代码

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" http://www.w3.org/TR/xht ...

  9. Javascript模块化编程之路——(require.js)

    转自:http://www.ruanyifeng.com/blog/2012/10/javascript_module.html Javascript模块化编程(一):模块的写法 随着网站逐渐变成&q ...

随机推荐

  1. 2. MongoDB基本操作 —— 用Mongo.exe操作数据库增删改查

    一.开篇 传统的关系数据库一般由数据库(database).表(table).记录(record)三个层次概念组成,MongoDB是由数据库(database).集合(collection).文档对象 ...

  2. 【Cocos2d-Js基础教学(6)网络层(弱联网)的封装及使用】

    谈到联网,在游戏中也是非常核心的模块,在官方Js-test中我们可以找到联网部分 的NetworkTest文件下有两个类 SocketIOTest.js(Socket 类) WebSocketTest ...

  3. C# winForm 窗体闪烁问题

    在构造函数里加上以下代码: this.DoubleBuffered = true;//设置本窗体            SetStyle(ControlStyles.UserPaint, true); ...

  4. 初探Stage3D(一) 3D渲染基础原理

    关于本文 本文主要想介绍一下3D渲染的基本流程,及怎样把一个三角形(0,1,0),(1,0,1),(0,0,1)最终渲染到屏幕上来.文章的目的是对3D渲染流程做一个简单的介绍,其中不涉及任何语言的AP ...

  5. [转载]寻找两个有序数组中的第K个数或者中位数

    http://blog.csdn.net/realxie/article/details/8078043 假设有长度分为为M和N的两个升序数组A和B,在A和B两个数组中查找第K大的数,即将A和B按升序 ...

  6. css3实现进度条的模拟

    两种进度条动画的实现: 1.css3,但IE9-不支持. 2.js动画,兼容性好,但没有css3实现的顺畅 Demo: <html>    <head>        < ...

  7. Android Studio配置和使用OpenCV3.x,不需要OpencvManager

    转载声明,本文转自CSDN:http://blog.csdn.net/qq_22033759/article/details/51156121 ps:本来在贴吧上有人问,想自己写的,但时间有限,当初自 ...

  8. 注解Annotation 详解(转)

    要深入学习注解,我们就必须能定义自己的注解,并使用注解,在定义自己的注解之前,我们就必须要了解Java为我们提供的元注解和相关定义注解的语法. 元注解: 元注解的作用就是负责注解其他注解.Java5. ...

  9. CreateProcessAsUser,C#写的windows服务弹框提示消息或者启动子进程

    服务(Service)对于大家来说一定不会陌生,它是Windows 操作系统重要的组成部分.我们可以把服务想像成一种特殊的应用程序,它随系统的“开启-关闭”而“开始-停止”其工作内容,在这期间无需任何 ...

  10. 解决clone问题之外的体会

    adlnkoh.sh started at Thu Aug 25 15:42:51 CST 2016 Log file located at /u02/db/testdb/11.1.0/appsuti ...