Skip to content
This repository has been archived by the owner on Sep 19, 2021. It is now read-only.

Commit

Permalink
Добавил возможность указывать рисунок кота через мета-тег #18
Browse files Browse the repository at this point in the history
`<meta name="kittycheck_cat" content="default" />`

Рисунки добавлять в inject.js в переменную cats
  • Loading branch information
Aleksandr Gornostal committed May 31, 2012
1 parent 49bcb35 commit 0f05ec9
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion js/inject.js
Expand Up @@ -2,6 +2,14 @@

var inject = function($){

var cats = {
'default': {
url: 'http://kittycheck.com/img/cat1.png',
width: 64,
height: 64
}
};

var rumble = function(){
if(typeof soundManager !== 'undefined')
{
Expand Down Expand Up @@ -174,6 +182,23 @@
IFRAME_URL += '?site_uniq_id=' + encodeURIComponent($suid_meta.attr('content'));
}

// example: <meta name="kittycheck_cat" content="default" />
var $catImg = $('meta[name="kittycheck_cat"]');
var imgId;
try {
imgId = $catImg.attr('content');
if (!cats[imgId].url) {
throw '';
}
} catch (e) {
imgId = 'default';
}
var catImg = {
'background-image': "url('" + cats[imgId].url + "')",
width: cats[imgId].width,
height: cats[imgId].height
};

// example: <meta name="kittycheck_position" content="top=10,left=10" />
var $position = $('meta[name="kittycheck_position"]'),
catCss = $position.length && (function(){
Expand Down Expand Up @@ -229,7 +254,7 @@
var $iframeFix = $('<div>')
.addClass('kittycheck-iframefix');
var $cat = $('<div>')
.css(catCss)
.css($.extend({}, catCss, catImg))
.addClass('kittycheck-cat');

$(parent).append($cat);
Expand Down

0 comments on commit 0f05ec9

Please sign in to comment.