Skip to content

Commit

Permalink
Fixed \d in regular expressions.
Browse files Browse the repository at this point in the history
Fixed wikipedia's showHighRes support.
  • Loading branch information
romain.vallet committed Oct 12, 2010
1 parent 9a193cf commit 9c59e5f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion hoverzoom.js
Expand Up @@ -312,7 +312,7 @@ var hoverZoom = {
titledElement.parents('[title]').andSelf().add('[title]').removeAttr('title');
} else {
var alt = link.attr('alt') || link.find('[alt]').attr('alt');
if (alt && alt.length > 6 && !/^[0-9]+$/.test(alt)) {
if (alt && alt.length > 6 && !/^\d+$/.test(alt)) {
link.data('hoverZoomCaption', alt);
}
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/cnet.js
Expand Up @@ -7,8 +7,8 @@ hoverZoomPlugins.push( {
version: '0.1',
prepareImgLinks: function(callback) {
var res = [],
filter1 = /^(.*)_[0-9]+x[0-9]+\.(jpg|png|gif).*$/i,
//filter2 = /^(.*\/cnwk\..*\/[0-9]+-[0-9]+)-[0-9]+-(.*)\.(jpg|png|gif).*$/i,
filter1 = /^(.*)_\d+x\d+\.(jpg|png|gif).*$/i,
//filter2 = /^(.*\/cnwk\..*\/\d+-\d+)-\d+-(.*)\.(jpg|png|gif).*$/i,
imgs = $('a img[src*=i.com.com]');

imgs.each(function() {
Expand Down
4 changes: 2 additions & 2 deletions plugins/gawker.js
Expand Up @@ -11,8 +11,8 @@ hoverZoomPlugins.push( {
var img = $(this),
url = hoverZoom.getThumbUrl(this);
if (!url) { return; }
url = url.replace(/\/([0-9]+x[0-9]*|gallery)_/, '/');
if (img.hasClass('avatar')) { url = url.replace(/_[0-9]+\./, '_160.'); }
url = url.replace(/\/(\d+x\d*|gallery)_/, '/');
if (img.hasClass('avatar')) { url = url.replace(/_\d+\./, '_160.'); }
url = url.substr(0, url.lastIndexOf('.'));
img.data('hoverZoomSrc', [url + '.jpg', url + '.png', url + '.gif', url]);
res.push(img);
Expand Down
6 changes: 3 additions & 3 deletions plugins/threadless.js
Expand Up @@ -10,12 +10,12 @@ hoverZoomPlugins.push( {
hoverZoom.urlReplace(res,
//'a[href*=/product/] img[src*=threadlesskids], a.thumblink img, a[href^=/gallery/] img, img.product',
'img[src*=-minizoom], img[src*=-view]',
/product\/[0-9]+x[0-9]+\/([0-9]+)-/,
/product\/\d+x\d+\/(\d+)-/,
'product/$1/'
);
hoverZoom.urlReplace(res,
'a[href*=/product/] img',
/[0-9]+x[0-9]+/,
/\d+x\d+/,
'636x460'
);
$('td').filter(function() {
Expand All @@ -31,7 +31,7 @@ hoverZoomPlugins.push( {
$('img[src*=/profiles/]:not([src*=noimage]), img[src*=teeriffic], .product_image').each(function() {
var _this = $(this),
url = hoverZoom.getThumbUrl(this);
url = url.replace(/\/[0-9]+x[0-9]+/, '');
url = url.replace(/\/\d+x\d+/, '');
url = url.substr(0, url.lastIndexOf('.'));
_this.data('hoverZoomSrc', [url + '.jpg', url + '.gif', url + '.png']);
res.push(_this);
Expand Down
5 changes: 1 addition & 4 deletions plugins/wikipedia.js
Expand Up @@ -21,10 +21,7 @@ hoverZoomPlugins.push( {
}
var srcs = [];
if (!options.showHighRes) {
srcs.push(src.replace(/\/[0-9]+px-/, '/800px-'));
srcs.push(src.replace(/\/[0-9]+px-/, '/600px-'));
srcs.push(src.replace(/\/[0-9]+px-/, '/400px-'));
srcs.push(src.replace(/\/[0-9]+px-/, '/200px-'));
srcs.push(src.replace(/\/\d+px-/, '/800px-'));
}
srcs.push(src.substring(0, src.indexOf(ext) + ext.length).replace(/thumb\//, ''));
$(this).data('hoverZoomSrc', srcs);
Expand Down

0 comments on commit 9c59e5f

Please sign in to comment.