shift_exchange.js 24 KB
Newer Older
Administrator committed
1 2 3 4 5 6 7 8 9 10
/*
Deal with the shift exchanges or shift registrations for ftop partners
  or ABCD partners who need to catch-up for a missed shift.

(ftop = volant; ABCD = inscrit à un créneau)
*/

var optDate = {weekday: "long", year: "numeric", month: "long", day: "numeric"};
var listeShiftPartner =[];
var listStates = {
11 12 13 14 15 16 17 18 19
    not_concerned: "Non concerné",
    up_to_date:" A jour ",
    alert:"Alerte",
    exempted:"Exempté",
    delay:"Délai (extension en cours)",
    suspended:"Suspendu(e)",
    unsubscribed:"Désinscrit",
    unpayed: "Impayé"
};
Administrator committed
20

21 22 23 24 25 26 27 28 29
var limitDate = null,
    dp = null,
    lastY = null,
    loaded_events = [],
    make_up_nb = 0,
    non_regular_shifts = [],
    can_make_exchange = false,
    can_add_shift = false,
    extra_info = $('#templates .extra_info').html();
Administrator committed
30 31 32


// Init Dom for member's shifts
33 34 35 36 37 38 39 40 41 42
function iniListShift(listeShift, echange) {
    if (echange) {
        $('#shifts').html("");
        listeShift.forEach(function f(shift) {
            var dateStart = new Date(shift.date_begin);

            monshift = '<div class="shift_list_item"><label> <input type="checkbox" name = "shiftRadio" value="' + shift.id + '"" /> <span class="shift_booked">' + dateStart.toLocaleDateString("fr-fr", optDate) + " --- " + dateStart.toLocaleTimeString("fr-fr") + '</span></label></div>';
            $('#shifts').append(monshift);
        });
    }
Administrator committed
43 44 45
}

// Load the shifts the member is registered to
46 47 48 49 50 51 52 53 54 55 56
function loadShiftPartner(partner_id) {
    $.getJSON('/shifts/get_list_shift_partner/' + partner_id, function(donnees) {
        // Init the partner's shifts list
        listeShiftPartner = [];
        donnees.forEach(function f(shift) {
            var dateStart = new Date(shift.date_begin);

            if (dateStart.getHours() < 22) {
                listeShiftPartner.push(shift);
            }
        });
Administrator committed
57

58 59
        $('#shift_msg').remove();
        $('#partnerData').append('<div id="shift_msg"></div>');
60
        if (dataPartner.shift_type == "ftop" || listeShiftPartner.length > 0) {
Administrator committed
61
        // ftop, no shift planned
62 63 64 65 66 67 68 69 70 71 72
            if (listeShiftPartner.length == 0) {
                var date = new Date(dataPartner.next_regular_shift_date);
                // ftop looses 1 point if points >=0, looses 2 otherwise
                var lost_points = "un point";

                if (dataPartner.final_ftop_point < 0) {
                    lost_points = "deux points";
                }

                var msg = "Je m'inscris à un service, en cliquant sur un des services du calendrier ci-dessous.<br/>";
                /*** TODO : add message structure to html #templates
Administrator committed
73 74 75
          msg += "Si je ne fais pas de service avant le " + date.toLocaleDateString("fr-fr") + ", mon compteur perdra " + lost_points + ".  <i class=\"fas fa-info-circle\" title=\"Je clique pour avoir plus de détails.\"></i><div class=\"infocircle\"> <div class=\"close\" onclick=\"closeInfo(this)\"><i class=\"far fa-times-circle\"></i></div>Mon compteur sera diminué de 1 point le "+date.toLocaleDateString("fr-fr")+" si mon solde est supérieur ou égal à 0, sinon de 2 points, comme tous <strong>les jeudis de semaine A</strong> pour tou.te.s les volant.e.s.</div>"
          **/

76 77 78 79 80 81
                $('#shift_msg').append('<span id="new_shift_msg" class="highlight"><br />'+msg+'</span>');
            } else {
                $('#new_shift_msg').remove();

                // Set DOM for partner's shifts and shift message for ftops
                iniListShift(listeShiftPartner, true);
82
                if (dataPartner.shift_type == "ftop") {
83 84 85
                    $('#shift_msg').append("<br /><strong>Je peux choisir d'autres services pour les mois à venir ou échanger un de ceux de la liste.</strong>");
                }
            }
Administrator committed
86
        }
87
    });
Administrator committed
88 89 90
}

