Skip to content

Instantly share code, notes, and snippets.

View ridhotegar's full-sized avatar

Ridho Tegar Pambudi ridhotegar

View GitHub Profile
@ridhotegar
ridhotegar / show_hide.php
Last active December 1, 2019 12:50
Show Hide Post JS on Post Blog
<div>
<div style="margin-bottom: 2px;">
<b><small>klik ☛ </small></b><input onclick="if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = ''; this.innerText = ''; this.value = 'Hide'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = 'Show'; }" style="font-size: 10px; margin: 0px; padding: 0px; width: 60px;" type="button" value="Show" />
</div>
<div style="border: 1px inset; margin: 0px; padding: 0px;">
<div style="display: none;">
TEKS
</div>
@ridhotegar
ridhotegar / Foreach_Carousel.php
Last active September 11, 2022 22:28
Simple Foreach on Carousel Bootstrap
@ridhotegar
ridhotegar / Other_page.php
Created February 1, 2020 05:14
Simple OnLoad Loading JQuery CodeIgniter
Call With :
<?php $this->load->view('loading'); ?>
File location :
loading.php on views folder
Custom Call function :
$(".preloader").fadeIn();
Stop function :
@ridhotegar
ridhotegar / Manage Menu CI
Created November 20, 2020 06:48
Dinamic manage menu codeigniter
public function tes()
{
$this->load->view('menu/test');
}
public function result()
{
$id_group_pengguna = '1';
$this->db->update('my_menu', array('status' => '0'), array('id_group_pengguna' => $id_group_pengguna));
foreach ($this->input->post() as $name => $value) {
@ridhotegar
ridhotegar / Check_all_input.js
Last active December 23, 2021 05:07
validation all input
let checkInput = new Promise(function(solved, reject){
let istirahat = {}
try {
document.querySelectorAll('input').forEach(function(el, index){
if (!el.checkValidity()) {
alert(el.validationMessage)
el.focus()
throw istirahat
} else {
solved()
@ridhotegar
ridhotegar / Show_Hide_JQuery.js
Last active December 23, 2021 05:07
Simple show hide jquery
function deskripsi(id) {
if ( $('#deskripsi_'+id).is(':visible') ) {
$('#deskripsi_'+id).hide()
} else {
$('.deskripsi').hide()
$('#deskripsi_'+id).show()
}
}
@ridhotegar
ridhotegar / Date_Format.js
Last active December 23, 2021 05:06
Formatting date on JS
/*
waktu.add(*{format tanggal}, *{jenis}, *{jumlah penambahan}, {custom date / null})
waktu.add('DD, dd FF YY', 'dd', 1) | waktu.add('DD, dd FF YY', 'dd', 1, '2020-09-25 13:30:00')
waktu.set('dd-MM-YY') | waktu.set('dd/MM/YY H:i:s', '2020-09-25')
*/
var waktu = {
add : (format, jenis, plus, value = null) => {
let d = (value != null) ? new Date(value) : new Date();
@ridhotegar
ridhotegar / JQuery_Prototype_Property.js
Last active December 23, 2021 05:05
Sample constructor function Data table JQuery
$(document).ready(function() {
$.fn.setDt = function(){
this.dataTable({
"paging" : true,
"ordering" : false,
"info" : true,
"searching" : true
})
}
});
@ridhotegar
ridhotegar / Disable_All_Onclick_JQuery.js
Last active December 23, 2021 05:03
Disable all onclick on page html with jquery
let clickAct = []
const _do = {
disable: () => {
let el = $('[onclick]'), count = el.length
el.each((i, e) => {
$(e).addClass(`click_${i}`)
clickAct[i] = $(e).attr('onclick')
if(!--count) { el.removeAttr("onclick") }
})
},
@ridhotegar
ridhotegar / JQuery_File_Download.js
Last active December 23, 2021 05:02
XMLHttpRequest download with JQuery
$.ajax({
url: "https://file-examples-com.github.io/uploads/2017/02/zip_10MB.zip",
cache: false,
xhr: function(){
var xhr = new XMLHttpRequest();
xhr.responseType= 'blob';
xhr.onprogress = e => console.log(`${parseInt((e.loaded/e.total)*100)}%`)
return xhr;
},
success: e => console.log('done')