src/Server/js/caliban.js
/*
             * Add session data as hidden inputs to FORM elements, except those set to be ignored.
             * This can be called repeatedly on the same form as session data may change or a form may be rendered after initial DOM load.
             */
Add session data as hidden inputs to FORM elements, except those set to be ignored.
This can be called repeatedly on the same form as session data may change or a form may be rendered after initial DOM load.
Add session data as hidden inputs to FORM elements except those set to be ignored . This can be called repeatedly on the same form as session data may change or a form may be rendered after initial DOM load .
function addFormData(trackerInstance) {
                var i,
                    ignorePattern = getClassesRegExp(configIgnoreClasses, 'ignore'),
                    formElements = documentAlias.forms,
                    formElement = null,
                    formMethod = null,
                    trackerType = null;
                configDebug && console.log('[CALIBAN_DEBUG] Forms found:', formElements ? query.htmlCollectionToArray(formElements) : null);
                if (formElements) {
                    for (i = 0; i < formElements.length; i++) {
                        formElement = formElements[i];
                        configDebug &&
                            console.log('[CALIBAN_DEBUG] Checking eligibility of form `' + (formElement.id || formElement.name) + '`');
                        formMethod = query.getAttributeValueFromNode(formElement, 'method') || '';
                        if (!ignorePattern.test(formElement.className) && formMethod.toUpperCase() === 'POST') {
                            trackerType = typeof formElement.calibanTrackers;
                            configDebug &&
                                console.log('[CALIBAN_DEBUG] Append session data to form `' + (formElement.id || formElement.name) + '`');
                            if ('undefined' === trackerType) {
                                formElement.calibanTrackers = [];
                            }
                            formElement.calibanTrackers.push(trackerInstance);
                            addFormParams(formElement);
                        } else {
                            configDebug && console.log('[CALIBAN_DEBUG] Ignoring form `' + (formElement.id || formElement.name) + '`');
                        }
                    }
                }
            }
function addFormData ( trackerInstance ) { var i , ignorePattern = getClassesRegExp ( configIgnoreClasses , 'ignore' ) , formElements = documentAlias . forms , formElement = null , formMethod = null , trackerType = null ; configDebug && console . log ( '[CALIBAN_DEBUG] Forms found:' , formElements ? query . htmlCollectionToArray ( formElements ) : null ) ; if ( formElements ) { for ( i = 0 ; i < formElements . length ; i ++ ) { formElement = formElements [ i ] ; configDebug && console . log ( '[CALIBAN_DEBUG] Checking eligibility of form `' + ( formElement . id || formElement . name ) + '`' ) ; formMethod = query . getAttributeValueFromNode ( formElement , 'method' ) || '' ; if ( ! ignorePattern . test ( formElement . className ) && formMethod . toUpperCase ( ) === 'POST' ) { trackerType = typeof formElement . calibanTrackers ; configDebug && console . log ( '[CALIBAN_DEBUG] Append session data to form `' + ( formElement . id || formElement . name ) + '`' ) ; if ( 'undefined' === trackerType ) { formElement . calibanTrackers = [ ] ; } formElement . calibanTrackers . push ( trackerInstance ) ; addFormParams ( formElement ) ; } else { configDebug && console . log ( '[CALIBAN_DEBUG] Ignoring form `' + ( formElement . id || formElement . name ) + '`' ) ; } } } }
Add session data as hidden inputs to FORM elements, except those set to be ignored.
Add session data as hidden inputs to FORM elements except those set to be ignored .
// iterate through FORM elements // Add tracker to FORM for accessing API off element later // Appened form params as hidden elements