// Proceed to shift exchange or registration
91 92 93
function changeShift(idOldRegister, idNewShift) {
    if (is_time_to('change_shift')) {
        openModal(); // loading on
Administrator committed
94

95
        tData = 'idNewShift=' + idNewShift +'&idPartner=' + dataPartner.partner_id + '&shift_type=' + dataPartner.shift_type + '&verif_token=' + dataPartner.verif_token;
96 97 98 99 100 101 102 103
        if (idOldRegister == "") {
            tUrl = '/shifts/add_shift';
        } else {
            register = listeShiftPartner.find(function(shift) {
                return shift.id === Number(idOldRegister);
            });
            tUrl = '/shifts/change_shift';
            tData = tData + '&idOldShift='+ register.shift_id[0] +'&idRegister=' + idOldRegister;
Administrator committed
104
        }
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135

        $.ajaxSetup({headers: {"X-CSRFToken": getCookie('csrftoken')}});
        $.ajax({
            type: 'POST',
            url: tUrl,
            dataType:"json",
            data: tData,
            timeout: 3000,
            complete: function () {
                $("#box_load").fadeOut();
            },
            success: function(data) {
                if (data.result) {
                    closeModal();
                    setTimeout( // Due to chrome effect
                        function() {
                            parent.window.postMessage('scrollToTop', '*');
                            msg = "Parfait! ";
                            if (idOldRegister == "") {
                                msg += "Le service choisi a été ajouté.";
                            } else {
                                msg += "Le service a été échangé.";
                            }
                            alert(msg);
                            loadShiftPartner(dataPartner.partner_id);
                            $('#dp').fullCalendar('refetchEvents');
                        }
                        , 500
                    );
                }
            },
136
            error: function(error) {
137
                closeModal();
138 139

                if (error.status === 400) {
François committed
140
                    alert(`Désolé ! Le service que vous souhaitez échanger démarre dans moins de 24h. Il n'est plus possible de l'échanger.`);
141 142 143 144

                } else {
                    alert('Une erreur est survenue. Il est néanmoins possible que la requête ait abouti, veuillez patienter quelques secondes puis vérifier vos services enregistrés.');
                }
145 146 147 148 149 150 151 152 153 154 155 156
                // Refectch shifts anyway:
                //  in case an error rises but the registration/exchange was still succesful
                setTimeout( // Due to chrome effect
                    function() {
                        loadShiftPartner(dataPartner.partner_id);
                        $('#dp').fullCalendar('refetchEvents');
                    }
                    , 500
                );
            }
        });
    }
Administrator committed
157 158 159 160
}

// Check if the member can proceed to a service exchange
function canMakeExchange() {
161 162
    var answer = false;
    // Set the partner's limit date (after which he'll loose a point)
Administrator committed
163

164
    if (dataPartner.dateProlonge != "False" || dataPartner.final_standard_point < 0 || dataPartner.shift_type == "ftop") {
165 166
        var dateProlonge = new Date(dataPartner.dateProlonge);
        var dateNextRegularShift = new Date(dataPartner.next_regular_shift_date);
Administrator committed
167

168 169 170 171 172
        limitDate = dateNextRegularShift;

        // For ABCD : the limit date is end of alert
        var dateEndAlert = new Date(dataPartner.date_alert_stop);

173
        if (dataPartner.shift_type == "ftop" && limitDate < dateEndAlert) {
174
            limitDate = dateEndAlert;
Administrator committed
175
        }
176 177 178 179

        // For partner in delay : limit date is end of delay
        if (dateProlonge - dateNextRegularShift < 0 || dataPartner.cooperative_state == 'delay') {
            limitDate = dateProlonge;
Administrator committed
180
        }
181
    }
Administrator committed
182

183 184
    let shifts_before_limit = 0;
    // If has shifts
Administrator committed
185

186 187 188 189 190 191
    if (listeShiftPartner.length > 0) {
    // Calculate needed data
        non_regular_shifts = [];
        listeShiftPartner.forEach(function(s) {
            if (limitDate) {
                var s_date_begin = new Date(s.date_begin);
Administrator committed
192

193 194 195 196 197 198 199 200 201 202 203 204 205 206
                if (s_date_begin - limitDate <= 0) {
                    shifts_before_limit += 1; // any shift before limit date
                }
                try {
                    if (s.shift_id[1].indexOf(dataPartner.regular_shift_name) == -1 && s_date_begin - limitDate <= 0) {
                        non_regular_shifts.push(s.date_begin); // non regular shifts before limit date
                    }
                } catch (e) {
                    //nothnig special to do
                }
            }
        });

        // Allow exchange if points >= 0 or he already has enough services booked before the limit date
207
        var partner_points = dataPartner.shift_type == "ftop" ? dataPartner.final_ftop_point : dataPartner.final_standard_point;
Administrator committed
208

209 210 211 212 213 214 215 216 217 218
        if (partner_points >= 0 || shifts_before_limit >= 1) {
            answer = true;
        }

        // If member in alert, allow service exchange if he selected enough 'catch-ups'
        if (dataPartner.cooperative_state == "alert" || dataPartner.cooperative_state == "delay") {
            answer = (shifts_before_limit >= 1) && (non_regular_shifts.length >= Math.abs(partner_points));
        }

        // ftop can always exchange service
219
        if (dataPartner.shift_type == "ftop") {
220 221
            answer = true;
        }
Administrator committed
222 223
    }

224
    return answer;
Administrator committed
225 226 227 228 229 230 231 232
}

/*
Génère le message à afficher lorsque le coop doit faire un rattrapage.
  L'affiche si besoin.
  Pour les volants, chaque service compte comme un rattrapage.
*/
function addMakeUpMsg() {
233
    var partner_points = dataPartner.shift_type == "ftop" ? dataPartner.final_ftop_point : dataPartner.final_standard_point;
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
    let shifts_before_limit = 0;

    // Calcul du nombre de rattrapages à faire
    if (partner_points < 0) {
        let s_date_begin = null;

        // Calcul du nombre de rattrapages déjà prévus avant la date limite
        non_regular_shifts.forEach(function(s) {
            s_date_begin = new Date(s);
            if (s_date_begin > new Date() && s_date_begin - limitDate <= 0) {
                shifts_before_limit += 1;
            }
        });
        make_up_nb = parseInt(partner_points) + shifts_before_limit;
        // Besoin de choisir un rattrapage : afficher message rattrapage
        if (make_up_nb < 0) {
            make_up_nb = Math.abs(make_up_nb);
            var msg = "";

            var mun_letters = "un";

            if (make_up_nb == 2) {
                mun_letters = "deux";
            } else if (make_up_nb == 3) {
                mun_letters = "trois";
            } else if (make_up_nb == 4) {
                mun_letters = "quatre";
            } else if (make_up_nb == 5) {
                mun_letters = "cinq";
            }

            msg = "Je dois ";
            if (non_regular_shifts > 0) {
                msg += "encore";
            }
            msg += " m'inscrire à " + mun_letters + " service";
            if (make_up_nb > 1) {
                msg += "s de rattrapage en les sélectionant ";
            } else {
                msg +=" de rattrapage en en sélectionant un ";
            }
            msg +=" dans le calendrier ci-dessous.";

            if (make_up_nb > 1) {
                msg += "<br/>Ces services doivent être fait ";
            } else {
                msg += "<br/>Ce service doit être fait ";
            }

            // Si le membre est un volant
284
            if (dataPartner.shift_type == "ftop") {
285 286 287 288 289 290 291
                msg = "Je dois faire " + make_up_nb + " service";
                if (make_up_nb > 1) msg += "s";
                if (non_regular_shifts.length > 0) msg += " en plus";
            }

            msg += " avant le " + limitDate.toLocaleDateString("fr-fr", optDate) + ", faute de quoi je serai suspendu.e à cette date.";

292 293 294
            msg += "<br/>Je dois m'inscrire à tous mes services de rattrapage avant de pouvoir échanger mes services.";

            $('#partnerData').append("<p class=\"need_make_up_area\"><span class=\"need_make_up\"><strong>"+ msg + "</strong></span></p>");
295 296 297 298
            $('.need_make_up').show();
        } else {
            $('.need_make_up').hide();
        }
Administrator committed
299
    } else {
300
        $('.need_make_up').hide();
Administrator committed
301 302 303
    }
}

