// Kapsulointiesimerkki
// 25.3.2015 added example relation to real protocols
// 15.3.2016 poistetaan H1 myös kytkimessä
// 29.3.2016 pienennetty kerrosten välejä että näkyy paremmin pienellä näytöllä + real protocols examplea muokataan myös silloin kuin headereitä poistetaan
// 10.1.2018 Kavennettu, jotta mahtuisi 768 pikseliä leveeseen TIM-sivuun
// TODO: siisti koodia, jos jaksat, vois yksinkertaistaa
var alas = 50;
var testattava = "";
var leveys = 0;
var kerros = 'H5';
var tila = 0;
var orig = '| GET / HTTP/1.1 jne. |';
var protot = ['|TCP portit 80 jne|', '|IP osoiteet ja otsikot |', '|MAC osoitteet|', '|Muunnos fyysiseksi signaaliksi|'];
var nextHeader = {
'H5': 0,
'H4': 1,
'H3': 2,
'H2': 3
};
$(document).ready(function() {
$('.sanoma').click(function() {
if (kerros != 'H5') {
kliku(this);
} else {
$('.' + this.className).animate({
top: 30 + alas
});
leveys += $(this).width();
kapsuloi($(this), kerros);
}
});
});
function kapsuloi(element, h) {
var kerrokset = ["k", "v", "l", "f"];
var headerit = ['H4', 'H3', 'H2', 'H1'];
var index = nextHeader[h];
//$("#result").html(protot[index] + $("#result").html());
//$("#result").html(orig + protot.slice(0, index+1).join(""));
$("#result")
.delay(1000)
.queue(function(n) {
$(this).html(orig + protot.slice(0, index + 1).join(""));
n();
})
// create header
createDiv(headerit[index], 'sanoma', kerrokset[index] + headerit[index]);
$('#' + kerrokset[index] + headerit[index]).animate({
left: 85 + leveys // Mihin kohtaan suhteessa sanomaan tulee headerit
});
leveys += $('#' + kerrokset[index] + headerit[index]).width();
kerros = headerit[index]; // update what layer we are on
}
function createDiv(text, luokka, id) {
d = document.createElement('div');
var paljon = {
'H4': 50,
'H3': 100,
'H2': 150,
'H1': 200
};
var vari = {
'H4': '#F2FFCC',
'H3': '#22FF00',
'H2':...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.