Plugin Directory

Changeset 1471996


Ignore:
Timestamp:
08/11/2016 05:02:51 AM (10 years ago)
Author:
ughimire1
Message:

design change and some issue fixed

Location:
patro/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • patro/trunk/Patro.php

    r1266313 r1471996  
    55 * Description:Show Nepali Patro (BS Calender)
    66 * Author: Umesh Ghimire
    7  * Version: 1.1
     7 * Version: 1.2
    88 * Author URI: http://umeshghimire.com.np
    99 */
  • patro/trunk/css/patro.css

    r1266313 r1471996  
    7878
    7979}
     80
     81.NepaliPatroElement table {
     82
     83    width: 100%;
     84
     85    border: none;
     86}
     87
     88.NepaliPatroElement table td, .NepaliPatroElement table th {
     89
     90    border-left: 1px solid #e1e1e1;
     91    border-right: 0 !important;
     92    border-top: 0 !important;
     93    border-bottom: 1px solid #e1e1e1;
     94    padding: 0.4em;
     95    font-weight: normal;
     96
     97}
     98
     99/* version 2 */
     100table#NepaliPatro thead tr:first-child th:first-child:hover {
     101    cursor: pointer;
     102}
  • patro/trunk/js/patro.js

    r1266313 r1471996  
    1     var $ = jQuery;
     1var $ = jQuery;
    22
    33(function ($) {
     
    66
    77
    8         var selector = this.selector;
    9         console.log($(this.selector));
    10 
    11 
    12         var Lang;
    13 
    14         function getCookie(cname) {
    15             var name = cname + "=";
    16             var ca = document.cookie.split(';');
    17             for (var i = 0; i < ca.length; i++) {
    18                 var c = ca[i];
    19                 while (c.charAt(0) == ' ') c = c.substring(1);
    20                 if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
     8        $.each($(this), function () {
     9            //$.eac($(this),function(){
     10
     11            var $selector = $(this);
     12
     13
     14            var Lang;
     15
     16            function getCookie(cname) {
     17                var name = cname + "=";
     18                var ca = document.cookie.split(';');
     19                for (var i = 0; i < ca.length; i++) {
     20                    var c = ca[i];
     21                    while (c.charAt(0) == ' ') c = c.substring(1);
     22                    if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
     23                }
     24                return "";
    2125            }
    22             return "";
    23         }
    24 
    25         document.cookie = "PatroLangCookie=np";
    26         Lang = getCookie("PatroLangCookie");
    27 
    28 
    29         Lang == '' ? Lang = "np" : Lang;
    30 
    31 
    32         if (Lang == "en") {
    33             var PatroLang = {
    34                 Prev: "Prev",
    35                 CurrentMonth: "January",
    36                 Next: "Next",
    37                 FirstDay: "Sun",
    38                 SecondDay: "Mon",
    39                 ThirdDay: "Tue",
    40                 FourthDay: "Wed",
    41                 FifthDay: "Thu",
    42                 SixthDay: "Fri",
    43                 SeventhDay: "Sat",
     26
     27            document.cookie = "PatroLangCookie=np";
     28            Lang = getCookie("PatroLangCookie");
     29
     30
     31            Lang == '' ? Lang = "np" : Lang;
     32
     33
     34            if (Lang == "en") {
     35                var PatroLang = {
     36                    Prev: "Prev",
     37                    CurrentMonth: "January",
     38                    Next: "Next",
     39                    FirstDay: "Sun",
     40                    SecondDay: "Mon",
     41                    ThirdDay: "Tue",
     42                    FourthDay: "Wed",
     43                    FifthDay: "Thu",
     44                    SixthDay: "Fri",
     45                    SeventhDay: "Sat",
     46                    One: "1",
     47                    Two: "2",
     48                    Three: "3",
     49                    Four: "4",
     50                    Five: "5",
     51                    Six: "6",
     52                    Seven: "7",
     53                    Eight: "8",
     54                    Nine: "9",
     55                    Zero: "0",
     56                    CurrentYear: '2015'
     57
     58                }
     59            } else if (Lang == "np") {
     60
     61                var PatroLang = {
     62                    //Prev: "अघि",
     63                    Prev: "<<",
     64                    CurrentMonth: "वैशाख",
     65                    Next: ">>",
     66                    //Next: "पछि",
     67                    FirstDay: "आईत",
     68                    SecondDay: "सोम",
     69                    ThirdDay: "मंगल",
     70                    FourthDay: "बुध",
     71                    FifthDay: "बिही",
     72                    SixthDay: "शुक्र",
     73                    SeventhDay: "शनी",
     74                    One: "१",
     75                    Two: "२",
     76                    Three: "३",
     77                    Four: "४",
     78                    Five: "५",
     79                    Six: "६",
     80                    Seven: "७",
     81                    Eight: "८",
     82                    Nine: "९",
     83                    Zero: "०",
     84                    CurrentYear: "२०७२"
     85
     86                }
     87            }
     88
     89            var BaseDigit = new Array("Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine");
     90
     91            var NPDigit = {
     92
     93                One: "१",
     94                Two: "२",
     95                Three: "३",
     96                Four: "४",
     97                Five: "५",
     98                Six: "६",
     99                Seven: "७",
     100                Eight: "८",
     101                Nine: "९",
     102                Zero: "०"
     103
     104            }
     105
     106            var ENDigit = {
     107
    44108                One: "1",
    45109                Two: "2",
     
    51115                Eight: "8",
    52116                Nine: "9",
    53                 Zero: "0",
    54                 CurrentYear: '2015'
     117                Zero: "0"
    55118
    56119            }
    57         } else if (Lang == "np") {
    58 
    59             var PatroLang = {
    60                 //Prev: "अघि",
    61                 Prev: "<<",
    62                 CurrentMonth: "वैशाख",
    63                 Next: ">>",
    64                 //Next: "पछि",
    65                 FirstDay: "आईत",
    66                 SecondDay: "सोम",
    67                 ThirdDay: "मंगल",
    68                 FourthDay: "बुध",
    69                 FifthDay: "बिही",
    70                 SixthDay: "शुक्र",
    71                 SeventhDay: "शनी",
    72                 One: "१",
    73                 Two: "२",
    74                 Three: "३",
    75                 Four: "४",
    76                 Five: "५",
    77                 Six: "६",
    78                 Seven: "७",
    79                 Eight: "८",
    80                 Nine: "९",
    81                 Zero: "०",
    82                 CurrentYear: "२०७२"
     120
     121            var NPWeekDay = new Array("आईत", "सोम", "मंगल", "बुध", "बिही", "शुक्र", "शनी");
     122
     123            var NPMonth = new Array("बैशाख", "जेठ", "अषाढ", "श्रावण", "भाद्र", "आश्विन", "कार्तिक", "मङ्सिर", "पौष", "माघ", "फाल्गुन", "चैत्र");
     124
     125            var ENMonth = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
     126            var GlobalObj;
     127
     128
     129            var RefDate = {
     130
     131                BS: '2000/01/01',
     132                AD: '1943/04/14'
     133
    83134
    84135            }
    85         }
    86 
    87         var BaseDigit = new Array("Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine");
    88 
    89         var NPDigit = {
    90 
    91             One: "१",
    92             Two: "२",
    93             Three: "३",
    94             Four: "४",
    95             Five: "५",
    96             Six: "६",
    97             Seven: "७",
    98             Eight: "८",
    99             Nine: "९",
    100             Zero: "०"
    101 
    102         }
    103 
    104         var ENDigit = {
    105 
    106             One: "1",
    107             Two: "2",
    108             Three: "3",
    109             Four: "4",
    110             Five: "5",
    111             Six: "6",
    112             Seven: "7",
    113             Eight: "8",
    114             Nine: "9",
    115             Zero: "0"
    116 
    117         }
    118 
    119         var NPWeekDay = new Array("आईत", "सोम", "मंगल", "बुध", "बिही", "शुक्र", "शनी");
    120 
    121         var NPMonth = new Array('बैशाख', 'जेठ', 'अषाढ', 'श्रावण', 'भाद्र', 'आश्विन', 'कार्तिक', 'मङ्सिर', 'पौष', 'माघ', 'फाल्गुन', 'चैत्र');
    122 
    123         var ENMonth = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
    124         var GlobalObj;
    125 
    126 
    127         var RefDate = {
    128 
    129             BS: '2000/01/01',
    130             AD: '1943/04/14'
    131 
    132 
    133         }
    134 
    135         var BS = {};
    136         BS[2000] = new Array(30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31);
    137         BS[2001] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
    138         BS[2002] = new Array(31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30);
    139         BS[2003] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31);
    140         BS[2004] = new Array(30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31);
    141         BS[2005] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
    142         BS[2006] = new Array(31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30);
    143         BS[2007] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31);
    144         BS[2008] = new Array(31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31);
    145         BS[2009] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
    146         BS[2010] = new Array(31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30);
    147         BS[2011] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31);
    148         BS[2012] = new Array(31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30);
    149         BS[2013] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
    150         BS[2014] = new Array(31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30);
    151         BS[2015] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31);
    152         BS[2016] = new Array(31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30);
    153         BS[2017] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
    154         BS[2018] = new Array(31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30);
    155         BS[2019] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31);
    156         BS[2020] = new Array(31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30);
    157         BS[2021] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
    158         BS[2022] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30);
    159         BS[2023] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31);
    160         BS[2024] = new Array(31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30);
    161         BS[2025] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
    162         BS[2026] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31);
    163         BS[2027] = new Array(30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31);
    164         BS[2028] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
    165         BS[2029] = new Array(31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30);
    166         BS[2030] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31);
    167         BS[2031] = new Array(30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31);
    168         BS[2032] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
    169         BS[2033] = new Array(31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30);
    170         BS[2034] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31);
    171         BS[2035] = new Array(30, 32, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31);
    172         BS[2036] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
    173         BS[2037] = new Array(31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30);
    174         BS[2038] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31);
    175         BS[2039] = new Array(31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30);
    176         BS[2040] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
    177         BS[2041] = new Array(31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30);
    178         BS[2042] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31);
    179         BS[2043] = new Array(31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30);
    180         BS[2044] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
    181         BS[2045] = new Array(31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30);
    182         BS[2046] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31);
    183         BS[2047] = new Array(31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30);
    184         BS[2048] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
    185         BS[2049] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30);
    186         BS[2050] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31);
    187         BS[2051] = new Array(31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30);
    188         BS[2052] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
    189         BS[2053] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30);
    190         BS[2054] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31);
    191         BS[2055] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
    192         BS[2056] = new Array(31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30);
    193         BS[2057] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31);
    194         BS[2058] = new Array(30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31);
    195         BS[2059] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
    196         BS[2060] = new Array(31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30);
    197         BS[2061] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31);
    198         BS[2062] = new Array(30, 32, 31, 32, 31, 31, 29, 30, 29, 30, 29, 31);
    199         BS[2063] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
    200         BS[2064] = new Array(31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30);
    201         BS[2065] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31);
    202         BS[2066] = new Array(31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31);
    203         BS[2067] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
    204         BS[2068] = new Array(31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30);
    205         BS[2069] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31);
    206         BS[2070] = new Array(31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30);
    207         BS[2071] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
    208         BS[2072] = new Array(31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30);
    209         BS[2073] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31);
    210         BS[2074] = new Array(31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30);
    211         BS[2075] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
    212         BS[2076] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30);
    213         BS[2077] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31);
    214         BS[2078] = new Array(31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30);
    215         BS[2079] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
    216         BS[2080] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30);
    217         BS[2081] = new Array(31, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30);
    218         BS[2082] = new Array(30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30);
    219         BS[2083] = new Array(31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30);
    220         BS[2084] = new Array(31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30);
    221         BS[2085] = new Array(31, 32, 31, 32, 30, 31, 30, 30, 29, 30, 30, 30);
    222         BS[2086] = new Array(30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30);
    223         BS[2087] = new Array(31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30);
    224         BS[2088] = new Array(30, 31, 32, 32, 30, 31, 30, 30, 29, 30, 30, 30);
    225         BS[2089] = new Array(30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30);
    226         BS[2090] = new Array(30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30);
    227 
    228 
    229         var self = {
    230 
    231             GlobalDate: '',
    232 
    233             init: function () {
    234 
    235 
    236                 var CurrentDateObject = new Date();
    237 
    238                 if (Lang == "en") {
    239 
    240                     self.GlobalDate = CurrentDateObject.getFullYear() + '/' + (CurrentDateObject.getMonth() + 1) + '/' + CurrentDateObject.getDate();
    241 
    242                 } else if (Lang == "np") {
    243 
    244                     var NepDate = self.AdToBsDate(CurrentDateObject.getFullYear() + '/' + (CurrentDateObject.getMonth() + 1) + '/' + CurrentDateObject.getDate());
    245 
    246                     self.GlobalDate = NepDate.substr(0, NepDate.lastIndexOf("/"));
    247 
    248                 }
    249 
    250 
    251                 this.populateDate();
    252 
    253                 this.CreateCalenderElement();
    254 
    255                 this.getDate();
    256 
    257 
    258             },
    259 
    260 
    261             CreateCalenderElement: function () {
    262 
    263 
    264                 var Element = '<div class="NepaliPatroElement noselect">';
    265 
    266                 Element += '<table id="NepaliPatro">';
    267 
    268                 Element += '<thead><tr style="background:#F39A9A"><th class="noselect Prev">' + PatroLang.Prev + '</th><th data-date="' + self.GlobalDate + '" colspan="5" class="PatroCenter CurrentDateAndMonth noselect">' + PatroLang.CurrentYear + ' ' + PatroLang.CurrentMonth + '</th><th class="noselect Next">' + PatroLang.Next + '</th> </tr>';
    269 
    270                 Element += '<tr style="background:#F39A9A" ><th>' + PatroLang.FirstDay + '</th><th>' + PatroLang.SecondDay + '</th><th>' + PatroLang.ThirdDay + '</th><th>' + PatroLang.FourthDay + '</th><th>' +
    271 
    272                 PatroLang.FifthDay + '</th><th>' + PatroLang.SixthDay + '</th><th>' + PatroLang.SeventhDay + '</th></tr></thead>';
    273 
    274                 Element += '<tbody>';
    275 
    276 
    277                 Element += '</tbody>';
    278 
    279                 Element += '</table>';
    280 
    281 
    282                 $('body').find(selector).append(Element);
    283 
    284                 return Element;
    285 
    286 
    287             },
    288             getDate: function () {
    289 
    290 
    291                 var FullDate = self.GlobalDate.split('/');
    292 
    293                 PatroLang.CurrentYear = this.NumberToLanguageDigit(FullDate[0]);
    294 
    295 
    296                 PatroLang.CurrentMonth = eval(Lang.toUpperCase() + 'Month' + "[" + (parseInt(FullDate[1]) - 1) + "]");
    297 
    298 
    299                 //if (GlobalObj) {
    300                 //
    301                 //
    302                 //    $(GlobalObj).closest('.CurrentDateAndMonth').html(PatroLang.CurrentYear + ' ' + PatroLang.CurrentMonth);
    303                 //}
    304 
    305 
    306                 this.populateMonth(self.GlobalDate, Lang);
    307 
    308 
    309             },
    310             populateDate: function () {
    311 
    312 
    313                 var FullDate = self.GlobalDate.split('/');
    314 
    315 
    316                 PatroLang.CurrentYear = this.NumberToLanguageDigit(FullDate[0]);
    317 
    318 
    319                 PatroLang.CurrentMonth = eval(Lang.toUpperCase() + 'Month' + "[" + (parseInt(FullDate[1]) - 1) + "]");
    320 
    321 
    322             },
    323             populateMonth: function ($date, Language) {
    324 
    325                 //CurrentDateAndMonth
    326 
    327 
    328                 if (Language == "en") {
    329 
    330                     var PatroDate = new Date($date);
    331 
    332                     PatroWeekDay = (PatroDate.getDay() + 1);
    333 
    334                     PatroYear = PatroDate.getFullYear();
    335 
    336                     PatroMonth = PatroDate.getMonth() + 1;
    337 
    338                     PatroDay = PatroDate.getDate();
    339 
    340                     NumberOfDays = new Date(PatroYear, (PatroMonth + 1), 0).getDate();
    341 
    342 
    343                 } else if (Language == "np") {
    344 
    345 
    346                     NepaliDate = $date.split('/');//this.AdToBsDate(PatroDate.getFullYear() + '/' + (PatroDate.getMonth() + 1) + '/' + PatroDate.getDate()).split('/');
    347 
    348 
    349                     //if (BS[NepaliDate[0]] === undefined) {
     136
     137            var BS = {};
     138            BS[2000] = new Array(30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31);
     139            BS[2001] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
     140            BS[2002] = new Array(31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30);
     141            BS[2003] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31);
     142            BS[2004] = new Array(30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31);
     143            BS[2005] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
     144            BS[2006] = new Array(31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30);
     145            BS[2007] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31);
     146            BS[2008] = new Array(31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31);
     147            BS[2009] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
     148            BS[2010] = new Array(31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30);
     149            BS[2011] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31);
     150            BS[2012] = new Array(31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30);
     151            BS[2013] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
     152            BS[2014] = new Array(31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30);
     153            BS[2015] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31);
     154            BS[2016] = new Array(31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30);
     155            BS[2017] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
     156            BS[2018] = new Array(31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30);
     157            BS[2019] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31);
     158            BS[2020] = new Array(31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30);
     159            BS[2021] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
     160            BS[2022] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30);
     161            BS[2023] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31);
     162            BS[2024] = new Array(31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30);
     163            BS[2025] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
     164            BS[2026] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31);
     165            BS[2027] = new Array(30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31);
     166            BS[2028] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
     167            BS[2029] = new Array(31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30);
     168            BS[2030] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31);
     169            BS[2031] = new Array(30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31);
     170            BS[2032] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
     171            BS[2033] = new Array(31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30);
     172            BS[2034] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31);
     173            BS[2035] = new Array(30, 32, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31);
     174            BS[2036] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
     175            BS[2037] = new Array(31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30);
     176            BS[2038] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31);
     177            BS[2039] = new Array(31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30);
     178            BS[2040] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
     179            BS[2041] = new Array(31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30);
     180            BS[2042] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31);
     181            BS[2043] = new Array(31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30);
     182            BS[2044] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
     183            BS[2045] = new Array(31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30);
     184            BS[2046] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31);
     185            BS[2047] = new Array(31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30);
     186            BS[2048] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
     187            BS[2049] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30);
     188            BS[2050] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31);
     189            BS[2051] = new Array(31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30);
     190            BS[2052] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
     191            BS[2053] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30);
     192            BS[2054] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31);
     193            BS[2055] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
     194            BS[2056] = new Array(31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30);
     195            BS[2057] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31);
     196            BS[2058] = new Array(30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31);
     197            BS[2059] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
     198            BS[2060] = new Array(31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30);
     199            BS[2061] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31);
     200            BS[2062] = new Array(30, 32, 31, 32, 31, 31, 29, 30, 29, 30, 29, 31);
     201            BS[2063] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
     202            BS[2064] = new Array(31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30);
     203            BS[2065] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31);
     204            BS[2066] = new Array(31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31);
     205            BS[2067] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
     206            BS[2068] = new Array(31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30);
     207            BS[2069] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31);
     208            BS[2070] = new Array(31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30);
     209            BS[2071] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
     210            BS[2072] = new Array(31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30);
     211            BS[2073] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31);
     212            BS[2074] = new Array(31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30);
     213            BS[2075] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
     214            BS[2076] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30);
     215            BS[2077] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31);
     216            BS[2078] = new Array(31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30);
     217            BS[2079] = new Array(31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30);
     218            BS[2080] = new Array(31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30);
     219            BS[2081] = new Array(31, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30);
     220            BS[2082] = new Array(30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30);
     221            BS[2083] = new Array(31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30);
     222            BS[2084] = new Array(31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30);
     223            BS[2085] = new Array(31, 32, 31, 32, 30, 31, 30, 30, 29, 30, 30, 30);
     224            BS[2086] = new Array(30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30);
     225            BS[2087] = new Array(31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30);
     226            BS[2088] = new Array(30, 31, 32, 32, 30, 31, 30, 30, 29, 30, 30, 30);
     227            BS[2089] = new Array(30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30);
     228            BS[2090] = new Array(30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30);
     229
     230
     231            var self = {
     232
     233                GlobalDate: '',
     234
     235                init: function () {
     236
     237
     238                    var CurrentDateObject = new Date();
     239
     240                    if (Lang == "en") {
     241
     242                        self.GlobalDate = CurrentDateObject.getFullYear() + '/' + (CurrentDateObject.getMonth() + 1) + '/' + CurrentDateObject.getDate();
     243
     244                    } else if (Lang == "np") {
     245
     246                        var NepDate = self.AdToBsDate(CurrentDateObject.getFullYear() + '/' + (CurrentDateObject.getMonth() + 1) + '/' + CurrentDateObject.getDate());
     247
     248                        self.GlobalDate = NepDate.substr(0, NepDate.lastIndexOf("/"));
     249
     250                    }
     251
     252
     253                    this.populateDate();
     254
     255                    this.CreateCalenderElement();
     256
     257                    this.getDate();
     258
     259
     260                },
     261
     262
     263                CreateCalenderElement: function () {
     264
     265
     266                    var Element = '<div class="NepaliPatroElement noselect">';
     267
     268                    Element += '<table id="NepaliPatro">';
     269
     270                    Element += '<thead><tr style="background:#F39A9A"><th class="noselect Prev">' + PatroLang.Prev + '</th><th data-date="' + self.GlobalDate + '" colspan="5" class="PatroCenter CurrentDateAndMonth noselect">' + PatroLang.CurrentYear + ' ' + PatroLang.CurrentMonth + '</th><th class="noselect Next">' + PatroLang.Next + '</th> </tr>';
     271
     272                    Element += '<tr style="background:#F39A9A" ><th>' + PatroLang.FirstDay + '</th><th>' + PatroLang.SecondDay + '</th><th>' + PatroLang.ThirdDay + '</th><th>' + PatroLang.FourthDay + '</th><th>' +
     273
     274                    PatroLang.FifthDay + '</th><th>' + PatroLang.SixthDay + '</th><th>' + PatroLang.SeventhDay + '</th></tr></thead>';
     275
     276                    Element += '<tbody>';
     277
     278
     279                    Element += '</tbody>';
     280
     281                    Element += '</table>';
     282
     283
     284                    //$('body').find(selector).append(Element);
     285                    $selector.append(Element);
     286
     287                    return Element;
     288
     289
     290                },
     291                getDate: function () {
     292
     293
     294                    var FullDate = self.GlobalDate.split('/');
     295
     296                    PatroLang.CurrentYear = this.NumberToLanguageDigit(FullDate[0]);
     297
     298
     299                    PatroLang.CurrentMonth = eval(Lang.toUpperCase() + 'Month' + "[" + (parseInt(FullDate[1]) - 1) + "]");
     300
     301
     302                    //if (GlobalObj) {
    350303                    //
    351                     //    alert('Date Overflow');
    352304                    //
    353                     //    return;
     305                    //    $(GlobalObj).closest('.CurrentDateAndMonth').html(PatroLang.CurrentYear + ' ' + PatroLang.CurrentMonth);
    354306                    //}
    355307
    356308
    357                     PatroYear = NepaliDate[0];
    358 
    359                     PatroMonth = (NepaliDate[1]) - 1;
    360 
    361                     PatroDay = NepaliDate[2];
    362 
    363                     NumberOfDays = BS[PatroYear][PatroMonth];
    364 
    365                     var ADDate = self.BsToAD($date);
    366 
    367                     PatroWeekDay = self.BsToAD($date);
    368 
    369                     PatroWeekDay = (PatroWeekDay[(PatroWeekDay.length - 1)]);
    370 
    371 
    372                 }
    373 
    374 
    375                 WeekStartDay = NumberOfDays;
    376 
    377 
    378                 var Divider = (Math.floor((PatroDay / 7)));
    379 
    380                 var Reminder = PatroDay - (Divider * 7); // Same week day on this day
    381 
    382 
    383                 if (Reminder == 1) {
    384 
    385 
    386                     var FirstDayWeekDay = PatroWeekDay;
    387 
    388                 } else {
    389 
    390                     Reminder = Reminder == 0 ? 7 : Reminder;
    391 
    392 
    393                     var wkDay = PatroWeekDay;
    394 
    395                     for (p = Reminder; p <= Reminder; p--) {
    396 
    397 
    398                         if (wkDay == 0) {
    399                             wkDay = 7;
     309                    this.populateMonth(self.GlobalDate, Lang);
     310
     311
     312                },
     313                populateDate: function () {
     314
     315
     316                    var FullDate = self.GlobalDate.split('/');
     317
     318
     319                    PatroLang.CurrentYear = this.NumberToLanguageDigit(FullDate[0]);
     320
     321
     322                    PatroLang.CurrentMonth = eval(Lang.toUpperCase() + 'Month' + "[" + (parseInt(FullDate[1]) - 1) + "]");
     323
     324
     325                },
     326                populateMonth: function ($date, Language) {
     327
     328                    //CurrentDateAndMonth
     329
     330
     331                    if (Language == "en") {
     332
     333                        var PatroDate = new Date($date);
     334
     335                        PatroWeekDay = (PatroDate.getDay() + 1);
     336
     337                        PatroYear = PatroDate.getFullYear();
     338
     339                        PatroMonth = PatroDate.getMonth() + 1;
     340
     341                        PatroDay = PatroDate.getDate();
     342
     343                        NumberOfDays = new Date(PatroYear, (PatroMonth + 1), 0).getDate();
     344
     345
     346                    } else if (Language == "np") {
     347
     348
     349                        NepaliDate = $date.split('/');//this.AdToBsDate(PatroDate.getFullYear() + '/' + (PatroDate.getMonth() + 1) + '/' + PatroDate.getDate()).split('/');
     350
     351
     352                        //if (BS[NepaliDate[0]] === undefined) {
     353                        //
     354                        //    alert('Date Overflow');
     355                        //
     356                        //    return;
     357                        //}
     358
     359
     360                        PatroYear = NepaliDate[0];
     361
     362                        PatroMonth = (NepaliDate[1]) - 1;
     363
     364                        PatroDay = NepaliDate[2];
     365
     366                        NumberOfDays = BS[PatroYear][PatroMonth];
     367
     368                        var ADDate = self.BsToAD($date);
     369
     370                        PatroWeekDay = self.BsToAD($date);
     371
     372                        PatroWeekDay = (PatroWeekDay[(PatroWeekDay.length - 1)]);
     373
     374
     375                    }
     376
     377
     378                    WeekStartDay = NumberOfDays;
     379
     380
     381                    var Divider = (Math.floor((PatroDay / 7)));
     382
     383                    var Reminder = PatroDay - (Divider * 7); // Same week day on this day
     384
     385
     386                    if (Reminder == 1) {
     387
     388
     389                        var FirstDayWeekDay = PatroWeekDay;
     390
     391                    } else {
     392
     393                        Reminder = Reminder == 0 ? 7 : Reminder;
     394
     395
     396                        var wkDay = PatroWeekDay;
     397
     398                        for (p = Reminder; p <= Reminder; p--) {
     399
     400
     401                            if (wkDay == 0) {
     402                                wkDay = 7;
     403                            }
     404
     405                            if (p == 0) {
     406
     407                                FirstDayWeekDay = wkDay + 1;
     408
     409                                break;
     410
     411                            }
     412
     413                            wkDay--;
    400414                        }
    401415
    402                         if (p == 0) {
    403 
    404                             FirstDayWeekDay = wkDay + 1;
    405 
    406                             break;
    407 
     416                    }
     417
     418
     419                    if (GlobalObj) {
     420
     421
     422                        $patroBody = $(GlobalObj).closest('table').find('tbody')
     423
     424
     425                    } else {
     426
     427                        //alert('no-alert');
     428
     429
     430                        $patroBody = $selector.find('#NepaliPatro tbody');
     431                        //$patroBody = $('body').find(selector + ' #NepaliPatro tbody');
     432
     433                    }
     434                    $patroBodyHTML = '';
     435
     436                    var days = 0;
     437
     438                    var i = 0;
     439
     440                    for (i = 0; i < 6; i++) {
     441
     442                        $patroBodyHTML += '<tr>';
     443
     444                        for (j = 0; j < 7; j++) {
     445
     446                            var TdClass = '';
     447
     448                            if (PatroDay == (days + 1)) {
     449
     450
     451                                var currentDateArray = this.CurrentBsDate().split('/');
     452
     453                                var selectedDateArray = $selector.find('table#NepaliPatro thead tr:first-child th:nth-child(2)').attr('data-date').split('/');
     454
     455
     456                                if (currentDateArray[0] == selectedDateArray[0] && currentDateArray[1] == selectedDateArray[1] && currentDateArray[2] == selectedDateArray[2]) {
     457
     458
     459                                    TdClass += 'today';
     460                                }
     461
     462
     463                            }
     464
     465                            if (j == 6) {
     466
     467                                TdClass += ' week_holiday';
     468
     469                            }
     470
     471
     472                            $patroBodyHTML += '<td class="' + TdClass + '">';
     473
     474
     475                            if (days < NumberOfDays) {
     476
     477                                if (i == 0 && (FirstDayWeekDay - 1) <= j) {
     478                                    days++;
     479                                    $patroBodyHTML += this.NumberToLanguageDigit(days);
     480                                }
     481                                if (i > 0) {
     482                                    days++;
     483
     484                                    $patroBodyHTML += this.NumberToLanguageDigit(days);
     485                                }
     486                            }
     487
     488
     489                            $patroBodyHTML += '</td>';
    408490                        }
    409 
    410                         wkDay--;
    411                     }
    412 
    413                 }
    414 
    415 
    416                 if (GlobalObj) {
    417 
    418 
    419                     $patroBody = $(GlobalObj).closest('table').find('tbody')
    420 
    421 
    422                 } else {
    423 
    424                     //alert('no-alert');
    425 
    426                     $patroBody = $('body').find(selector + ' #NepaliPatro tbody');
    427 
    428                 }
    429                 $patroBodyHTML = '';
    430 
    431                 var days = 0;
    432                 var i = 0;
    433                 for (i = 0; i < 6; i++) {
    434                     $patroBodyHTML += '<tr>';
    435 
    436                     for (j = 0; j < 7; j++) {
    437 
    438                         var TdClass = '';
    439 
    440                         if (PatroDay == (days + 1)) {
    441 
    442                             TdClass += 'today';
     491                        $patroBodyHTML += '</tr>';
     492
     493
     494                    }
     495
     496                    $patroBody.html('');
     497                    $patroBody.append($patroBodyHTML);
     498
     499
     500                    CurrentDate = PatroYear + '/' + (parseInt(PatroMonth) + 1) + '/' + PatroDay;
     501
     502
     503                    if (GlobalObj) {
     504
     505
     506                        $(GlobalObj).closest('#NepaliPatro').find('.CurrentDateAndMonth').html(PatroLang.CurrentYear + ' ' + PatroLang.CurrentMonth);
     507
     508
     509                    }
     510
     511                },
     512
     513
     514                NumberToLanguageDigit: function (RawNumber) {
     515
     516
     517                    RawNumber = String(RawNumber);
     518
     519                    if (Lang == "en") {
     520
     521                        return RawNumber;
     522                    }
     523                    var OutputNumber = '';
     524
     525                    for (i = 0; i < RawNumber.length; i++) {
     526
     527                        OutputNumber += eval(Lang.toUpperCase() + 'Digit' + "." + BaseDigit[RawNumber[i]] + "")
     528
     529                    }
     530
     531
     532                    return OutputNumber;
     533
     534
     535                },
     536
     537                CurrentBsDate: function (FullDate) {
     538
     539
     540                    var PatroDate = (FullDate == null) ? new Date() : FullDate;
     541
     542                    if (Lang == "np") {
     543
     544
     545                        if (FullDate != null) {
     546
     547
     548                            var CurrentDate = this.BsToAD(FullDate);
     549
     550                            CurrentDate.split('/');
     551
     552                            return FullDate;
    443553
    444554
    445555                        }
    446556
    447                         if (j == 6) {
    448 
    449                             TdClass += ' week_holiday';
    450 
     557                        return this.AdToBsDate(PatroDate.getFullYear() + '/' + (PatroDate.getMonth() + 1 ) + '/' + PatroDate.getDate());
     558
     559                    } else if (Lang == "en") {
     560
     561                        return (PatroDate.getFullYear() + '/' + (PatroDate.getMonth() ) + '/' + PatroDate.getDate() + (PatroDate.getDay() + 1));
     562                    }
     563
     564
     565                },
     566
     567                getFirstDayOfMonth: function () {
     568
     569                    if (Lang == "np") {
     570
     571
     572                    }
     573
     574
     575                },
     576
     577                AdToBsDate: function (AD) {
     578
     579                    var ADDate = new Date(AD);
     580
     581                    var Day = (ADDate.getDay() + 1);
     582                    console.log('ad is ' + AD);
     583
     584                    var NumOfDays = (new Date(AD) - new Date(RefDate.AD)) / (24 * 60 * 60 * 1000);
     585
     586
     587                    var AdditionalDay = 0;
     588
     589                    var NepDate = '';
     590                    $.each(BS, function (index, value) {
     591
     592                        $.each(value, function (monthIndex, monthValue) {
     593
     594                            AdditionalDay += monthValue;
     595
     596                            if (NumOfDays < AdditionalDay) {
     597
     598
     599                                NepDate = index + '/' + (monthIndex + 1) + '/' + (monthValue - (AdditionalDay - NumOfDays) + 1) + '/' + Day;
     600
     601
     602                                return false;
     603
     604
     605                            }
     606                        });
     607
     608                        if (NepDate != '') {
     609
     610                            return false;
    451611                        }
    452612
    453613
    454                         $patroBodyHTML += '<td class="' + TdClass + '">';
    455 
    456 
    457                         if (days < NumberOfDays) {
    458 
    459                             if (i == 0 && (FirstDayWeekDay - 1) <= j) {
    460                                 days++;
    461                                 $patroBodyHTML += this.NumberToLanguageDigit(days);
    462                             }
    463                             if (i > 0) {
    464                                 days++;
    465 
    466                                 $patroBodyHTML += this.NumberToLanguageDigit(days);
     614                    });
     615
     616
     617                    return (NepDate);
     618
     619                },
     620
     621                BsToAD: function (BSDate) {
     622
     623                    var FullBSDate = BSDate.split('/');
     624                    FullBSDate[1] = parseInt(FullBSDate[1]) - 1;
     625                    FullBSDate[2] = parseInt(FullBSDate[2]) - 1;
     626
     627                    var TotalDays = 0;
     628                    var LoopBreak = 0;
     629
     630                    $.each(BS, function (Index, Value) {
     631
     632
     633                        if (parseInt(FullBSDate[0]) >= parseInt(Index)) {
     634
     635                            $.each(Value, function (MonthIndex, MonthValue) {
     636
     637                                if (parseInt(Index) == parseInt(FullBSDate[0]) && parseInt(MonthIndex) == parseInt(FullBSDate[1])) {
     638
     639
     640                                    if (parseInt([FullBSDate[2]]) <= MonthValue) {
     641
     642                                        TotalDays += parseInt(FullBSDate[2]);
     643
     644                                    } else {
     645
     646                                        TotalDays += parseInt(MonthValue);
     647                                    }
     648                                    LoopBreak = 1;
     649                                    return false;
     650
     651                                }
     652                                TotalDays += parseInt(MonthValue);
     653
     654                            });
     655                            if (LoopBreak == 1) {
     656
     657                                return false;
    467658                            }
    468659                        }
    469 
    470 
    471                         $patroBodyHTML += '</td>';
    472                     }
    473                     $patroBodyHTML += '</tr>';
     660                    });
     661
     662
     663                    var ConvertedDate = new Date(RefDate.AD);
     664
     665
     666                    ConvertedDate.setDate(ConvertedDate.getDate() + TotalDays);
     667
     668
     669                    return (ConvertedDate.getFullYear() + '/' + (ConvertedDate.getMonth() + 1) + '/' + ConvertedDate.getDate() + '/' + (ConvertedDate.getDay() + 1));
     670
     671
     672                },
     673                CurrentWeekDay: function () {
     674
     675                    var PatroDate = new Date();
     676
     677                    return (PatroDate.getDay());
     678
     679                },
     680
     681                NepaliDate: function () {
     682
     683                    var currentDate = this.CurrentBsDate();
     684                    var currentWeekDay = this.CurrentWeekDay();
    474685
    475686
    476687                }
    477688
    478                 $patroBody.html('');
    479                 $patroBody.append($patroBodyHTML);
    480 
    481 
    482                 CurrentDate = PatroYear + '/' + (parseInt(PatroMonth) + 1) + '/' + PatroDay;
    483 
    484 
    485                 if (GlobalObj) {
    486 
    487 
    488                     $(GlobalObj).closest('#NepaliPatro').find('.CurrentDateAndMonth').html(PatroLang.CurrentYear + ' ' + PatroLang.CurrentMonth);
    489 
    490 
     689
     690            }
     691
     692
     693            self.init();
     694
     695
     696            // $('body').on('click', selector + ' #NepaliPatro .Prev', function () {
     697            $selector.on('click', '#NepaliPatro .Prev', function () {
     698                //$('body').on('click', selector + ' #NepaliPatro .Prev', function () {
     699
     700
     701                var currDate = $(this).parent('tr').find('.CurrentDateAndMonth').attr('data-date'); //.split('/');
     702
     703                var $Date = currDate.split('/');
     704
     705
     706                var Month, Year;
     707
     708                if (parseInt($Date[1]) == 1) {
     709
     710                    Month = 12;
     711                    Year = parseInt($Date[0]) - 1;
     712
     713
     714                } else {
     715                    Year = parseInt($Date[0]);
     716
     717                    Month = (parseInt($Date[1]) - 1);
    491718                }
    492719
    493             },
    494 
    495 
    496             NumberToLanguageDigit: function (RawNumber) {
    497 
    498 
    499                 RawNumber = String(RawNumber);
    500 
    501                 if (Lang == "en") {
    502 
    503                     return RawNumber;
     720
     721                self.GlobalDate = Year + '/' + Month + '/' + $Date[2];
     722
     723
     724                $(this).parent('tr').find('.CurrentDateAndMonth').attr('data-date', self.GlobalDate);
     725
     726
     727                var FullDate = self.GlobalDate.split('/');
     728
     729                PatroLang.CurrentYear = self.NumberToLanguageDigit(FullDate[0]);
     730
     731
     732                PatroLang.CurrentMonth = eval(Lang.toUpperCase() + 'Month' + "[" + (parseInt(FullDate[1]) - 1) + "]");
     733
     734
     735                GlobalObj = this;
     736
     737
     738                self.getDate();
     739
     740                $.each($(this).closest('.NepaliPatroElement'), function () {
     741
     742                    if ($(this).find('table tbody tr:first-child td:last-child').html() == '') {
     743
     744                        $(this).find('table tbody tr:first-child').remove();
     745                    }
     746
     747
     748                    if ($(this).find('table tbody tr:last-child td:first-child').html() == '') {
     749
     750                        $(this).find('table tbody tr:last-child').remove();
     751                    }
     752
     753
     754                });
     755
     756
     757            });
     758
     759            //$('body').on('click', selector + ' #NepaliPatro .Next', function () {
     760            $selector.on('click', '#NepaliPatro .Next', function () {
     761
     762                var currDate = $(this).parent('tr').find('.CurrentDateAndMonth').attr('data-date'); //.split('/');
     763
     764
     765                var $Date = currDate.split('/');
     766
     767                var Month, Year;
     768
     769                if (parseInt($Date[1]) == 12) {
     770
     771                    Month = 1;
     772                    Year = parseInt($Date[0]) + 1;
     773
     774
     775                } else {
     776                    Year = parseInt($Date[0]);
     777
     778                    Month = (parseInt($Date[1]) + 1);
    504779                }
    505                 var OutputNumber = '';
    506 
    507                 for (i = 0; i < RawNumber.length; i++) {
    508 
    509                     OutputNumber += eval(Lang.toUpperCase() + 'Digit' + "." + BaseDigit[RawNumber[i]] + "")
    510 
    511                 }
    512 
    513 
    514                 return OutputNumber;
    515 
    516 
    517             },
    518 
    519             CurrentADDate: function (FullDate) {
    520 
    521 
    522                 var PatroDate = (FullDate == null) ? new Date() : FullDate;
    523 
    524                 if (Lang == "np") {
    525 
    526 
    527                     if (FullDate != null) {
    528 
    529 
    530                         var CurrentDate = this.BsToAD(FullDate);
    531 
    532                         CurrentDate.split('/');
    533 
    534                         return FullDate;
    535 
    536 
    537                     }
    538 
    539                     return this.AdToBsDate(PatroDate.getFullYear() + '/' + (PatroDate.getMonth() + 1 ) + '/' + PatroDate.getDate());
    540 
    541                 } else if (Lang == "en") {
    542 
    543                     return (PatroDate.getFullYear() + '/' + (PatroDate.getMonth() ) + '/' + PatroDate.getDate() + (PatroDate.getDay() + 1));
    544                 }
    545 
    546 
    547             },
    548 
    549             getFirstDayOfMonth: function () {
    550 
    551                 if (Lang == "np") {
    552 
    553 
    554                 }
    555 
    556 
    557             },
    558 
    559             AdToBsDate: function (AD) {
    560 
    561                 var ADDate = new Date(AD);
    562 
    563                 var Day = (ADDate.getDay() + 1);
    564                 console.log('ad is ' + AD);
    565 
    566                 var NumOfDays = (new Date(AD) - new Date(RefDate.AD)) / (24 * 60 * 60 * 1000);
    567 
    568 
    569                 var AdditionalDay = 0;
    570 
    571                 var NepDate = '';
    572                 $.each(BS, function (index, value) {
    573 
    574                     $.each(value, function (monthIndex, monthValue) {
    575 
    576                         AdditionalDay += monthValue;
    577 
    578                         if (NumOfDays < AdditionalDay) {
    579 
    580 
    581                             NepDate = index + '/' + (monthIndex + 1) + '/' + (monthValue - (AdditionalDay - NumOfDays) + 1) + '/' + Day;
    582 
    583 
    584                             return false;
    585 
    586 
    587                         }
    588                     });
    589 
    590                     if (NepDate != '') {
    591 
    592                         return false;
     780
     781
     782                self.GlobalDate = Year + '/' + Month + '/' + $Date[2];
     783
     784                $(this).parent('tr').find('.CurrentDateAndMonth').attr('data-date', self.GlobalDate);
     785
     786
     787                var FullDate = self.GlobalDate.split('/');
     788
     789                PatroLang.CurrentYear = self.NumberToLanguageDigit(FullDate[0]);
     790
     791
     792                PatroLang.CurrentMonth = eval(Lang.toUpperCase() + 'Month' + "[" + (parseInt(FullDate[1]) - 1) + "]");
     793
     794
     795                //  self.populateMonth(self.GlobalDate, Lang, this);
     796                GlobalObj = this;
     797
     798                self.getDate();
     799
     800                $.each($(this).closest('.NepaliPatroElement'), function () {
     801
     802                    if ($(this).find('table tbody tr:first-child td:last-child').html() == '') {
     803
     804                        $(this).find('table tbody tr:first-child').remove();
     805                    }
     806
     807
     808                    if ($(this).find('table tbody tr:last-child td:first-child').html() == '') {
     809
     810                        $(this).find('table tbody tr:last-child').remove();
    593811                    }
    594812
     
    597815
    598816
    599                 return (NepDate);
    600 
    601             },
    602 
    603             BsToAD: function (BSDate) {
    604 
    605                 var FullBSDate = BSDate.split('/');
    606                 FullBSDate[1] = parseInt(FullBSDate[1]) - 1;
    607                 FullBSDate[2] = parseInt(FullBSDate[2]) - 1;
    608 
    609                 var TotalDays = 0;
    610                 var LoopBreak = 0;
    611 
    612                 $.each(BS, function (Index, Value) {
    613 
    614 
    615                     if (parseInt(FullBSDate[0]) >= parseInt(Index)) {
    616 
    617                         $.each(Value, function (MonthIndex, MonthValue) {
    618 
    619                             if (parseInt(Index) == parseInt(FullBSDate[0]) && parseInt(MonthIndex) == parseInt(FullBSDate[1])) {
    620 
    621 
    622                                 if (parseInt([FullBSDate[2]]) <= MonthValue) {
    623 
    624                                     TotalDays += parseInt(FullBSDate[2]);
    625 
    626                                 } else {
    627 
    628                                     TotalDays += parseInt(MonthValue);
    629                                 }
    630                                 LoopBreak = 1;
    631                                 return false;
    632 
    633                             }
    634                             TotalDays += parseInt(MonthValue);
    635 
    636                         });
    637                         if (LoopBreak == 1) {
    638 
    639                             return false;
    640                         }
    641                     }
    642                 });
    643 
    644 
    645                 var ConvertedDate = new Date(RefDate.AD);
    646 
    647 
    648                 ConvertedDate.setDate(ConvertedDate.getDate() + TotalDays);
    649 
    650 
    651                 return (ConvertedDate.getFullYear() + '/' + (ConvertedDate.getMonth() + 1) + '/' + ConvertedDate.getDate() + '/' + (ConvertedDate.getDay() + 1));
    652 
    653 
    654             },
    655             CurrentWeekDay: function () {
    656 
    657                 var PatroDate = new Date();
    658 
    659                 return (PatroDate.getDay());
    660 
    661             },
    662 
    663             NepaliDate: function () {
    664 
    665                 var currentDate = this.CurrentADDate();
    666                 var currentWeekDay = this.CurrentWeekDay();
    667 
    668 
    669             }
    670 
    671 
    672         }
    673 
    674 
    675         self.init();
    676 
    677 
    678         $('body').on('click', selector + ' #NepaliPatro .Prev', function () {
    679 
    680 
    681             var currDate = $(this).parent('tr').find('.CurrentDateAndMonth').attr('data-date'); //.split('/');
    682 
    683             var $Date = currDate.split('/');
    684 
    685 
    686             var Month, Year;
    687 
    688             if (parseInt($Date[1]) == 1) {
    689 
    690                 Month = 12;
    691                 Year = parseInt($Date[0]) - 1;
    692 
    693 
    694             } else {
    695                 Year = parseInt($Date[0]);
    696 
    697                 Month = (parseInt($Date[1]) - 1);
    698             }
    699 
    700 
    701             self.GlobalDate = Year + '/' + Month + '/' + $Date[2];
    702 
    703 
    704             $(this).parent('tr').find('.CurrentDateAndMonth').attr('data-date', self.GlobalDate);
    705 
    706 
    707             var FullDate = self.GlobalDate.split('/');
    708 
    709             PatroLang.CurrentYear = self.NumberToLanguageDigit(FullDate[0]);
    710 
    711 
    712             PatroLang.CurrentMonth = eval(Lang.toUpperCase() + 'Month' + "[" + (parseInt(FullDate[1]) - 1) + "]");
    713 
    714 
    715             GlobalObj = this;
    716 
    717 
    718             self.getDate();
    719 
    720             $.each($(this).closest('.NepaliPatroElement'), function () {
     817            });
     818
     819
     820            $.each($('.NepaliPatroElement'), function () {
    721821
    722822                if ($(this).find('table tbody tr:first-child td:last-child').html() == '') {
     
    735835
    736836
    737         });
    738 
    739         $('body').on('click', selector + ' #NepaliPatro .Next', function () {
    740 
    741             var currDate = $(this).parent('tr').find('.CurrentDateAndMonth').attr('data-date'); //.split('/');
    742 
    743 
    744             var $Date = currDate.split('/');
    745 
    746             var Month, Year;
    747 
    748             if (parseInt($Date[1]) == 12) {
    749 
    750                 Month = 1;
    751                 Year = parseInt($Date[0]) + 1;
    752 
    753 
    754             } else {
    755                 Year = parseInt($Date[0]);
    756 
    757                 Month = (parseInt($Date[1]) + 1);
     837            function ShowPopHoverDate($obj) {
     838
     839                $($obj).find(".popoverDate").remove();
     840
     841                var currDate = $($obj).closest('table').find('.CurrentDateAndMonth ').attr('data-date').split('/');
     842
     843                $($obj).append('<div class="popoverDate"><span>' + self.NumberToLanguageDigit(currDate[0]) + '/' + self.NumberToLanguageDigit(currDate[1]) + '/' + $($obj).html() + '</span></div>');
     844
    758845            }
    759846
    760 
    761             self.GlobalDate = Year + '/' + Month + '/' + $Date[2];
    762 
    763             $(this).parent('tr').find('.CurrentDateAndMonth').attr('data-date', self.GlobalDate);
    764 
    765 
    766             var FullDate = self.GlobalDate.split('/');
    767 
    768             PatroLang.CurrentYear = self.NumberToLanguageDigit(FullDate[0]);
    769 
    770 
    771             PatroLang.CurrentMonth = eval(Lang.toUpperCase() + 'Month' + "[" + (parseInt(FullDate[1]) - 1) + "]");
    772 
    773 
    774             //  self.populateMonth(self.GlobalDate, Lang, this);
    775             GlobalObj = this;
    776 
    777             self.getDate();
    778 
    779             $.each($(this).closest('.NepaliPatroElement'), function () {
    780 
    781                 if ($(this).find('table tbody tr:first-child td:last-child').html() == '') {
    782 
    783                     $(this).find('table tbody tr:first-child').remove();
     847            function RemovePophover($obj) {
     848
     849                $($obj).find(".popoverDate").remove();
     850
     851            }
     852
     853
     854            $('body').on('mouseover', '.NepaliPatroElement table tbody td:not(.NepaliPatroElement table tbody td:empty)', function (event) {
     855
     856
     857                if (event.target.tagName == "TD") {
     858
     859                    ShowPopHoverDate(this);
    784860                }
    785 
    786 
    787                 if ($(this).find('table tbody tr:last-child td:first-child').html() == '') {
    788 
    789                     $(this).find('table tbody tr:last-child').remove();
    790                 }
    791 
    792 
    793861            });
    794862
    795863
    796         });
    797 
    798 
    799         $.each($('.NepaliPatroElement'), function () {
    800 
    801             if ($(this).find('table tbody tr:first-child td:last-child').html() == '') {
    802 
    803                 $(this).find('table tbody tr:first-child').remove();
    804             }
    805 
    806 
    807             if ($(this).find('table tbody tr:last-child td:first-child').html() == '') {
    808 
    809                 $(this).find('table tbody tr:last-child').remove();
    810             }
    811 
    812 
    813         });
    814 
    815 
    816         function ShowPopHoverDate($obj) {
    817 
    818             $($obj).find(".popoverDate").remove();
    819 
    820             var currDate = $($obj).closest('table').find('.CurrentDateAndMonth ').attr('data-date').split('/');
    821 
    822             $($obj).append('<div class="popoverDate"><span>' + self.NumberToLanguageDigit(currDate[0]) + '/' + self.NumberToLanguageDigit(currDate[1]) + '/' + $($obj).html() + '</span></div>');
    823 
    824         }
    825 
    826         function RemovePophover($obj) {
    827 
    828             $($obj).find(".popoverDate").remove();
    829 
    830         }
    831 
    832 
    833         $('body').on('mouseover', '.NepaliPatroElement table tbody td:not(.NepaliPatroElement table tbody td:empty)', function (event) {
    834 
    835 
    836             if (event.target.tagName == "TD") {
    837 
    838                 ShowPopHoverDate(this);
    839             }
    840         });
    841 
    842 
    843         $('body').on('mouseleave', '.NepaliPatroElement table tbody td:not(.NepaliPatroElement table tbody td:empty)', function (event) {
    844             //if (event.target.tagName == "TD" || event.target.tagName == "SPAN") {
    845 
    846             RemovePophover(this);
    847             //}
    848 
    849 
     864            $('body').on('mouseleave', '.NepaliPatroElement table tbody td:not(.NepaliPatroElement table tbody td:empty)', function (event) {
     865                //if (event.target.tagName == "TD" || event.target.tagName == "SPAN") {
     866
     867                RemovePophover(this);
     868                //}
     869
     870
     871            });
    850872        });
    851873    }
    852874
     875
    853876}(jQuery));
    854877
Note: See TracChangeset for help on using the changeset viewer.