304
function manageCheckedBoxes() {
Administrator committed
305 306
    let clicked = $(this);
    let checked = clicked.is(':checked');
307 308 309

    $('[name="shiftRadio"]').prop('checked', false);
    if (checked) clicked.prop('checked', checked);
Administrator committed
310 311 312 313 314 315 316 317 318 319
}

/*
  Check if a partner can add a new shift.
  Those who can't are:
    - ftops, with points <0 and new service selected after limit date
    - ABCD up to date (or with enough catch-ups)
    - ABCD who choose catch-up after their limit date
*/
function canAddShift(date_new_shift) {
320
    var answer = false;
Administrator committed
321

322
    // If partner is ftop (ftop = volant)
323
    if (dataPartner["shift_type"] == "ftop") {
Administrator committed
324
    // If points >= 0 : can register to any shift
325 326 327 328 329 330 331 332
        if (dataPartner.final_ftop_point >= 0) {
            answer = true;
        } else {
            // If points < 0 : can only register to a shift before the limit date
            if (date_new_shift < limitDate) {
                answer = true;
            }
        }
Administrator committed
333
    }
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363
    // Rattrapages des ABCD
    else if (dataPartner["cooperative_state"] != "up_to_date") {
        // how many makeup have already been choosen ? (before end of alert)
        var dateEndAlert = null;

        if (dataPartner["dateProlonge"] == "False") {
            dateEndAlert = new Date(dataPartner["date_alert_stop"]);
        } else {
            dateEndAlert = new Date(dataPartner["dateProlonge"]);
        }

        var choosen_makeups = 0;

        $.each(listeShiftPartner, function(i, e) {
            if (new Date(e.date_begin) < dateEndAlert && e.shift_id[1].indexOf(dataPartner["regular_shift_name"]) < 0) {
                choosen_makeups++;
            }
        });

        // Si moins de rattrapages sélectionnés que de points à rattraper :
        //   dois faire un rattrapage, donc peut ajouter un service.
        if (choosen_makeups < Math.abs(dataPartner["final_standard_point"])) {
            // can only register to a shift before the limit date
            if (date_new_shift < limitDate) {
                answer = true;
            }
        }
    }

    return answer;
Administrator committed
364 365 366 367 368
}

// Request a delay for the current member, starting at the end of his limit date
// TODO : shift_common
function request_delay() {
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385
    openModal(); // Loading on

    var formated_limit_date = limitDate.getFullYear()+'-'+(limitDate.getMonth()+1)+'-'+limitDate.getDate();
    let delay_data = {
        idPartner: dataPartner.partner_id,
        verif_token: dataPartner.verif_token,
        start_date: formated_limit_date // date when the 28 days delay begins
    };

    // If not already in delay
    if (dataPartner.cooperative_state != 'delay') {
        let today = new Date();
        var extension_beginning = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();

        // set today as the actual starting date for the object delay
        // so odoo take account of the delay
        delay_data['extension_beginning'] = extension_beginning;
Administrator committed
386
    }
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408

    $.ajaxSetup({headers: {"X-CSRFToken": getCookie('csrftoken')}});
    $.ajax({
        type: 'POST',
        url: '/shifts/request_delay',
        dataType: 'json',
        timeout: 3000,
        data: delay_data,
        success: function(doc) {
            closeModal();
            alert("L'extension a bien été accordée ! Cette page va se recharger...");
            setTimeout( // Due to chrome effect
                function() {
                    document.location.reload();
                }
                , 500
            );
        },
        error: function() {
            alert('Impossible de créer l\'extension. Je dois passer au Bureau des membres pour régler le problème.');
        }
    });
Administrator committed
409 410 411 412
}


