Friday, June 12, 2009

Блогтоо календар нэмэх


Энэ календар нь JavaScript хэл дээр бичигдсэн юм байна. Хэрэглэхэд хялбар. Мөн нэг давуу тал нь хажуудаа цаг гаргаж байх юм да. Ер нь дараа нь ямар төрлийн хичээлүүд нэмэж болохоор байна надад саналаа хэлвэл яасан юм. Энд тавичихмаар олон л юм байна. Зав гарахаараа л нэгийг нь хөрвүүлэх юм. Зарим нэг сар өдрийг нь орчуулаад тавьсан үлдснийг нь та хийгээрэй. Ингээд эхлэе. Блогтоо нэвтрээд -> Dashboard -> Layout -> Page Element -> HTML/JavaScript -> Add a Gadget - HTML/JavaScript гэж ороод доорхи кодыг хуулж тавь.


<style type="text/css">

<!--

body,td,th {

font-size: 10px;

}

-->

</style><script>

/*Copyright 1996 - Tomer and Yehuda Shiran

Feel free to "steal" this code provided that you leave this notice as is.

Additional examples from the book can be found at http://www.geocities.com/SiliconValley/9000/

For more information contact Tomer or Yehuda Shiran <yshiran@iil.intel.com>*/



setCal()



function getTime() {

// initialize time-related variables with current time settings

var now = new Date()

var hour = now.getHours()

var minute = now.getMinutes()

now = null

var ampm = ""



// validate hour values and set value of ampm

if (hour >= 12) {

hour -= 12

ampm = "PM"

} else

ampm = "AM"

hour = (hour == 0) ? 12 : hour



// add zero digit to a one digit minute

if (minute < 10)

minute = "0" + minute // do not parse this number!



// return time string

return hour + ":" + minute + " " + ampm

}



function leapYear(year) {

if (year % 4 == 0) // basic rule

return true // is leap year

/* else */ // else not needed when statement is "return"

return false // is not leap year

}



function getDays(month, year) {

// create array to hold number of days in each month

var ar = new Array(12)

ar[0] = 31 // Нэгдүгээр сар

ar[1] = (leapYear(year)) ? 29 : 28 // Хоёрдугаар сар

ar[2] = 31 // Гуравдугаар сар

ar[3] = 30 // Дөрөвдүгээр сар

ar[4] = 31 // Тавдугаар сар

ar[5] = 30 // Зургадугаар сар

ar[6] = 31 // Долдугаар сар

ar[7] = 31 // Наймдугаар сар

ar[8] = 30 // Есдүгээр сар

ar[9] = 31 // Аравдугаар сар

ar[10] = 30 // Арван нэгдүгээр сар

ar[11] = 31 // Арван хоёрдугаар сар



// return number of days in the specified month (parameter)

return ar[month]

}



function getMonthName(month) {

// create array to hold name of each month

var ar = new Array(12)

ar[0] = "January"

ar[1] = "February"

ar[2] = "March"

ar[3] = "April"

ar[4] = "May"

ar[5] = "Зургадугаар сар"

ar[6] = "July"

ar[7] = "August"

ar[8] = "September"

ar[9] = "October"

ar[10] = "November"

ar[11] = "December"



// return name of specified month (parameter)

return ar[month]

}



function setCal() {

// standard time attributes

var now = new Date()

var year = now.getYear()

if (year < 1000)

year+=1900

var month = now.getMonth()

var monthName = getMonthName(month)

var date = now.getDate()

now = null



// create instance of first day of month, and extract the day on which it occurs

var firstDayInstance = new Date(year, month, 1)

var firstDay = firstDayInstance.getDay()

firstDayInstance = null



// number of days in current month

var days = getDays(month, year)



// call function to draw calendar

drawCal(firstDay + 1, days, date, monthName, year)

}



