Skip to content

Instantly share code, notes, and snippets.

@nicco88
nicco88 / socialBox.js
Last active December 25, 2016 06:52
Social box disappearing
window.onscroll = function(){scrollStop()};
function scrollStop(){
var socialBox = document.getElementsByClassName("indexadv")[0];
var breakingPoint = document.body.offsetHeight - document.getElementById("footer").offsetHeight;
var socialBoxHeight = socialBox.clientHeight;
if ((document.body.scrollTop + socialBoxHeight + 50) > breakingPoint){
socialBox.style.display = "none";
} else {
socialBox.style.display = "block";
@nicco88
nicco88 / gist:ba8e41d8d2f9319747eef17fd4e69e48
Last active December 21, 2016 08:11
Form able / disable
<!-- Payment options -->
<div id="payment-methods">
<!-- Payment Form -->
<form id="paytment-form" action="index.html" method="post">
<!-- Online Payments -->
<div id="online-payments" class="payments" >
<input type="radio" id="onlinePayInput" name="payment-method" value="bank-A" onmousedown="this.__chk = this.checked" onclick="if (this.__chk) this.checked = false"> <span class="option">線上付款</span> <br>
</div>
<!-- Online Payment Methods -->
<div id="online-options" style="display: none;">
@nicco88
nicco88 / custom.js
Created December 23, 2016 08:45
Arrow toggle
// Toggle panel-title arrow script
arrowToggle();
function arrowToggle() {
var panelTitle = document.getElementsByClassName("panel-title");
var arrowDown = "arrow_drop_down";
var arrowUp = "arrow_drop_up";
for(var i = 0; i < panelTitle.length; i++) {
panelTitle[i].addEventListener("click", function() {
// DRY code = don't repeat yourself
// WHILE LOOPS
// Repeat the code while the condition is true
while(someCondition) {
// run the code
}
// Printing n. from 1-5
@nicco88
nicco88 / gist:b30a378cc6ee6cd65ac47ef23614bba1
Last active January 9, 2017 01:50
broweser sync command
Access the folder through terminal and type:
browser-sync start --server --index mysite.html --files="*.html,css/*.css"
/usr/bin/env: node: No such file or directory
Posted on 2015.12.22 by Tim Habersack
If you are getting this error, odds are you are trying to run something nodejs related on a Ubuntu/Debian Linux distro and having problems.
I was having this problem, then found this excellent help from StackOverflow:
sudo ln -s "$(which nodejs)" /usr/bin/node
function openExpTable(evt, tableName){
var tabContent, tabLinks;
// get all elements with class="tab-content" and hide them
tabContent = document.getElementsByClassName("tab-content-exp");
for (var i = 0; i < tabContent.length; i++) {
tabContent[i].style.display = "none";
}
// get all elements with class="tab-links" and remove the class "active"
@nicco88
nicco88 / todoList.js
Last active June 8, 2022 06:49
Todo List app study (by Gordon Zhu), www.watchandcode.com
// VERSION 1 - Arrays
// 1 It should have a place to store todos
// 2 It should have a way to display todos
// 3 It should have a way to add new todos
// 4 It should have a way to change a todo
// 5 It should have a way to delete a todo
/*-------------------------------------*/
@nicco88
nicco88 / btsPay.js
Last active January 4, 2017 02:50
toggle menu
var payTab = {
onlineMethod: document.getElementById("online-method"),
offlineMethod: document.getElementById("offline-method"),
onlineOption: document.getElementsByClassName("online-option"),
offlineOption: document.getElementsByClassName("offline-option"),
onlineBtn: document.getElementById("online-radio-btn").getElementsByTagName("ins")[0],
toggleOnlineOption: function() {
// toggle online options
for (var i = 0; i < this.onlineOption.length; i++) {
if (this.onlineOption[i].style.display === "") {
@nicco88
nicco88 / slider.js
Last active January 12, 2017 07:16
slider.js
// Slider script
var brandSlider = {
sliderContainer: document.getElementById("sliderContainer"),
totPagesNum: document.getElementsByClassName("pages").length,
pagesStripe: document.getElementById("pagesStripe"),
respStripe: function() {
this.pagesStripe.style.width = this.totPagesNum * 100 + "%";
},
index: 0,
@nicco88
nicco88 / slider.css
Last active January 12, 2017 07:16
slider.css
/*Image Slider Div (brand.html)*/
.container {
margin: 0;
}
#titleDiv {
display: block;
margin: 0 auto;