Skip to content

Instantly share code, notes, and snippets.

@haidv35
Created September 17, 2017 13:52
Show Gist options
  • Save haidv35/fb2457f01f7f726e52593fbd162f7e8a to your computer and use it in GitHub Desktop.
Save haidv35/fb2457f01f7f726e52593fbd162f7e8a to your computer and use it in GitHub Desktop.
haiclover.js
//<![CDATA[
var summary = 76;
jQuery(document)["ready"](function($){$(window)["load"](function(){
jQuery(".slides")["addClass"]("loaded")});var aboveHeight=$("#leader-wrapper")["outerHeight"]()
;$(window)["scroll"](function(){
})});
function stripHtmlTags(e, r) {
return e["replace"](/<.*?>/gi, "")["split"](/\s+/)["slice"](0, r - 1)["join"](" ")
}
function bintiz(e, r, t, s, i) {
var n = t,
r = r,
l = document["getElementById"](e),
m = l["innerHTML"];
if (/<!--\s*more\s*-->/ ["test"](m)) {
l["innerHTML"] = getSummaryLikeWP(e)
} else {
{
var c = ""
}
var o = "<p>" + stripHtmlTags(m, summary) + "... </p>";
l["innerHTML"] = o;
};
}
rcomment = "comments";
rdisable = "disable comments";
commentYN = "no";
var dw = "";
titles = new Array;
titlesNum = 0;
urls = new Array;
timeR = new Array;
thumb = new Array;
commentsNum = new Array;
comments = new Array;
function related_results_labels(c) {
for (var b = 0; b < c.feed.entry.length; b++) {
var d = c.feed.entry[b];
titles[titlesNum] = d.title.$t;
for (var a = 0; a < d.link.length; a++) {
if ("thr$total" in d) commentsNum[titlesNum] = d.thr$total.$t + " " + rcomment;
else commentsNum[titlesNum] = rdisable;
if (d.link[a].rel == "alternate") {
urls[titlesNum] = d.link[a].href;
timeR[titlesNum] = d.published.$t;
if ("media$thumbnail" in d) thumb[titlesNum] = d.media$thumbnail.url;
else thumb[titlesNum] = "http://lh3.ggpht.com/--Z8SVBQZ4X8/TdDxPVMl_sI/AAAAAAAAAAA/jhAgjCpZtRQ/no-image.png";
titlesNum++;
break
}
}
}
}
function removeRelatedDuplicates() {
var b = new Array(0);
c = new Array(0);
e = new Array(0);
f = new Array(0);
g = new Array(0);
for (var a = 0; a < urls.length; a++) if (!contains(b, urls[a])) {
b.length += 1;
b[b.length - 1] = urls[a];
c.length += 1;
c[c.length - 1] = titles[a];
e.length += 1;
e[e.length - 1] = timeR[a];
f.length += 1;
f[f.length - 1] = thumb[a];
g.length += 1;
g[g.length - 1] = commentsNum[a]
}
urls = b;
titles = c;
timeR = e;
thumb = f;
commentsNum = g
}
function contains(b, d) {
for (var c = 0; c < b.length; c++) if (b[c] == d) return true;
return false
}
function printRelatedLabels(a) {
var y = a.indexOf("?m=0");
if (y != -1) a = a.replace(/\?m=0/g, "");
for (var b = 0; b < urls.length; b++) if (urls[b] == a) {
urls.splice(b, 1);
titles.splice(b, 1);
timeR.splice(b, 1);
thumb.splice(b, 1);
commentsNum.splice(b, 1)
}
var c = Math.floor((titles.length - 1) * Math.random());
var b = 0;
if (titles.length == 0) dw += rn;
else {
dw += ry;
dw += "<ul>";
while (b < titles.length && b < 20 && b < maxresults) {
if (y != -1) urls[c] = urls[c] + "?m=0";
if (commentYN == "yes") comments[c] = " - " + commentsNum[c];
else comments[c] = "";
dw += '<li class="related_gallery in-lefter"><a href="' + urls[c] + '" title="' + titles[c] + '" rel="nofollow" class="related-thumbs"><img alt="' + titles[c] + '" src="' + thumb[c].replace(/\/s72\-c/, "/s" + size + "") + '"/></a><a class="related-title" href="' + urls[c] + '">' + titles[c] + "</a></li></div>";
if (c < titles.length - 1) c++;
else c = 0;
b++
}
dw += "</ul>"
}
urls.splice(0, urls.length);
titles.splice(0, titles.length);
document.getElementById("related-article").innerHTML = dw
};
function ShowPost1(_19) { (function (_4) {
var _0 = {
blogURL: "",
MaxPost: 5,
idcontaint: "",
FirstImageSize: 300,
ImageSize: 300,
Summarylength: 120,
animated: false,
loadingClass: "loadingz",
pBlank: "http://2.bp.blogspot.com/-RFdFqW5Klsc/UitLuFMcVxI/AAAAAAAADpM/y5UnpsxUSrc/s1600/noimgs.jpg",
MonthNames: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
tagName: true
};
_0 = _4["extend"]({},
_0, _19);
var _8 = _4(_0["idcontaint"]);
_8["html"]("<div class=\"box-content\"><ul></ul></div>")["addClass"](_0["loadingClass"]);
_4["get"]((_0["blogURL"] === "" ? window["location"]["protocol"] + "//" + window["location"]["host"] : _0["blogURL"]) + "/feeds/posts/summary" + (_0["tagName"] === false ? "": "/-/" + _0["tagName"]) + "?max-results=" + _0["MaxPost"] + "&orderby=published&alt=json-in-script", function (_21) {
var _9, _10, _6, _20, _3, _14, _7, _15, _17, _11, _16, _5, _22, _18, _13 = "",
_2 = _21["feed"]["entry"];
for (var _1 = 0; _1 < _2["length"]; _1++) {
for (var _12 = 0; _12 < _2[_1]["link"]["length"]; _12++) {
if (_2[_1]["link"][_12]["rel"] == "alternate") {
_9 = _2[_1]["link"][_12]["href"];
break
}
};
for (var _5 = 0; _5 < _12; _5++) {
if (_2[_1]["link"][_5]["rel"] == "replies" && _2[_1]["link"][_5]["type"] == "text/html") {
_20 = _2[_1]["link"][_5]["title"]["split"](" ")[0];
break
}
};
if ("media$thumbnail" in _2[_1]) {
_3 = _2[_1]["media$thumbnail"]["url"]
} else {
_3 = _0["pBlank"]
};
if ("content" in _2[_1]) {
_6 = _2[_1]["content"]["$t"]
} else {
if ("summary" in _2[_1]) {
_6 = _2[_1]["summary"]["$t"]
} else {
_6 = ""
}
};
_6 = _6["replace"](/<\S[^>]*>/g, "");
if (_6["length"] > _0["Summarylength"]) {
_6 = _6["substring"](0, _0.Summarylength) + "..."
};
if (_2[_1] === _2[0]) {
_3 = _3["replace"](/\/s[0-9]+\-c/g, "/s" + _0["FirstImageSize"] + "-p");
if (_3["indexOf"]("i.ytimg.com/vi/") != -1) {
_3 = _3["replace"]("default", "0")
};
_7 = "<p>" + _6 + "</p>"
} else {
_3 = _3["replace"](/\/s[0-9]+\-c/g, "/s" + _0["ImageSize"] + "-p");
_7 = ""
};
_10 = _2[_1]["title"]["$t"];
_18 = _2[_1]["author"][0]["gd$image"]["src"];
_5 = _2[_1]["published"]["$t"]["substring"](0, 10);
_15 = _5["substring"](0, 4);
_17 = _5["substring"](5, 7);
_11 = _5["substring"](8, 10);
_16 = _0["MonthNames"][parseInt(_17, 10) - 1];
_14 = "<div class=\"uj_thumb\"><a title=\"" + _10 + "\" class=\" \" href=\"" + _9 + "\"><img src=\"" + _3 + "\"/></span></a></div>";
j = "<a class=\"more-link\" href=\"" + _9 + "\">Read More</a>";
_13 += "<li><div class=\"inner-content\" >" + _14 + "<div class=\"denz\"><h2><a href=\"" + _9 + "\">" + _10 + "</a></h2><span class=\"post-meta\"> <span class=\"dd\"> <i class=\"fa fa-calendar-o\"></i> " + _11 + "</span> <span class=\"dm\">" + _16 + "</span> <span class=\"dy\">" + _15 + " <i class=\"fa fa-dasho\"> - </i> </span> <span class=\"comt\"> <i class=\"fa fa-comment-o\"></i> " + _20 + " comment</span> </span></div>" + _7 + "</div></li>"
};
_4("ul", _8)["append"](_13);
_4(_0["idcontaint"] + " li:first-child .uj_thumb")["hover"](function () {
_4(_0["idcontaint"])["find"](".nb_slide_icon ")["stop"]()["animate"]({
top: 0
},
{
queue: false,
duration: 300
})
},
function () {
_4(_0["idcontaint"])["find"](".nb_slide_icon ")["stop"]()["animate"]({
top: "-60px"
},
{
queue: false,
duration: 300
})
});
_8["removeClass"](_0["loadingClass"])
},
"jsonp")
})(jQuery)
};
$(document).ready(function () {
var w = 726;
var h = 290;
$('.bukshan,.bukshan img').find('img').each(function (n, image) {
var image = $(image);
image.attr({
src: image.attr('src').replace(/s\B\d{2,4}/, 'w' + w + '-h' + h + '-c')
});
image.attr('width', w);
image.attr('height', h);
});
});
$(document).ready(function()
{
$(".with-ul").click(function()
{
var X=$(this).attr('id');
if(X==1)
{
$(".sub-menu").hide();
$(this).attr('id', '0');
}
else
{
$(".sub-menu").show();
$(this).attr('id', '1');
}
});
$(".sub-menu").mouseup(function()
{
return false
});
$(".with-ul").mouseup(function()
{
return false
});
$(document).mouseup(function()
{
$(".sub-menu").hide();
$(".with-ul").attr('id', '');
});
});
$(document).ready(function(){
$('.dropdown').each(function() {
var $dropdown = $(this);
$(".dropdown-link", $dropdown).click(function(e) {
e.preventDefault();
$div = $(".dropdown-container", $dropdown);
$div.toggle();
$(".dropdown-container").not($div).hide();
return false;
});
});
$('html').click(function(){
$(".dropdown-container").hide();
});
});
$(document).ready(function () {
var touch = $('#duled');
var menu = $('.menu');
$(touch).on('click', function (e) {
e.preventDefault();
menu.slideToggle();
});
$(window).resize(function () {
var w = $(window).width();
if (w > 800 && menu.is(':hidden')) {
menu.removeAttr('style');
}
});
});
$(document).ready(function () {
var touch = $('#duled1');
var menu = $('.Pagemenu');
$(touch).on('click', function (e) {
e.preventDefault();
menu.slideToggle();
});
$(window).resize(function () {
var w = $(window).width();
if (w > 800 && menu.is(':hidden')) {
menu.removeAttr('style');
}
});
});
$(function() {
$.fn.scrollToTop = function() {
$(this).hide().removeAttr("href");
if ($(window).scrollTop() != "0") {
$(this).fadeIn("slow")}
var scrollDiv = $(this);
$(window).scroll(function() {
if ($(window).scrollTop() == "0") {
$(scrollDiv).fadeOut("slow")
} else { $(scrollDiv).fadeIn("slow") } });
$(this).click(function() {
$("html, body").animate({ scrollTop: 0 }, "slow")
})
}
});
$(function() {
$("#MD-StoTop").scrollToTop();
});
var lastScroll = 0;
jQuery(document).ready(function($) {
$(".backer").addClass("default23");
$(window).scroll(function(){
var scroll = $(window).scrollTop();
if (scroll > lastScroll) {
$(".backer").removeClass("default23").addClass("fixed23");
} else if (scroll < lastScroll) {
$(".backer").addClass("default23").removeClass("fixed23");
}
lastScroll = scroll;
});
});
var numpost = 5;
function rcpost(json){var entry=json.feed.entry,posturl;for(var i=0;i<numpost;i++){for(var j=0;j<entry[i].link.length;j++){if(entry[i].link[j].rel=='alternate'){posturl=entry[i].link[j].href;break;}}
var poststitle=entry[i].title.$t;document.write('<li><a href="'+posturl+'" rel="nofollow">'+poststitle+'</a></li>');}}
function av(a){var b=a.entry.author[0];c=b.name.$t;d=b.gd$image.src.replace(/\/s[0-9]+(-*c*)\//,'/s30$1/');document.write('<img alt="'+c+'" class="avatar-author" src="'+d+'" title="'+c+'"/>')}
function copyTextToClipboard(text) {
var textArea = document.createElement("textarea");
textArea.style.position = 'fixed';
textArea.style.top = 0;
textArea.style.left = 0;
textArea.style.width = '2em';
textArea.style.height = '2em';
textArea.style.padding = 0;
textArea.style.border = 'none';
textArea.style.outline = 'none';
textArea.style.boxShadow = 'none';
textArea.style.background = 'transparent';
textArea.value = text;
document.body.appendChild(textArea);
textArea.select();
try {
var successful = document.execCommand('copy');
var msg = alert("Đã sao chép liên kết!");
} catch (err) {
var msg = alert("Không thể sao chép liên kết!");
}
document.body.removeChild(textArea);
}
function CopyLink() {
copyTextToClipboard(location.href);
}
jQuery(document).ready(function($){
//open popup
$('.cd-popup-trigger').on('click', function(event){
event.preventDefault();
$('.cd-popup').addClass('is-visible');
});
//close popup
$('.cd-popup').on('click', function(event){
if( $(event.target).is('.cd-popup-close') || $(event.target).is('.cd-popup') ) {
event.preventDefault();
$(this).removeClass('is-visible');
}
});
$('.cd-popup').on('click', function(event){
if( $(event.target).is('.clickbutton') || $(event.target).is('.cd-popup') ) {
event.preventDefault();
$(this).removeClass('is-visible');
}
});
//close popup when clicking the esc keyboard button
$(document).keyup(function(event){
if(event.which=='27'){
$('.cd-popup').removeClass('is-visible');
}
});
});
//]]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment