Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var num_wins=0;
- var zz;
- //-----------------------------------------
- function init()
- {
- zz=document.createElement('div');
- zz.className='floatblock';
- zz.style.background='#ffffe0';
- zz.style.left='10px';
- zz.style.top='90px';
- document.body.appendChild(zz);
- };
- function ShowMe (el,startX, startY, startOpacity, x,y) {
- //-----------------------------
- function setAll () {
- el.style.left=Math.floor(el.x)+'px';
- el.style.top=Math.floor(el.y)+'px';
- if (el.opacityVal) {
- el.style.opacity=el.opacityVal;
- el.style.filter="Alpha(Opacity="+(el.opacityVal*100)+")";
- }
- };
- //-----------------------------
- function animOut() {
- var x1=el.x;
- //alert(x1);
- //alert(x1);
- var y1=el.y;
- var x=el.xtarget;
- var y=el.ytarget;
- if ((Math.abs(x-x1)>4) || (Math.abs(y-y1)>4))
- {
- el.x+=(x-x1)/100;
- el.y+=(y-y1)/100;
- if (el.opacityVal<1)
- el.opacityVal+=0.01;
- //endif
- setAll();
- setTimeout(arguments.callee,1);
- }}
- //-----------------------------
- if (el.className=="floatblock")
- {
- zz.innerHTML+=el.innerHTML+' ';
- el.x=startX;
- el.y=startY;
- el.opacityVal=startOpacity;
- el.xtarget=x;
- el.ytarget=y;
- setAll();
- animOut();
- }
- }
- //-----------------------------------------
- function addblock(x,y,inText)
- {
- b=document.body;
- u=document.getElementsByTagName('div');
- for (i=0;i<u.length;i++)
- {
- //alert (u[i].firstChild.nodeValue);
- if (u[i].className=='floatblock')
- {
- //alert(u[i].innerHTML);
- r=u[i];
- if (r.moveOut)
- r.moveOut();
- //return;
- }
- }
- var z=document.createElement('div');
- z.className="floatblock";
- //z.onclick=function(){this.showMe(300,100)};
- z.innerHTML=inText;
- z.moveOut=function() {
- o=this;
- setTimeout(
- function f() {ShowMe(o, o.x, o.y, num_wins*20, 700+num_wins*20,6)},40)}
- ShowMe(z, 50,50, 0, x+num_wins*20,y);
- b.appendChild(z);
- //alert(z);
- //z.showMe(300,100);
- return(z);
- }
- //---------------------------------------
- function confirmation(info) {
- x=confirm(info+' Продолжить?');
- if (!x)
- return;
- y=prompt('Укажите Ваше имя','');
- if (y.trim().length!=0)
- alert('Здравствуйте, '+y);
- }
- //---------------------------------------
- function navinfo()
- {
- num_wins++;
- zz.innerHTML='->';
- z=addblock(300,100,num_wins);
- }
- ----------------------------------------------------------------------------------------------
- ----------------------------------------------------------------------------------------------
- function init() {
- //---------------------------------------------
- HTMLDivElement.prototype.getu=function(s) {
- var y=this.style[s];
- y1=parseInt(y,y.slice(y,1,y.indexOf('px')-1));
- return y1;
- }
- HTMLDivElement.prototype.setu=function(s,x) {
- for (var i=0;i<s.length;i++) {
- this.style[s[i]]=x[i]+'px';
- }
- }
- HTMLDivElement.prototype.wr=function(s) {
- this.innerHTML+='<p>'+s+'</p>';
- }
- Document.prototype.appSquare=function () {
- zblock=this.createElement('DIV');
- zblock.className='menublock';
- this.body.appendChild(zblock);
- return (zblock);
- }
- //---------------------------------------------
- m= document.appSquare();
- m.setu(['left','top','width','height'],
- [100,100,300,300]);
- texts=["Таблица символов","Экранирование"];
- funcs=[
- //-----------------------------
- function() {
- popup=document.appSquare();
- popup.setu(['left','top','width','height'],
- [10,10,1200,600]);
- popup.onclick= function () {this.parentNode.removeChild(this)};
- popup.style["font-size"]="small";
- var tmp='';
- for (var i=0;i<=10000;i++) {
- switch (i<10) {
- case true:
- tmp3='0'+i;
- break;
- case false:
- tmp3=i;
- break;
- }
- tmp+=''+tmp3+' = <b>&#'+tmp3+';</b> <br> ';
- }
- popup.innerHTML=tmp;
- },
- //-----------------------------
- function() {
- document.write('<script> alert(\'test\'); </script>');
- }
- ]
- ul=document.createElement('UL');
- m.appendChild(ul);
- for (var i=0; i<document.links.length;i++) {
- if (i>=texts.length) break;
- z=document.createTextNode(texts[i]);
- document.links[i].appendChild(z);
- document.links[i].onclick=funcs[i];
- li=document.createElement('LI');
- li.appendChild(document.links[i]);
- ul.appendChild(li);
- }
- //-------------------------------------------
- t= document.appSquare();
- t.setu(['left','top','width','height'],
- [500,50,400,600]);
- t.wr('Тесты');
- //---------------------------------------------
- var s2=' \u2014\x20';
- var s = 'Это \u2014\u0020про\сто\x20пример';
- t.wr(s2.concat(' - ',s,' - ',s.toUpperCase(),'-',s.toLowerCase()));
- t.wr(s.replace('\u2014','\u4010'));
- t.wr(Math.pow(2,10));
- //---------------------------------------------
- s='we use all means to reach our goals';
- t.wr('----------');
- t.wr(s);
- var s1='';
- for (var i=0; i<s.length;i++) {
- s1+=s.charAt(i)+'-'+s.charCodeAt(i)+'; ';
- }
- t.wr(s1);
- t.wr('----------');
- arr=s.split(' ');
- t.wr(arr);
- t.wr('<b>arr.slice(2,4)</b> '+arr.slice(2,4).join(' '));
- t.wr('<b>arr.slice(-3,-1)</b> ' +arr.slice(-3,-1).join(' '));
- t.wr('<b>arr.splice(2,2,\'different\',\'tools\')</b> '+ arr.splice(2,2,'different','tools').join(' '));
- t.wr(arr.join(' '));
- arr.sort(function(a,b) {return (a.length==b.length)? ((a<b)?-1:1) :(a.length-b.length);});
- t.wr('<b>sorted</b> '+arr.join(' ')); //arr.push arr.pop arr.unshift(12,3) arr.shift
- //---------------------------------------------
- t.wr('-----------');
- var s3 = 'Мы знаем, что монохромный цвет - это градации серого'; //исходная строка
- var text = 'хром'; //известная часть слова
- var word;
- /*
- Найти слово, содержащее строку «хром» и записать в переменную word
- indexOf(), lastIndexOf(), slice()
- */
- word = s3.slice(s3.lastIndexOf(' ', s3.indexOf("хром"))+1,s3.indexOf(' ',s3.indexOf("хром")));
- t.wr(word);
- //---------------------------------------------
- x=(s=='inf')? 4: 6;
- switch (s) {
- case 'inf':
- alert('test1');
- break;
- case 'inf5':
- alert('test5');
- break;
- default:
- s='inf8';
- }
- //-----------------------------------
- }
- ----------------------------------------------------------------------------------------------
- ----------------------------------------------------------------------------------------------
- //------------------------------functions to apply to div objects
- getu=function(s) {
- var y=this.style[s];
- y1=parseInt(y.substring(0,y.indexOf('px')));
- return y1;
- }
- setu=function(s,x) {
- for (var i=0;i<s.length;i++) {
- this.style[s[i]]=x[i]+'px';
- }
- }
- wr=function(s) {
- this.innerHTML.concat('<p>',s,'</p>');
- }
- //--------------------------------------------------------
- document.appDiv = function (className) {
- zblock=this.createElement('DIV');
- zblock.className=className;
- this.body.appendChild(zblock);
- return(zblock);
- }
- //-------------------------------
- addInput=function (type,name,value,nrow,ncol) {
- var inp=document.createElement('INPUT');
- inp.type=type;
- inp.name=name;
- inp.value=value;
- inp.id=name;
- var inTabs=this.getElementsByTagName('TABLE');
- var inTab=inTabs[0];
- //alert(inTab);
- var targetCell=inTab.rows[nrow].cells[ncol];
- targetCell.appendChild(inp);
- }
- //-------------------------------
- function filltable () {
- function addSection(section,num) {
- //alert(section);
- var zrow, td;
- for (var i=0;i<num; i++) {
- zrow=section.insertRow(i);
- for (var j=0;j<num;j++) {
- td=zrow.insertCell(j);
- }
- }
- }
- //alert(this);
- addSection ((this.tBodies[0] && this.tBodies[this.tBodies.length-1]) || this, 3);
- }
- //-----------------------------------------------------------
- function move () {
- //alert('test');
- pic=document.getElementById('pic88');
- switch (this.name) {
- case 'bup':
- pic.y--;
- break;
- case 'bdown':
- pic.y++;
- break;
- case 'bleft':
- pic.x--;
- break;
- case 'bright':
- pic.x++;
- }
- pic.style["background-position"]=pic.x+'px '+pic.y+'px';
- var f=document.forms.yandsearch;
- if (!f)
- f=document.forms[0];
- f.text3.value=pic.style["background-position"];
- }
- window.onload= function()
- {
- picdiv=document.appDiv("menublock test");
- setu.apply(picdiv,
- [['left','top','width','height'],
- [100,50,400,400]]);
- picdiv.id="pic88";
- picdiv.x=0;
- picdiv.y=0;
- //picdiv.appendClass('test');
- frmdiv=document.appDiv("menublock");
- setu.call(frmdiv, ['left','top','width','height'],
- [50,50,300,300]);
- //------------------------set frmdiv at right of picdiv
- var leftOfs=0;
- var t_el=picdiv;
- while (t_el) {
- leftOfs+=t_el.offsetLeft;
- t_el=t_el.offsetParent;
- }
- leftOfs+=picdiv.offsetWidth+5;
- setu.call(frmdiv,['left'],[leftOfs]);
- //---------------------------------------------
- frmdiv.id="frm88";
- frmnames=["yandsearch","controlpanel"];
- for (i=0;i<frmnames.length;i++) {
- var frm=document.createElement('FORM');
- frm.name=frmnames[i];
- frm.id=frmnames[i];
- var layTab=document.createElement('TABLE');
- layTab.className="formtable";
- filltable.apply(layTab);
- frm.appendChild(layTab);
- a=document.getElementById("frm88");
- a.appendChild(frm);
- }
- //-------------------------------
- var f=document.forms["yandsearch"];
- if (!f)
- f=document.forms[0];
- f.method="get";
- f.action="http://yandex.ru/yandsearch";
- f.addInput=addInput;
- f.addInput('TEXT','text3','введите текст',1,1);
- f.addInput('SUBMIT','subm','Search',2,1);
- var submf=f.subm;
- if (!submf)
- submf=document.getElementById('subm');
- //alert(submf);
- submf.onclick=function() {
- pic=document.getElementById('pic88');
- pic.style["background-position"]=this.parentNode.text3.value;
- return false;
- }
- textf=f.text3;
- if (!textf)
- textf=f.elements[0];
- textf.onfocus=function() {if (this.value=='введите текст') this.value='';}
- textf.onblur=function() {if (this.value=='') this.value='введите текст';}
- //-------------------------------
- var f=document.forms.controlpanel;
- if (!f)
- f=document.forms[1];
- f.addInput=addInput;
- f.addInput('BUTTON','bup','\u25b2',0,1);
- f.addInput('BUTTON','bdown','\u25bc',2,1);
- f.addInput('BUTTON','bleft','\u25c0',1,0);
- f.addInput('BUTTON','bright','\u25b6',1,2);
- f.bup.onclick=move;
- f.bdown.onclick=move;
- f.bleft.onclick=move;
- f.bright.onclick=move;
- }
- ----------------------------------------------------------------------------------------------
- ----------------------------------------------------------------------------------------------
- function intro() {
- var s='';
- for (var i=0;i<20; i++) {
- s+='<br />';
- }
- els=document.getElementById("intext");
- //els.innerHTML=s;
- el=document.createElement('DIV');
- el.className='posterBlock';
- el.id='poster88';
- el.style.left='800px';
- el.style.top='50px';
- el.style["padding-right"]='20px';
- el.style["padding-top"]='20px';
- //var s=el.style["left"];
- //s=s.slice(0,s.indexOf('px'));
- // word = s.slice(s.lastIndexOf(' ', s.indexOf("хром"))+1,s.indexOf(' ',s.indexOf("хром")));
- //alert(s);
- document.body.appendChild(el);
- infos=['window','document','location','history','navigator',
- 'screen','frames','status','defaultStatus'];
- //---------------------------------------------------------
- function getInfel(p) {
- el=document.getElementById('infoel88');
- if (el==undefined) {
- el=document.createElement('DIV');
- el.id='infoel88';
- //----------------------------------
- el.tex=function(intext) {
- brEl=document.createElement('BR');
- this.appendChild(brEl);
- this.insertBefore(document.createTextNode(intext),brEl);
- }
- //------------------------------------
- p.appendChild(el);
- return(el);
- }
- else
- return el;
- }
- //---------------------------------------------------------
- ouinf= function (p,inf) {
- infel=getInfel(p);
- infel.innerHTML='';
- infel.tex(inf);
- for (var prop in eval(inf))
- {
- infel.tex(prop+' : '+eval(inf+'.'+prop));
- }
- return false;
- }
- //---------------------------------------------------------
- for (var i=0;i<infos.length; i++) {
- txel=document.createElement('A');
- txel.href='#';
- txel.info=infos[i];
- txel.onclick= function () {
- s=this.info;
- return ouinf(this.parentNode, s)};
- txel.appendChild(document.createTextNode(infos[i]));
- el.appendChild(txel);
- }
- }
- ----------------------------------------------------------------------------------------------
- ----------------------------------------------------------------------------------------------
- //-------------------------------------------------
- function wr(el,s) {
- a=document.getElementById(el);
- if (s=='cls')
- a.innerHTML=''
- else {
- a.innerHTML+=s+'<br/>';
- }
- }
- //-------------------------------------------------
- function showSysInfo() {
- el="sysinfo";
- wr(el,'cls');
- //------------------------------------
- wr(el,'----- Navigator Info ------');
- wr(el,navigator.appCodeName);
- wr(el,navigator.appName);
- wr(el,navigator.appVersion);
- //------------------------------------
- wr(el,navigator.userAgent);
- wr(el,navigator.onLine);
- wr(el,navigator.cookieEnabled);
- wr(el,navigator.platform);
- wr(el,'JavaEnabled='+navigator.javaEnabled);
- //------------------------------------
- wr(el,'');
- wr(el,'----- Location Info -----=');
- wr(el,'protocol='+location.protocol);
- wr(el,'host='+location.host);
- wr(el,'hostname='+location.hostname);
- wr(el,'port='+location.port);
- wr(el,'pathname='+location.pathname);
- wr(el,'search='+location.search);
- wr(el,'hash='+location.hash);
- wr(el,'href='+location.href);
- //---------------------------Location operations
- wr(el, '<a href="#" onclick="location.assign(\'http://ya.ru\');return false;">'+
- 'location.assign(url)</a>');
- wr(el,'<a href="#" onclick="location.replace(\'http://ya.ru\');return false;">'+
- 'location.replace(url)</a>');
- //--------------------------history operations
- wr(el,'');
- wr(el, '-------- History and Screen---------');
- wr(el,'history.length='+history.length);
- wr(el, '<a href="#" onclick="history.back();return false;">history.back()</a>');
- wr(el,'screen.width x screen.height = '+screen.width+' x '+screen.height);
- wr(el,'availWidth x availHeight = '+screen.availWidth+' x '+screen.availHeight);
- }
- //-------------------------------------------------
- function showCreateWins() {
- //-------------------------------Block position
- var el=document.getElementById('createwins');
- var z=document.getElementById('sysinfo');
- var xScroll=document.documentElement.scrollLeft || document.body.scrollLeft;
- var yScroll=document.documentElement.scrollTop || document.body.scrollTop;
- var xWin=document.documentElement.clientLeft || document.body.clientLeft;
- var yWin=document.documentElement.clientTop || document.body.clientTop;
- var z_rect=z.getBoundingClientRect();
- var x_All = xScroll - xWin + z_rect.left + z.offsetWidth+1;
- el.style.left=x_All+'px';
- wr('createwins','scrollLeft='+xScroll);
- wr('createwins','scrollTop='+yScroll);
- wr('createwins','clientLeft='+xWin);
- wr('createwins','clientTop='+yWin);
- wr('createwins','sysinfo.left='+z_rect.left+' : '+z.offsetLeft);
- wr('createwins','sysinfo.offsetWidth='+z.offsetWidth);
- //------------------------Block content
- var e = 'createwins';
- }
- //-------------------------------------------------
- function init() {
- showSysInfo();
- showCreateWins();
- }
- //-------------------------------------------------
- function func_iframe() {
- wr('iframeinfo','number of frames='+frames.length);
- x=frames["content"];
- wr('iframeinfo','frame[\'content\']='+x);
- wr('iframeinfo',x.body);
- x.document.body.style.background="#cf0";
- //alert(x.document.body.innerHTML);
- }
- //------------------------------------------Проверка формы вызова окна
- function checkForm() {
- function sc (s, type) {
- switch (type) {
- //-------------------
- case 1:
- if (s=='')
- return false
- else
- {
- re=new RegExp(/^[1-9][0-9]{1,4}$/ig);
- if (!re.test(s))
- return false
- else
- return true;
- }
- break;
- //-------------------
- case 3:
- if (s=='')
- return false
- else
- return true;
- }
- }
- //------------------------------
- var f=document.forms["controlform"];
- var isOk=true;
- for (var i=0;i<f.length;i++) {
- var el=f.elements[i];
- //------------------------
- if (el.name)
- //---------------------------------number elements
- if (el.name.slice(0,1).toUpperCase()=='N') {
- if (!sc(el.value,1)) {
- el.style.background="rgb(255,200,200)";
- isOk=false;
- }
- else
- el.style.background="white";
- }
- //----------------------------text elements
- else if (el.name.slice(0,1).toUpperCase()=='T') {
- if (!sc(el.value,3)) {
- el.style.background="rgb(255,250,200)";
- isOk=false;
- }
- else
- el.style.background="white";
- }
- }
- //----------------------------------
- if (isOk) {
- var paramStr= 'width='+f.ninpwidth.value+','+
- 'height='+f.ninpheight.value+','+
- 'left='+f.ninpleft.value+','+
- 'top='+f.ninptop.value+','+
- 'location='+f.rinlocation.value+','+
- 'menubar='+f.rinmenubar.value+','+
- 'scrollbars='+f.rinscrollbars.value+','+
- 'toolbar='+f.rintoolbar.value+','+
- 'status='+f.rinstatus.value+','+
- 'resizable='+f.rinresizable.value;
- alert(paramStr);
- popupWin= open (f.tinpurl.value, f.tinpname.value, paramStr);
- setTimeout('popupWin.close()',4000);
- }
- return false;
- }
- ----------------------------------------------------------------------------------------------
- ----------------------------------------------------------------------------------------------
- var servers = Array('PHP1. Основы серверного','PHP2. Работа с MySQL', 'PHP3. ООП и XML');
- var clients = Array('Javascript1. Основы','Javascript2. Чуть большее.');
- function showNames(v) {
- var names=document.getElementById("names");
- var arr=eval(v);
- while (names.length>0)
- names.remove(0);
- for (var i=0; i<arr.length; i++) {
- var o= new Option(arr[i],i,false,false);
- try {
- names.add(o,null);
- } catch(e) {
- names.add(o);
- }
- }
- }
- function addYear(e, flag) {
- var select=e.form.yearzz;
- var ff = (flag) ? select.length-1:0;
- var posit = (flag) ? null: select.options[0];
- var bf = (flag) ? 1: -1;
- var year= parseInt(select.options[ff].value)+bf;
- var o = new Option(year,year, false, true);
- try {
- select.add(o,posit);}
- catch (e) {
- if (flag)
- select.add(o);
- else
- select.add(o,0);
- }
- }
- ----------------------------------------------------------------------------------------------
- ----------------------------------------------------------------------------------------------
- //-----------------------------------------------
- var Helper= {
- words:['treuber','zonner','annus','crane','et','us','alarm','between','then','you','found','round',
- 'like','any','other','flower','music','on','great','intro','step','trek','listening','of','hot','jar'],
- fillin: function(num) {
- var st='';
- for (var i=0;i<num; i++) {
- st+=this.words[Math.floor(Math.random()*25)]+' ';
- }
- return st;
- }
- }
- //-----------------------------------------------
- function rr(section,rowindex,cellindex,opa) {
- opa-=.006;
- //alert(rowindex);
- for (var m=0; m<section.rows.length; m++) {
- if (m==rowindex) {
- section.rows[m].cells[cellindex].style.opacity=opa;
- section.rows[m].cells[cellindex].style.filter="Alpha(opacity="+Math.floor(opa*100)+")";
- if (opa<=0.01) {
- //alert('test');
- section.rows[m].deleteCell[cellindex];
- }
- }
- }
- if (opa>.01)
- setTimeout(function f() { rr(section,rowindex,cellindex,opa)},1);
- }
- //-----------------------------------------------
- function addSection(tab, section, num) {
- var row, td;
- for (var i=0; i<num; i++) {
- row=section.insertRow(i);
- for (var j=0; j<3; j++) {
- td=row.insertCell(j);
- td.innerHTML=j;
- td.sect=section;
- }
- }
- }
- //-----------------------------------------------
- function filltab() {
- addSection(this,this.tBodies[0] && this.tBodies[this.tBodies.length-1] || this, 5);
- addSection(this,this.createTHead(),2);
- addSection(this,this.createTFoot(),1);
- }
- //-----------------------------------------------
- window.onload=function() {
- tabs=document.getElementsByTagName('TABLE');
- for (var i=0;i<tabs.length;i++) {
- //tab.ft=filltab;
- //tab.ft();
- //alert(tabs[i].className);
- if (tabs[i].nodeName=='TABLE')
- {
- filltab.apply(tabs[i],[]);
- tabs[i].onselectstart=function() {return false;};
- for (var i8=0; i8<tabs[i].rows.length; i8++) {
- var row=tabs[i].rows[i8];
- for (var j8=0; j8<row.cells.length; j8++) {
- var cel=row.cells[j8];
- cel.innerHTML=Helper.fillin(1);
- cel.i=i8;
- cel.onclick= function () {
- //for (var m=0; m<this.x.rows.length;m++){
- //this.x.rows[m].deleteCell(this.cellIndex);
- //};
- var d=this.cellIndex;
- var zi=this.i;
- var sect=this.sect;
- setTimeout(function f() {rr(sect, zi,d,1)},1);
- }
- }
- }
- }
- }
- }
- ----------------------------------------------------------------------------------------------
- ----------------------------------------------------------------------------------------------
- //-----------------------------------------
- appForm = function(inDiv,formName) {
- //----------------------------------
- function fillTable(x) {
- //---------------------
- function addSection(section,num) {
- var row,td;
- for (var i=0; i<num; i++) {
- row=section.insertRow(i);
- for (var j=0;j<num; j++) {
- td=row.insertCell(j);
- }
- }
- }
- //---------------------
- addSection( (x.tBodies[0] && x.tBodies[x.tBodies.length-1]) || x, 3);
- //addSection(x.createTHead(),2);
- //addSection(x.createTFoot(),1);
- }
- //----------------------------------
- var frm=document.createElement('FORM');
- frm.name=formName;
- frm.addInput=addInput;
- var layTab=document.createElement('TABLE');
- layTab.className="formtable";
- //layTab.setAttribute('border',"1");
- fillTable(layTab);
- frm.appendChild(layTab);
- inDiv.appendChild(frm);
- return frm;
- }
- //----------------------------------------------------------
- addInput = function (type,name,value,nRow,nCol) {
- var inp=document.createElement('INPUT');
- inp.type=type;
- inp.name=name;
- inp.value=value;
- inp.id=name;
- inTabs=this.getElementsByTagName('TABLE');
- inTab=inTabs[0];
- targetCell= inTab.rows[nRow].cells[nCol];
- targetCell.appendChild(inp);
- return inp;
- }
- //----------------------------------------
- function appEl(elID) {
- el=document.createElement('DIV');
- el.id=elID;
- document.body.appendChild(el);
- return el;
- }
- //---------------------------------runClock
- function runClock(inDiv) {
- //---------------------------------------show clock
- function animate(x) {
- //-------------------------------
- function getP(num) {
- pIn=x.firstChild;
- var i=-1;
- do
- {
- if (pIn.nodeName=='P') {
- i++;
- if (i<num) pIn=pIn.nextSibling;
- }
- else {
- pIn=pIn.nextSibling;}
- }
- while ((pIn!=null) && (i<num));
- return pIn;
- }
- //-------------------------------
- var d = new Date();
- var d3 = new Date(2012,11,10, 14,5);
- var y=d.getFullYear();
- var m=d.getMonth();
- var day=d.getDay();
- var hour=d.getHours();
- var min=d.getMinutes();
- var s=d.getSeconds();
- getP(0).innerHTML='status';
- getP(1).innerHTML='today: '+d.toDateString();
- getP(2).innerHTML=Math.floor((d3-d)/1000/3600/24)+' days before';
- getP(3).innerHTML=d3.toDateString();
- getP(4).innerHTML='current time:';
- getP(5).innerHTML=hour+':'+min+':'+s;
- }
- //----------------------------------show login status
- function showLoginStatus(x) {
- var tmpS='';
- var s8,s5,s6;
- i9++;
- //if (document.cookie.length>0)
- tmpS=document.cookie;
- if (tmpS=='') {
- x.innerHTML=i9+' no cookies detected';
- return false;
- }
- //else
- // tmpS='non signed in';
- var arr=tmpS.split(';');
- tmpS='';
- for (var i=0; i<arr.length; i++) {
- s8=arr[i];
- s5=s8.substring(0,s8.indexOf('='));
- s6=s8.substring(s8.indexOf('=')+1,s8.length);
- tmpS+='<span style="color:red">'+s5+'</span>: '+decodeURIComponent(s6)+'<br>';
- }
- x.innerHTML=i9+' '+tmpS;
- }
- //--------------------------------------------------------------
- txDiv=document.createElement('DIV');
- txDiv.id="clocktx";
- inDiv.appendChild(txDiv);
- for (i=0; i<10;i++) {
- elP=document.createElement('P');
- txDiv.appendChild(elP);
- }
- setInterval(function () {animate(txDiv);},500);
- //-----------------------
- usrDiv=document.createElement('DIV');
- usrDiv.id="userinfo";
- document.body.appendChild(usrDiv);
- var i9=0;
- setInterval(function() {showLoginStatus(usrDiv);},3000);
- }
- //------------------------------------constructor
- function ButtonEl(type,name,value,nRow,nCol) {
- this.type=type;
- this.name=name;
- this.value=value;
- this.nRow=nRow;
- this.nCol=nCol;
- }
- //----------------------------------------initialization
- function init() {
- zinf=document.getElementById('test');
- basket=appEl('basket');
- basket.innerHTML+='<div id="doodler"></div>';
- controls88=appEl('controls');
- controls88.innerHTML='<div id="scol" style="float:left;"></div>'+
- '<div id="fcol" style="float:left;margin-right:5px;"></div>'+
- '<div id="tcol"></div>';
- clock=appEl('clock');
- //fcol=controls88.childNodes["fcol"];
- //---------------------------------------------
- in_fcol=document.getElementById('fcol');
- ctrlForm = appForm(in_fcol,'ctrlForm');
- ctrlForm.id="controlform";
- //controls88.childNodes[1].innerHTML='test';
- inpButtons= [
- new ButtonEl('BUTTON','bup','\u25b2',0,1),
- new ButtonEl('BUTTON','bdown','\u25bc',2,1),
- new ButtonEl('BUTTON','bleft','\u25c0',1,0),
- new ButtonEl('BUTTON','bright','\u25b6',1,2)
- ]
- for (var i=0; i<inpButtons.length;i++) {
- var tmp=inpButtons[i];
- if (tmp) {
- inp=ctrlForm.addInput(tmp.type,tmp.name,tmp.value,tmp.nRow,tmp.nCol);
- inp.onmousedown=function() {doodler_buttons(1, this.name);};
- inp.onmouseup=function() {doodler_buttons(2, this.name);};
- }
- }
- //---------------------------------------------
- var in_scol=document.getElementById('scol');
- loginForm=appForm(in_scol,'loginForm');
- //-----------------------login set cookie
- loginForm.onsubmit= function() {
- var usrEl=document.getElementById('username');
- //alert('test');
- document.cookie='foo='+encodeURIComponent(usrEl.value)+';';
- return false;
- }
- //-----------------------
- var stdStr='Введите имя пользователя'
- logiEls = [
- new ButtonEl('TEXT','username',stdStr,1,1),
- new ButtonEl('SUBMIT','subm','Отправить',2,1),
- new ButtonEl('RESET','reset','Сброс',2,1)
- ]
- for (var i=0;i<logiEls.length;i++) {
- var tmp=logiEls[i];
- if (tmp) {
- inp=loginForm.addInput(tmp.type,tmp.name,tmp.value,tmp.nRow,tmp.nCol);
- }
- }
- var usrn=loginForm.elements.username;
- if (!usrn)
- usrn=document.getElementById("username");
- usrn.size="30";
- usrn.onclick=function () {
- usrn.style["color"]="black";
- if (usrn.value==stdStr)
- usrn.value='';
- }
- usrn.onblur=function() {
- if (usrn.value=='') {
- usrn.style["color"]="#aaa";
- usrn.value=stdStr;
- }
- }
- usrn.onkeyup=function() {
- //alert(usrn.value);
- if ((usrn.value=='')||(usrn.value==stdStr)) {
- usrn.style["color"]="#aaa";
- loginForm.subm.disabled=true
- }
- else {
- usrn.style["color"]="black";
- loginForm.subm.disabled=false;
- }
- }
- usrn.onkeyup();
- //---------------------------------------------
- runClock(clock);
- doodler_g=document.getElementById('doodler');
- document.onkeydown=doodler_keys;
- document.onkeyup=doodler_keys;
- setInterval("frame()",10);
- }
- //----------------------globals
- var doodler_g
- var direct_g=1;
- var doodlerX_g=200;
- var doodlerY_g=0;
- var doodlerVX_g=0;
- var doodlerVY_g=0;
- var pressbut_g="";
- //------------------------------------------------main cycle
- function frame() {
- var d=doodler_g;
- switch (pressbut_g) {
- case 'bup':doodlerVY_g+=.2; direct_g=1; break;
- case 'bdown':doodlerVY_g-=.2; direct_g=1; break;
- case 'bleft':doodlerVX_g-=.2; direct_g=0; break;
- case 'bright':doodlerVX_g+=.2; direct_g=2; break;
- }
- doodlerX_g+=doodlerVX_g;
- doodlerY_g+=doodlerVY_g;
- if ((doodlerX_g<0) || (doodlerX_g>d.parentNode.offsetWidth-d.offsetWidth)) {
- doodlerVX_g=-doodlerVX_g;
- direct_g= direct_g==2 ? 0 :2;
- doodlerX_g+=doodlerVX_g*4;
- }
- if ((doodlerY_g<0) || (doodlerY_g>d.parentNode.offsetHeight-d.offsetHeight)) {
- doodlerVY_g=-doodlerVY_g;
- //direct_g= direct_g==2 ? 0 :2;
- doodlerY_g+=doodlerVY_g*4;
- }
- doodlerVX_g*=0.99;
- doodlerVY_g*=0.99;
- d.style.backgroundPosition="-"+62*direct_g+"px -215px";
- d.style["bottom"]=Math.floor(doodlerY_g)+"px";
- d.style["left"]=Math.floor(doodlerX_g)+"px"
- }
- //------------------------------------------------control
- function doodler_buttons(x, inname) {
- //alert(inname);
- pressbut_g= (x==1) ? inname : "";
- }
- //-------------------------------------------key controls
- function doodler_keys(e) {
- //alert(e.keyCode);
- if (e.type=="keydown") {
- switch (e.keyCode) {
- case 37:
- case 65: doodler_buttons(1,'bleft'); break;
- case 39:
- case 68: doodler_buttons(1,'bright');break;
- case 38:
- case 87: doodler_buttons(1,'bup');break;
- case 40: doodler_buttons(1,'bdown');
- }}
- else
- doodler_buttons(2,"");
- }
- ----------------------------------------------------------------------------------------------
- ----------------------------------------------------------------------------------------------
- //---------------------------- get elements collection by class
- if (document.getElementsByClassName) {
- getElementsByClass = function (classList, node) {
- return (node || document).getElementsByClassName(classList);
- }
- } else {
- getElementsByClass = function (classList, node) {
- var node=node||document,
- list=node.getElementsByTagName('*'),
- length=list.length,
- classArray=classList.split(/\s+/),
- classes=classArray.length,
- result= [],i,j
- for (i=0;i<length;i++) {
- for (j=0;j<classes;j++) {
- if (list[i].className.search('\\b'+classArray[j]+'\\b')!=-1) {
- result.push(list[i]);
- break;
- }
- }
- }
- return result;
- }
- }
- //------------------------------ Helper object
- function Helper() {
- //----------------------
- this.addEvent=function (el, ev, handler) {
- try {
- el.addEventListener(ev,handler,false);
- }
- catch (z) {
- el.attachEvent('on'+ev,handler);
- }
- }
- //----------------------
- this.removeEvent=function(el,ev,handler) {
- try {
- el.removeEventListener(ev,handler,false);
- }
- catch(z) {
- el.detachEvent('on'+ev,handler);
- }
- }
- //----------------------
- this.cancelEvent=function(e) {
- try {
- e.preventDefault();
- }
- catch(z) {
- e.returnValue=false;
- }
- }
- //----------------------
- this.stopEvent=function(e) {
- try {
- e.stopPropagation();
- }
- catch(z) {
- e.cancelBubble=true;
- }
- }
- }
- //------------------------------------------
- function DDrop(inProto) {
- this.prototype=inProto;
- this.iefunc=inProto;
- //----------------------
- var inEl=document.getElementById('inheader');
- this.bords=[
- inEl.offsetLeft,
- inEl.offsetTop,
- inEl.offsetLeft+inEl.offsetWidth,
- inEl.offsetTop+inEl.offsetHeight];
- this.mouseDown=function(e) {
- e=e||event;
- var target=e.target||e.srcElement;
- //alert(target);
- if (target.className=='pcard') {
- //---------------------start absolute mouse position
- target.x0=e.clientX;
- target.y0=e.clientY;
- //---------------start element position in block
- target.cornerX=target.offsetLeft;
- target.cornerY=target.offsetTop;
- $('#sysinfo').html(target.id+'<br>'+
- target.x0+' - '+target.y0+'<br>'+target.cornerX+' - '+target.cornerY);
- document.body.currel=target;
- var dd=target.ddrop;
- try {target.style['z-index']='1000';}
- catch(exc) {
- alert('zindex');
- };
- try {
- dd.prototype.addEvent(target,'mousemove',dd.mouseMove);
- dd.prototype.addEvent(target,'mouseup',dd.mouseUp);
- }
- catch(exc) {
- alert(this);
- //dd.iefunc.addEvent(this,'mousemove',dd.mouseMove);
- //dd.iefunc.addEvent(this,'mouseup',dd.mouseUp);
- }
- document.body.onselectstart= function() {return false};
- document.body.onmouseup=function() {document.body.onselectstart=null};
- return false;
- }
- }
- //----------------------
- this.mouseMove=function(e) {
- e=e||event;
- var target=e.target||e.srcElement;
- var b=target.ddrop.bords;
- if ((e.clientX<b[0]) || (e.clientY<b[1]) ||
- (e.clientX>b[2]) || (e.clientY>b[3])) {
- target.style.left=target.cornerX+'px';
- target.style.top=target.cornerY+'px';
- target.ddrop.mouseUp(e);
- return;
- }
- $('#sysinfo').html(target.id+'<br>'+
- e.clientX+' - '+e.clientY);
- target.style.left=(target.cornerX+(e.clientX-target.x0))+'px';
- target.style.top=(target.cornerY+(e.clientY-target.y0))+'px';
- }
- //----------------------
- this.mouseUp=function(e) {
- var dd=this.ddrop;
- if (!dd) {
- dd=document.body.currel.ddrop;
- //alert(dd);
- }
- var curobj= document.body.currel;
- dd.prototype.removeEvent(curobj,'mousemove',dd.mouseMove);
- dd.prototype.removeEvent(curobj,'mouseup',dd.mouseUp);
- //document.body.onselectstart=null;
- curobj.style['z-index']='0';
- //----------------animate card moving to target
- newFlyAnimator.flyTo(curobj);
- }
- //----------------------
- var wins=getElementsByClass('pcard');
- for (var i=0;i<wins.length;i++) {
- var win=wins[i];
- //win.style.left=(i*20+10)+'px';
- this.prototype.addEvent(win,"mousedown",this.mouseDown);
- win.ddrop=this;
- }
- //----------------------
- }
- //--------------------- Flying Animation object
- function flyAnimator() {
- //----------------------------animate card moving to target
- this.flyAnimate = function() {
- o.ii++;
- o.movEl.style.left = o.srcEl.x + (o.myTarget.x - o.srcEl.x) * o.ii / o.step +'px';
- o.movEl.style.top=o.srcEl.y + (o.myTarget.y-o.srcEl.y) * o.ii / o.step + 'px';
- o.movEl.style.width=o.srcEl.offsetWidth +
- (o.myTarget.offsetWidth - o.srcEl.offsetWidth) * o.ii / o.step +'px';
- o.movEl.style.height=o.srcEl.offsetHeight +
- (o.myTarget.offsetHeight - o.srcEl.offsetHeight) * o.ii / o.step +'px';
- o.movEl.style.opacity=1-o.ii/o.step;
- o.movEl.style.filter="Alpha(Opacity="+(100*(1-o.ii/o.step))+")";
- if (o.ii<o.step) {
- setTimeout(arguments.callee,o.time/o.step);
- }
- else {
- o.movEl.parentNode.removeChild(o.movEl);
- }
- }
- //---------------------------------------------
- this.flyTo= function (el) {
- this.step=20;
- this.time=500;
- this.ii=0;
- var w_scroll = document.documentElement.scrollLeft || document.body.scrollLeft;
- var h_scroll = document.documentElement.scrollTop || document.body.scrollTop;
- var w_client = document.documentElement.clientLeft || document.body.clientLeft;
- var h_client = document.documentElement.clientTop || document.body.clientTop;
- var elRect=el.getBoundingClientRect();
- el.x= elRect.left + w_scroll - w_client;
- el.y= elRect.top + h_scroll - h_client;
- this.srcEl=el;
- this.myTarget=document.getElementById('lefttarget');
- var targetRect=this.myTarget.getBoundingClientRect();
- this.myTarget.x= targetRect.left + w_scroll - w_client;
- this.myTarget.y= targetRect.top + h_scroll - h_client;
- this.movEl = el.cloneNode(true);
- this.movEl.style.left=el.x+'px';
- this.movEl.style.top=el.y+'px';
- document.body.appendChild(this.movEl);
- this.flyAnimate();
- }
- }
- words=['treuber','zonner','annus','crane','et','us','alarm','between','then','you','found','round',
- 'like','any','other','flower','music','on','great','intro','step','trek','listening','of','hot','jar'];
- blocks=['leftpart','rightpart','centerheader','leftcenterpart','rightcenterpart','centerfooter','footer'];
- //------------------------------------------
- //------------------------------------------
- function fillin(num) {
- var st='';
- for (var i=0; i<num; i++) {
- var f=words[Math.round(Math.random()*25)];
- if (st!='')
- st+=' ';
- st+=f;
- }
- return st;
- }
- //---------------------------------------
- mkmenu=function() {
- parel=document.getElementById('inmenublock');
- inf= fillin(10);
- inf8=fillin(10);
- var a=['Home','',0];
- var b=['Flash lessons',inf,1];
- var c=['links',inf8,1];
- var menuItems=[a,b,c];
- for (var i=0;i<menuItems.length;i++) {
- el=document.createElement('DIV');
- el.className='slide';
- if (menuItems[i][2]!=0)
- {
- el.innerHTML='<a href="#" class="btn-slide" id="slide'+i+'">'+menuItems[i][0]+'</a>';
- var pane=document.createElement('DIV');
- pane.className='panel';
- pane.id='panel'+i;
- parel.appendChild(el);
- rect3=el.getBoundingClientRect();
- pane.style.left=rect3.left+'px';
- pane.style.top=rect3.bottom+'px';
- var txNode=document.createTextNode(menuItems[i][1]);
- pane.appendChild(txNode);
- document.body.appendChild(pane);
- $("#slide"+i).data('num',i);
- //-----------------------------------------
- $("#slide"+i).click(function () {
- i=$(this).data('num');
- //$(this).toggleClass("active");
- var isact=$(this).hasClass("active");
- $(".btn-slide").removeClass("active");
- $(".panel").fadeOut("slow");
- //$("#panel"+i).slideToggle("slow");
- if (!isact) {
- $(this).addClass("active");
- $("#panel"+i).slideDown("slow");
- }
- return false;
- });
- //-----------------------------------------
- $("#panel"+i).click(function() {
- $(this).slideUp("slow");
- $('#slide'+this.id.slice(5,6)).removeClass('active');
- })
- }
- else
- {
- el.innerHTML='<a href="#" class="btn-slide" id="slide'+i+'">'+menuItems[i][0]+'</a>';
- parel.appendChild(el);
- }
- }
- }
- //---------------------------------------
- function mktree(iter,block) {
- //alert(iter);
- iter++;
- if (iter>3) {return 0};
- var n_nodes=Math.round(Math.random()*25);
- if (iter==1)
- n_nodes=Math.min(Math.max(5,n_nodes),10);
- else
- if (n_nodes>8)
- n_nodes=0;
- //if ((n_nodes>9) && (iter>1))
- // n_nodes=0;
- var node8=document.createElement('UL');
- node8.className='treeContainer';
- block.appendChild(node8);
- for (var i=0; i<n_nodes;i++) {
- var li8=document.createElement('LI');
- li8.className='treeNode';
- li8.id='node'+iter*100+i;
- var tmpDiv=document.createElement('DIV');
- tmpDiv.className='treeExpand';
- li8.appendChild(tmpDiv);
- tmpDiv=document.createElement('DIV');
- tmpDiv.className='treeContent';
- li8.appendChild(tmpDiv);
- var subnodes=arguments.callee(iter,li8);
- tmpDiv.appendChild(document.createTextNode('Item-'+iter+'-'+i+'-'+subnodes));
- if (subnodes>0)
- $(li8).addClass('ExpandClosed')
- else
- $(li8).addClass('ExpandLeaf');
- //------
- if ((iter==1) && (i==0) && (subnodes==0)) {
- $(li8).addClass('IsUpper');
- }
- if (iter==1)
- $(li8).addClass('IsRoot');
- if (i==n_nodes-1)
- $(li8).addClass('IsLast');
- node8.appendChild(li8);
- }
- //alert(n_nodes);
- return n_nodes;
- }
- //-------------------------------------
- function hasClass(node,className) {
- return new RegExp("(\s|\S)*"+className+"(\s|\S)*").test(node.className);
- }
- //-------------------------------------
- function tree_toggle(event) {
- //alert('test');
- event= event || window.event;
- var clickedElem=event.target || event.srcElement;
- //alert(clickedElem.className);
- if (!hasClass(clickedElem,'Expand')) {
- return;
- }
- //alert('test');
- var node=clickedElem.parentNode;
- if (hasClass(node,'ExpandLeaf')) {
- return;
- }
- //alert('test');
- var newClass=hasClass(node,'ExpandOpen') ? 'ExpandClosed' : 'ExpandOpen';
- var re= /(^|\s)(ExpandOpen|ExpandClosed)(\s|$)/;
- node.className=node.className.replace(re,'$1'+newClass+'$3');
- }
- //---------------------------------------
- function mkacco(inel) {
- for (var i=0;i<4;i++) {
- var tmpDiv=document.createElement('DIV');
- tmpDiv.id=inel.id+'_'+'p'+i;
- var tmp=document.createElement('H3')
- tmp.appendChild(document.createTextNode('Element '+i));
- tmpDiv.appendChild(tmp);
- tmp=document.createElement('P');
- tmp.appendChild(document.createTextNode(fillin(50)));
- tmpDiv.appendChild(tmp);
- inel.appendChild(tmpDiv);
- }
- }
- //---------------------------------------------
- function toggleTabs() {
- isact=$(this).hasClass('active');
- isfull=$(this).parent().parent().hasClass('fullopen');
- if (!isfull) {
- $(this).parent().parent().find('p:visible').slideUp('fast');
- $(this).parent().parent().find('h3').removeClass('active');
- if (!isact) {
- $(this).next('p').slideDown('fast');
- $(this).addClass('active');
- }
- }
- else {
- if (!isact) {
- $(this).next('p').slideDown('fast');
- $(this).addClass('active');
- }
- else {
- $(this).next('p').slideUp('fast');
- $(this).removeClass('active');
- }
- }
- }
- //---------------------------------------------
- function switchpic() {
- //alert(this.pic);
- var img = new Image(150,150);
- img.src=this.pic;
- img.id='tempimg88';
- $('#inpic').empty();
- $('#inpic').append(img);
- }
- //---------------------------------------------
- function addInput(name,value) {
- var inp=document.createElement('INPUT');
- inp.type='BUTTON';
- inp.name=name;
- inp.id=name;
- inp.className='switchbutton';
- inp.value=value;
- inp.pic='photo/img'+inp.name.slice(3,4)+'.jpg';
- inp.onclick=switchpic;
- this.appendChild(inp);
- }
- //---------------------------------------------
- function mkpicdiv(el) {
- var tmpDiv=document.createElement('DIV');
- tmpDiv.id='inpic';
- el.appendChild(tmpDiv);
- var frm=document.createElement('FORM');
- frm.name='picchangeform';
- frm.id='picchangeform88';
- for (var i=1;i<6;i++) {
- addInput.apply(frm,['inp'+i,i]);
- }
- frm.inp1.onclick();
- $('#'+el.id).append(frm);
- }
- //---------------------------------------------
- //---------------------------------------------
- $(document).ready(function() {
- //---------------fill dummy content
- for (var i=0; i<blocks.length;i++) {
- el=document.getElementById(blocks[i]);
- var n_words= (el.id.indexOf('left')!=-1) ? 100:100;
- if (el.id!='leftcenterpart')
- el.appendChild(document.createTextNode(fillin(n_words)));
- else
- el.insertBefore(document.createTextNode(fillin(n_words)),el.firstChild);
- }
- //---------------------------mk menu
- mkmenu();
- //-------------------------mk tree
- var lp=document.getElementById('leftpart');
- var tmpDiv=document.createElement('DIV');
- tmpDiv.id='lefttree';
- lp.appendChild(tmpDiv);
- tmpDiv.onclick=function() {tree_toggle(arguments[0])};
- mktree(0,tmpDiv);
- //----------------------mk accordion
- mkacco(document.getElementById("acco1"));
- mkacco(document.getElementById("acco3"));
- $('#acco3').addClass('fullopen');
- $('.acco h3').click(toggleTabs);
- //---------------------picdiv
- mkpicdiv(document.getElementById('changephoto'));
- //-----------------------mk target
- lp=document.getElementById('leftcenterpart');
- tmpDiv=document.createElement('DIV');
- tmpDiv.id='lefttarget';
- //lp.insertBefore(tmpDiv,document.getElementById('changephoto'));
- lp.appendChild(tmpDiv);
- //------------------------Drag-n-Drop
- var ddin=$('#inheader');
- var bgimages=['bubi','chervi','piki','trefi'];
- for (var i=0;i<4;i++) {
- tmpDiv=document.createElement('DIV');
- tmpDiv.className='pcard';
- tmpDiv.id='pcard'+i;
- ddin.append(tmpDiv);
- tmpDiv.style['left']=((i*(tmpDiv.offsetWidth+3))+150)+'px';
- tmpDiv.style['background']='white url(pics/'+bgimages[i]+'.gif) center center no-repeat';
- }
- //-----------------------create drag n drop object
- newHelper=new Helper;
- dd=new DDrop(newHelper);
- //------------------------create fly animation object
- newFlyAnimator = new flyAnimator;
- o=newFlyAnimator;
- //---------------------correct blocks
- checkWin=function() {
- var winWidth=document.documentElement.clientWidth || document.body.clientWidth;
- var winHeight=document.documentElement.clientHeight || document.body.clientHeight;
- $('#sysinfo').html('width x height<br>'+winWidth+' x '+winHeight);
- function switchBlock(block,limitWidth) {
- if (winWidth<limitWidth)
- $(block).css('display','none');
- else
- $(block).css('display','block');
- }
- //$('#rightcenterpart').animate({width:"0"},"slow");
- switchBlock('#rightcenterpart',1000);
- switchBlock('#leftcenterpart',850);
- switchBlock('#centerpart',750);
- };
- window.onresize=checkWin;
- checkWin();
- //$('#lefttree').click(tree_toggle(arguments[0]));
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement