Changeset b3374f6 in OpenWorkouts-current for ow/static/js/ow.js


Ignore:
Timestamp:
Feb 12, 2019, 5:55:33 PM (5 years ago)
Author:
Borja Lopez <borja@…>
Branches:
current, feature/docs, master
Children:
c999b73e
Parents:
f713dbc
Message:

(#52) - Make map screenshot generation async and non-blocker of the dashboard
and user profile pages:

  • workout.map_screenshot is a property again, returns a string with the static path (suitable for use with request.static_url()) for the map screenshot file if exists, none otherwise
  • added a couple of helpers to build the proper screenshot name and full path on the filesystem
  • added a view to generate the map if needed, returning the full static url to the screenshot file in a json-encoded stream
  • added a new js ow tool that looks for workouts that still don't have a map screenshot, calling the view to generate that screenshot and updating the map screenshot when the file is ready
  • modified the dashboard and user profile templates, so a dummy/placeholder image is shown when no map screenshot is yet ready, plus setup and calls for the js tool that generates the maps.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ow/static/js/ow.js

    rf713dbc rb3374f6  
    452452
    453453};
     454
     455
     456owjs.map_shots = function(spec) {
     457
     458    "use strict";
     459
     460    var img_selector = spec.img_selector;
     461
     462    var run = function run(){
     463        $(img_selector).each(function(){
     464            var img = $(this);
     465            var a = $(this).parent();
     466            var url = a.attr('href') + 'map-shot';
     467            var jqxhr = $.getJSON(url, function(info) {
     468                img.fadeOut('fast', function () {
     469                    img.attr('src', info['url']);
     470                    img.fadeIn('fast');
     471                });
     472                img.removeClass('js-needs-map');
     473            });
     474        });
     475    };
     476
     477    var that = {}
     478    that.run = run;
     479    return that
     480
     481};
Note: See TracChangeset for help on using the changeset viewer.