Index: branches/MwEmbedStandAlone/remotes/mediaWiki.js |
— | — | @@ -670,6 +670,32 @@ |
671 | 671 | } |
672 | 672 | |
673 | 673 | /** |
| 674 | + * Similar to php isset function checks if the variable exists. Does a safe |
| 675 | + * check of a descendant method or variable |
| 676 | + * |
| 677 | + * @param {String} |
| 678 | + * objectPath |
| 679 | + * @return {Boolean} true if objectPath exists false if objectPath is |
| 680 | + * undefined |
| 681 | + */ |
| 682 | +mwIsset = function( objectPath ) { |
| 683 | + if ( !objectPath || typeof objectPath != 'string') { |
| 684 | + return false; |
| 685 | + } |
| 686 | + var pathSet = objectPath.split( '.' ); |
| 687 | + var cur_path = ''; |
| 688 | + |
| 689 | + for ( var p = 0; p < pathSet.length; p++ ) { |
| 690 | + cur_path = ( cur_path == '' ) ? cur_path + pathSet[p] : cur_path + '.' + pathSet[p]; |
| 691 | + eval( 'var ptest = typeof ( ' + cur_path + ' ); ' ); |
| 692 | + if ( ptest == 'undefined' ) { |
| 693 | + return false; |
| 694 | + } |
| 695 | + } |
| 696 | + return true; |
| 697 | +}; |
| 698 | + |
| 699 | +/** |
674 | 700 | * Load the mwEmbed library: |
675 | 701 | * |
676 | 702 | * @param {mixed} function or classSet to preload |
— | — | @@ -769,32 +795,7 @@ |
770 | 796 | waitForJqueryUi(); |
771 | 797 | } |
772 | 798 | |
773 | | -/** |
774 | | - * Similar to php isset function checks if the variable exists. Does a safe |
775 | | - * check of a descendant method or variable |
776 | | - * |
777 | | - * @param {String} |
778 | | - * objectPath |
779 | | - * @return {Boolean} true if objectPath exists false if objectPath is |
780 | | - * undefined |
781 | | - */ |
782 | | -mwIsset = function( objectPath ) { |
783 | | - if ( !objectPath || typeof objectPath != 'string') { |
784 | | - return false; |
785 | | - } |
786 | | - var pathSet = objectPath.split( '.' ); |
787 | | - var cur_path = ''; |
788 | 799 | |
789 | | - for ( var p = 0; p < pathSet.length; p++ ) { |
790 | | - cur_path = ( cur_path == '' ) ? cur_path + pathSet[p] : cur_path + '.' + pathSet[p]; |
791 | | - eval( 'var ptest = typeof ( ' + cur_path + ' ); ' ); |
792 | | - if ( ptest == 'undefined' ) { |
793 | | - return false; |
794 | | - } |
795 | | - } |
796 | | - return true; |
797 | | -}; |
798 | | - |
799 | 800 | /** |
800 | 801 | * Check if the gadget is installed |
801 | 802 | * run after mwEmbed setup so $j and mw interface is available: |