$(document).ready(function() {
413 414 415 416
    // Retrieve and display partner's shifs
    loadShiftPartner(dataPartner.partner_id);

    // Display information depending on partner's type and state
417
    if (dataPartner.shift_type == "ftop") {
418 419
        $('div.intro div h2').text("Bienvenue dans le système de choix et d'échange de services");
        $('.additionnal_intro_data').text(' ou en choisir un nouveau');
420

421 422
        var partnerData = "Je suis en statut <span class=\"status\">" + listStates[dataPartner.cooperative_state]+ "</span>.<br>";
        /** TODO : Change code to use a parameter to know if following assertion has to be shown or not
Administrator committed
423 424 425 426 427 428 429
    partnerData += "Je suis volant.e et j'ai <strong>"+ dataPartner.final_ftop_point +" point";
    if(Math.abs(dataPartner.final_ftop_point) > 1) {
      partnerData += "s";
    }
    partnerData += "</strong>. "
    **/

430 431 432
        if (typeof extra_info !== "undefined" && extra_info.length > 0) {
            partnerData += '<br/>' + extra_info;
        }
433
        $('#partnerData').html(partnerData);
Administrator committed
434
    } else {
435 436
        $('.additionnal_intro_data').text(' ou choisir un rattrapage');
        var msg = "Je suis inscrit.e sur le créneau du " + get_litteral_shift_template_name(dataPartner.regular_shift_name) + '.';
Administrator committed
437

438 439 440 441 442 443 444 445 446 447
        if (dataPartner.final_standard_point < 0) {
            msg += " J'ai " + dataPartner.final_standard_point+" point";
            if (dataPartner.final_standard_point < -1) {
                msg += "s";
            }
            msg += ".";
        }
        $('#partnerData').html(msg);
        if (dataPartner.cooperative_state == "up_to_date") {
            $('#partnerData').append("<br> Je suis à jour.");
Administrator committed
448
        } else {
449 450
            $('#partnerData').append("<br> Je suis en statut <span class=\"status\">"+ listStates[dataPartner.cooperative_state] +"</span>.<br />");
        }
451 452 453
        if (typeof extra_info !== "undefined" && extra_info.length > 0) {
            $('#partnerData').append("<br/>" + extra_info);
        }
454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524
    }

    if (dataPartner.is_leave == "True") {
        var dateFinConge = new Date(dataPartner.leave_stop_date);
        var dateDebutConge = new Date(dataPartner.leave_start_date);

        $('#partnerData').append("<br/> En congé du " + dateDebutConge.toLocaleDateString("fr-fr", optDate) + " au " + dateFinConge.toLocaleDateString("fr-fr", optDate) + '<br/>');
    }

    // Listeners on click
    $(document).on("click", ".fa-info-circle", function() {
        var clicked = $(this);

        clicked.parent().find('>.infocircle')
            .toggle();
    });
    $(document).on("click", '[name="shiftRadio"]', manageCheckedBoxes);

    // Set calendar

    dp = $('#dp').fullCalendar({
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay,listWeek'
        },
        timeFormat: 'HH:mm',
        locale: "fr",
        navLinks: true, // can click day/week names to navigate views
        eventLimit: showMoreLinks, // allow "more" link when too many events showMoreLinks defines in view HTML
        height: 900,
        minTime: "06:00:00",
        maxTime: "22:00:00",
        hiddenDays: daysToHide,
        initialView: calInitialView,
        weekNumbers: true,
        events: function(start, end, timezone, callback) {
            // Load possible shifts
            $.ajax({
                url: '/shifts/get_list_shift_calendar/' + dataPartner.partner_id,
                dataType: 'json',
                data: {
                    start: start.format('YYYY-MM-DD'),
                    end: end.format('YYYY-MM-DD')
                },
                success: function(doc) {
                    loaded_events = doc;
                    // Show service exchange panel if allowed
                    can_make_exchange = canMakeExchange();
                    if (can_make_exchange) {
                        $('#exchange_instructions').show();
                    }

                    // Show make-up instructions if needed
                    $('.need_make_up').remove();
                    addMakeUpMsg();

                    callback(loaded_events);
                }
            });
        },
        eventClick: function(event) {
            // When a service is clicked
            if (event.changed) {
                var dateShiftNew = new Date(event.start);

                can_make_exchange = canMakeExchange();
                can_add_shift = canAddShift(dateShiftNew);

                if (dataPartner.is_leave == "True" && (dateShiftNew < dateFinConge && dateShiftNew > dateDebutConge)) {
                    alert("Je suis en congé à cette date ... ");
Administrator committed
525
                } else {
526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545
                    var idShiftOld = Number($('input[name=shiftRadio]:checked').val() || "");
                    var msg = '';

                    // si un service a été sélectionné --> Echange (pour tout le monde)
                    if (idShiftOld != "" && can_make_exchange) {
                        var resOldShift = listeShiftPartner.find(function(shift) {
                            return shift.id === idShiftOld;
                        });
                        var dateShiftOld = new Date(resOldShift.date_begin);

                        msg = '<div>Je suis sur le point d\'échanger le service du : </div>';
                        msg += '<div>' + dateShiftOld.toLocaleDateString("fr-fr", optDate) + ' à ' + dateShiftOld.toLocaleTimeString("fr-fr") +'</div>';
                        msg += '<div>par celui de : </div>';
                        msg += '<div>'+ dateShiftNew.toLocaleDateString("fr-fr", optDate) + ' à ' + dateShiftNew.toLocaleTimeString("fr-fr") + '</div>';
                    } else {
                        // Pas de service selectionné --> Ajout d'un service

                        // For partners who can't add a shift as it is
                        if (!can_add_shift) {
                            // Partners who could ask for a delay
546
                            if (dataPartner.shift_type == "ftop" || dateShiftNew > limitDate) {
547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591
                                // Member can ask for 6 delays, which is 24 weeks after entering alert status
                                // 'date_alert_stop' field is begining of alert + 4 weeks
                                let date_end_alert = new Date(dataPartner.date_alert_stop);

                                date_end_alert.setDate(date_end_alert.getDate()+20*7);

                                // If member can ask for delay
                                if (new Date() < date_end_alert) {
                                    openModal(
                                        "Pour pouvoir sélectionner un service à partir du <strong>" + limitDate.toLocaleDateString("fr-fr", optDate) + "</strong> je dois demander une extension.<br/>"
                            + "Je devrais re-sélectionner ce service dans l'agenda une fois l'extension accordée.",
                                        request_delay,
                                        "Demander une extension"
                                    );
                                } else {
                                    // can't ask for delays anymore
                                    openModal(
                                        "Je dois sélectionner un service <strong>avant le " + limitDate.toLocaleDateString("fr-fr", optDate) + "</strong>",
                                        closeModal, "J'ai compris"
                                    );
                                }
                            } else { // ABCD up-to-date
                                openModal(
                                    "Je dois sélectionner un service à échanger.",
                                    closeModal, "J'ai compris"
                                );
                            }
                            // Can add shift
                        } else {
                            msg = "<div>Je suis sur le point de m'inscrire au service du : </div>";
                            msg += '<div>'+ dateShiftNew.toLocaleDateString("fr-fr", optDate) + ' à ' + dateShiftNew.toLocaleTimeString("fr-fr") +'</div>';
                        }
                    }
                    if (msg != '') {
                        openModal(
                            msg,
                            function() {
                                var bl = $('#box_load');

                                bl.fadeIn(50);
                                bl.css('top', (lastY - 300) + 'px');
                                changeShift(idShiftOld, event.id);
                            }, 'Valider'
                        );
                    }
Administrator committed
592 593 594
                }
            }
        }
595
    });
Administrator committed
596 597 598

});

599 600 601
$(document).mousedown(function(e) {
    lastY = e.clientY;
});