Skip to content

Instantly share code, notes, and snippets.

View fczbkk's full-sized avatar
💭
writing Javascript

Riki Fridrich fczbkk

💭
writing Javascript
View GitHub Profile
@fczbkk
fczbkk / jquery-iife.js
Created July 18, 2019 11:59
Jquery IIFE
var Jquery = {/* kód Jquery */}
var $ = {/* kód inej knižnice */}
(function ($) {
// v tomto bloku mám prístup k metódam Jquery cez $ ...
})(Jquery)
// ... zatiaľ čo mimo blok (v globálnom namespace) $ stále odkazuje na inú knižnicu, Jquery nič neprepísalo
@fczbkk
fczbkk / counter.js
Last active December 10, 2018 03:08
/**
* Creates a simple counter that starts at 0 and is raised by 1 on each bump.
* @return {{getCurrentValue: (function(): number), bump: (function(): number)}}
* @example
* const myCounter = createCounter()
* myCounter.getCurrentValue() // 0
* myCounter.bump() // 1
* myCounter.bump() // 2
* myCounter.getCurrentValue() // 2
*/
@fczbkk
fczbkk / keybase.md
Created July 23, 2018 12:33
keybase.md

Keybase proof

I hereby claim:

  • I am fczbkk on github.
  • I am fczbkk (https://keybase.io/fczbkk) on keybase.
  • I have a public key ASBd_Qk2_rbwia5PRg3r_55K6bwSNGMGQgCT0l6UD87YYwo

To claim this, I am signing this object:

@fczbkk
fczbkk / step_callback.js
Created July 6, 2017 07:53
Conditional step skip for Inline Manual Player
function customSkipStep (player, topic_id, step_index) {
if (my_element_exists) {
my_player.activateStep(my_topic_id, my_step_index);
return false;
}
return true;
}
@fczbkk
fczbkk / unlimited_undo.js
Last active June 27, 2017 06:24
Inline Manual Player: unlimited undo
// take latest step from the list of previous steps and activate it
function activatePreviousStep () {
var steps_history = JSON.parse(localStorage.getItem('inm_steps_history')) || [];
var step_data = steps_history.pop();
if (step_data) {
inline_manual_player.activateStep(step_data.topic_id, step_data.step_index);
}
localStorage.setItem('inm_steps_history', JSON.stringify(steps_history));
}
@fczbkk
fczbkk / simple_undo.js
Last active June 27, 2017 06:03
Inline Manual Player: simple undo
// call this function to display previous step
function activatePreviousStep () {
var previous_topic = localStorage.getItem('inm_previous_topic');
var previous_step = localStorage.getItem('inm_previous_step');
inline_manual_player.activateStep(previous_topic, previous_step);
}
// remember topic/step whenever step is deactivated
// e.g. when user goes to next step
inline_manual_player.setOptions({
@fczbkk
fczbkk / index.html
Created May 22, 2017 06:49
Simple extensible form validation
<html>
<head>
<script>
/**
* @typedef {Object} validation_result
* @property {('ok'|'fail')} status
* @property {string} [message]
*/
@fczbkk
fczbkk / test1.html
Last active January 13, 2016 15:16
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<div>
<p id="myElement">First paragraph.</p>
@fczbkk
fczbkk / minified.js
Last active January 27, 2016 06:13
Inline Manual Player embed code
!function(){var e=document.createElement("script"),t=document.getElementsByTagName("script")[0];e.async=1,e.src="https://inlinemanual.com/embed/player.js",e.charset="UTF-8",t.parentNode.insertBefore(e,t)}();
@fczbkk
fczbkk / is_array.coffee
Created August 24, 2014 05:07
Cross browser bridge to check, if provided object is an array.
isArray = Array.isArray or (obj) -> Object::toString.call obj is '[object Array]'