function drawCal(firstDay, lastDate, date, monthName, year) {

// constant table settings

var headerHeight = 10 // height of the table's header cell

var border = 1 // 3D height of table's border

var cellspacing = 1 // width of table's border

var headerColor = "midnightblue" // color of table's header

var headerSize = "+1" // size of tables header font

var colWidth = 40 // width of columns in table

var dayCellHeight = 10 // height of cells containing days of the week

var dayColor = "darkblue" // color of font representing week days

var cellHeight = 10 // height of cells representing dates in the calendar

var todayColor = "red" // color specifying today's date in the calendar

var timeColor = "purple" // color of font representing current time



// create basic table structure

var text = "" // initialize accumulative variable to empty string

text += '<center>'

text += '<table border=" + border + " cellspacing=" + cellspacing + ">' // table settings

text += '<th colspan="7" height=" + headerHeight + ">' // create table header cell

text += '<font color="' + headerColor + '" size=" + headerSize + ">' // set font for table header

text += monthName + ' ' + year

text += '</font>' // close table header's font settings

text += '</th>' // close header cell



// variables to hold constant settings

var openCol = '<td width=" + colWidth + " height=" + dayCellHeight + ">'

openCol += '<font color="' + dayColor + '">'

var closeCol = '</font></td>'



// create array of abbreviated day names

var weekDay = new Array(7)

weekDay[0] = "Sun"

weekDay[1] = "Mon"



weekDay[2] = "Tues"

weekDay[3] = "Wed"

weekDay[4] = "Thu"

weekDay[5] = "Fri"

weekDay[6] = "Sat"



// create first row of table to set column width and specify week day

text += '<tr valign="center" align="center">'

for (var dayNum = 0; dayNum < 7; ++dayNum) {

text += openCol + weekDay[dayNum] + closeCol

}

text += '</tr>'



// declaration and initialization of two variables to help with tables

var digit = 1

var curCell = 1



for (var row = 1; row <= Math.ceil((lastDate + firstDay - 1) / 7); ++row) {

text += '<tr valign="top" align="right">'

for (var col = 1; col <= 7; ++col) {

if (digit > lastDate)

break

if (curCell < firstDay) {

text += '<td></td>';

curCell++

} else {

if (digit == date) { // current cell represent today's date

text += '<td height=" + cellHeight + ">'

text += '<font color="' + todayColor + '">'

text += digit

text += '</font><br>'

text += '<font color="' + timeColor + '" size="1">'

text += '<center>' + getTime() + '</center>'

text += '</font>'

text += '</td>'

} else

text += '<td height=" + cellHeight + ">' + digit + '</td>'

digit++

}

}

text += '</tr>'

}



// close all basic table tags

text += '</table>'

text += '</center>'



// print accumulative HTML string

document.write(text)

}

</script>

Save лараад боллоо.

8 comments:

Anonymous said...

Hi. payral payment system on your website made easier- sedbeer hicheel oruulj ogohiig hysch bna.

lesson said...

Хэрэглэгчийн хүсэлт:
payral биш payрal payment-г асуусан байлгүй дээ. Энэ талаар энд бичээд яахав дэлгэрэнгүй мэдээлэлтэй сайтын холбоос орууллаа. Эндээс үз
http://www.asuult.net/paypal.php

bayaraa said...

bayarlalaa mash ix sanal asuulga oruulj ogooch.

bayaraa said...

mash ix bayalaj bna tanid gunee talarhaj bn. tsas oruulah mon google reklam bairluulah mon huulhaas hamgaalah mon adminas mendchilgee ireh jishee n blogiig neehed jijig tsonxoor odriin mend geed l bas, mon alga boldgui tsonhig dagaad yavaad bdg zurag bairlulax mon blog neegdehed duu tavij bolxuu edgeer bolomjtoi yu xariu ogoore tanai blogoos oor haanaas cod olj bolx ve. ta haanaas olood bn.

Tu[R]uu*[mN] said...

Yuch oilgodoggvi ee

delden said...

odoo l uchriig ni olloo bayrlasan shuu
ushuu goy goy yum bicheeree ok

E.Janlav said...

bi neg blog neesen uhaantai ymaa terendee hicheel gesen linked medeelel oruuldh gesen medleg dutaad boldoggvi tuslaach anda

Badamlynhua Enhbayar said...

Календар тавих гэсэн юмаа кодыг нь хаанаас яаж авах вэ?

Post a Comment