Exemplo n.º 1
0
    def js_coords_list(self, world, postback, sofaurl):
        room_keys = self.cache_get_or_put_room_keys(world)

        js1 = "var roomIds = ["
        js = "\nvar rooms = ["

        for room_key in room_keys:

            room = room_key.get()

            if room.visible:
                lats = room.latitudes
                lons = room.longitudes

                js1 += "'" + encode(str(room.key.id())) + "',"
                if len(lats) > 0:
                    js += "["
                    for x in range(len(lats)):
                        js += "new google.maps.LatLng(" + encode(
                            lats[x]) + ", " + encode(lons[x]) + "),"
                    js = js[:-1] + "],"

        js1 = js1[:-1] + "];"
        js = js[:-1] + "];"
        js = js1 + js

        js += "\nrooms.sort(function() { return 0.5 - Math.random() });"

        js += "\nvar postUrl = \"%s\";" % postback
        js += "\nvar sofaUrl = \"%s\";" % sofaurl
        js += "\nvar voidText = \"%s\";" % world.void_text

        return js
Exemplo n.º 2
0
    def js_coords_list(self, world, postback, sofaurl):
        room_keys = self.cache_get_or_put_room_keys(world)

        js1 = "var roomIds = ["
        js = "\nvar rooms = ["

        for room_key in room_keys:

            room = room_key.get()

            if room.visible:
                lats = room.latitudes
                lons = room.longitudes

                js1 += "'" + encode(str(room.key.id())) + "',"
                if len(lats) > 0:
                    js += "["
                    for x in range(len(lats)):
                        js += "new google.maps.LatLng("+encode(lats[x])+", "+encode(lons[x])+"),"
                    js = js[:-1] + "],"

        js1 = js1[:-1] + "];"
        js = js[:-1] + "];"
        js = js1 + js

        js += "\nrooms.sort(function() { return 0.5 - Math.random() });"

        js += "\nvar postUrl = \"%s\";" % postback
        js += "\nvar sofaUrl = \"%s\";" % sofaurl
        js += "\nvar voidText = \"%s\";" % world.void_text

        return js
Exemplo n.º 3
0
 def js_one_room_on_map(self, text):
     lats = text.latitudes
     lons = text.longitudes
     if len(lats) > 0:
         js = "var aRoom = ["
         for index, lat in enumerate(lats):
             js += "new google.maps.LatLng(%s, %s)," % (encode(lat), encode(lons[index]))
         js = js[:-1] + "];"
     else:
         js = "var aRoom = [];"
     return js
Exemplo n.º 4
0
 def js_one_room_on_map(self, text):
     lats = text.latitudes
     lons = text.longitudes
     if len(lats) > 0:
         js = "var aRoom = ["
         for index, lat in enumerate(lats):
             js += "new google.maps.LatLng(%s, %s)," % (encode(lat),
                                                        encode(lons[index]))
         js = js[:-1] + "];"
     else:
         js = "var aRoom = [];"
     return js
Exemplo n.º 5
0
    def js_all_rooms_on_map(self, world):
        rooms_ftr = world.get_rooms()
        rooms = rooms_ftr.get_result()
        
        if rooms == []:
            js = "var rooms=[];"
            return js

        js = "var rooms = ["

        for room in rooms:
            lats = room.latitudes
            lons = room.longitudes

            if len(lats) > 0 and len(lons) > 0:
                js += "["
                for x in range(len(lats)):
                    js += "new google.maps.LatLng("+encode(lats[x])+", "+encode(lons[x])+"),"
                js = js[:-1] + "],"

        js = js[:-1] + "];"

        return js
Exemplo n.º 6
0
    def js_all_rooms_on_map(self, world):
        rooms_ftr = world.get_rooms()
        rooms = rooms_ftr.get_result()

        if rooms == []:
            js = "var rooms=[];"
            return js

        js = "var rooms = ["

        for room in rooms:
            lats = room.latitudes
            lons = room.longitudes

            if len(lats) > 0 and len(lons) > 0:
                js += "["
                for x in range(len(lats)):
                    js += "new google.maps.LatLng(" + encode(
                        lats[x]) + ", " + encode(lons[x]) + "),"
                js = js[:-1] + "],"

        js = js[:-1] + "];"

        return js