Javascript Tooltips, Popups, Captions - BoxOver  

Go Back   Javascript Tooltips, Popups, Captions - BoxOver > Javascipt calendar > Feedback
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
  #1  
Old 07-25-2007, 03:45 PM
zeroasterisk zeroasterisk is offline
Junior Member
 
Join Date: Jul 2007
Posts: 3
Send a message via AIM to zeroasterisk Send a message via Yahoo to zeroasterisk
Default modified script - past dates, date format, prefix with 0

See my attached modification of the most recent release (retrieved 2007.07.24).

It's got some vars at the top to control the date format and if to prefix the dates and months with a '0' . The formatting is respected on the output value as well as the input parsing.

I've also setup a variable to disable past date selections or to allow them.

This is without adding much to the size (7.3KB).

...hope this helps someone...

thanks,
-alan-
Attached Files
File Type: txt calendar.js.txt (7.3 KB, 646 views)
Reply With Quote
  #2  
Old 07-26-2007, 09:51 AM
carenthir carenthir is offline
Junior Member
 
Join Date: Jul 2007
Location: Paris
Posts: 3
Send a message via ICQ to carenthir
Thumbs up

Excellent ! That's precisely what was missing to the widget, IMHO, to complete Oliver's brilliant job. And what I also started to hack, but now can spare myself doing

mmmh, wait a minute... what's this ugly pink as a background ?? lol

I've just updated it a bit, and attached the code, to make it more standard compliant ( by adding "px" units for top and left positioning values ) as discussed in another topic here.

Thanks.

William
Attached Files
File Type: txt calendar.js.txt (7.4 KB, 355 views)
Reply With Quote
  #3  
Old 07-26-2007, 07:00 PM
darkloud darkloud is offline
Junior Member
 
Join Date: Jul 2007
Posts: 1
Default

Change the codes:
ccd=parseInt(curdtarr[0]); (etc)

for

ccd=parseInt(curdtarr[0], 10);


Motive:

When the month is september ('09') this undertand this like octal base, and convert to (0), giving then a undefined month.
Reply With Quote
  #4  
Old 08-03-2007, 08:36 AM
wantmore wantmore is offline
Junior Member
 
Join Date: Aug 2007
Posts: 1
Default Fixed calendar with past month and past year.

Hey guys,

I fixed the calendar and now it can do past month and year and without the "undefine date" problem.

Below is the code




/* --- Swazz Javascript Calendar ---
/* --- v 1.0 3rd November 2006
By Oliver Bryant
http://calendar.swazz.org
Modified by Alan Blount - alan[a7]zeroasterisk[d07]com
Modified by William Eriau - inmagnaveritas[at]gmail.com - fixed positioning problem when using doctype */

//var dateformat = 'ymd'; // year-month-date
//var dateformat = 'mdy'; // date-month-year
var dateformat = 'dmy'; // date-month-year (default)
var datesplitter = '/'; // in between date, month, year... typically '/' or '-'
var prefix0 = true; // months and dates less than 10, get prefixed w/ a '0'
var disablepast = false; // disable date selection in the past

document.write('<table id="fc" style="position:absolute;border-collapse:collapse;background:#FFFFFF;border:1px solid #ABABAB;display:none" cellpadding=2>');
document.write('<tr><td style="cursorointer" onclick="csuby()"><img src="arrowleftyear.gif" alt="Previous Year"></td><td style="cursorointer" onclick="csubm()"><img src="arrowleftmonth.gif" alt="Previous Month"></td><td colspan=3 id="mns" align="center" style="font:bold 13px Arial"></td><td align="right" style="cursorointer" onclick="caddm()"><img src="arrowrightmonth.gif" alt="Next Month"></td><td align="right" style="cursorointer" onclick="caddy()"><img src="arrowrightyear.gif" alt="Next Year"></td></tr>');
document.write('<tr><td align=center style="background:#ABABAB;font:12px Arial">S</td><td align=center style="background:#ABABAB;font:12px Arial">M</td><td align=center style="background:#ABABAB;font:12px Arial">T</td><td align=center style="background:#ABABAB;font:12px Arial">W</td><td align=center style="background:#ABABAB;font:12px Arial">T</td><td align=center style="background:#ABABAB;font:12px Arial">F</td><td align=center style="background:#ABABAB;font:12px Arial">S</td></tr>');
for(var kk=1;kk<=6;kk++) {
document.write('<tr>');
for(var tt=1;tt<=7;tt++) {
num=7 * (kk-1) - (-tt);
document.write('<td id="v' + num + '" style="width:18px;height:18px"> </td>');
}
document.write('</tr>');
}
document.write('</table>');

