~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/webapp/tutorial/media/tutorial.js

Tutorial: Added a message, "no attempts have been made to this exercise",
    rather than displaying the empty box and View button.
    As a contingency, also fixed the View button - won't crash if there are no
    items in the list.

Show diffs side-by-side

added added

removed removed

Lines of Context:
484
484
    var openarea = attempthistory.getElementsByTagName("div")[0];
485
485
    var dropdown = attempthistory.getElementsByTagName("select")[0];
486
486
    var textarea = attempthistory.getElementsByTagName("textarea")[0];
 
487
    /* Further handles on the paragraphs for showing/hiding */
 
488
    var attemptslist = openarea.getElementsByTagName("p")[1];
 
489
    var noattempts = openarea.getElementsByTagName("p")[2];
487
490
 
488
491
    /* Clear the dropdown box */
489
492
    dom_removechildren(dropdown);
537
540
            openbutton.setAttribute("style", "display: none");
538
541
            openarea.setAttribute("style", "display: auto");
539
542
            textarea.setAttribute("style", "display: none");
 
543
            attemptslist.setAttribute("style", "display: none");
 
544
            noattempts.setAttribute("style", "display: none");
 
545
            // NOTE: This must go after setting openarea to visible. For some
 
546
            // reason, Firefox will not display these elements otherwise.
 
547
            if (attempts.length > 0)
 
548
                attemptslist.setAttribute("style", "display: auto");
 
549
            else
 
550
                noattempts.setAttribute("style", "display: auto");
540
551
        }
541
552
    attempts_path = "api/subjects/" + subject + "/+worksheets/" + worksheet 
542
553
        + "/" + filename + '/+attempts/' + username;
581
592
    var textarea = attempthistory.getElementsByTagName("textarea")[0];
582
593
 
583
594
    /* Get the "value" of the selected option */
 
595
    if (dropdown.selectedIndex < 0)
 
596
        // Nothing is selected. Fail silently (should not occur in practice).
 
597
        return;
584
598
    var date = dropdown.options[dropdown.selectedIndex].getAttribute("value");
585
599
 
586
600
    /* Send the form as multipart/form-data, since we are sending a whole lump