PageSourceSearch

https://www2.myworkpension.co.uk/Resources/Client/THPA/MemberSiteTHPA/Javascript/globalroutinesoverride.js

js myworkpension.co.uk collected 2026-10-04 17:57:54 UTC 3,518 bytes, 106 lines download raw bytes

1/*
2    override the display of error messages by providing a replacement error message class
3*/
4function clsMessages2() {
5    // Adds a message.
6    this.add = function (astrMessage) {
7        this.Fmessages.push(astrMessage);
8    }
9
10    // Returns the messages separated by the string astrSeparator.
11    this.messages = function (astrSeparator) {
12        return this.Fmessages.join(astrSeparator);
13    }
14
15    // Returns the messages in an HTML format.
16    this.messagesAsHTML = function () {
17        return "<li>" + this.messages("</li><li>") + "</li>";
18    }
19
20    // Returns the messages in a Text format.
21    this.messagesAsText = function () {
22        return this.messages(String.fromCharCode(13, 10));
23    }
24
25    // Clears all the messages.
26    this.reset = function () {
27        this.Fmessages = new Array();
28        $(".errors").remove();
29        $(".errorindicator").removeClass("validationError", "");
30        $(".errorindicator").remove();
31    }
32
33    // Returns the number of messages.
34    this.length = function () {
35        return this.Fmessages.length;
36    }
37
38    // Creates a DIV element containing the errors.
39    this.displayErrors = function () {
40
41      if (this.Fmessages.length > 0) {
42        $("#errorcontainer").html(this.messagesAsHTML());
43        if ($("#errdialog").length > 0)
44          $("#errdialog").dialog('open');     // Using jQueryUI
45        else
46          $("#bootstraperr").modal('show');   // Using Bootstrap
47      }
48    }
49
50    this.reset();
51}
52
53// redefine the global gMessages to be an instance of the new class
54gMessages = new clsMessages2();
55
56// override the function that determines how error text is built (do not number errors, and do not make them links!)
57var addFieldError = function (aField, astrMessage, aUID) {
58    var lstrMessage = astrMessage;
59    if (aUID) { lstrMessage += "  (<b>Continue?</B> <input type='checkbox' onclick='ignoreWarning(findErrorElement(" + (gMessages.length() + 1) + "), " + aUID + ", this)'>)"; }
60
61    gMessages.add(lstrMessage);
62
63    if (aField) {
64        if ((aField.style.display != "none") && (aField.type != "hidden")) {
65            if (aUID) aField.setAttribute("ignore" + aUID, 0);
66            aField.setAttribute("errorindicator", 1);
67            aField.setAttribute("errorindicatorid", gMessages.length());
68            $(aField).addClass("validationError");
69        }
70    }
71}
72
73showInDialog = function (p1, p2) {
74  if ($('#dialog-err').length < 1) {
75    $('body').append(
76    '<div id="dialog-err" class="modal fade" role="dialog"> \
77      <div class="modal-dialog">\
78      <div class="modal-content">\
79      <div class="modal-header">\
80      <button type="button" class="close" data-dismiss="modal"></button>\
81      <h4 id="modaltitle" class="modal-title">Message</h4>\
82      </div>\
83      <div id="dialog-err-body" class="modal-body">\
84      <div id="divErrorMessage" runat="server" class="validationfailed" role="alert"></div>\
85      </div>\
86      <div class="modal-footer">\
87      <button type="button" class="close" data-dismiss="modal" aria-label="Close">Close</button>\
88      </div>\
89      </div>\
90      </div>\
91      </div>');
92  }
93  $('.validationfailed').html(p1);
94  $('#modaltitle').text(p2);
95  $('#dialog-err').modal()
96}
97
98function maskMandatory(sender) {
99  var lstrResult = sender.value;
100  if (lstrResult.length == 0)
101  { sender.style.backgroundColor = "#f0f0f0"; }
102  else
103  { sender.style.backgroundColor = ""; }
104}
105
106

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.