function substr_(str, key) {
if (str == null) {
str = '';
return str
}
var index = str.indexOf(key);
if (index != -1) {
return str.substring(index + key.length)
}
return str
}
function bi_get_first_image(content) {
src = '';
key0 = '\u003cimg ';
key1 = 'src\u003d\"';
key2 = '\"';
index0 = content.indexOf(key0);
if (index0 != -1) {
index1 = content.indexOf(key1, index0);
if (index0 != -1) {
index2 = content.indexOf(key2, index1 + key1.length);
if (index0 != -1) {
src = content.substring(index1 + key1.length, index2)
}
}
}
if (src == '') {
key0 = 'data-thumbnail-src\u003d\"';
key1 = '\"';
index0 = content.indexOf(key0);
if (index0 != -1) {
index1 = content.indexOf(key1, index0 + key0.length);
if (index0 != -1) {
src = content.substring(index0 + key0.length, index1)
}
}
}
if (src == '') {
key0 = '\u003ciframe ';
key1 = 'src\u003d\"';
key2 = '\"';
index0 = content.indexOf(key0);
if (index0 != -1) {
index1 = content.indexOf(key1, index0);
if (index0 != -1) {
index2 = content.indexOf(key2, index1 + key1.length);
if (index0 != -1) {
src = content.substring(index1 + key1.length, index2);
src = src.replace('http://www.youtube.com/watch?v=', '');
src = src.replace('http://www.youtube.com/embed/', '');
src = src.replace('?rel=0', '');
src = 'http://img.youtube.com/vi/' + src + '/mqdefault.jpg'
}
}
}
}
return src
}
function bi_date_format(pub_date, format) {
pub_date = pub_date.split('-');
date = new Date(pub_date[0], pub_date[1] - 1, pub_date[2].substring(0, 2));
dd = date.getDate() + 1;
mm = date.getMonth() + 1;
yyyy = date.getFullYear();
format = format.replace('dd', dd);
format = format.replace('mm', mm);
format = format.replace('yyyy', yyyy);
return format
}
function bi_script(url) {
document.write('<script type="text/javascript" src="' + url + '"><\/script>')
}
function bi_jshort(json) {
var blog = new Object();
var re = /<\S[^>]*>/g;
blog.id = json.feed.id.$t;
key = 'blog-';
index = blog.id.indexOf(key);
blog.id = blog.id.substring(index + key.length);
blog.id = blog.id.replace('.comments', '');
blog.cate = new Array();
if ('category' in json.feed) {
for (i = 0; i < json.feed.category.length; i++) {
blog.cate[i] = json.feed.category[i].term
}
}
blog.title = '';
if ('title' in json.feed) {
blog.title = json.feed.title.$t
}
blog.subtitle = '';
if ('subtitle' in json.feed) {
blog.subtitle = json.feed.subtitle.$t
}
blog.admin = new Object();
blog.admin.name = 'Anonymous';
blog.admin.uri = '';
blog.admin.avatar = 'http://img1.blogblog.com/img/anon36.png';
if ('name' in json.feed.author[0]) {
blog.admin.name = json.feed.author[0].name.$t
}
if ('uri' in json.feed.author[0]) {
blog.admin.uri = json.feed.author[0].uri.$t
}
if ('gd$image' in json.feed.author[0]) {
if (json.feed.author[0].gd$image.src != 'http://img1.blogblog.com/img/blank.gif') {
blog.admin.avatar = json.feed.author[0].gd$image.src
}
}
blog.total_entry = Number(json.feed.openSearch$totalResults.$t);
blog.start_index = Number(json.feed.openSearch$startIndex.$t);
blog.item_per_page = Number(json.feed.openSearch$itemsPerPage.$t);
blog.entry_number = 0;
if ('entry' in json.feed) {
blog.entry_number = json.feed.entry.length
}
blog.entry = new Array();
for (i = 0; i < blog.entry_number; i++) {
blog.entry[i] = new Object();
temp = new Object();
entry = json.feed.entry[i];
temp.id = entry.id.$t;
key = 'post-';
index = temp.id.indexOf(key);
temp.id = temp.id.substring(index + key.length);
temp.published = '';
if ('published' in entry) {
temp.published = entry.published.$t
}
temp.cate = new Array();
if ('category' in entry) {
for (j = 0; j < entry.category.length; j++) {
temp.cate[j] = entry.category[j].term
}
}
temp.title = '';
if ('title' in entry) {
temp.title = entry.title.$t
}
temp.content = '';
if ('content' in entry) {
temp.content = entry.content.$t
}
temp.summary = '';
if ('summary' in entry) {
temp.summary = entry.summary.$t
}
if (temp.summary == '') {
temp.summary = temp.content.replace(re, '')
}
if (temp.content == '') {
temp.content = temp.summary
}
temp.link = '';
temp.reply_label = 'comments';
if ('link' in entry) {
for (j = 0; j < entry.link.length; j++) {
if (entry.link[j].rel == 'alternate') {
temp.link = entry.link[j].href
}
if (entry.link[j].rel == 'replies') {
temp.reply_label = entry.link[j].title
}
}
}
temp.author = new Object();
temp.author.name = 'Anonymous';
temp.author.uri = '';
temp.author.avatar = 'http://img1.blogblog.com/img/anon36.png';
a0 = entry.author[0];
if ('name' in a0) {
temp.author.name = a0.name.$t
}
if ('uri' in a0) {
temp.author.uri = a0.uri.$t
}
if ('gd$image' in a0) {
if (a0.gd$image.src != 'http://img1.blogblog.com/img/blank.gif') {
temp.author.avatar = a0.gd$image.src
}
}
temp.thumbnail = '';
if ('media$thumbnail' in entry) {
temp.thumbnail = entry.media$thumbnail.url
}
temp.reply_number = 0;
if ('thr$total' in entry) {
temp.reply_number = Number(entry.thr$total.$t)
}
temp.reply_label = temp.reply_label.replace(temp.reply_number + ' ', '');
temp.reply_to = '';
temp.reply_json = '';
temp.reply_title = '';
if ('thr$in-reply-to' in entry) {
temp.reply_to = entry['thr$in-reply-to'].href;
temp.reply_json = entry['thr$in-reply-to'].source;
temp.reply_json = temp.reply_json.replace('/default/', '/summary/');
temp.reply_json = temp.reply_json + '?alt=json-in-script'
}
temp.pid = '';
if ('gd$extendedProperty' in entry) {
for (j = 0; j < entry.gd$extendedProperty.length; j++) {
if (entry.gd$extendedProperty[j].name == 'blogger.itemClass') {
temp.pid = entry.gd$extendedProperty[j].value
}
}
}
temp.pid = temp.pid.replace('pid-', '');
blog.entry[i] = temp
}
return blog
}
function bi_jmerge(jshort1, jshort2) {
for (i = 0; i < jshort2.entry_number; i++) {
jshort1.entry[i + jshort1.entry_number] = jshort2.entry[i]
}
jshort1.entry_number += jshort2.entry_number;
return jshort1
}
$('#logo-ads .widget.Image:first-child').each(function() {
image = $(this).find('img').parent('*').html();
$(this).html('<a href="/">' + image + '</a>')
});
var dd_level = -1;
var dd_html = '';
$('#drop-menu .widget li').each(function() {
text = $(this).text();
href = $(this).find('a').attr('href');
index = 0;
for (var i = 0; i < text.length; i++) {
index = text.indexOf('_', index);
if (index == -1) break;
index++
}
level = i;
if (level > dd_level) {
dd_html += '<ul>'
}
if (level < dd_level) {
offset = dd_level - level;
for (var i = 0; i < offset; i++) {
dd_html += '</ul></li>'
}
}
text = text.replace(/_/gi, '');
dd_html += '<li><a href="' + href + '">' + text + '</a>';
dd_level = level
});
for (var i = 0; i <= dd_level; i++) {
dd_html += '</ul>';
if (i != 0) {
dd_html += '</li>'
}
}
$('#drop-menu').html(dd_html);
$('#newsletter-follow .widget.LinkList a').each(function() {
href = $(this).attr('href');
if (href != null) {
if (href.indexOf('facebook.com') != -1) {
$(this).addClass('facebook')
} else if (href.indexOf('twitter.com') != -1) {
$(this).addClass('twitter')
} else if (href.indexOf('plus.google.com') != -1) {
$(this).addClass('plus')
} else {
$(this).addClass('other')
}
}
});
var Blog;
var Excluded = '';
var Label_List = [];
var Label_List_Index = 0;
var Home_Index_Html = '';
function home_index_optimize_image() {
var optimized_all = true;
$('.home-index .thumb img').each(function() {
src = $(this).attr('src');
if (src != null) {
if (src.indexOf('/s72-c/') != -1) {
src = src.replace('/s72-c/', '/s300-c/');
$(this).attr('src', src)
}
}
cl = $(this).attr('class');
var need = false;
if (cl != null) {
if (cl.indexOf('optimized') == -1) {
need = true
}
} else {
need = true
}
if (need) {
h = Number($(this).height());
w = Number($(this).width());
if (h == 0 || w == 0) {
optimized_all = false;
return
}
th = Number($(this).parents('.thumb').height());
tw = Number($(this).parents('.thumb').width());
if (h > w) {
$(this).css('width', tw + 'px');
h = (h / w) * tw;
margin_top = (th - h) / 2;
$(this).css('margin-top', margin_top + 'px')
} else {
$(this).css('height', th + 'px');
w = (w / h) * th;
margin_left = (tw - w) / 2;
$(this).css('margin-left', margin_left + 'px')
}
$(this).addClass('optimized')
}
});
if (!optimized_all) {
setTimeout(function() {
home_index_optimize_image()
}, 50)
}
}
function home_index_optimize_layout() {
$('.home-index .hot .item-0').each(function() {
$(this).css('height', 'auto')
});
$('.home-index .hot .item-0').each(function() {
height = $(this).parent('.hot').height();
$(this).css('height', height + 'px')
});
$('.home-index .wide .item-0').each(function() {
$(this).css('height', 'auto')
});
$('.home-index .wide .item-0').each(function() {
ph = Number($(this).parent('.wide').height());
lh = Number($(this).parent('.wide').find('.label-link').outerHeight());
padding = $(this).css('padding-top');
padding = padding.replace('px', '');
padding = Number(padding);
$(this).css('height', (ph - padding * 2 - lh) + 'px')
})
}
function home_index_show(json) {
Blog = bi_jshort(json);
for (var i = 0; i < Label_List_Index; i++) {
var total_add = 0;
var html_add = '';
for (var j = 0; j < Blog.entry_number; j++) {
entry = Blog.entry[j];
if (Excluded.indexOf(entry.id) != -1) continue;
for (var k = 0; k < entry.cate.length; k++) {
if (entry.cate[k] == Label_List[i].text) {
Excluded += entry.id + ',';
var image = bi_get_first_image(entry.content);
if (image == '') image = entry.thumbnail;
if (image == '') {
image = no_thumb
}
html_add += '<div class="item item-' + total_add + '">';
if (image != '') {
image = '<img src="' + image + '"/>';
html_add += '<div class="thumb"><a href="' + entry.link + '">' + image + '</a></div>'
}
html_add += '<h2 class="title"><a href="' + entry.link + '">' + entry.title + '</a></h2>';
html_add += '<div class="meta">';
html_add += entry.author.name + ', ' + bi_date_format(entry.published, date_format);
if (entry.reply_number > 0) {
html_add += ', ' + entry.reply_number + ' ' + entry.reply_label
}
html_add += '</div>';
if (i == 0 && total_add == 0) {
var snip = entry.summary;
if (snip.length > snip_length) {
snip = snip.substring(0, snip_length)
}
snip += '...';
html_add += '<p class="snip">' + snip + '</p>'
}
html_add += '<div class="clear"></div></div>';
total_add++;
break
}
}
if (total_add == 6 || (i != 0 && total_add == 5)) {
break
}
}
if (i != 0) {
html_add = '<div class="label-link"><a href="' + Label_List[i].href + '">' + Label_List[i].text + '</a></div>' + html_add
}
html_add += '<div class="clear"></div>';
if (i == 0) {
html_add = '<div class="hot">' + html_add + '</div>'
} else {
var index = i - 1;
if (index % 3 == 0) {
html_add = '<div class="wide">' + html_add + '</div>'
} else if (index % 3 == 1) {
if (index + 2 == Label_List_Index) {
html_add = '<div class="wide">' + html_add + '</div>'
} else {
html_add = '<div class="small small-first">' + html_add + '</div>'
}
} else if (index % 3 == 2) {
html_add = '<div class="small small-last">' + html_add + '</div>'
}
}
Home_Index_Html += html_add
}
$('.home-index').html(Home_Index_Html);
home_index_optimize_image();
home_index_optimize_layout()
}
$('.home-index').each(function() {
Label_List[Label_List_Index] = new Object();
Label_List[Label_List_Index].href = '/search/label/Hot';
Label_List[Label_List_Index].text = 'Hot';
Label_List_Index++;
$('#main .widget.Label ul li a').each(function() {
href = $(this).attr('href');
text = $(this).text();
for (var i = 0; i < Label_List_Index; i++) {
if (Label_List[i].text == text) break
}
if (i >= Label_List_Index) {
Label_List[Label_List_Index] = new Object();
Label_List[Label_List_Index].href = href;
Label_List[Label_List_Index].text = text;
Label_List_Index++
}
});
bi_script('/feeds/posts/default?alt=json-in-script&max-results=500&callback=home_index_show')
});
function post_index_optimize_image() {
var optimized_all = true;
$('.post-index .index-thumbnail img').each(function() {
src = $(this).attr('src');
if (src != null) {
if (src.indexOf('/s72-c/') != -1) {
src = src.replace('/s72-c/', '/s300-c/');
$(this).attr('src', src)
}
}
var cl = $(this).attr('class');
var src = $(this).attr('src');
if (src != null && src.indexOf('youtube.com') != -1) {
src = src.replace('/default.', '/mqdefault.');
$(this).attr('src', src)
}
var need = false;
if (cl != null) {
if (cl.indexOf('optimized') == -1) {
need = true
}
} else {
need = true
}
if (need) {
h = Number($(this).height());
w = Number($(this).width());
if (h == 0 || w == 0) {
optimized_all = false;
return
}
th = Number($(this).parents('.index-thumbnail').height());
tw = Number($(this).parents('.index-thumbnail').width());
if (h > w) {
$(this).css('width', tw + 'px');
h = (h / w) * tw;
margin_top = (th - h) / 2;
$(this).css('margin-top', margin_top + 'px')
} else {
$(this).css('height', th + 'px');
w = (w / h) * th;
margin_left = (tw - w) / 2;
$(this).css('margin-left', margin_left + 'px')
}
$(this).addClass('optimized')
}
});
if (!optimized_all) {
setTimeout(function() {
post_index_optimize_image()
}, 50)
}
}
post_index_optimize_image();
var search_html = '<form method="get" id="search-form" action="' + search_engine + '" target="_blank" class="gsc-search-box" accept-charset="utf-8" ><table cellspacing="0" cellpadding="0" class="gsc-search-box"><tbody><tr><td class="gsc-input"><input id="search-query" placeholder="Type keywords" autocomplete="on" type="text" size="10" class="gsc-input" name="q" title="search"></td><td class="gsc-search-button"><input type="submit" value="Search" class="gsc-search-button" title="search"></td></tr></tbody></table></form>';
$('#page-list-search .CustomSearch').html(search_html);
$('#search-form').submit(function() {
val = $('#search-query').val();
hn = window.location.hostname;
hn = substr_(hn, '://');
hn = substr_(hn, 'www.');
val = val.replace(' site:' + hn, '');
val += (' site:' + hn);
$('#search-query').val(val);
return true
});
$('#search-query').focus(function() {
val = $(this).val();
hn = window.location.hostname;
hn = substr_(hn, '://');
hn = substr_(hn, 'www.');
val = val.replace(' site:' + hn, '');
$('#search-query').val(val)
});
$(window).resize(function() {
$('img').removeClass('optimized');
home_index_optimize_image();
post_index_optimize_image()
});
var main_color = $('#blog-copyright').css('color');
var bi_license = false;
$('#footer .meta a#bi-license').each(function() {
bi_license = true;
style = 'height:10px;background:none!important;color:' + main_color + '!important;display:inline!important;font-size:12px!important;position:initial!important;visibility:visible!important;margin:0!important;opacity:1!important;filter:alpha(opacity=100)!important';
$(this).attr('style', style);
$(this).attr('href', 'http://bloggeritems.com/templates/easy-news-responsive-magazine-blogger-template')
});
if (!bi_license) {
var html_copy = '<a style="background: none!important;color: #999!important;display: block!important;font-size: 10px!important;font-weight: bold!important;height: 16px!important;line-height: 16px!important;margin-bottom: 0px!important;margin-left: 0px!important;margin-right: 0px!important;margin-top: 0px!important;text-align: right!important;visibility:visible!important;opacity:1!important;filter:alpha(opacity=100)!important;" href="http://bloggeritems.com/templates/easy-news-responsive-magazine-blogger-template" target="_blank" rel="dofollow">Templated by Blogger Items</a>';
$('body').append(html_copy)
}