Subversion Repositories oidplus

Rev

Rev 702 | Rev 1036 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
702 daniel-mar 1
/*
2
 * OIDplus 2.0
3
 * Copyright 2019 - 2021 Daniel Marschall, ViaThinkSoft
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 *     http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17
 
18
captcha_plugin_combobox_change_callbacks.push(function(strPlugin) {
1016 daniel-mar 19
        $("#CAPTCHAPLUGIN_PARAMS_RECAPTCHA")[0].style.display = (strPlugin.toLowerCase() == 'reCAPTCHA'.toLowerCase()) ? "Block" : "None";
702 daniel-mar 20
});
21
 
22
rebuild_callbacks.push(function() {
23
        var e = $("#captcha_plugin")[0];
24
        var strPlugin = e.options[e.selectedIndex].value;
1016 daniel-mar 25
        if (strPlugin.toLowerCase() != 'reCAPTCHA'.toLowerCase()) return true;
702 daniel-mar 26
 
27
        $("#recaptcha_public")[0].innerHTML = '';
28
        $("#recaptcha_private")[0].innerHTML = '';
29
 
30
        error = false;
31
 
32
        // Check 1: Public key must not be empty
33
        if ($("#recaptcha_public")[0].value.length == 0)
34
        {
35
                $("#recaptcha_public_warn")[0].innerHTML = '<font color="red">'+_L('Please specify a public key!')+'</font>';
1016 daniel-mar 36
                $("#config")[0].innerHTML = '<b>&lt?php</b><br><br><i>// ERROR: Please specify a reCAPTCHA public key!</i>'; // do not translate
702 daniel-mar 37
                error = true;
38
        } else {
39
                $("#recaptcha_public_warn")[0].innerHTML = '';
40
        }
41
 
42
        // Check 2: Private key must not be empty
43
        if ($("#recaptcha_private")[0].value.length == 0)
44
        {
45
                $("#recaptcha_private_warn")[0].innerHTML = '<font color="red">'+_L('Please specify a private key!')+'</font>';
1016 daniel-mar 46
                $("#config")[0].innerHTML = '<b>&lt?php</b><br><br><i>// ERROR: Please specify a reCAPTCHA private key!</i>'; // do not translate
702 daniel-mar 47
                error = true;
48
        } else {
49
                $("#recaptcha_private_warn")[0].innerHTML = '';
50
        }
51
 
52
        return !error;
53
});
54
 
55
captcha_rebuild_config_callbacks.push(function() {
56
        var e = $("#captcha_plugin")[0];
57
        var strPlugin = e.options[e.selectedIndex].value;
1016 daniel-mar 58
        if (strPlugin.toLowerCase() != 'reCAPTCHA'.toLowerCase()) return '';
59
        return 'OIDplus::baseConfig()->setValue(\'RECAPTCHA_VERSION\', '+$("#recaptcha_version").find('option:selected').attr("name")+');<br>' +
60
               'OIDplus::baseConfig()->setValue(\'RECAPTCHA_PUBLIC\',  \''+$("#recaptcha_public")[0].value+'\');<br>' +
702 daniel-mar 61
               'OIDplus::baseConfig()->setValue(\'RECAPTCHA_PRIVATE\', \''+$("#recaptcha_private")[0].value+'\');<br>';
62
});