Skip to content

Instantly share code, notes, and snippets.

View ozknozsrt's full-sized avatar
🚀
Focusing

Özkan ÖZSERT ozknozsrt

🚀
Focusing
View GitHub Profile
@ozknozsrt
ozknozsrt / findGrandParent.js
Created November 8, 2023 14:26
findGrandParent
function findGrandParent(array, id) {
// Diziyi her bir eleman için döngüye sok
for (let i = 0; i < array.length; i++) {
// Eğer elemanın id'si aranan id ile eşitse, elemanı, üst nesneyi ve üst nesnenin üst nesnesini döndür
if (array[i].StepId === id) {
return { item: array[i], parent: array, grandParent: array.parent };
}
// Eğer elemanın Steps adında bir özelliği varsa, recursive olarak fonksiyonu çağır
if (array[i].Steps) {
// Recursive çağrı yapmadan önce, dizinin üst nesnesini Steps özelliğine ata
@ozknozsrt
ozknozsrt / index.js
Created September 5, 2023 10:36
window-onbeforeunload-not-working-on-the-ipad
// https://stackoverflow.com/questions/3239834/window-onbeforeunload-not-working-on-the-ipad
if (typeof (onbeforeunloadCallBack) === "function") {
//newWindow.onbeforeunload = function (param) {
// onbeforeunloadCallBack(param);
//}
var isOnIOS = navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPhone/i);
var eventName = isOnIOS ? "pagehide" : "beforeunload";
@ozknozsrt
ozknozsrt / index.js
Created June 8, 2023 07:24
knockout js ko component example
// wwwroot/js/ui-components klasörü açıp içinde her component'e özel dosyalar olabilir:
// alert-message.js
ko.components.register('alert-message', {
viewModel: function (params) {
var self = this;
self.css = params.css;
self.icon = params.icon;
self.text = params.text;
self.title = translate(`global.${self.icon}`);
},
@ozknozsrt
ozknozsrt / script.js
Created September 16, 2022 13:00
click outside with javascript composedPath()
const box = document.querySelector(".box");
document.addEventListener("click", function(e) {
if(e.composedPath().includes(box)) {
console.log("clicked inside it!")
} else {
console.log("clicked outside it!")
}
})
@ozknozsrt
ozknozsrt / es6-element-ready.js
Created June 9, 2022 14:55 — forked from jwilson8767/es6-element-ready.js
Wait for an element to exist. ES6, Promise, MutationObserver
// MIT Licensed
// Author: jwilson8767
/**
* Waits for an element satisfying selector to exist, then resolves promise with the element.
* Useful for resolving race conditions.
*
* @param selector
* @returns {Promise}
*/
@ozknozsrt
ozknozsrt / code-tag.txt
Created May 26, 2022 14:46 — forked from brun0xff/code-tag.txt
TODO: FIXME, HACK, and REVIEW
# Use TODO to note missing features or functionality that should be added at a later date.
# Use FIXME to note broken code that needs to be fixed.
# Use OPTIMIZE to note slow or inefficient code that may cause performance problems.
# Use HACK to note code smells where questionable coding practices were used and should be refactored away.
# Use REVIEW to note anything that should be looked at to confirm it is working as intended.
@ozknozsrt
ozknozsrt / inputmask.js
Created October 26, 2021 08:16
inputmask decimal options like for currency "100.000.000,00"
$(input).inputmask({
'alias': 'decimal',
'radixPoint': ',',
'groupSeparator': '.',
'autoGroup': true,
'rightAlign': false,
'digits': 2,
'suffix': ` ${bnvst.options.selectedCurrencySymbol}`,
'digitsOptional': false,
'placeholder': '0,00',
@ozknozsrt
ozknozsrt / selectpicker-collapsible.js
Created June 24, 2021 14:19
bootstrap-select (selectpicker) make collapsible with optgroup
// Selectpicker converts to collapsible when the inside has a optgroup
$('.selectpicker').on('shown.bs.select', function (e, clickedIndex, isSelected, previousValue) {
if ($(e.target).find("optgroup").length > 0) {
//.bootstrap-select .dropdown-menu .dropdown-header
$(e.target).closest(".bootstrap-select").find(".dropdown-menu .dropdown-header").click(function (e) {
e.stopImmediatePropagation();
var $this = $(this),
$thisOpt = $this.attr("class").split(" ")[1],
$opt = $this.siblings("li").not(".dropdown-header, .dropdown-divider");
@ozknozsrt
ozknozsrt / reduce.js
Created May 4, 2021 09:39
Group objects in Array using reduce
let meetingOriginal = [{
id: 19,
datetime: '2019-01-02T13:28:03+05:30',
status: 'proposed',
createdBy: 'buyer',
buyerId: 2,
buyerFirstName: 'Demo',
buyerLastName: 'User',
buyerProfileUrl: null,
petId: 1,
@ozknozsrt
ozknozsrt / readme.md
Last active September 20, 2020 15:13
How To Github delete a commit

How To Github delete a commit

Source YouTube link

1- Clone the repo to your machine.

git clone your_repo_link

2- Find ID of the commit which comes just before the commit which you want to delete.