<commit_before>﻿var hoverZoomPlugins = hoverZoomPlugins || [];
hoverZoomPlugins.push({
    name:'thingiverse.com',
    version:'1.0',
    prepareImgLinks:function (callback) {

        var res = [];

        var re1 = /_preview_.*?\./;
        var re2 = /_display_.*?\./;
        var re3 = /_thumb_.*?\./;
        var patch = '_display_large.';

        hoverZoom.urlReplace(res,
            'img[src]',
            [re1, re2, re3],
            [patch, patch, patch]
        );

        $('[style*=url]').each(function() {
            // extract url from style
            var backgroundImage = this.style.backgroundImage;
            var reUrl = /.*url\s*\(\s*(.*)\s*\).*/i
            backgroundImage = backgroundImage.replace(reUrl, '$1');
            // remove leading & trailing quotes
            var backgroundImageUrl = backgroundImage.replace(/^['"]/, '').replace(/['"]+$/, '');
            var fullsizeUrl = backgroundImageUrl.replace(re1, patch).replace(re2, patch).replace(re3, patch);
            if (fullsizeUrl != backgroundImageUrl) {
                var link = $(this);
                if (link.data().hoverZoomSrc == undefined) { link.data().hoverZoomSrc = [] }
                if (link.data().hoverZoomSrc.indexOf(fullsizeUrl) == -1) {
                    link.data().hoverZoomSrc.unshift(fullsizeUrl);
                    res.push(link);
                }
            }
        });

        callback($(res), this.name);
    }
});<commit_msg>Reimplement thingiverse plugin using api calls as discussed in #667<commit_after>﻿var hoverZoomPlugins = hoverZoomPlugins || [];
hoverZoomPlugins.push({
    name:'thingiverse.com',
    version:'1.0',
    prepareImgLinks:function (callback) {
        $('a > img[src*="card_preview"]').one('mouseover', function() {
            var link = $(this).parent(), data = link.data();
            var href = link.attr('href');
            var thingId = href.substring(href.lastIndexOf(':') + 1);
            $.ajax('https://api.thingiverse.com/things/' + thingId + '/images', {headers: {'Authorization': 'Bearer 56edfc79ecf25922b98202dd79a291aa'}}).done(function (images) {
                var urls = [];
                for (var i = 0; i < images.length; i++) {
                    var sizes = images[i].sizes;
                    var url = [];
                    for (var j = 0; j < sizes.length; j++) {
                        if (sizes[j].size === 'large')
                            url.splice(0, 0, sizes[j].url);
                    }
                    if (url.length > 0) {
                        urls.push(url);
                    }
                }
                hoverZoom.prepareLink(link, urls);
            });
        });
    }
});
{'fraction_non_alphanumeric': 0.16266173752310537, 'fraction_numerical': 0.01589648798521257, 'mean_word_length': 1.6898608349900597, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3705644', 'n_tokens_mistral': 812, 'n_tokens_neox': 766, 'n_words': 148}