document.all?document.attachEvent('onclick',checkC lick):document.addEventListener('click',checkClick ,false);

// Calendar script
var now = new Date;
var sccm=now.getMonth();
var sccy=now.getFullYear();
var scfd=now.getDate();
var ccm=sccm;
var ccy=sccy;
var cfd=scfd;

var updobj;


var mn=new Array('JAN','FEB','MAR','APR','MAY','JUN','JUL','A UG','SEP','OCT','NOV','DEC');
var mnn=new Array('31','28','31','30','31','30','31','31','30' ,'31','30','31');
var mnl=new Array('31','29','31','30','31','30','31','31','30' ,'31','30','31');
var calvalarr=new Array(42);
prepcalendar('',ccm,ccy);
//getObj('fc'+cc).style.visibility='hidden';



function getObj(objID)
{
if (document.getElementById) {return document.getElementById(objID);}
else if (document.all) {return document.all[objID];}
else if (document.layers) {return document.layers[objID];}
}

function checkClick(e) {
e?evt=e:evt=event;
CSE=evt.target?evt.target:evt.srcElement;
if (getObj('fc'))
if (!isChild(CSE,getObj('fc')))
getObj('fc').style.display='none';
}

function isChild(s,d) {
while(s) {
if (s==d)
return true;
s=s.parentNode;
}
return false;
}

function Left(obj)
{
var curleft = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curleft += obj.offsetLeft
obj = obj.offsetParent;
}
}
else if (obj.x)
curleft += obj.x;
return curleft;
}

function Top(obj)
{
var curtop = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curtop += obj.offsetTop
obj = obj.offsetParent;
}
}
else if (obj.y)
curtop += obj.y;
return curtop;
}

function lcs(ielem) {
updobj=ielem;
getObj('fc').style.left = Left(ielem) + "px";
getObj('fc').style.top = Top(ielem) + ielem.offsetHeight + "px";
getObj('fc').style.display = '';

// First check date is valid
curdt=ielem.value;
curdtarr=curdt.replace(/\ /gi,'').replace(/[^0-9]/gi,'/').split('/');
isdt=true;
for(var k=0;k<curdtarr.length;k++) {
if (isNaN(parseInt(curdtarr[k])))
isdt=false;
}
if (isdt&(curdtarr.length==3)) {
if (dateformat=='ymd') {
ccy=parseInt(curdtarr[0], 10);
ccm=parseInt(curdtarr[1], 10)-1;
ccd=parseInt(curdtarr[2], 10);
} else if (dateformat=='mdy') {
ccy=parseInt(curdtarr[2], 10);
ccm=parseInt(curdtarr[0], 10)-1;
ccd=parseInt(curdtarr[1], 10);
} else {
ccy=parseInt(curdtarr[2], 10);
ccm=parseInt(curdtarr[1], 10)-1;
ccd=parseInt(curdtarr[0], 10);
}
prepcalendar(ccd,ccm,ccy);
}
}

function evtTgt(e)
{
var el;
if(e.target)el=e.target;
else if(e.srcElement)el=e.srcElement;
if(el.nodeType==3)el=el.parentNode; // defeat Safari bug
return el;
}
function EvtObj(e){if(!e)e=window.event;return e;}
function cs_over(e) {
evtTgt(EvtObj(e)).style.background='#FFCC66';
}
function cs_out(e) {
evtTgt(EvtObj(e)).style.background='#FFF0F5';
}
function cs_click(e) {
updobj.value=calvalarr[evtTgt(EvtObj(e)).id.substring(1,evtTgt(EvtObj(e)) .id.length)];
getObj('fc').style.display='none';

}

function f_cps(obj) {
obj.style.background='#FFF0F5';
obj.style.font='10px Arial';
obj.style.color='#333333';
obj.style.textAlign='center';
obj.style.textDecoration='none';
obj.style.border='1px solid #FFE4E1';
obj.style.cursor='pointer';
}

function f_cpps(obj) {
obj.style.background='#FFF0F5';
obj.style.font='10px Arial';
obj.style.color='#ABABAB';
obj.style.textAlign='center';
obj.style.textDecoration='line-through';
obj.style.border='1px solid #FAF0E6';
obj.style.cursor='default';
}

