Changeset 2817

Show
Ignore:
Timestamp:
11/15/08 04:13:45 (8 weeks ago)
Author:
freakerz
Message:

Moving the DB credential checks to their schema js files.

Location:
branches/081018-handlers/htdocs/system
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • branches/081018-handlers/htdocs/system/schema/mysql/install/install.js

    r2815 r2817  
    11habari.installer.registerSchema('mysql'); 
    22habari.installer.mysql = { 
     3    checkDBCredentials: function() { 
     4        if ( ( $('#db_type').val() == 'mysql' ) && ( $('#mysqldatabasehost').val() != '' ) && ( $('#mysqldatabaseuser').val() != '' ) && ( $('#mysqldatabasename').val() != '' ) ) { 
     5            $.ajax({ 
     6                type: 'POST', 
     7                url: 'ajax/check_mysql_credentials', 
     8                data: { // Ask InstallHandler::ajax_check_mysql_credentials to check the credentials 
     9                    ajax_action: 'check_mysql_credentials', 
     10                    host: $('#mysqldatabasehost').val(), 
     11                    database: $('#mysqldatabasename').val(), 
     12                    user: $('#mysqldatabaseuser').val(), 
     13                    pass: $('#mysqldatabasepass').val() 
     14                }, 
     15                success: function(xml) { 
     16                    $('#installerror').fadeOut(); 
     17                    switch($('status',xml).text()) { 
     18                    case '0': // Show warning, fade the borders and hide the next step 
     19                        $('id',xml).each(function(id) { 
     20                        ido= $('id',xml).get(id); 
     21                        warningtext= $('message',xml).text(); 
     22                        $('#siteconfiguration').children('.options').fadeOut().removeClass('ready').removeClass('done'); 
     23                        $('#install').children('.options').fadeOut().removeClass('ready').removeClass('done'); 
     24                        $($(ido).text()).parents('.installstep').removeClass('done'); 
     25                        $($(ido).text()).parents('.inputfield').removeClass('invalid').removeClass('valid').addClass('invalid').find('.warning').html(warningtext).fadeIn(); 
     26                        }); 
     27                        break; 
     28                    case '1': // Hide the warnings, highlight the borders and show the next step 
     29                        ida= new Array( '#mysqldatabasename', '#mysqldatabasehost', '#mysqldatabasepass', '#mysqldatabaseuser' ); 
     30                        $(ida).each(function(id) { 
     31                            ido= $(ida).get(id); 
     32                            $(ido).parents('.inputfield').removeClass('invalid').addClass('valid').find('.warning:visible').fadeOut(); 
     33                            $(ido).parents('.installstep').addClass('done') 
     34                        }); 
     35                        $('#siteconfiguration').children('.options').fadeIn().addClass('ready'); 
     36                        $('#sitename').focus() 
     37                        break; 
     38                    } 
     39                }, 
     40                error: handleAjaxError 
     41            }); 
     42        } 
     43    } 
    344}; 
  • branches/081018-handlers/htdocs/system/schema/pgsql/install/install.js

    r2815 r2817  
    11habari.installer.registerSchema('pgsql'); 
    22habari.installer.pgsql = { 
     3    checkDBCredentials: function() { 
     4        if ( ( $('#db_type').val() == 'pgsql' ) && ( $('#pgsqldatabasehost').val() != '' ) && ( $('#pgsqldatabaseuser').val() != '' ) && ( $('#pgsqldatabasename').val() != '' ) ) { 
     5            $.ajax({ 
     6                type: 'POST', 
     7                url: 'ajax/check_pgsql_credentials', 
     8                data: { // Ask InstallHandler::ajax_check_pgsql_credentials to check the credentials 
     9                    ajax_action: 'check_pgsql_credentials', 
     10                    host: $('#pgsqldatabasehost').val(), 
     11                    database: $('#pgsqldatabasename').val(), 
     12                    user: $('#pgsqldatabaseuser').val(), 
     13                    pass: $('#pgsqldatabasepass').val() 
     14                }, 
     15                success: function(xml) { 
     16                    $('#installerror').fadeOut(); 
     17                    switch($('status',xml).text()) { 
     18                    case '0': // Show warning, fade the borders and hide the next step 
     19                        $('id',xml).each(function(id) { 
     20                        ido= $('id',xml).get(id); 
     21                        warningtext= $('message',xml).text(); 
     22                        $('#siteconfiguration').children('.options').fadeOut().removeClass('ready').removeClass('done'); 
     23                        $('#install').children('.options').fadeOut().removeClass('ready').removeClass('done'); 
     24                        $($(ido).text()).parents('.installstep').removeClass('done'); 
     25                        $($(ido).text()).parents('.inputfield').removeClass('invalid').removeClass('valid').addClass('invalid').find('.warning').html(warningtext).fadeIn(); 
     26                        }); 
     27                        break; 
     28                    case '1': // Hide the warnings, highlight the borders and show the next step 
     29                        ida= new Array( '#pgsqldatabasename', '#pgsqldatabasehost', '#pgsqldatabasepass', '#pgsqldatabaseuser' ); 
     30                        $(ida).each(function(id) { 
     31                            ido= $(ida).get(id); 
     32                            $(ido).parents('.inputfield').removeClass('invalid').addClass('valid').find('.warning:visible').fadeOut(); 
     33                            $(ido).parents('.installstep').addClass('done') 
     34                        }); 
     35                        $('#siteconfiguration').children('.options').fadeIn().addClass('ready'); 
     36                        $('#sitename').focus() 
     37                        break; 
     38                    } 
     39                }, 
     40                error: handleAjaxError 
     41            }); 
     42        } 
     43    } 
    344}; 
  • branches/081018-handlers/htdocs/system/schema/sqlite/install/install.js

    r2815 r2817  
    11habari.installer.registerSchema('sqlite'); 
    22habari.installer.sqlite = { 
     3    checkDBCredentials: function() { 
     4        if ( ( $('#db_type').val() == 'sqlite' ) && ( $('#databasefile').val() != '' ) ) { 
     5            $.ajax({ 
     6                type: 'POST', 
     7                url: 'ajax/check_sqlite_credentials', 
     8                data: { // Ask InstallHandler::ajax_check_sqlite_credentials to check the credentials 
     9                    ajax_action: 'check_sqlite_credentials', 
     10                    file: $('#databasefile').val() 
     11                }, 
     12                success: function(xml) { 
     13                    $('#installerror').fadeOut(); 
     14                    switch($('status',xml).text()) { 
     15                    case '0': // Show warning, fade the borders and hide the next step 
     16                        $('id',xml).each(function(id) { 
     17                        ido= $('id',xml).get(id); 
     18                        warningtext= $('message',xml).text(); 
     19                        $('#siteconfiguration').children('.options').fadeOut().removeClass('ready').removeClass('done'); 
     20                        $('#install').children('.options').fadeOut().removeClass('ready').removeClass('done'); 
     21                        $($(ido).text()).parents('.installstep').removeClass('done'); 
     22                        $($(ido).text()).parents('.inputfield').removeClass('invalid').removeClass('valid').addClass('invalid').find('.warning').html(warningtext).fadeIn(); 
     23                        }); 
     24                        break; 
     25                    case '1': // Hide the warnings, highlight the borders and show the next step 
     26                        ida= new Array( '#databasefile' ); 
     27                        $(ida).each(function(id) { 
     28                        ido= $(ida).get(id); 
     29                            $(ido).parents('.inputfield').removeClass('invalid').addClass('valid').find('.warning:visible').fadeOut(); 
     30                            $(ido).parents('.installstep').addClass('done') 
     31                        }); 
     32                        $('#siteconfiguration').children('.options').fadeIn().addClass('ready'); 
     33                        break; 
     34                    } 
     35                }, 
     36                error: handleAjaxError 
     37            }); 
     38        } 
     39    } 
    340}; 
  • branches/081018-handlers/htdocs/system/themes/installer/script.js

    r2815 r2817  
    2020    }, 
    2121     
    22     checkDBCredentials: {}, 
     22    checkDBCredentials: function() { 
     23        var toCall = 'habari.installer.' + $('#db_type').val() + '.checkDBCredentials()'; 
     24        if (eval(toCall)) { 
     25            $('.installstep:first').removeClass('done'); 
     26            $('#siteconfiguration').children('.options').fadeOut().removeClass('ready').removeClass('done'); 
     27            $('#install').children('.options').fadeOut().removeClass('ready').removeClass('done'); 
     28        } 
     29    }, 
    2330     
    2431    checkSiteConfiguration: function () { 
     
    7683        '<p>'+error_msg.replace(/(<([^>]+)>)/ig,"")+'</p>' 
    7784    ).fadeIn(); 
    78 } 
    79  
    80 function checkDBCredentials() 
    81 { 
    82     if ( ( $('#db_type').val() == 'mysql' ) && ( $('#mysqldatabasehost').val() != '' ) && ( $('#mysqldatabaseuser').val() != '' ) && ( $('#mysqldatabasename').val() != '' ) ) { 
    83         $.ajax({ 
    84             type: 'POST', 
    85             url: 'ajax/check_mysql_credentials', 
    86             data: { // Ask InstallHandler::ajax_check_mysql_credentials to check the credentials 
    87                 ajax_action: 'check_mysql_credentials', 
    88                 host: $('#mysqldatabasehost').val(), 
    89                 database: $('#mysqldatabasename').val(), 
    90                 user: $('#mysqldatabaseuser').val(), 
    91                 pass: $('#mysqldatabasepass').val() 
    92             }, 
    93             success: function(xml) { 
    94                 $('#installerror').fadeOut(); 
    95                 switch($('status',xml).text()) { 
    96                 case '0': // Show warning, fade the borders and hide the next step 
    97                     $('id',xml).each(function(id) { 
    98                     ido= $('id',xml).get(id); 
    99                     warningtext= $('message',xml).text(); 
    100                     $('#siteconfiguration').children('.options').fadeOut().removeClass('ready').removeClass('done'); 
    101                     $('#install').children('.options').fadeOut().removeClass('ready').removeClass('done'); 
    102                     $($(ido).text()).parents('.installstep').removeClass('done'); 
    103                     $($(ido).text()).parents('.inputfield').removeClass('invalid').removeClass('valid').addClass('invalid').find('.warning').html(warningtext).fadeIn(); 
    104                     }); 
    105                     break; 
    106                 case '1': // Hide the warnings, highlight the borders and show the next step 
    107                     ida= new Array( '#mysqldatabasename', '#mysqldatabasehost', '#mysqldatabasepass', '#mysqldatabaseuser' ); 
    108                     $(ida).each(function(id) { 
    109                         ido= $(ida).get(id); 
    110                         $(ido).parents('.inputfield').removeClass('invalid').addClass('valid').find('.warning:visible').fadeOut(); 
    111                         $(ido).parents('.installstep').addClass('done') 
    112                     }); 
    113                     $('#siteconfiguration').children('.options').fadeIn().addClass('ready'); 
    114                     $('#sitename').focus() 
    115                     break; 
    116                 } 
    117             }, 
    118             error: handleAjaxError 
    119         }); 
    120     } 
    121     else if ( ( $('#db_type').val() == 'pgsql' ) && ( $('#pgsqldatabasehost').val() != '' ) && ( $('#pgsqldatabaseuser').val() != '' ) && ( $('#pgsqldatabasename').val() != '' ) ) { 
    122         $.ajax({ 
    123             type: 'POST', 
    124             url: 'ajax/check_pgsql_credentials', 
    125             data: { // Ask InstallHandler::ajax_check_pgsql_credentials to check the credentials 
    126                 ajax_action: 'check_pgsql_credentials', 
    127                 host: $('#pgsqldatabasehost').val(), 
    128                 database: $('#pgsqldatabasename').val(), 
    129                 user: $('#pgsqldatabaseuser').val(), 
    130                 pass: $('#pgsqldatabasepass').val() 
    131             }, 
    132             success: function(xml) { 
    133                 $('#installerror').fadeOut(); 
    134                 switch($('status',xml).text()) { 
    135                 case '0': // Show warning, fade the borders and hide the next step 
    136                     $('id',xml).each(function(id) { 
    137                     ido= $('id',xml).get(id); 
    138                     warningtext= $('message',xml).text(); 
    139                     $('#siteconfiguration').children('.options').fadeOut().removeClass('ready').removeClass('done'); 
    140                     $('#install').children('.options').fadeOut().removeClass('ready').removeClass('done'); 
    141                     $($(ido).text()).parents('.installstep').removeClass('done'); 
    142                     $($(ido).text()).parents('.inputfield').removeClass('invalid').removeClass('valid').addClass('invalid').find('.warning').html(warningtext).fadeIn(); 
    143                     }); 
    144                     break; 
    145                 case '1': // Hide the warnings, highlight the borders and show the next step 
    146                     ida= new Array( '#pgsqldatabasename', '#pgsqldatabasehost', '#pgsqldatabasepass', '#pgsqldatabaseuser' ); 
    147                     $(ida).each(function(id) { 
    148                     ido= $(ida).get(id); 
    149                     $(ido).parents('.inputfield').removeClass('invalid').addClass('valid').find('.warning:visible').fadeOut(); 
    150                     $(ido).parents('.installstep').addClass('done') 
    151                     }); 
    152                     $('#siteconfiguration').children('.options').fadeIn().addClass('ready'); 
    153                     $('#sitename').focus() 
    154                     break; 
    155                 } 
    156             }, 
    157             error: handleAjaxError 
    158         }); 
    159     } 
    160     else if ( ( $('#db_type').val() == 'sqlite' ) && ( $('#databasefile').val() != '' ) ) { 
    161         $.ajax({ 
    162             type: 'POST', 
    163             url: 'ajax/check_sqlite_credentials', 
    164             data: { // Ask InstallHandler::ajax_check_sqlite_credentials to check the credentials 
    165                 ajax_action: 'check_sqlite_credentials', 
    166                 file: $('#databasefile').val() 
    167             }, 
    168             success: function(xml) { 
    169                 $('#installerror').fadeOut(); 
    170                 switch($('status',xml).text()) { 
    171                 case '0': // Show warning, fade the borders and hide the next step 
    172                     $('id',xml).each(function(id) { 
    173                     ido= $('id',xml).get(id); 
    174                     warningtext= $('message',xml).text(); 
    175                     $('#siteconfiguration').children('.options').fadeOut().removeClass('ready').removeClass('done'); 
    176                     $('#install').children('.options').fadeOut().removeClass('ready').removeClass('done'); 
    177                     $($(ido).text()).parents('.installstep').removeClass('done'); 
    178                     $($(ido).text()).parents('.inputfield').removeClass('invalid').removeClass('valid').addClass('invalid').find('.warning').html(warningtext).fadeIn(); 
    179                     }); 
    180                     break; 
    181                 case '1': // Hide the warnings, highlight the borders and show the next step 
    182                     ida= new Array( '#databasefile' ); 
    183                     $(ida).each(function(id) { 
    184                     ido= $(ida).get(id); 
    185                         $(ido).parents('.inputfield').removeClass('invalid').addClass('valid').find('.warning:visible').fadeOut(); 
    186                         $(ido).parents('.installstep').addClass('done') 
    187                     }); 
    188                     $('#siteconfiguration').children('.options').fadeIn().addClass('ready'); 
    189                     break; 
    190                 } 
    191             }, 
    192             error: handleAjaxError 
    193         }); 
    194     } 
    195     else { 
    196         $('.installstep:first').removeClass('done'); 
    197         $('#siteconfiguration').children('.options').fadeOut().removeClass('ready').removeClass('done'); 
    198         $('#install').children('.options').fadeOut().removeClass('ready').removeClass('done'); 
    199     } 
    200 } 
    201  
    202 function checkSiteConfigurationCredentials() { 
    203  
    20485} 
    20586 
     
    304185    itemManage.init(); 
    305186    habari.installer.setDatabaseType(); 
    306     checkDBCredentials(); 
    307     checkSiteConfigurationCredentials(); 
     187    habari.installer.checkDBCredentials(); 
     188    habari.installer.checkSiteConfiguration(); 
    308189    $('#db_type').change(function(){habari.installer.setDatabaseType()}); 
    309     $('#databasesetup input').keyup(function(){queueTimer(checkDBCredentials)}); 
    310     $('#siteconfiguration input').keyup(function(){queueTimer(checkSiteConfigurationCredentials)}); 
    311     $('#locale').focus().change(function() { 
    312         $('#locale-form').submit(); 
    313     }); 
     190    $('#databasesetup input').keyup(function(){queueTimer(habari.installer.checkDBCredentials)}); 
     191    $('#siteconfiguration input').keyup(function(){queueTimer(habari.installer.checkSiteConfiguration)}); 
     192    $('#locale').focus().change(function(){$('#locale-form').submit()}); 
    314193});