This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function merge(mainObject) { | |
for (var i = 1; i < arguments.length; i++) { | |
for (var key in arguments[i]){ | |
mainObject[key] = arguments[i][key]; | |
} | |
} | |
return mainObject | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function truncate($text, $limit = 150, $elips = '...') | |
{ | |
$text = html_entity_decode($text, ENT_COMPAT | ENT_HTML401, 'UTF-8'); | |
$len = strlen($text); | |
if ($len > $limit) { | |
preg_match('/(.{' . $limit . '}.*?)\b/', $text, $matches); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hasClass(element, className) { | |
return element.className && new RegExp("(^|\\s)" + className + "(\\s|$)").test(element.className); | |
} | |
var myDiv = document.getElementById('MyDiv'); | |
hasClass(myDiv, 'active'); | |
// OR |