views:

72

answers:

1

Which fragment of code bellow can not work in MSIE?

 $(document).ready(function() {
            var minId;
            var fadeTime = '25';

            $.ajax({
                url: 'JsonFileWrite.php',
                type: "POST",
                data: "idRequest=true",
                success: function(data) {
                    minId = data;
                }
            });

            $(".close").click(function(){
                $(".showable").fadeOut(fadeTime);
            });

            $("#selected").bind('keypress', function(e){
                var code = (e.keyCode ? e.keyCode : e.which);
                if(code == 13) {
                    $("#selected-ok").click();
                }
                }).corner();
            $("#clicked").bind('keypress', function(e){
                var code = (e.keyCode ? e.keyCode : e.which);
                if(code == 13) {
                    $("#clicked-ok").click();
                }
                }).corner();


            $("#shadow").corner();
            $("#shadow2").corner();

            $("#selected-ok").click(function(){
                $(".close").click();
                var $inputs = $('#selectForm :input');
                var values = {};
                $inputs.each(function() {
                    values[this.name] = $(this).val();
                });
                values['allDay'] = $("#allDayT:checked").val();
                if(values['allDay'] == 'caly'){
                    values['allDay'] = true;
                }
                else{
                    values['allDay'] = false;
                }
                minId++;
                calendar.fullCalendar('renderEvent',
                {
                    id: minId,
                    title: values['name'],
                    start: values['start'],
                    end: values['end'],
                    allDay: values['allDay']
                },
                true);
                $.ajax({
                url: 'JsonFileWrite.php',
                type: "POST",
                data: 'id='+minId+'&title='+values['name']+'&start='+values['start']+'&end='+values['end']+'&allDay='+values['allDay']+'',
                success: function(data) {

                }
                });
                calendar.fullCalendar('unselect');
                return false;
            });

            $("#clicked-ok").click(function(){
                $(".close").click();
                var $inputs = $('#clickForm :input');
                var values = {};
                $inputs.each(function() {
                    values[this.name] = $(this).val();
                });

                values['allDay'] = $("#allDayCT:checked").val();
                if(values['allDay'] == 'caly'){
                    values['allDay'] = true;
                }
                else{
                    values['allDay'] = false;
                }

                $.ajax({
                url: 'JsonFileWrite.php',
                type: "POST",
                data: 'id='+values['id']+'&title='+values['name']+'&start='+values['start']+'&end='+values['end']+'&allDay='+values['allDay']+'',
                success: function(data) {

                }
                });
                calendar.fullCalendar( 'removeEvents',  values['id']);

                calendar.fullCalendar('renderEvent',
                {
                    id: values['id'],
                    title: values['name'],
                    start: values['start'],
                    end: values['end'],
                    allDay: values['allDay']
                },
                true);
                return false;
            });

            $("#clicked-delete").click(function(){
                if(confirm("Czy na pewno usunąć wydarzenie?")){
                    $(".close").click();
                    var $inputs = $('#clickForm :input');
                    var values = {};
                    $inputs.each(function() {
                        values[this.name] = $(this).val();
                    });
                    }
                    calendar.fullCalendar( 'removeEvents',  values['id']);
                    $.ajax({
                        url: 'JsonFileWrite.php',
                        type: "POST",
                        data: 'delId='+values['id'],
                        success: function(data) {
                        }
                    });
            });

            function addEvent(title, start, end, allDay){
                if (title) {
                        calendar.fullCalendar('renderEvent',
                        {
                            title: title,
                            start: start,
                            end: end,
                            allDay: allDay
                        },
                        true // make the event "stick"
                    );
                    }
                    calendar.fullCalendar('unselect');
            }

            function convertDate(date, addH, addM){
                //Sat Jul 10 2010 00:00:00 GMT+02
                if(date != null){
                    var arr = explodeArray(date, " ");
                    var time = explodeArray(arr[4], ":");

                    addH = typeof(addH) != 'undefined' ? addH : 0;
                    addM = typeof(addM) != 'undefined' ? addM : 0;
                    time[0] = parseInt(time[0], 10) + parseInt(addH, 10);
                    time[1] = parseInt(time[1], 10) + parseInt(addM, 10);
                    time[0] = time[0] < 10 ? '0' + time[0].toString() : time[0];
                    time[1] = time[1] < 10 ? '0' + time[1].toString() : time[1];

                    switch(arr[1]){
                        case 'Jan':
                            arr[1] = '01'
                        break;
                        case 'Feb':
                            arr[1] = '02'
                        break;
                        case 'Mar':
                            arr[1] = '03'
                        break;
                        case 'Apr':
                            arr[1] = '04'
                        break;
                        case 'May':
                            arr[1] = '05'
                        break;
                        case 'Jun':
                            arr[1] = '06'
                        break;
                        case 'Jul':
                            arr[1] = '07'
                        break;
                        case 'Aug':
                            arr[1] = '08'
                        break;
                        case 'Sep':
                            arr[1] = '09'
                        break;
                        case 'Oct':
                            arr[1] = '10'
                        break;
                        case 'Nov':
                            arr[1] = '11'
                        break;
                        case 'Dec':
                            arr[1] = '12'
                        break;
                        default:
                            arr[1] = 'ERROR!'
                        break;
                    }

                    return arr[3]+'-'+arr[1]+'-'+arr[2]+' '+ time[0] +':'+time[1];
                }
                else{
                    return "";
                }
                return date;
            }

            function explodeArray(item,delimiter) {
                tempArray=new Array(1);
                var Count=0;
                var tempString=new String(item);
                while (tempString.indexOf(delimiter)>0) {
                    tempArray[Count]=tempString.substr(0,tempString.indexOf(delimiter));
                    tempString=tempString.substr(tempString.indexOf(delimiter)+1,tempString.length-tempString.indexOf(delimiter)+1);
                    Count=Count+1
                }

                tempArray[Count]=tempString;
                return tempArray;
            }

            var AnyTimeCfgArray = {
                format: "%Y-%m-%d %H:%i",
                labelTitle: "Data i czas",
                labelHour: "Godzina",
                labelMinute: "Minuta",
                labelDismiss: '<img src="img/close.png" alt="Zamknij..." />',
                labelDayOfMonth: "Dzień",
                labelMonth: "Miesiąc",
                labelYear: "Rok",
                monthAbbreviations: ['Sty', 'Lut', 'Mar', 'Kwi', 'Maj', 'Cze', 'Lip', 'Sie', 'Wrz', 'Paź', 'Lis', 'Gru'],
                monthNames: ['Styczeń', 'Luty', 'Marzec', 'Kwiecień', 'Maj', 'Czerwiec', 'Lipiec', 'Sierpień', 'Wrzesień', 'Październik', 'Listopad', 'Grudzień'],
                dayAbbreviations: ['N', 'Pn', 'Wt', 'Śr', 'Cz', 'Pt', 'So'],
                dayNames: ['Niedziela', 'Poniedziałek', 'Wtorek', 'Środa', 'Czwartek', 'Piątek', 'Sobota'],
                firstDOW: 1
            }
            $("#sStart").AnyTime_picker(AnyTimeCfgArray).focus(function(){ $("div.AnyTime-win").corner();});
            $("#sEnd").AnyTime_picker(AnyTimeCfgArray).focus(function(){ $("div.AnyTime-win").corner();});
            $("#cStart").AnyTime_picker(AnyTimeCfgArray).focus(function(){ $("div.AnyTime-win").corner();});
            $("#cEnd").AnyTime_picker(AnyTimeCfgArray).focus(function(){ $("div.AnyTime-win").corner();});

            $(".showable").hide();
            var calendar = $('#calendar').fullCalendar({
                allDayText: 'Wydarzenie całodniowe',
                allDaySlot: true,
                axisFormat: 'HH:mm',
                buttonText: {
                    prev:     '&nbsp;&#9668;&nbsp;',  // left triangle
                    next:     '&nbsp;&#9658;&nbsp;',  // right triangle
                    prevYear: '&nbsp;&lt;&lt;&nbsp;', // <<
                    nextYear: '&nbsp;&gt;&gt;&nbsp;', // >>
                    today:    'dziś',
                    month:    'miesiąc',
                    week:     'tydzień',
                    day:      'dzień'
                },
                columnFormat: {
                    month: 'ddd',
                    week: 'ddd d.MM.yyyy',
                    day: 'dddd, d.MM.yyyy'  // Monday 9/7
                },
                firstDay: 1,
                titleFormat: {
                    month: 'MMMM yyyy',                             // September 2009
                    week: "d[ yyyy]{ '&#8212;'[ MMM] d MMMM yyyy}", // 7 - 13 September 2009
                    day: 'dddd, d MMMM yyyy'                  // Tuesday, 8 September 2009
                },
                header: {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'month,agendaWeek,agendaDay'
                },
                monthNames: ['Styczeń', 'Luty', 'Marzec', 'Kwiecień', 'Maj', 'Czerwiec', 'Lipiec', 'Sierpień', 'Wrzesień', 'Październik', 'Listopad', 'Grudzień'],
                monthNamesShort: ['Styczeń', 'Luty', 'Marzec', 'Kwiecień', 'Maj', 'Czerwiec', 'Lipiec', 'Sierpień', 'Wrzesień', 'Październik', 'Listopad', 'Grudzień'],
                dayNames: ['Niedziela', 'Poniedziałek', 'Wtorek', 'Środa', 'Czwartek', 'Piątek', 'Sobota'],
                dayNamesShort: ['N', 'Pn', 'Wt', 'Śr', 'Cz', 'Pt', 'So'],
                selectable: true,
                selectHelper: true,

                select: function(start, end, allDay, jsEvent, view) {
                    $(".showable").fadeOut(fadeTime);
                    $("#selected").fadeOut(fadeTime, function(){

                        $("#sStart").val(convertDate(start));
                        if (start.toString() == end.toString()){
                            $("#sEnd").val(convertDate(end, 23, 59));
                        }
                        else{
                            $("#sEnd").val(convertDate(end));
                        }
                        $("#allDayT").attr('checked', allDay);
                        $("#allDayN").attr('checked', !allDay);

                        /*var content = '';
                        content += '        Od: <input type="text" id="sStart" name="start" value="'+convertDate(start)+'" /><br />';
                        if (start.toString() == end.toString()){
                            content += '        Do: <input type="text" id="sEnd" name="end" value="'+convertDate(end, 23, 59)+'" /><br />';
                        }
                        else{
                            content += '        Do: <input type="text" id="sEnd" name="end" value="'+convertDate(end)+'" /><br />';
                        }
                        content += '        Nazwa: <input type="text" name="name" value="" /><br />';
                        content += '        Wydarzenie całodniowe: <br /><input id="allDayT" name="allDay" value="caly" type="radio"';
                        if(allDay){
                            content += ' checked="checked"';
                        }
                        content += ' /> <label for="allDayT">Tak</label> <input id="allDayN" name="allDay" value="niecaly" type="radio"';
                        if(!allDay){
                            content += ' checked="checked"';
                        }
                        content += ' /> <label for="allDayN">Nie</label>';
                        $("#selected-content").html(content);*/

                        $('#selected').css('left', jsEvent.pageX);
                        $('#selected').css('top', jsEvent.pageY);
                        $("#selected").fadeIn(fadeTime);
                        var width = $("#selected").width();
                        var height = $("#selected").height();
                        $('#shadow').css('width', width + 5);
                        $('#shadow').css('height', height + 5);
                        $('#shadow').css('left', jsEvent.pageX + 3);
                        $('#shadow').css('top', jsEvent.pageY + 3);
                        $("#shadow").fadeIn(fadeTime);
                    });
                },
                editable: true,
                eventClick: function(calEvent, jsEvent, view) {
                    $(".showable").fadeOut(fadeTime);
                    $("#clicked").fadeOut('100', function(){
                        $("#cId").val(calEvent.id.toString());
                        $("#cStart").val(convertDate(calEvent.start));
                        $("#cEnd").val(convertDate(calEvent.end));
                        $("#cName").val(calEvent.title);
                        $("#allDayCT").attr('checked', calEvent.allDay);
                        $("#allDayCN").attr('checked', !calEvent.allDay);

                        /*var content = '     <input type="hidden" name="id" value="'+calEvent.id+'" />';
                        content += '        Od: <input type="text" id="cStart" name="start" value="'+convertDate(calEvent.start)+'" /><br />';
                        content += '        Do: <input type="text" id="cEnd" name="end" value="'+convertDate(calEvent.end)+'" /><br />';
                        content += '        Nazwa: <input type="text" name="name" value="'+calEvent.title+'" /><br />';
                        content += '        Wydarzenie całodniowe: <br /><input id="allDayCT" name="allDay" value="caly" type="radio"';
                        if(calEvent.allDay){
                            content += ' checked="checked"';
                        }
                        content += ' /> <label for="allDayCT">Tak</label> <input id="allDayCN" name="allDay" value="niecaly" type="radio"';
                        if(!calEvent.allDay){
                            content += ' checked="checked"';
                        }
                        content += ' /> <label for="allDayCN">Nie</label>';
                        $("#clicked-content").html(content);*/

                        $('#clicked').css('left', jsEvent.pageX);
                        $('#clicked').css('top', jsEvent.pageY);
                        $("#clicked").fadeIn(fadeTime);
                        var width = $("#clicked").width();
                        var height = $("#clicked").height();
                        $('#shadow2').css('width', width + 5);
                        $('#shadow2').css('height', height + 5);
                        $('#shadow2').css('left', jsEvent.pageX + 3);
                        $('#shadow2').css('top', jsEvent.pageY + 3);
                        $("#shadow2").fadeIn(fadeTime);
                    });
                },

                eventDragStart: function(){$(".close").click();},
                eventDragStop: function(){$(".close").click();},

                eventResizeStart: function(){$(".close").click();},
                eventResizeStop: function(){$(".close").click();},
                viewDisplay: function(){$(".close").click();},

                eventDrop: function(event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view) {
                    $(".close").click();
                    $.ajax({
                        url: 'JsonFileWrite.php',
                        type: "POST",
                        data: 'id='+event.id+'&title='+event.title+'&start='+convertDate(event.start)+'&end='+convertDate(event.end)+'&allDay='+allDay+'',
                        success: function(data) {
                        }
                    });
                },
                eventResize: function(event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, view){
                    $(".close").click();
                    $.ajax({
                        url: 'JsonFileWrite.php',
                        type: "POST",
                        data: 'id='+event.id+'&title='+event.title+'&start='+convertDate(event.start)+'&end='+convertDate(event.end)+'&allDay='+event.allDay+'',
                        success: function(data) {
                        }
                    });
                },
                events: "json-events.php"
            });

        });
A: 

In other browsers calendar shows properly. In MSIE I've got only window with ID = "clicked-ok". Maybe sharing whole project will be better idea?

Zozo