Skip to content

Instantly share code, notes, and snippets.

View davodaslanifakor's full-sized avatar
🔬
Work at office

Davod Aslani Fakor davodaslanifakor

🔬
Work at office
View GitHub Profile
@adhithyan15
adhithyan15 / countdown.js
Last active May 10, 2024 09:35
A simple countdown timer in Javascript
/********************************************************************************************************************
Countdown.js is a simple script to add a countdown timer
for your website. Currently it can only do full minutes
and partial minutes aren't supported. This script is a fork of http://jsfiddle.net/HRrYG/ with some
added extensions. Since the original code that I forked was released under Creative Commons by SA license,
I have to release this code under the same license. You can view a live demo of this code at http://jsfiddle.net/JmrQE/2/.
********************************************************************************************************************/
function countdown(minutes) {
var seconds = 60;
var mins = minutes
@simonewebdesign
simonewebdesign / scroll.html
Last active October 8, 2023 15:32
Scrolling feature for a web chat, without using libraries.It behaves like Skype: if the user is way too far from the bottom, it just doesn't scroll, because the user may be reading old posts.On the other hand, it will automatically scroll to the bottom on a "new message" event (in this demo, on button's click event).
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<style>
.content {
@Erichain
Erichain / msconvert.js
Last active December 25, 2023 19:15 — forked from remino/msconvert.js
JavaScript: Convert milliseconds to object with days, hours, minutes, and seconds
function convertMS( milliseconds ) {
var day, hour, minute, seconds;
seconds = Math.floor(milliseconds / 1000);
minute = Math.floor(seconds / 60);
seconds = seconds % 60;
hour = Math.floor(minute / 60);
minute = minute % 60;
day = Math.floor(hour / 24);
hour = hour % 24;
return {
@fgilio
fgilio / axios-catch-error.js
Last active August 15, 2024 01:45
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
@Gregg
Gregg / timeout.js
Created October 11, 2018 14:53
Example of how to clear a timeout on beforeDestroy
var Component = {
mounted() {
this.setTimeOutClose()
},
beforeDestroy() {
clearTimeout(this.timeout);
},
data() {
return {
timeout: null
@amir9480
amir9480 / helpers.js
Created November 15, 2018 08:16
javascript helpers
window.enToFa = function (text) {
text = String(text);
text = text.replace(/0/g, '۰');
text = text.replace(/1/g, '۱');
text = text.replace(/2/g, '۲');
text = text.replace(/3/g, '۳');
text = text.replace(/4/g, '۴');
text = text.replace(/5/g, '۵');
text = text.replace(/6/g, '۶');
text = text.replace(/7/g, '۷');
@AnalyzePlatypus
AnalyzePlatypus / vue-click-outside.md
Last active April 27, 2024 05:32
Vue.js 2.7: Detect clicks outside an element (Close modals, popups, etc.)

Detecting outside clicks in Vue.js

See this StackOverflow thread

First off, include the directive at the end of this gist.

  1. On your open button, make sure to use @click.stop to prevent the open click event from closing your modal.
  2. On your modal, add the v-click-outside directive and points it at a function to call when clicked outside.

Example: