SỐ LƯỢT TRUY CẬP

5
2
7
6
1
8
1
4

Tiêu đề

Lịch sự kiện - Trang chủ 

XslContent

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:msxsl="urn:schemas-microsoft-com:xslt"
  xmlns:rs='urn:schemas-microsoft-com:rowset'
  xmlns:z='#RowsetSchema'
  xmlns:js="urn:custom-javascript"
  exclude-result-prefixes="msxsl js"
  xmlns:cs="urn:my-scripts"
  >
  <xsl:output method="xml" indent="yes"/>

  <xsl:template match="rs:data">

    <xsl:variable name="Page">/pages/su-kien-noi-bat.aspx</xsl:variable>

    <xsl:variable name="ItemCount" select="@ItemCount"/>

    <!--<link rel="stylesheet" type="text/css" href="/_CONTROLTEMPLATES/LacViet.CMS.TopNews/css/eventcalendar.css"></link>-->
    <script type="text/javascript" src="/SiteAssets/js/jquery/1.4.4/jquery.min.js">a = 0;</script>
    <script type="text/javascript" >
      <xsl:text disable-output-escaping="yes">
          <![CDATA[
          function padleft(val, ch, num) {
            var re = new RegExp(".{" + num + "}$");
            var pad = "";
            if (!ch) ch = " ";
            do {
                pad += ch;
            } while (pad.length < num);
            return re.exec(pad + val)[0];
          }
           function countdown_clock(year, month, day, hour, minute, format,begin,end) {

               countdown(year, month, day, hour, minute, format);
               changeevent(begin, end);
           }
           function changeevent(begin, end) {

               if (begin == end)
                   begin = 0;

               $(".ecline").hide();
               $(".event" + begin).show();

               begin = begin + 1;

               setTimeout('changeevent(' + begin + ',' + end +');', 10000);
           }

           function countdown(year, month, day, hour, minute, format, classname) {
            
               Today = new Date();
               Todays_Year = Today.getFullYear() - 2000;
             
               Todays_Month = Today.getMonth();

               //Convert both today's date and the target date into miliseconds.                          
               Todays_Date = (new Date(Todays_Year, Todays_Month, Today.getDate(),
                                   Today.getHours(), Today.getMinutes(), Today.getSeconds())).getTime();
               Target_Date = (new Date(year, month - 1, day, hour, minute, 00)).getTime();

               //Find their difference, and convert that into seconds.                 
               Time_Left = Math.round((Target_Date - Todays_Date) / 1000);

               if (Time_Left < 0)
                   Time_Left = 0;

               var innerHTML = '';

               switch (format) {
                   case 0:
                       //The simplest way to display the time left.
                       innerHTML = Time_Left + ' giây';
                       break;
                   case 1:
                       //More datailed.
                       days = Math.floor(Time_Left / (60 * 60 * 24));
                       Time_Left %= (60 * 60 * 24);
                       hours = Math.floor(Time_Left / (60 * 60));
                       Time_Left %= (60 * 60);
                       minutes = Math.floor(Time_Left / 60);
                       Time_Left %= 60;
                       seconds = Time_Left;

                       dps = ''; hps = ''; mps = ''; sps = '';
                       //ps is short for plural suffix.
                       if (days == 1) dps = '';
                       if (hours == 1) hps = '';
                       if (minutes == 1) mps = '';
                       if (seconds == 1) sps = '';

                       innerHTML = "Còn " + days + ' ngày ' + dps + ' ';
                       innerHTML += padleft(hours, '0', '2') + ':' + hps;
                       innerHTML += padleft(minutes, '0', '2') + ':' + mps;
                       innerHTML += padleft(seconds, '0', '2');
                       break;
                   default:
                       innerHTML = "Còn" + Time_Left + ' giây';
               }

                $("." + classname).html(innerHTML);
                if (days == 0 && hours == 0 && minutes == 0)
                {
                    $("." + classname).html("Sự kiện đang diễn ra");
                }
                else
                {
                   setTimeout('countdown(' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ',' + format + ',"'+ classname  +'");', 1000);
                }
                
                
                
           }

              $(document).ready(function () {
               
                 $(".ectimercountdown").each(function () {

                    var year = $(this).attr("year");
                    var month = $(this).attr("month");
                    var day = $(this).attr("day");
                    var hour = $(this).attr("hour");
                    var minute = $(this).attr("minute");
                    var classname = $(this).attr("classname");
                    var indexelement =  $(this).attr("index");
                    var urlpopup = $(this).attr("UrlPopup");
                    var status = $(this).attr("status");
                      
                    var titlepopup = "EventInformation" + indexelement;
                    if (status == "1")                    
                    {
                      $("." + classname).html("Sự kiện đang diễn ra");
                      var distance = (200 - (indexelement*50));
                      var configpopup = "menubar=1,resizable=1,left=" + distance + ",top=" + distance;
                      window.open (urlpopup,titlepopup,configpopup);
                      //window.location = urlpopup;
                    }
                    if (status == "2" || status == "" || status == null)
                    {
                      $("." + classname).html(" ");
                    }
                    if (status == "0")
                    {
                        countdown(year,month,day,hour,minute,1,classname);
                    }

                    
                     changeevent(0, ]]>
      </xsl:text>
      <xsl:value-of select="$ItemCount"/>
      <xsl:text disable-output-escaping="yes"><![CDATA[ );
                 });
             });

          ]]>
      </xsl:text>
    </script>

    <div class="eventcalender">
      <!--<a href="{$Page}">-->
      <a href="/pages/truyen-hinh-truc-tiep.aspx">
        <div class="ectitle">
          Sự kiện
        </div>
      </a>
      <xsl:for-each select="z:row">

        <xsl:variable name="levelCount" select="position() - 1"/>
        <xsl:variable name="year" select="cs:year(@ows_StartDate)"/>
        <xsl:variable name="month" select="cs:month(@ows_StartDate)"/>
        <xsl:variable name="day" select="cs:day(@ows_StartDate)"/>
        <xsl:variable name="hour" select="cs:hour(@ows_StartDate)"/>
        <xsl:variable name="minute" select="cs:minute(@ows_StartDate)"/>
        <xsl:variable name="status" select="cs:status(@ows_StartDate,@ows_EndDate)"/>

        <xsl:variable name="UrlLink">
          <xsl:if test="cs:CheckEmptyText(@ows_UrlLink) = '1'">#</xsl:if>
          <xsl:if test="cs:CheckEmptyText(@ows_UrlLink) = '0'">
            <xsl:value-of select="@ows_UrlLink"/>
          </xsl:if>
        </xsl:variable>

        <xsl:variable name="Target">
          <xsl:if test="$UrlLink = '#'">_self</xsl:if>
          <xsl:if test="$UrlLink != '#'">_blank</xsl:if>
        </xsl:variable>

        <xsl:variable name="UrlDetail">
          <xsl:value-of select="$Page"/>?ItemID=<xsl:value-of select="@ows_ID"/>
        </xsl:variable>

        <div class="ecline event{$levelCount}">

          <div class="eczone1">
            <a href="{$UrlLink}" target="{$Target}" title="{@ows_Description}">
            <!--<a href="{$UrlDetail}" title="{@ows_Description}">-->
              <div class="ecimg">
                <img alt="@ows_Description" src="{@ows_ImageThumbnail}" class="ecimgsrc" />
              </div>
              <div class="ectimercountdown ectimer{$levelCount}" index="{$levelCount}" year="{$year}" month="{$month}" day="{$day}" hour="{$hour}" minute="{$minute}" classname="ectimer{$levelCount}" StartDate="{@ows_StartDate}" EndDate="{@ows_EndDate}" urlpopup="{@ows_UrlPopup}" status="{$status}" >
                .
              </div>
            </a>
          </div>

          <div class="eczone2">
            <div class="eczone2title">
              <a href="{$UrlDetail}" title="{@ows_Description}">
                <xsl:value-of select="@ows_Title"/>
              </a>
            </div>
            <div class="eczone2description">
              <div class="ecstartdate">
                <span class="ecstartdate-title">
                  Ngày bắt đầu:
                </span>
                <span class="ecstartdate-value">
                  <xsl:value-of select="substring(@ows_StartDate, 9, 2)"/>/<xsl:value-of select="substring(@ows_StartDate, 6, 2)"/>/<xsl:value-of select="substring(@ows_StartDate, 1, 4)"/><xsl:text disable-output-escaping="yes">,<![CDATA[&nbsp;]]></xsl:text><xsl:value-of select="substring(@ows_StartDate, 12, 2)"/>:<xsl:value-of select="substring(@ows_StartDate, 15, 2)"/>
                </span>

              </div>
              <div class="eclocation">
                <div class="eclocation-title">
                  Địa điểm diễn ra sự kiện:
                </div>
                <div class="eclocation-value">
                  <xsl:value-of select="@ows_Location"/>
                </div>

              </div>
            </div>
          </div>

        </div>
      </xsl:for-each>

    </div>
  </xsl:template>

  <msxsl:script language="C#" implements-prefix="cs">
    <![CDATA[
    
    
     public string status(string startdate,string enddate)
    {
        try
        {

            DateTime Today= DateTime.Now;
            DateTime StartDate = Convert.ToDateTime(startdate);
            DateTime EndDate = Convert.ToDateTime(enddate);
            if (StartDate <= Today && Today <= EndDate)
                return "1";
            if ( Today > EndDate)
                return "2";
            if (Today < StartDate)
                return "0";
            return "0";
        }
        catch
        {

            return "";
        }
    }
    
        public string CheckEmptyText(string text)
        {
          return string.IsNullOrEmpty(text) ? "1" : "0";
        }
      
        public string year(string datetime)
        {
            try
            {
                DateTime startDate = Convert.ToDateTime(datetime);
                int currentYear = startDate.Year - 2000;
                return currentYear + "";
            }
            catch
            {
                return "";
            }
        }
        
          public string month(string datetime)
          {
              try
              {
                  DateTime startDate = Convert.ToDateTime(datetime);
                  int currentMonth = startDate.Month;
                  return currentMonth + "";
              }
              catch
              {
                  return "";
              }
          }

          public string day(string datetime)
          {
              try
              {
                  DateTime startDate = Convert.ToDateTime(datetime);
                  int currentDay = startDate.Day;
                  return currentDay + "";
              }
              catch
              {

                  return "";
              }
          }

          public string hour(string datetime)
          {
              try
              {
                  DateTime startDate = Convert.ToDateTime(datetime);
                  int currentHour = startDate.Hour;
                  return currentHour + "";
              }
              catch
              {
                  return "";
              }
          }

          public string minute(string datetime)
          {
              try
              {
                  DateTime startDate = Convert.ToDateTime(datetime);
                  int currentMinute = startDate.Minute;
                  return currentMinute + "";
              }
              catch
              {
                  return "";
              }
          }
        
    ]]>
  </msxsl:script>

</xsl:stylesheet>
Tệp đính kèm
Đã tạo vào thời điểm 09/04/2015 3:12 CH  bởi System Account 
Được sửa tại 09/04/2015 3:12 CH  bởi System Account