Skip to content

Instantly share code, notes, and snippets.

@simonewebdesign
simonewebdesign / applyDebug.js
Last active September 16, 2020 20:30
Debugging a JS app with Aspect Oriented Programming
function applyDebug(obj) {
for (var f in obj) {
if (obj.hasOwnProperty(f) && typeof obj[f] === 'function') {
console.log(obj[f].toString());
origFunc = obj[f];
obj[f] = function () {
console.debug("called at " + new Date());
return origFunc.apply(this, arguments);
@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 {
@simonewebdesign
simonewebdesign / scrollHorz.js
Created August 26, 2013 13:42
jQuery cycle horizontal scroll effect - demo: http://jquery.malsup.com/cycle/scrollhv.html
$('.foo').cycle({
fx: 'scrollHorz'
});
@simonewebdesign
simonewebdesign / centered.css
Created August 26, 2013 10:42
CSS class for centering a div box
.centered {
position: relative;
float: left;
}
.centered.outer {
text-align: justify;
right: 50%;
}
@simonewebdesign
simonewebdesign / fullscreen3.js
Last active October 15, 2021 19:34
JavaScript Full Screen API (completely cross-browser!)
// quando clicco su enterfullscreen:
// vai in fullscreen
// all'entrata in fullscreen:
// mostra pulsante exitfullscreen
// nascondi header e footer
// quando clicco su exitfullscreen:
// esci da fullscreen
@simonewebdesign
simonewebdesign / fullscreen2.js
Created August 8, 2013 09:48
Full Screen in JavaScript (cross-browser) - another approach, with two different buttons
// quando clicco su enterfullscreen:
// vai in fullscreen
// mostra pulsante exitfullscreen
// nascondi header e footer
// quando clicco su exitfullscreen:
// esci da fullscreen
// mostra pulsante enterfullscreen
// mostra header e footer
@simonewebdesign
simonewebdesign / events.js
Last active December 20, 2015 19:19
JavaScript how to get all events in window object
var ev = '',
out = [];
for (ev in window) {
if (/^on/.test(ev)) {
out[out.length] = ev;
}
}
console.log(out.join(', '));
@simonewebdesign
simonewebdesign / fullscreen.js
Last active September 28, 2023 04:23
go fullscreen on click (cross-browser) - with a single button
$('.fullscreenbutton').on('click', function () {
function toggleFullScreen() {
if (!document.fullscreenElement && // alternative standard method
!document.mozFullScreenElement && !document.webkitFullscreenElement) { // current working methods
if (document.documentElement.requestFullscreen) {
document.documentElement.requestFullscreen();
} else if (document.documentElement.mozRequestFullScreen) {
document.documentElement.mozRequestFullScreen();
} else if (document.documentElement.webkitRequestFullscreen) {
/*
Common vector operations
Author: Tudor Nita | cgrats.com
Version: 0.51
*/
function Vec2(x_,y_)
{
this.x = x_;
this.y = y_;
//
// DetailsController.m
// iOsNative
#import "DetailsController.h"
#import "CustomDetailsCell.h"
#import "JsonReader.h"
#import "PList.h"
@implementation DetailsController