Skip to content

Instantly share code, notes, and snippets.

@CoolS2
CoolS2 / top_links.md
Last active September 13, 2024 07:23
Tops
function when_external_loaded (callback) {
if (typeof videoOptions === 'undefined') {
setTimeout (function () {
when_external_loaded (callback);
}, 500); // wait 100 ms
} else { callback (); }
}
when_external_loaded (function () {
setTimeout(videoOptions(ads, device, startTime, intervalTime, muteTab), 500);
@CoolS2
CoolS2 / Social buttons.txt
Created January 12, 2017 14:14
Social buttons
<div class="share-buttons">
<a class="share-btn-fb" href="http://www.facebook.com/sharer/sharer.php?s=100&p%5Btitle%5D=<?=get_the_title($id)?>&p%5Bsummary%5D=DESC&p%5Burl%5D=<?=$actual_link?>&p%5Bimages%5D%5B0%5D=<?=wp_get_attachment_image_src( get_post_thumbnail_id($id), 'medium' )[0]?>" onclick="return !window.open(this.href, 'Facebook', 'width=640,height=580')">
<div class="facebook share-block">
<i class="fa fa-facebook" aria-hidden="true"></i>
</div>
</a>
<a href="http://vk.com/share.php?url=<?=$actual_link?>&title=<?=get_the_title($id)?>&description=<?=get_the_excerpt($id)?>&image=<?=wp_get_attachment_image_src( get_post_thumbnail_id($id), 'medium' )[0]?>&noparse=true" target="_blank" onclick="return Share.me(this);">
<div class="vk share-block">
<i class="fa fa-vk" aria-hidden="true"></i>
</div>
$(document).mouseup(function (e){
var lang = $(".dropdown-lang");
if (!lang.is(e.target) // if the target of the click isn't the container...
&& lang.has(e.target).length === 0) // ... nor a descendant of the container
{
lang.hide();
}
});
$.fn.followTo = function (pos) {
var $this = this,
$window = $(window);
$window.scroll(function (e) {
if ($window.scrollTop() > pos) {
$this.css({
position: 'absolute',
top: pos
});
@CoolS2
CoolS2 / Text from url
Last active August 1, 2016 12:56
Text from url on javascript
// Option 1
var url = "http://mywebsite.com/extractMe/test";
var extractedText = url.split("/")[3];
​// Option 2
// If when a trailing slash is present you want to return "test", use this code
var url = "http://mywebsite.com/extractMe/test/";
var urlAry = url.split("/");
var extractedText = urlAry[urlAry.length - 2];
flowplayer(function (api, root) {
var fsbutton = document.createElement("a"),
anchors = root.getElementsByTagName("a"),
divs = root.getElementsByTagName("div"),
i, elem;
fsbutton.className = "fp-fullscreen";
for (i = 0; i < anchors.length; i += 1) {