public function outputJavascript()
    {
        ?>
        <script type="text/javascript" language="JavaScript">

            var shortCodeDocUrls = {
                '': 'http://cfdbplugin.com/?page_id=89',
                '[cfdb-html]': 'http://cfdbplugin.com/?page_id=284',
                '[cfdb-table]': 'http://cfdbplugin.com/?page_id=93',
                '[cfdb-datatable]': 'http://cfdbplugin.com/?page_id=91',
                '[cfdb-value]': 'http://cfdbplugin.com/?page_id=98',
                '[cfdb-count]': 'http://cfdbplugin.com/?page_id=278',
                '[cfdb-json]': 'http://cfdbplugin.com/?page_id=96',
                '[cfdb-export-link]': 'http://cfdbplugin.com/?page_id=419'
            };

            function showHideOptionDivs() {
                var shortcode = jQuery('#shortcode_ctrl').val();
                jQuery('#doc_url_tag').attr('href', shortCodeDocUrls[shortcode]);
                jQuery('#doc_url_tag').html(shortcode + " <?php 
        echo htmlspecialchars(__('Documentation', 'contact-form-7-to-database-extension'));
        ?>
");
                switch (shortcode) {
                    case "[cfdb-html]":
                        jQuery('#show_hide_div').show();
                        jQuery('#limitorder_div').show();
                        jQuery('#html_format_div').hide();
                        jQuery('#dt_options_div').hide();
                        jQuery('#editcolumns_div').hide();
                        jQuery('#json_div').hide();
                        jQuery('#value_div').hide();
                        jQuery('#template_div').show();
                        jQuery('#url_link_div').hide();
                        jQuery('#headers_div').hide();
                        break;
                    case "[cfdb-table]":
                        jQuery('#show_hide_div').show();
                        jQuery('#limitorder_div').show();
                        jQuery('#html_format_div').show();
                        jQuery('#dt_options_div').hide();
                        jQuery('#editcolumns_div').hide();
                        jQuery('#json_div').hide();
                        jQuery('#value_div').hide();
                        jQuery('#template_div').hide();
                        jQuery('#url_link_div').hide();
                        jQuery('#headers_div').show();
                        break;
                    case "[cfdb-datatable]":
                        jQuery('#show_hide_div').show();
                        jQuery('#limitorder_div').show();
                        jQuery('#html_format_div').show();
                    <?php 
        if (!$this->plugin->isEditorActive()) {
            ?>
                        jQuery('#edit_mode_cntl').attr('disabled', 'disabled'); <?php 
        }
        ?>
                        jQuery('#dt_options_div').show();
                        jQuery('#editcolumns_div').show();
                        jQuery('#json_div').hide();
                        jQuery('#value_div').hide();
                        jQuery('#template_div').hide();
                        jQuery('#url_link_div').hide();
                        jQuery('#headers_div').show();
                        break;
                    case "[cfdb-value]":
                        jQuery('#show_hide_div').show();
                        jQuery('#limitorder_div').show();
                        jQuery('#html_format_div').hide();
                        jQuery('#dt_options_div').hide();
                        jQuery('#editcolumns_div').hide();
                        jQuery('#json_div').hide();
                        jQuery('#value_div').show();
                        jQuery('#template_div').hide();
                        jQuery('#url_link_div').hide();
                        jQuery('#headers_div').hide();
                        break;
                    case "[cfdb-count]":
                        jQuery('#show_hide_div').hide();
                        jQuery('#limitorder_div').hide();
                        jQuery('#html_format_div').hide();
                        jQuery('#dt_options_div').hide();
                        jQuery('#editcolumns_div').hide();
                        jQuery('#json_div').hide();
                        jQuery('#value_div').hide();
                        jQuery('#template_div').hide();
                        jQuery('#url_link_div').hide();
                        jQuery('#headers_div').hide();
                        break;
                    case "[cfdb-json]":
                        jQuery('#show_hide_div').show();
                        jQuery('#limitorder_div').show();
                        jQuery('#html_format_div').hide();
                        jQuery('#dt_options_div').hide();
                        jQuery('#editcolumns_div').hide();
                        jQuery('#json_div').show();
                        jQuery('#value_div').hide();
                        jQuery('#template_div').hide();
                        jQuery('#url_link_div').hide();
                        jQuery('#headers_div').show();
                        break;
                    case "[cfdb-export-link]":
                        jQuery('#show_hide_div').show();
                        jQuery('#limitorder_div').show();
                        jQuery('#html_format_div').hide();
                        jQuery('#dt_options_div').hide();
                        jQuery('#editcolumns_div').hide();
                        jQuery('#json_div').hide();
                        jQuery('#value_div').hide();
                        jQuery('#template_div').hide();
                        jQuery('#url_link_div').show();
                        jQuery('#headers_div').show();
                        break;
                    default:
                        jQuery('#show_hide_div').show();
                        jQuery('#limitorder_div').show();
                        jQuery('#html_format_div').hide();
                        jQuery('#dt_options_div').hide();
                        jQuery('#editcolumns_div').hide();
                        jQuery('#json_div').hide();
                        jQuery('#value_div').hide();
                        jQuery('#template_div').hide();
                        jQuery('#url_link_div').hide();
                        jQuery('#headers_div').hide();
                        break;
                }
                var exportSelected = jQuery('#export_cntl').val();
                jQuery('#label_export_link').show();
                jQuery('#label_gld_function').hide();
                jQuery('#userpass_span_msg').show();
                jQuery('#gld_userpass_span_msg').hide();
                if (exportSelected) {
                    if (exportSelected == 'RSS') {
                        jQuery('#itemtitle_span').show();
                        jQuery('#csvdelim_span').hide();
                    }
                    else {
                        jQuery('#itemtitle_span').hide();
                        jQuery('#headers_div').show();
                        if (exportSelected == "GLD") {
                            jQuery('#userpass_span_msg').hide();
                            jQuery('#gld_userpass_span_msg').show();
                            jQuery('#label_export_link').hide();
                            jQuery('#label_gld_function').show();
                        }

                        if (exportSelected == "JSON") {
                            jQuery('#json_div').show();
                        }
                        else {
                            jQuery('#json_div').hide();
                        }

                        if (['CSVUTF8BOM', 'CSVUTF8', 'CSVSJIS'].indexOf(exportSelected) > -1) {
                            jQuery('#csvdelim_span').show();
                        }
                        else {
                            jQuery('#csvdelim_span').hide();
                        }
                    }
                } else {
                    jQuery('#itemtitle_span').hide();
                    jQuery('#csvdelim_span').hide();
                    jQuery('#userpass_span_msg').show();
                    jQuery('#gld_userpass_span_msg').hide();
                    jQuery('#label_gld_script').hide();
                }
            }

            function getValue(attr, value, errors) {
                if (value) {
                    if (errors && value.indexOf('"') > -1) {
                        errors.push('<?php 
        echo htmlspecialchars(__('Error: "', 'contact-form-7-to-database-extension'));
        ?>
'
                                + attr +
                                '<?php 
        echo htmlspecialchars(__('" should not contain double-quotes (")', 'contact-form-7-to-database-extension'));
        ?>
');
                        value = value.replace('"', "'");
                    }
                    return attr + '="' + value + '"';
                }
                return '';
            }

            function pushNameValue(attr, value, array, errors) {
                if (value) {
                    if (errors && value.indexOf('"') > -1) {
                        errors.push('<?php 
        echo htmlspecialchars(__('Error: "', 'contact-form-7-to-database-extension'));
        ?>
'
                                + attr +
                                '<?php 
        echo htmlspecialchars(__('" should not contain double-quotes (")', 'contact-form-7-to-database-extension'));
        ?>
');
                        value = value.replace('"', "'");
                    }
                    array.push(attr);
                    array.push(value);
                    return true;
                }
                return false;
            }

            function getValueUrl(attr, value) {
                if (value) {
                    return attr + '=' + encodeURIComponent(value)
                }
                return '';
            }


            function join(arr, delim) {
                if (delim == null) {
                    delim = ' ';
                }
                var tmp = [];
                for (idx = 0; idx < arr.length; idx++) {
                    if (arr[idx] != '') {
                        tmp.push(arr[idx]);
                    }
                }
                return tmp.join(delim);
            }

            function chopLastChar(text) {
                return text ? text.substr(0, text.length - 1) : text;
            }

            function createShortCodeAndExportLink() {
                var scElements = [];
                var scUrlElements = [];
                var scValidationErrors = [];

                var exportUrlElements = [];
                var exportValidationErrors = [];

                var googleScriptElements = [];
                var googleScriptValidationErrors = [];

                var shortcode = jQuery('#shortcode_ctrl').val();
                if (shortcode == '') {
                    jQuery('#shortcode_result_text').html('');
                }
                scElements.push(chopLastChar(shortcode));

                var pushErrorMessagesToAll = function (errMsg) {
                    scValidationErrors.push(errMsg);
                    exportValidationErrors.push(errMsg);
                    googleScriptValidationErrors.push(errMsg);
                };

                var formName = jQuery('#form_name_cntl').val();
                var errMsg;
                if (!formName || Array.isArray(formName) && !formName.length) {
                    errMsg = '<?php 
        echo htmlspecialchars(__('Error: no form is chosen', 'contact-form-7-to-database-extension'));
        ?>
';
                    jQuery('#form_validations_text').html(errMsg);
                    pushErrorMessagesToAll(errMsg);
                }
                else {
                    jQuery('#form_validations_text').html('');
                    scElements.push('form="' + formName + '"');
                    scUrlElements.push('form=' + encodeURIComponent(formName));
                    exportUrlElements.push('form=' + encodeURIComponent(formName));
                    googleScriptElements.push('<?php 
        echo $this->siteUrl;
        ?>
');
                    googleScriptElements.push(formName);
                    googleScriptElements.push('<?php 
        echo is_user_logged_in() ? wp_get_current_user()->user_login : '******';
        ?>
');
                    googleScriptElements.push('&lt;password&gt;');
                }

                var pushValueToAll = function (name, val) {
                    scElements.push(getValue(name, val, scValidationErrors));
                    scUrlElements.push(getValueUrl(name, val));
                    exportUrlElements.push(getValueUrl(name, val));
                    pushNameValue(name, val, googleScriptElements, googleScriptValidationErrors);
                };

                var val;
                if (shortcode != '[cfdb-count]') {
                    val = jQuery('#show_cntl').val();
                    pushValueToAll('show', val);

                    val = jQuery('#hide_cntl').val();
                    pushValueToAll('hide', val);
                }

                val = jQuery('#role_cntl').val();
                pushValueToAll('role', val);

                val = jQuery('#permissionmsg_cntl').val();
                pushValueToAll('permissionmsg', val);

                val = jQuery('#trans_cntl').val();
                pushValueToAll('trans', val);


                var handleFilterSearch = function (filterName, filter, searchName, search) {
                    if (filter) {
                        pushValueToAll(filterName, filter);
                        if (search) {
                            var errMsg = '<?php 
        echo htmlspecialchars(__('Warning: "search" field ignored because FIELD is used (use one but not both)', 'contact-form-7-to-database-extension'));
        ?>
'.replace('FIELD', filterName);
                            pushErrorMessagesToAll(errMsg);
                        }
                    }
                    else {
                        pushValueToAll(searchName, search);
                    }
                };
                var filter = jQuery('#filter_cntl').val();
                var search = jQuery('#search_cntl').val();
                handleFilterSearch('filter', filter, 'search', search);

                var tfilter = jQuery('#tfilter_cntl').val();
                var tsearch = jQuery('#tsearch_cntl').val();
                handleFilterSearch('tfilter', tfilter, 'tsearch', tsearch);


                if (shortcode != '[cfdb-count]') {

                    var handleLimit = function (limitName, limitRows, limitStart) {
                        if (limitStart && !limitRows) {
                            errMsg = '<?php 
        echo htmlspecialchars(__('Error: "FIELD": if you provide a value for "Start Row" then you must also provide a value for "Num Rows"', 'contact-form-7-to-database-extension'));
        ?>
'.replace('FIELD', limitName);
                            pushErrorMessagesToAll(errMsg);
                        }
                        if (limitRows) {
                            if (!/^\d+$/.test(limitRows)) {
                                errMsg = '<?php 
        echo htmlspecialchars(__('Error: "FIELD": "Num Rows" must be a positive integer', 'contact-form-7-to-database-extension'));
        ?>
'.replace('FIELD', limitName);
                                pushErrorMessagesToAll(errMsg);
                            }
                            else {
                                var limitOption = '';
                                var limitOptionUrl = limitName + '=';
                                if (limitStart) {
                                    if (!/^\d+$/.test(limitStart)) {
                                        errMsg = '<?php 
        echo htmlspecialchars(__('Error: "FIELD": "Start Row" must be a positive integer', 'contact-form-7-to-database-extension'));
        ?>
'.replace('FIELD', limitName);
                                        pushErrorMessagesToAll(errMsg);
                                    }
                                    else {
                                        limitOption += limitStart + ",";
                                        limitOptionUrl += encodeURIComponent(limitStart + ",");
                                    }
                                }
                                limitOption += limitRows;
                                limitOptionUrl += limitRows;
                                scElements.push(limitName + '="' + limitOption + '"');
                                scUrlElements.push(limitOptionUrl);
                                exportUrlElements.push(limitOptionUrl);
                                pushNameValue(limitName, limitOption, googleScriptElements, googleScriptValidationErrors);
                            }
                        }
                    };

                    var limitRows = jQuery('#limit_rows_cntl').val();
                    var limitStart = jQuery('#limit_start_cntl').val();
                    handleLimit('limit', limitRows, limitStart);

                    var tlimitRows = jQuery('#tlimit_rows_cntl').val();
                    var tlimitStart = jQuery('#tlimit_start_cntl').val();
                    handleLimit('tlimit', tlimitRows, tlimitStart);


                    val = jQuery('#random_cntl').val();
                    scElements.push(getValue('random', val, scValidationErrors));
                    scUrlElements.push(getValueUrl('random', val));
                    pushNameValue("random", val, googleScriptElements, googleScriptValidationErrors);

                    if (jQuery('#unbuffered_cntl').is(':checked')) {
                        scElements.push('unbuffered="true"');
                        scUrlElements.push(getValueUrl('unbuffered', 'true'));
                        exportUrlElements.push('unbuffered=true');
                        pushNameValue("unbuffered", "true", googleScriptElements, googleScriptValidationErrors);
                    }

                    var handleOrderBy = function (name, val) {
                        if (val) {
                            var orderByElem = getValue(name, val, scValidationErrors);
                            var orderByElemUrl = getValueUrl(name, val);
                            var orderByDir = jQuery('#' + name + 'dir_cntl').val();
                            if (orderByDir) {
                                orderBy += ' ' + orderByDir;
                                orderByElem = chopLastChar(orderByElem) + ' ' + orderByDir + '"';
                                orderByElemUrl = orderByElemUrl + encodeURIComponent(' ' + orderByDir);
                            }
                            scElements.push(orderByElem);
                            scUrlElements.push(orderByElemUrl);
                            exportUrlElements.push(orderByElemUrl);
                            pushNameValue(name, orderBy, googleScriptElements, googleScriptValidationErrors);
                        }
                    };
                    var orderBy = jQuery('#orderby_cntl').val();
                    handleOrderBy('orderby', orderBy);

                    var torderBy = jQuery('#torderby_cntl').val();
                    handleOrderBy('torderby', torderBy);
                }

                var scText;
                switch (shortcode) {
                    case '[cfdb-html]':
                        val = jQuery('#filelinks_cntl').val();
                        scElements.push(getValue('filelinks', val, scValidationErrors));
                        scUrlElements.push(getValueUrl('filelinks', val));

                        val = jQuery('#wpautop_cntl').val();
                        scElements.push(getValue('wpautop', val, scValidationErrors));
                        scUrlElements.push(getValueUrl('wpautop', val));

                        val = jQuery('#stripbr_cntl').val();
                        scElements.push(getValue('stripbr', val, scValidationErrors));
                        scUrlElements.push(getValueUrl('stripbr', val));

                        var template = jQuery('#content_cntl').val();
                        var content = template;
                        var contentBefore = jQuery('#before_cntl').val();
                        var contentAfter = jQuery('#after_cntl').val();
                        if (contentBefore) {
                            content = "<?php 
        echo CFDBShortCodeContentParser::BEFORE_START_DELIMITER;
        ?>
" + contentBefore + "<?php 
        echo CFDBShortCodeContentParser::BEFORE_END_DELIMITER;
        ?>
" + content;
                        }
                        if (contentAfter) {
                            content += "<?php 
        echo CFDBShortCodeContentParser::AFTER_START_DELIMITER;
        ?>
" + contentAfter + "<?php 
        echo CFDBShortCodeContentParser::AFTER_END_DELIMITER;
        ?>
";
                        }
                        scUrlElements.push('content=' + encodeURIComponent(content));
                        scUrlElements.push('enc=HTMLTemplate');
                        scText = join(scElements) + ']' +
                                // Escape html tags for display on page
                                content.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;') +
                                '[/cfdb-html]';
                        if (template == "") {
                            scValidationErrors.push('<?php 
        echo htmlspecialchars(__('Error: [cfdb-html] has empty Template. It will not output anything. ', 'contact-form-7-to-database-extension'));
        echo htmlspecialchars(__('(Shortcode Specific option)', 'contact-form-7-to-database-extension'));
        ?>
');
                            jQuery('#content_cntl').addClass('validation'); // highlight template area
                        }
                        else {
                            jQuery('#content_cntl').removeClass('validation'); // remove highlight template area
                        }
                        break;
                    case '[cfdb-table]':
                        if (!jQuery('#header_cntl').is(':checked')) {
                            scElements.push('header="false"');
                            scUrlElements.push(getValueUrl('header', 'false'));
                            pushNameValue("header", "false", googleScriptElements, googleScriptValidationErrors);
                        }
                        val = jQuery('#headers_cntl').val();
                        scElements.push(getValue('headers', val, scValidationErrors));
                        scUrlElements.push(getValueUrl('headers', val));

                        val = jQuery('#id_cntl').val();
                        scElements.push(getValue('id', val, scValidationErrors));
                        scUrlElements.push(getValueUrl('id', val));

                        val = jQuery('#class_cntl').val();
                        scElements.push(getValue('class', val, scValidationErrors));
                        scUrlElements.push(getValueUrl('class', val));

                        val = jQuery('#style_cntl').val();
                        scElements.push(getValue('style', val, scValidationErrors));
                        scUrlElements.push(getValueUrl('style', val));

                        var contentBefore = jQuery('#before_cntl').val();
                        var contentAfter = jQuery('#after_cntl').val();
                        var content = '';
                        if (contentBefore) {
                            content = "<?php 
        echo CFDBShortCodeContentParser::BEFORE_START_DELIMITER;
        ?>
" + contentBefore + "<?php 
        echo CFDBShortCodeContentParser::BEFORE_END_DELIMITER;
        ?>
" + content;
                        }
                        if (contentAfter) {
                            content += "<?php 
        echo CFDBShortCodeContentParser::AFTER_START_DELIMITER;
        ?>
" + contentAfter + "<?php 
        echo CFDBShortCodeContentParser::AFTER_END_DELIMITER;
        ?>
";
                        }
                        scUrlElements.push('content=' + encodeURIComponent(content));

                        scUrlElements.push('enc=HTML');
                        scText = join(scElements) + ']';
                        if (content) {
                            // Escape html tags for display on page
                            scText += content.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;') +
                                    '[/cfdb-table]';
                        }
                        break;
                    case '[cfdb-datatable]':
                        if (!jQuery('#header_cntl').is(':checked')) {
                            scElements.push('header="false"');
                            scUrlElements.push(getValueUrl('header', 'false'));
                        }
                        val = jQuery('#headers_cntl').val();
                        scElements.push(getValue('headers', val, scValidationErrors));
                        scUrlElements.push(getValueUrl('headers', val));
                        var hadHeaders = val != '';

                        val = jQuery('#id_cntl').val();
                        scElements.push(getValue('id', val, scValidationErrors));
                        scUrlElements.push(getValueUrl('id', val));

                        val = jQuery('#class_cntl').val();
                        scElements.push(getValue('class', val, scValidationErrors));
                        scUrlElements.push(getValueUrl('class', val));

                        val = jQuery('#style_cntl').val();
                        scElements.push(getValue('style', val, scValidationErrors));
                        scUrlElements.push(getValueUrl('style', val));

                        val = jQuery('#edit_mode_cntl').val();
                        scElements.push(getValue('edit', val, scValidationErrors));
                        scUrlElements.push(getValueUrl('edit', val));
                        if (hadHeaders && val == 'true') {
                            scValidationErrors.push('<?php 
        echo htmlspecialchars(__('Error: "edit=true" will not work properly when setting "headers" ', 'contact-form-7-to-database-extension'));
        ?>
');
                        }

                        val = jQuery('#dt_options_cntl').val();
                        scElements.push(getValue('dt_options', val, scValidationErrors));
                        scUrlElements.push(getValueUrl('dt_options', val));

                        val = jQuery('#editcolumns_cntl').val();
                        scElements.push(getValue('editcolumns', val, scValidationErrors));
                        scUrlElements.push(getValueUrl('editcolumns', val));

                        var contentBefore = jQuery('#before_cntl').val();
                        var contentAfter = jQuery('#after_cntl').val();
                        var content = '';
                        if (contentBefore) {
                            content = "<?php 
        echo CFDBShortCodeContentParser::BEFORE_START_DELIMITER;
        ?>
" + contentBefore + "<?php 
        echo CFDBShortCodeContentParser::BEFORE_END_DELIMITER;
        ?>
" + content;
                        }
                        if (contentAfter) {
                            content += "<?php 
        echo CFDBShortCodeContentParser::AFTER_START_DELIMITER;
        ?>
" + contentAfter + "<?php 
        echo CFDBShortCodeContentParser::AFTER_END_DELIMITER;
        ?>
";
                        }
                        scUrlElements.push('content=' + encodeURIComponent(content));

                        scUrlElements.push('enc=DT');
                        scText = join(scElements) + ']';
                        if (content) {
                            // Escape html tags for display on page
                            scText += content.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;') +
                                    '[/cfdb-datatable]';
                        }
                        break;
                    case '[cfdb-value]':
                        val = jQuery('#function_cntl').val();
                        scElements.push(getValue('function', val, scValidationErrors));
                        scUrlElements.push(getValueUrl('function', val));

                        val = jQuery('#delimiter_cntl').val();
                        scElements.push(getValue('delimiter', val, scValidationErrors));
                        scUrlElements.push(getValueUrl('delimiter', val));

                        var contentBefore = jQuery('#before_cntl').val();
                        var contentAfter = jQuery('#after_cntl').val();
                        var content = '';
                        if (contentBefore) {
                            content = "<?php 
        echo CFDBShortCodeContentParser::BEFORE_START_DELIMITER;
        ?>
" + contentBefore + "<?php 
        echo CFDBShortCodeContentParser::BEFORE_END_DELIMITER;
        ?>
" + content;
                        }
                        if (contentAfter) {
                            content += "<?php 
        echo CFDBShortCodeContentParser::AFTER_START_DELIMITER;
        ?>
" + contentAfter + "<?php 
        echo CFDBShortCodeContentParser::AFTER_END_DELIMITER;
        ?>
";
                        }
                        scUrlElements.push('content=' + encodeURIComponent(content));

                        scUrlElements.push('enc=VALUE');
                        scText = join(scElements) + ']';
                        if (content) {
                            // Escape html tags for display on page
                            scText += content.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;') +
                                    '[/cfdb-value]';
                        }
                        break;
                    case '[cfdb-count]':
                        var contentBefore = jQuery('#before_cntl').val();
                        var contentAfter = jQuery('#after_cntl').val();
                        var content = '';
                        if (contentBefore) {
                            content = "<?php 
        echo CFDBShortCodeContentParser::BEFORE_START_DELIMITER;
        ?>
" + contentBefore + "<?php 
        echo CFDBShortCodeContentParser::BEFORE_END_DELIMITER;
        ?>
" + content;
                        }
                        if (contentAfter) {
                            content += "<?php 
        echo CFDBShortCodeContentParser::AFTER_START_DELIMITER;
        ?>
" + contentAfter + "<?php 
        echo CFDBShortCodeContentParser::AFTER_END_DELIMITER;
        ?>
";
                        }
                        scUrlElements.push('content=' + encodeURIComponent(content));

                        scUrlElements.push('enc=COUNT');
                        scText = join(scElements) + ']'; // hopLastChar(scElements.join(' ')) + ']';
                        if (content) {
                            // Escape html tags for display on page
                            scText += content.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;') +
                                    '[/cfdb-count]';
                        }
                        break;
                    case '[cfdb-json]':
                        if (!jQuery('#header_cntl').is(':checked')) {
                            scElements.push('header="false"');
                            scUrlElements.push(getValueUrl('header', 'false'));
                            pushNameValue("header", "false", googleScriptElements, googleScriptValidationErrors);
                        }
                        val = jQuery('#headers_cntl').val();
                        scElements.push(getValue('headers', val, scValidationErrors));
                        scUrlElements.push(getValueUrl('headers', val));

                        val = jQuery('#var_cntl').val();
                        scElements.push(getValue('var', val, scValidationErrors));
                        scUrlElements.push(getValueUrl('var', val));

                        val = jQuery('#format_cntl').val();
                        scElements.push(getValue('format', val, scValidationErrors));
                        scUrlElements.push(getValueUrl('format', val));

                        var contentBefore = jQuery('#before_cntl').val();
                        var contentAfter = jQuery('#after_cntl').val();
                        var content = '';
                        if (contentBefore) {
                            content = "<?php 
        echo CFDBShortCodeContentParser::BEFORE_START_DELIMITER;
        ?>
" + contentBefore + "<?php 
        echo CFDBShortCodeContentParser::BEFORE_END_DELIMITER;
        ?>
" + content;
                        }
                        if (contentAfter) {
                            content += "<?php 
        echo CFDBShortCodeContentParser::AFTER_START_DELIMITER;
        ?>
" + contentAfter + "<?php 
        echo CFDBShortCodeContentParser::AFTER_END_DELIMITER;
        ?>
";
                        }
                        scUrlElements.push('content=' + encodeURIComponent(content));

                        scUrlElements.push('enc=JSON');
                        scText = join(scElements) + ']';
                        if (content) {
                            // Escape html tags for display on page
                            scText += content.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;') +
                                    '[/cfdb-json]';
                        }
                        break;
                    case '[cfdb-export-link]':
                        enc = jQuery('#enc_cntl').val();
                        scElements.push(getValue('enc', enc, scValidationErrors));
                        scUrlElements.push(getValueUrl('enc', enc));

                        if (['CSVUTF8BOM', 'CSVUTF8', 'CSVSJIS'].indexOf(enc) > -1) {
                            delim = jQuery('#export_link_csv_delim').val();
                            if (delim != ',') {
                                scElements.push(getValue('delimiter', delim, scValidationErrors));
                                scUrlElements.push(getValueUrl('delimiter', delim));
                            }
                        }

                        scElements.push(getValue('urlonly', jQuery('#urlonly_cntl').val(), scValidationErrors));
                        scElements.push(getValue('linktext', jQuery('#linktext_cntl').val(), scValidationErrors));

                        if (!jQuery('#header_cntl').is(':checked')) {
                            scElements.push('header="false"');
                            scUrlElements.push(getValueUrl('header', 'false'));
                        }
                        val = jQuery('#headers_cntl').val();
                        scElements.push(getValue('headers', val, scValidationErrors));
                        scUrlElements.push(getValueUrl('headers', val));

                        scText = join(scElements) + ']';
                        break;
                    default:
                        scText = shortcode;
                        break;
                }

                var urlBase = '<?php 
        echo $this->plugin->getAdminUrlPrefix('admin-ajax.php');
        ?>
action=cfdb-export&';

                if (shortcode) {
                    // Output short code text
                    var scUrl = urlBase + join(scUrlElements, '&');
                    jQuery('#shortcode_result_text').html('<a target="_cfdb_sc_results" href="' + scUrl + '">' + scText + '</a>');

                    // Output short code errors
                    jQuery('#shortcode_validations_text').html(scValidationErrors.join('<br/>'));
                }
                else {
                    // Don't report errors
                    jQuery('#shortcode_validations_text').html('');
                }

                // Export link or Google Spreadsheet function call
                var exportSelection = jQuery('#export_cntl').val();
                if (exportSelection) {
                    if (exportSelection != 'GLD') {
                        exportUrlElements.push(getValueUrl('enc', exportSelection));
                    }
                    if (exportSelection == 'RSS') {
                        exportUrlElements.push(getValueUrl('itemtitle', jQuery('#add_itemtitle').val()));
                    } else {
                        if (!jQuery('#header_cntl').is(':checked')) {
                            exportUrlElements.push(getValueUrl('header', 'false'));
                            pushNameValue("header", "false", googleScriptElements, googleScriptValidationErrors);
                        }
                        val = jQuery('#headers_cntl').val();
                        exportUrlElements.push(getValueUrl('headers', val, scValidationErrors));
                        pushNameValue("headers", val, googleScriptElements, googleScriptValidationErrors);

                        exportUrlElements.push(getValueUrl('format', jQuery('#format_cntl').val(), scValidationErrors));
                    }

                    if (['CSVUTF8BOM', 'CSVUTF8', 'CSVSJIS'].indexOf(exportSelection) > -1) {
                        delim = jQuery('#csv_delim').val();
                        if (delim != '') {
                            exportUrlElements.push(getValueUrl("delimiter", delim));
                        }
                    }

                    var user = jQuery("#gld_user").val();
                    var pass = jQuery("#gld_pass").val();
                    var obfuscate = jQuery('#obfuscate_cntl').is(':checked')
                    if (user || pass) {
                        if (obfuscate) {
                            var key = 'kx82XcPjq8q8S!xafx%$&7p6';
                            exportUrlElements.push("l=" + encodeURI(printHex(des(key, user + "/" + pass, 1))));
                        } else {
                            exportUrlElements.push("username="******"password="******"<?php 
        echo htmlspecialchars(__('Warning: the function includes your WP login information. Avoid sharing it.', 'contact-form-7-to-database-extension'));
        ?>
");
                    }

                    // Output
                    var exportUrl = urlBase + join(exportUrlElements, '&');
                    if (exportSelection == 'GLD') {
                        if (!user || !pass) {
                            exportValidationErrors.push("<?php 
        echo htmlspecialchars(__('Error: WP User and Password are required for the Google Spreadsheet to pull data from your WordPress site.', 'contact-form-7-to-database-extension'));
        ?>
");
                        }
                        if (exportUrl.length > 255) {
                            exportValidationErrors.push("<?php 
        echo htmlspecialchars(__('Because the generated URL would be too long, you must use this alternative function and add its script to your Google Spreadsheet', 'contact-form-7-to-database-extension'));
        ?>
");
                            jQuery('#label_gld_script').show();
                            jQuery('#label_gld_function').hide();
                            jQuery('#export_result_text').html(formName ?
                                    ("=cfdbdata(\"" + googleScriptElements.join("\", \"") + "\")") :
                                    "");
                        } else {
                            jQuery('#export_result_text').html(formName ?
                                    ("<a target='_cfdb_exp_results' href='" + exportUrl + "'>=IMPORTDATA(\"" + exportUrl + "\")</a>") :
                                    "");
                        }
                    } else {
                        jQuery('#export_result_text').html(formName ? ('<a target="_cfdb_exp_results" href="' + exportUrl + '">' + exportUrl + '</a>') : '');
                    }

                    // Output export errors
                    jQuery('#export_validations_text').html(exportValidationErrors.join('<br/>'));

                } else {
                    jQuery('#export_result_text').html('');
                    // Don't report errors
                    jQuery('#export_validations_text').html('');
                }
            }

            var getFormFieldsUrlBase = '<?php 
        echo $this->plugin->getFormFieldsAjaxUrlBase();
        ?>
';
            function getFormFields() {
                jQuery('[id^=add]').attr('disabled', 'disabled');
                jQuery('[id^=btn]').attr('disabled', 'disabled');
                var formName = jQuery('#form_name_cntl').val();
                var url = getFormFieldsUrlBase + encodeURIComponent(formName);
                jQuery.ajax({
                    dataType: "json",
                    url: url,
                    async: false,
                    success: function (json) {
                        var optionsHtml = '<option value=""></option>';
                        jQuery(json).each(function () {
                            optionsHtml += '<option value="' + this + '">' + this + '</option>';
                        });
                        optionsHtml += '<option value="$_POST(param)">$_POST(param)</option>';
                        optionsHtml += '<option value="$_GET(param)">$_GET(param)</option>';
                        optionsHtml += '<option value="$_COOKIE(param)">$_COOKIE(param)</option>';
                        jQuery('[id^=add]').html(optionsHtml).removeAttr('disabled');
                        jQuery('[id^=btn]').removeAttr('disabled');
                    }
                });
            }

            function validateSubmitTime() {
                var url = "<?php 
        echo $this->plugin->getValidateSubmitTimeAjaxUrlBase();
        ?>
" + jQuery('#filter_val').val();
                jQuery.get(url, function (data) {
                    alert(data);
                });
            }

            function showValidateSubmitTimeHelp(show) {
                if (show) {
                    jQuery('#span_validate_submit_time').show();
                }
                else {
                    jQuery('#span_validate_submit_time').hide();
                }
            }

            function addFieldToShow() {
                var value = jQuery('#show_cntl').val();
                if (value) {
                    value += ',';
                }
                jQuery('#show_cntl').val(value + jQuery('#add_show').val());
                createShortCodeAndExportLink();
            }

            function addFieldToHide() {
                var value = jQuery('#hide_cntl').val();
                if (value) {
                    value += ',';
                }
                jQuery('#hide_cntl').val(value + jQuery('#add_hide').val());
                createShortCodeAndExportLink();
            }

            function addFieldToOrderBy(field) {
                var value = jQuery('#' + field + '_cntl').val();
                if (value) {
                    value += ',';
                }
                jQuery('#' + field + '_cntl').val(value + jQuery('#add_' + field).val());
                createShortCodeAndExportLink();
            }

            function addFieldToFilter(field) {
                var value = jQuery('#' + field + '_cntl').val();
                if (value) {
                    value += jQuery('#' + field + '_bool').val();
                }
                value += jQuery('#add_' + field).val() + jQuery('#' + field + '_op').val() + jQuery('#' + field + '_val').val();
                jQuery('#' + field + '_cntl').val(value);
                createShortCodeAndExportLink();
            }

            function addToTrans() {
                var value = jQuery('#trans_cntl').val();
                if (value) {
                    value += "&&";
                }
                var field = jQuery('#add_trans').val();
                if (field) {
                    value += field;
                    value += "="
                }
                value += jQuery('#trans_val').val();
                jQuery('#trans_cntl').val(value);
                createShortCodeAndExportLink();
            }

            function addFieldToHeaders() {
                var col = jQuery('#add_headers').val();
                var disp = jQuery('#headers_val').val();
                if (!col || !disp) {
                    return;
                }
                var value = jQuery('#headers_cntl').val();
                if (value) {
                    value += ',';
                }
                value += col + '=' + disp;
                jQuery('#headers_cntl').val(value);
                createShortCodeAndExportLink();
            }

            function addFieldToContent() {
                jQuery('#content_cntl').val(jQuery('#content_cntl').val() + '${' + jQuery('#add_content').val() + '}');
            }

            function reset() {
                // Form
                jQuery('#form_name_cntl').val(<?php 
        echo json_encode($this->requestParams['postedForm']);
        ?>
);
                getFormFields();

                // Export File
                jQuery('#export_cntl').val(<?php 
        echo json_encode($this->requestParams['postedEnc']);
        ?>
);
                jQuery('#add_itemtitle').val(<?php 
        echo json_encode($this->requestParams['postedItemtitle']);
        ?>
);
                jQuery('#csv_delim').val(<?php 
        echo json_encode("");
        ?>
);

                // Short Code
                jQuery('#shortcode_ctrl').val(<?php 
        echo json_encode($this->requestParams['postedSC']);
        ?>
);
                jQuery('#show_cntl').val(<?php 
        echo json_encode($this->requestParams['postedShow']);
        ?>
);
                jQuery('#hide_cntl').val(<?php 
        echo json_encode($this->requestParams['postedHide']);
        ?>
);
                jQuery('#role_cntl').val(<?php 
        echo json_encode($this->requestParams['postedRole']);
        ?>
);
                jQuery('#permissionmsg_cntl').val(<?php 
        echo json_encode($this->requestParams['postedPermissionmsg']);
        ?>
);
                jQuery('#trans_cntl').val(<?php 
        echo json_encode($this->requestParams['postedTrans']);
        ?>
);
                jQuery('#search_cntl').val(<?php 
        echo json_encode($this->requestParams['postedSearch']);
        ?>
);
                jQuery('#filter_cntl').val(<?php 
        echo json_encode($this->requestParams['postedFilter']);
        ?>
);
                jQuery('#tsearch_cntl').val(<?php 
        echo json_encode($this->requestParams['postedTSearch']);
        ?>
);
                jQuery('#tfilter_cntl').val(<?php 
        echo json_encode($this->requestParams['postedTFilter']);
        ?>
);
                jQuery('#limit_rows_cntl').val(<?php 
        echo json_encode($this->requestParams['postedLimitNumRows']);
        ?>
);
                jQuery('#limit_start_cntl').val(<?php 
        echo json_encode($this->requestParams['postedLimitStart']);
        ?>
);
                jQuery('#random_cntl').val(<?php 
        echo json_encode($this->requestParams['postedRandom']);
        ?>
);
                jQuery('#unbuffered_cntl').attr("checked", false);
                jQuery('#orderby_cntl').val(<?php 
        echo json_encode($this->requestParams['postedOrderby']);
        ?>
);
                jQuery('#torderby_cntl').val(<?php 
        echo json_encode($this->requestParams['postedTOrderby']);
        ?>
);
                jQuery('#header_cntl').prop("checked", <?php 
        echo $this->requestParams['$postedHeader'] == 'false' ? 'false' : 'true';
        ?>
); // default = true
                jQuery('#headers_cntl').val(<?php 
        echo json_encode($this->requestParams['postedHeaders']);
        ?>
);
                jQuery('#id_cntl').val(<?php 
        echo json_encode($this->requestParams['postedId']);
        ?>
);
                jQuery('#class_cntl').val(<?php 
        echo json_encode($this->requestParams['postedClass']);
        ?>
);
                jQuery('#style_cntl').val(<?php 
        echo json_encode($this->requestParams['postedStyle']);
        ?>
);
                jQuery('#edit_mode_cntl').val(<?php 
        echo json_encode($this->requestParams['postedEdit']);
        ?>
);
                jQuery('#dt_options_cntl').val(<?php 
        echo json_encode($this->requestParams['postedDtOptions']);
        ?>
);
                jQuery('#editcolumns_cntl').val(<?php 
        echo json_encode($this->requestParams['postedEditcolumns']);
        ?>
);
                jQuery('#var_cntl').val(<?php 
        echo json_encode($this->requestParams['postedVar']);
        ?>
);
                jQuery('#format_cntl').val(<?php 
        echo json_encode($this->requestParams['postedFormat']);
        ?>
);
                jQuery('#function_cntl').val(<?php 
        echo json_encode($this->requestParams['postedFunction']);
        ?>
);
                jQuery('#delimiter_cntl').val(<?php 
        echo json_encode($this->requestParams['postedDelimiter']);
        ?>
);
                jQuery('#filelinks_cntl').val(<?php 
        echo json_encode($this->requestParams['postedFilelinks']);
        ?>
);
                jQuery('#wpautop_cntl').val(<?php 
        echo json_encode($this->requestParams['postedWpautop']);
        ?>
);
                jQuery('#stripbr_cntl').val(<?php 
        echo json_encode($this->requestParams['postedStripbr']);
        ?>
);
                jQuery('#content_cntl').val(<?php 
        echo json_encode($this->requestParams['postedContent']);
        ?>
);
                jQuery('#before_cntl').val(<?php 
        echo json_encode($this->requestParams['postedContentBefore']);
        ?>
);
                jQuery('#after_cntl').val(<?php 
        echo json_encode($this->requestParams['postedContentAfter']);
        ?>
);
                jQuery('#enc_cntl').val(<?php 
        echo json_encode($this->requestParams['postedEnc']);
        ?>
);
                jQuery('#urlonly_cntl').val(<?php 
        echo json_encode($this->requestParams['postedUrlonly']);
        ?>
);
                jQuery('#linktext_cntl').val(<?php 
        echo json_encode($this->requestParams['postedLinktext']);
        ?>
);

                showValidateSubmitTimeHelp(false);
                showHideOptionDivs();
                createShortCodeAndExportLink();
            }

            jQuery.ajaxSetup({
                cache: false
            });

            jQuery(document).ready(function () {
                reset();
                showHideOptionDivs();
                createShortCodeAndExportLink();
                jQuery('#shortcode_ctrl').change(showHideOptionDivs);
                jQuery('#shortcode_ctrl').change(createShortCodeAndExportLink);
                jQuery('select[id$="cntl"]').change(createShortCodeAndExportLink);
                jQuery('input[id$="cntl"]').keyup(createShortCodeAndExportLink);
                jQuery('textarea[id$="cntl"]').keyup(createShortCodeAndExportLink);
                jQuery('#form_name_cntl').change(getFormFields);
                jQuery('#btn_show').click(addFieldToShow);
                jQuery('#btn_hide').click(addFieldToHide);
                jQuery('#btn_orderby').click(function () {
                    addFieldToOrderBy('orderby');
                });
                jQuery('#btn_torderby').click(function () {
                    addFieldToOrderBy('torderby');
                });
                jQuery('#btn_filter').click(function () {
                    addFieldToFilter('filter');
                });
                jQuery('#btn_tfilter').click(function () {
                    addFieldToFilter('tfilter');
                });
                jQuery('#btn_trans').click(addToTrans);
                jQuery('#header_cntl').click(createShortCodeAndExportLink);
                jQuery('#unbuffered_cntl').click(createShortCodeAndExportLink);
                jQuery('#edit_mode_cntl').click(createShortCodeAndExportLink);
                jQuery('#btn_headers').click(addFieldToHeaders);
                jQuery('#btn_content').click(function () {
                    addFieldToContent();
                    createShortCodeAndExportLink();
                });
                jQuery('#btn_editcolumns').click(function () {
                    addFieldToOrderBy('editcolumns');
                });

                var showHideExportLinkDelimiter = function () {
                    var enc = jQuery('#enc_cntl').val();
                    if (['CSVUTF8BOM', 'CSVUTF8', 'CSVSJIS'].indexOf(enc) > -1) {
                        jQuery('#export_link_csvdelim_span').show();
                    }
                    else {
                        jQuery('#export_link_csvdelim_span').hide();
                    }
                };
                jQuery('#enc_cntl').change(function () {
                    showHideExportLinkDelimiter();
                    createShortCodeAndExportLink();
                });
                showHideExportLinkDelimiter();
                jQuery('#urlonly_cntl').click(createShortCodeAndExportLink);
                jQuery('#reset_button').click(reset);
                jQuery('#btn_validate_submit_time').click(validateSubmitTime);
                jQuery('#add_filter').change(function () {
                    showValidateSubmitTimeHelp(jQuery('#add_filter').val() == "submit_time");
                });
                jQuery('#export_cntl').change(function () {
                    showHideOptionDivs();
                    createShortCodeAndExportLink();
                });
                jQuery('#add_itemtitle').change(createShortCodeAndExportLink);
                jQuery('#csv_delim').keyup(createShortCodeAndExportLink);
                jQuery('#export_link_csv_delim').keyup(createShortCodeAndExportLink);
                jQuery('#gld_user').change(createShortCodeAndExportLink);
                jQuery('#gld_user').keyup(createShortCodeAndExportLink);
                jQuery('#gld_pass').change(createShortCodeAndExportLink);
                jQuery('#gld_pass').keyup(createShortCodeAndExportLink);
                jQuery('#obfuscate_cntl').click(createShortCodeAndExportLink);
                jQuery('#form_name_cntl').change(createShortCodeAndExportLink);
            });


        </script>

        <?php 
    }
Exemplo n.º 2
0
    /**
     * @param CF7DBPlugin $plugin
     * @return void
     */
    public function setup($plugin)
    {
        ?>
    <div id="AddColumnDialog" style="display:none; background-color:#EEEEEE;">
        <input id="addColumnName" type="text" size="25" value=""/><br/>
        <input type="button" value="<?php 
        _e('Cancel', 'contact-form-7-to-database-extension');
        ?>
"
               onclick="jQuery('#AddColumnDialog').dialog('close');"/>
        <input id="addColumnOkButton" type="button" value=""
               onclick="addColumn();"/>
    </div>
    <div id="DeleteColumnDialog" style="display:none; background-color:#EEEEEE;">
        <select id="deleteColumnSelect"></select><br/>
        <input type="button" value="<?php 
        _e('Cancel', 'contact-form-7-to-database-extension');
        ?>
"
               onclick="jQuery('#DeleteColumnDialog').dialog('close');"/>
        <input id="deleteColumnOkButton" type="button" value=""
               onclick="deleteColumn();"/>
    </div>
    <script type="text/javascript" language="Javascript">
        jQuery('#edit_controls').html(
                '<input id="edit_cb" type="checkbox" onclick="oTable.fnDraw();"/>&nbsp;<label for="edit_cb">' +
                        jQuery('#edit_controls > a').text() + '</label>' +
                        '&nbsp;&nbsp;' +
                        '<input id="addColumnButton" type="button" value="">' +
                        '&nbsp;&nbsp;' +
                        '<input id="deleteColumnButton" type="button" value="">'
        );
        jQuery('#addColumnOkButton').val(addColumnLabelText);
        jQuery('#addColumnButton').val(addColumnLabelText).click(
                function() {
                    jQuery("#AddColumnDialog").dialog({ autoOpen: false, title: addColumnLabelText });
                    jQuery("#AddColumnDialog").dialog('open');
                    jQuery("#addColumnName").focus();
                });

        jQuery('#deleteColumnOkButton').val(deleteColumnLabelText);
        jQuery('#deleteColumnButton').val(deleteColumnLabelText).click(
                function() {
                    jQuery("#DeleteColumnDialog").dialog({ autoOpen: false, title: deleteColumnLabelText });
                    jQuery("#DeleteColumnDialog").dialog('open');
                    var url = '<?php 
        echo $plugin->getFormFieldsAjaxUrlBase();
        ?>
' + encodeURIComponent('<?php 
        echo $_REQUEST['form_name'];
        ?>
');
                    jQuery.getJSON(url, function(json) {
                        var optionsHtml = '';
                        jQuery(json).each(function() {
                            if (this != 'Submitted' && this != 'submit_time') { // can't delete submit_time
                                optionsHtml += '<option value="' + this + '">' + this + '</option>';
                            }
                        });
                        jQuery('#deleteColumnSelect').html(optionsHtml).focus();
                    });
                } );

        function addColumn() {
            jQuery('#addColumnOkButton').attr('disabled', 'disabled');
            var formName = '<?php 
        echo $_REQUEST['form_name'];
        ?>
';
            var colName = jQuery('#addColumnName').val();
            jQuery.ajax({
                cache: false,
                type: 'POST',
                url: '<?php 
        echo admin_url('admin-ajax.php') . '?action=cfdb-addColumn';
        ?>
',
                data: { form_name : formName, column_name : colName},
                success: function(data, textStatus, jqXHR) {
                    jQuery('#AddColumnDialog').dialog('close');
                    location.reload();
                },
                error: function(jqXHR, textStatus, errorThrown) {
                    alert('Error ' + textStatus + ': ' + textStatus);
                    jQuery('#addColumnOkButton').removeAttr('disabled');
                }
            });
        }
        function deleteColumn() {
            jQuery('#deleteColumnOkButton').attr('disabled', 'disabled');
            var formName = '<?php 
        echo $_REQUEST['form_name'];
        ?>
';
            var colName = jQuery('#deleteColumnSelect').val();
            jQuery.ajax({
                cache: false,
                type: 'POST',
                url: '<?php 
        echo admin_url('admin-ajax.php') . '?action=cfdb-deleteColumn';
        ?>
',
                data: { form_name : formName, column_name : colName},
                success: function(data, textStatus, jqXHR) {
                    jQuery('#DeleteColumnDialog').dialog('close');
                    location.reload();
                },
                error: function(jqXHR, textStatus, errorThrown) {
                    alert('Error ' + textStatus + ': ' + textStatus);
                    jQuery('#deleteColumnOkButton').removeAttr('disabled')
                }
            });
        }
    </script>

    <?php 
    }