function f_hds(obj) {
obj.style.background='#E36087';
obj.style.font='bold 10px Arial';
obj.style.color='#000000';
obj.style.textAlign='center';
obj.style.border='1px solid #250709';
obj.style.cursor='pointer';
}

// day selected
function prepcalendar(hd,cm,cy) {
now=new Date();
sd=now.getDate();
td=new Date();
td.setDate(1);
td.setFullYear(cy);
td.setMonth(cm);
cd=td.getDay();
getObj('mns').innerHTML=mn[cm]+ ' ' + cy;
marr=((cy%4)==0)?mnl:mnn;
for(var d=1;d<=42;d++) {
f_cps(getObj('v'+parseInt(d)));
if ((d >= (cd -(-1))) && (d<=cd-(-marr[cm]))) {
dip=(disablepast&&(d-cd < sd)&&(cm==sccm)&&(cy==sccy));
htd=((hd!='')&&(d-cd==hd));
if (dip)
f_cpps(getObj('v'+parseInt(d)));
else if (htd)
f_hds(getObj('v'+parseInt(d)));
else
f_cps(getObj('v'+parseInt(d)));

getObj('v'+parseInt(d)).onmouseover=(dip)?null:cs_ over;
getObj('v'+parseInt(d)).onmouseout=(dip)?null:cs_o ut;
getObj('v'+parseInt(d)).onclick=(dip)?null:cs_clic k;

getObj('v'+parseInt(d)).innerHTML=d-cd;

cmx = parseInt(cm)+1;
if (cmx < 10 && prefix0==true) {
cmx = '0'+cmx;
}
dx = d-cd;
if (dx < 10 && prefix0==true) {
dx = '0'+dx;
}
if (dateformat=='ymd') {
calvalarr[d]=''+cy+datesplitter+cmx+datesplitter+dx;
} else if (dateformat=='mdy') {
calvalarr[d]=''+cmx+datesplitter+dx+datesplitter+cy;
} else {
calvalarr[d]=''+dx+datesplitter+cmx+datesplitter+cy;
}
}
else {
getObj('v'+d).innerHTML=' ';
getObj('v'+parseInt(d)).onmouseover=null;
getObj('v'+parseInt(d)).onmouseout=null;
getObj('v'+parseInt(d)).style.cursor='default';
}
}
}

function caddm() {
marr=((ccy%4)==0)?mnl:mnn;

ccm+=1;
if (ccm>=12) {
ccm=0;
ccy++;
}
cdayf();
prepcalendar('',ccm,ccy);
}
//Added for Next Year Function
function caddy() {
marr=((ccy%4)==0)?mnl:mnn;
ccy++;
prepcalendar('',ccm,ccy);
}


function csubm() {
marr=((ccy%4)==0)?mnl:mnn;

ccm-=1;
if (ccm<0) {
ccm=11;
ccy--;
}
cdayf();
prepcalendar('',ccm,ccy);
}
//added for Previous Year Function
function csuby() {
marr=((ccy%4)==0)?mnl:mnn;

ccy--;
prepcalendar('',ccm,ccy);
}


function cdayf() {
if (!disablepast||((ccy>sccy)||((ccy==sccy)&&(ccm>=sc cm))))
return;
else {
ccy=sccy;
ccm=sccm;
cfd=scfd;
}
}
Reply With Quote
  #5  
Old 08-16-2007, 05:25 PM
Dreamweaver Dreamweaver is offline
Junior Member
 
Join Date: Jun 2007
Posts: 15
Default

Hi @all,

I've modified it again:

- You can choose German as second language
- You can choose your startday (Monday or Sunday)
- You can allow or disable the Past with only one command: lcs(this, true) or lcs(this, false).

Have fun with these featuers
Attached Files
File Type: txt calendar_150807.js.txt (11.3 KB, 569 views)
Reply With Quote
  #6  
Old 09-07-2007, 02:37 PM
jmc127 jmc127 is offline
Junior Member
 
Join Date: Sep 2007
Posts: 4
Default I want to Disable Saturday and Sunday!

Hey,

I want the past days as while as the present Saturday and Sunday field disable.
Reply With Quote
  #7  
Old 10-29-2007, 11:03 AM
addiakogiannis addiakogiannis is offline
Junior Member
 
Join Date: Oct 2007
Posts: 1
Default Greek as an extra language

I added Greek as an extra language
Attached Files
File Type: zip calendar.zip (4.8 KB, 210 views)
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 08:25 PM.