PageSourceSearch

https://queenslibrary.org/themes/renovate/js/chat.js?tlxmr6

js queenslibrary.org collected 2026-10-01 10:17:06 UTC 3,623 bytes, 137 lines download raw bytes

1// chat javascript
2function submitLibChatForm(form) {
3    if (checkItChat(form)) {
4        document.chatform.action = 'https://www.questionpoint.org/crs/servlet/org.oclc.chat.ClientInit';
5        document.forms["chatform"].submit();
6    }
7}
8
9function checkItChat(form) {
10    //   var name = form.chat_name.value;
11    //    var email = form.chat_email.value;
12
13    var name =document.getElementById("chat_name").value;
14    var email = document.getElementById("chat_email").value;
15    var tempobj = document.getElementById("library");
16    var lib;
17    var msg = '';
18
19    if (tempobj.selectedIndex >= 0) {
20        lib = tempobj.value;
21    }
22
23    if (lib == null) {
24        lib = document.getElementById("library").value;
25    }
26
27
28    
29    if(name.length < 1)
30        msg += 'Name';
31
32    if(email.length < 1) {
33        if(msg.length > 0)
34            msg += ', ';
35        msg += 'Email Address';
36    }
37
38    if (msg != ''){
39        alert("One or more required fields are blank\r\n" + msg);
40        return false;
41    }
42
43    if(lib.length < 1) {
44        alert("The library supplying this form has an error in the form. Please contact them and alert them to the problem\r\n");
45        return false;
46    }
47    if (emailCheck(email, true)) {
48        return true;
49    }
50    else {
51        return false;
52    }
53}
54
55function emailCheck (emailStr, alertflag) {
56
57    var emailPat=/^(.+)@(.+)$/
58
59    var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
60
61    var validChars="\[^\\s" + specialChars + "\]"
62    var quotedUser="(\"[^\"]*\")"
63    var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
64    var atom=validChars + '+'
65
66    var word="(" + atom + "|" + quotedUser + ")"
67
68    var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
69
70    var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
71
72
73
74    var matchArray=emailStr.match(emailPat)
75    if (matchArray==null) {
76        if (alertflag)
77            alert("Email address seems incorrect (check @ and .'s)")
78        return false
79    }
80    var user=matchArray[1]
81    var domain=matchArray[2]
82
83// See if "user" is valid
84    if (user.match(userPat)==null) {
85        // user is not valid
86        if (alertflag)
87            alert("The username doesn't seem to be valid.")
88        return false
89    }
90
91    /* if the e-mail address is at an IP address (as opposed to a symbolic
92     host name) make sure the IP address is valid. */
93    var IPArray=domain.match(ipDomainPat)
94    if (IPArray!=null) {
95        // this is an IP address
96        for (var i=1;i<=4;i++) {
97            if (IPArray[i]>255) {
98                if (alertflag)
99                    alert("Destination IP address is invalid!")
100                return false
101            }
102        }
103        return true
104    }
105
106// Domain is symbolic name
107    var domainArray=domain.match(domainPat)
108    if (domainArray==null) {
109        if (alertflag)
110            alert("The domain name doesn't seem to be valid.")
111        return false
112    }
113
114
115    var atomPat=new RegExp(atom,"g")
116    var domArr=domain.match(atomPat)
117    var len=domArr.length
118    if (domArr[domArr.length-1].length<2 ||
119        domArr[domArr.length-1].length>3) {
120        // the address must end in a two letter or three letter word.
121        if (alertflag)
122            alert("The address must end in a three-letter domain, or two letter country.")
123        return false
124    }
125
126// Make sure there's a host name preceding the domain.
127    if (len<2) {
128        var errStr="This address is missing a hostname!"
129        if (alertflag)
130            alert(errStr)
131        return false
132    }
133
134// If we've gotten this far, everything's valid!
135    return true;
136}
137// END OF SCRIPT

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.