Skip to content

Instantly share code, notes, and snippets.

View ShuvoHabib's full-sized avatar

Habib ShuvoHabib

  • Deriv
  • Dhaka, Bangladesh
View GitHub Profile
@ShuvoHabib
ShuvoHabib / detectOutsideClick.js
Last active January 18, 2018 12:54
Detect Outside Click and remove Dropdown
$('.cyan-right-icon').click(function (event) {
event.stopPropagation();
$(this).parent().toggleClass('right-margin');
$(".box-fake-chat").toggleClass('show');
});
// For All the devices including Safari, chrome, firefox
jQuery(document).on('click touchend touchstart','body', function (e) {
var target = e.target; //target div recorded
if ($('.box-fake-chat').hasClass("show")) {
@ShuvoHabib
ShuvoHabib / fixedFooter.js
Created January 24, 2018 04:20
Fixed footer in bottom jQuery Solution
var footerTag = $('footer.nb-footer');
var footerHeight = footerTag.height();
var bodyHeight = $(document).height();
if ((bodyHeight - footerHeight + 200) > $(window).height()) {
$(footerTag).css('position', 'relative');
} else {
$(footerTag).css('position', 'absolute');
}
@ShuvoHabib
ShuvoHabib / optimizelyDeviceDetector.js
Created February 14, 2018 09:36
Optimizely Device Detector Segment
(function(){
var deviceDetector = (function () {
var ua = navigator.userAgent.toLowerCase();
var detect = (function(s) {
if(s===undefined){
s=ua;
} else {
ua = s.toLowerCase();
}
if(/(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(ua)){
@ShuvoHabib
ShuvoHabib / incrementCookieOnPageRefresh.js
Last active February 16, 2018 14:25
Increment Cookie on Page Refresh
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
var expires = "expires=" + d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
function readCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
(function() {
if (window.location.hostname === "www.google.co.uk") {
if (window.location.href.indexOf("/links") > -1) {
document.body.style.opacity = "0";
var redirectURL = window.location.href.replace("//www.","//www1.");
console.log(redirectURL);
var expQueryParams = "alpha=1";
var queryParams = (redirectURL.indexOf("?") === -1) ? "?" + expQueryParams : "&" + expQueryParams;
redirectURL += queryParams;
window.location.replace(redirectURL);
Html
_____
<ul>
<li>
<a href="http://help.marksandspencer.com/support/legal-and-ethical/privacy-policy1">aa</a>
</li>
<li>
<a href="http://help.marksandspencer.com/support/legal-and-ethical/privacy-policy1">aa</a>
</li>
<li>
@ShuvoHabib
ShuvoHabib / start.js
Created May 21, 2018 08:30
ALL HTML, CSS and JS in one file
var TestName = {
init: function() {
this.TestNameCss(true);
this.mainJS();
},
TestNameCss: function(applyCss) {
if(applyCss){
var mainCss = '';
var headofdoc = document.getElementsByTagName('head')[0];
var s = document.createElement('style');
@ShuvoHabib
ShuvoHabib / checkbox.js
Created June 22, 2018 11:31
Check Box onclick value change
$("#squaredTwo").click(function(){
if(jQuery(this).val() === "unchecked") {
$(this).attr('value', 'checked');
console.log(jQuery("#squaredTwo").val());
} else {
$(this).attr('value', 'unchecked');
console.log(jQuery("#squaredTwo").val());
}
});
@ShuvoHabib
ShuvoHabib / threeColumn.html
Created June 27, 2018 12:05
Three Column Layout
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
box-sizing: border-box;
}
/* Create three equal columns that floats next to each other */
@ShuvoHabib
ShuvoHabib / masonarycolumn.html
Created June 28, 2018 10:40
Bootstrap Masonary column Like Pinterest
<style>
.row.make-columns {
-moz-column-width: 19em;
-webkit-column-width: 19em;
-moz-column-gap: 1em;
-webkit-column-gap:1em;
}
.row.make-columns > div {
display: inline-block;