Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

modified: WazeEmbeddedMapNoJQuery.js

	new file:   all.js
	new file:   contextbug.js
	modified:   index.js
	modified:   wazeconfig.js
  • Loading branch information...
commit fce47e6e0bdc3f71117c73b2d275b929dc4739be 1 parent 8f1723b
Shimon Doodkin authored October 28, 2010
2  WazeEmbeddedMapNoJQuery.js
@@ -27150,7 +27150,7 @@ function waze_map_info_callback(map_info) {
27150 27150
         }, 0);
27151 27151
     }
27152 27152
     if (typeof(onWazeMapInit) == "function") onWazeMapInit();
27153  
-    else if (typeof(g_waze_config.callback) == "function") g_waze_config.callback();
  27153
+    else if (typeof(g_waze_config.callback) == "function") g_waze_config.callback(g_waze_map);
27154 27154
 }
27155 27155
 $().ready(function () {
27156 27156
 console.log('ready called');
27,293  all.js
27293 additions, 0 deletions not shown
10  contextbug.js
... ...
@@ -0,0 +1,10 @@
  1
+var  sandbox = { setTimeout: setTimeout, console:console};
  2
+var myscript=0;
  3
+function run_scripts_in_same_context(text)
  4
+{
  5
+ process.binding('evals').Script.runInNewContext(text,sandbox,'myfile'+(myscript++)+'.js');
  6
+}
  7
+
  8
+run_scripts_in_same_context('var x="1"; function showx(){console.log("x="+x);} setTimeout(function(){showx();},100)');
  9
+run_scripts_in_same_context('x="5"; showx();');
  10
+console.log("the last x should be 5, if it is 1 so the contexts are not referenced");
22  index.js
@@ -3,14 +3,26 @@ var jsdom  = require("jsdom/lib/jsdom"),
3 3
     xhrCompat  = require("node-XMLHttpRequest/XMLHttpRequest.js"),
4 4
     window = jsdom.jsdom('<html><head>'+
5 5
     '<script src="'+"file://"+__dirname+"/jquery-1.4.2.min.js"+'">jstext</script>' +
6  
-    '<script src="'+"file://"+__dirname+"/wazeconfig.js"+'">jstext</script>' +
7  
-    '<script src="'+"file://"+__dirname+"/WazeEmbeddedMapNoJQuery.js"+'">jstext</script>' +
8  
-    '<script src="'+"file://"+__dirname+"/runinit.js"+'">jstext</script>' +
  6
+//    '<script src="'+"file://"+__dirname+"/wazeconfig.js"+'">jstext</script>' +
  7
+//    '<script src="'+"file://"+__dirname+"/WazeEmbeddedMapNoJQuery.js"+'">jstext</script>' +
  8
+//    '<script src="'+"file://"+__dirname+"/runinit.js"+'">jstext</script>' +
  9
+    '<script src="'+"file://"+__dirname+"/all.js"+'">jstext</script>' +
9 10
     '</head><body><div id="map" style="height:231px;width:217px">mapa</div></body></html>').createWindow();
10 11
     window.XMLHttpRequest=xhrCompat.XMLHttpRequest;
11 12
     window.Function=Function;
12 13
     window.console=console;
  14
+    window.onload2=function (){
13 15
     
  16
+     //console.log(window.jQuery.fn.jquery);
  17
+
  18
+     console.log(window.jQuery("#map")[0].innerHTML);
  19
+     // console.log(window.g_waze_map)
  20
+    };
  21
+    
  22
+    window.waze_found=function (address){
  23
+     //console.log(address);
  24
+     // console.log(window.g_waze_map)
  25
+    };
14 26
     
15 27
     //jsdom.jQueryify(window, "file://"+__dirname+"/jquery-1.4.2.min.js", function()
16 28
     //{
@@ -21,9 +33,7 @@ var jsdom  = require("jsdom/lib/jsdom"),
21 33
      //window.jQuery('body').append("<div class='testing'>Hello World, It works!</div>");
22 34
      //sys.puts(window.jQuery(".testing").text());
23 35
     //});
24  
-//console.log(window.document)
25  
-    
26  
-    
  36
+ 
27 37
     //console.log(window.jQuery.fn.jquery);
28 38
     // outputs: 1.4.2
29 39
     //console.log(window).jQuery("#map").text());
31  wazeconfig.js
... ...
@@ -1,13 +1,38 @@
1 1
 
2 2
 //var last_searched_address
3  
-    var g_waze_map;
  3
+
4 4
     
5  
-		function map_on_init() 			//called when map loads
  5
+		function map_on_init(g_waze_map) 			//called when map loads
6 6
 		{
7 7
 		  console.log('map_on_init done');
8 8
 	  	g_waze_map.find('יד חרוצים 12','map_find_callback'); //g_waze_map global variable
9 9
     }
10  
-    
  10
+
  11
+ function printMap() {
  12
+    // fetch the extent and image size
  13
+    var mapview = document.getElementById('map').contentWindow.map;
  14
+    var layers  = document.getElementById('map').contentWindow.layers;
  15
+    var extent  = mapview.getExtent();
  16
+        extent  = [extent.left,extent.bottom,extent.right,extent.top].join('+');
  17
+    var width   = mapview.getSize().w;
  18
+    var height  = mapview.getSize().h;
  19
+    // build a comma-joined list of layers
  20
+    var activelayers = [];
  21
+    for (i in layers) {
  22
+      if (!layers[i].getVisibility()) continue;
  23
+      if (!layers[i].calculateInRange()) continue;
  24
+      activelayers[activelayers.length] = layers[i].params['LAYERS'];
  25
+    }
  26
+    activelayers = activelayers.join('+');
  27
+    // open a window to our pure-Mapserver version
  28
+    var url = '/cgi-bin/mapserv?map=/maps/spraywatch2/wms/mapfile.map';
  29
+        url += '&mode=map';
  30
+        url += '&mapext=' + extent;
  31
+        url += '&mapsize=' + width+'+'+height;
  32
+        url += '&layers=' + activelayers;
  33
+    return url;
  34
+  }
  35
+  
11 36
     function map_find_callback(response)
12 37
 		{
13 38
 		  console.log('map_find_callback done');

0 notes on commit fce47e6

Please sign in to comment.
Something went wrong with that request. Please try again.