Search Results

Search found 55 results on 3 pages for 'ap257'.

Page 3/3 | < Previous Page | 1 2 3 

  • JavaScript: supposed to execute functions sequentially, not actually doing so?

    - by AP257
    I'm seeing a lot of answers on StackOverflow that say that JavaScript executes code sequentially, but I can actually see my own JavaScript not doing so. From the following code: function centre_map(lat, lng, zoom_level) { alert('centre_map'); map = new GMap2(document.getElementById('map_canvas')); var latlng = new GLatLng(lat, lng); map.setCenter(latlng, zoom_level); } function add_markers_within_bounds() { alert('add_markers_within_bounds'); // add numerous BLUE markers within map bounds using MarkerClusterer } function add_marker(lat, lng, place_name, grid, county) { alert('add_marker'); // add one ordinary RED Google Maps marker } centre_map('{{lat}}', '{{lng}}', 12); add_markers_within_bounds('{{grid}}', '{{place_name}}'); add_marker('{{lat}}', '{{lng}}', '{{place_name}}', '{{grid}}', '{{county}}'); I get the following sequence of events: 'centre_map' alert 'add_markers_within_bounds' alert 'add_marker' alert individual RED marker appears on map (i.e. add_marker renders) multiple BLUE markers appear on map (i.e. add_markers_within_bounds renders) Why doesn't add_markers_within_bounds complete before add_marker gets under way: and how can I make it do so? I know that one way might be to call add_marker from within add_markers_within_bounds, but for various reasons I'd rather keep it as a separate function.

    Read the article

  • Designing a database for a user/points system? (in Django)

    - by AP257
    First of all, sorry if this isn't an appropriate question for StackOverflow. I've tried to make it as generalisable as possible. I want to create a database (MySQL, site running Django) that has users, who can be allocated a certain number of points for various types of action - it's a collaborative game. My requirements are to obtain: the number of points a user has the user's ranking compared to all other users and the overall leaderboard (i.e. all users ranked in order of points) This is what I have so far, in my Django models.py file: class SiteUser(models.Model): name = models.CharField(max_length=250 ) email = models.EmailField(max_length=250 ) date_added = models.DateTimeField(auto_now_add=True) def points_total(self): points_added = PointsAdded.objects.filter(user=self) points_total = 0 for point in points_added: points_total += point.points return points_total class PointsAdded(models.Model): user = models.ForeignKey('SiteUser') action = models.ForeignKey('Action') date_added = models.DateTimeField(auto_now_add=True) def points(self): points = Action.objects.filter(action=self.action) return points class Action(models.Model): points = models.IntegerField() action = models.CharField(max_length=36) However it's rapidly becoming clear to me that it's actually quite complex (in Django query terms at least) to figure out the user's ranking and return the leaderboard of users. At least, I'm finding it tough. Is there a more elegant way to do something like this? This question seems to suggest that I shouldn't even have a separate points table - what do people think? It feels more robust to have separate tables, but I don't have much experience of database design.

    Read the article

  • Understanding a lighttpd.conf file?

    - by AP257
    Hi all, I've been given a lighttpd.conf that someone else wrote and need help working out how to serve it. I'm 90% of the way there but stuck... The index.html page appears, but links and CSS files don't point to the right place. To clarify, the links and CSS files are all pointing to a 'file:///' URL. So styles.css in the HTML header points to file:///html/styles.css, whereas it should be going to http://url.com/styles.css Maybe url.rewrite or url.redirect isn't working properly? server.document-root = "~/html" server.port = 28001 mimetype.assign = ( ".html" => "text/html", ".txt" => "text/plain", ".jpg" => "image/jpeg", ".png" => "image/png" ) url.rewrite = ( "^(.*)/($|\?.*)" => "$1/index.html", "^(.*)/([^.?]+)($|\?.*)$" => "$1/$2.html" ) $HTTP["scheme"] == "http" { url.redirect = ( "^/platform/index.html$" => "/platform", "^/about/company.html$" => "/about/company",, ) }

    Read the article

  • CSS: image link, change on hover

    - by AP257
    I have an image that is a link. I want to show a different image when the user hovers over the link. Currently I'm using this code: <a href="http://twitter.com/me" title="Twitter link"> <div id="twitterbird" class="sidebar-poster"></div></a> div.sidebar-poster { margin-bottom: 10px; background-position: center top; background-repeat: no-repeat; width: 160px; } #twitterbird { background-image: url('twitterbird.png'); } #twitterbird:hover { background-image: url('twitterbird_hover.png'); } But I'm having loads of problems: the div isn't picking up the CSS rules (the element just isn't showing the related CSS rules when I view it in Firebug). Perhaps this is because (as I know) this is invalid HTML: you can't put an <a> around a <div>. However, if I switch to <span> then it seems I get bigger problems, because you can't set a height and width on a span reliably. Help! How can I do this better?

    Read the article

  • jQuery: set the width of a textarea?

    - by AP257
    What it says on the tin: how do I set the width of a textarea in jQuery? I want to set the width of a textarea to match the width of a particular image. Using .width() works for setting the width of an image, but not of a textarea. $(document).ready(function() { var width = $("#my_image").width(); $("#another_image").width(width); // works $("#my_textarea").width(width); // fails }); How do I set the width of a textarea?

    Read the article

< Previous Page | 1 2 3