/** * JS for UI of iG:Syntax Hiliter plugin * * @author: Amit Gupta * @since: 2012-12-30 * @version: 2013-01-28 */ jQuery(document).ready(function($){ var html_sources = []; var text_sources = []; var link_text_plain = ig_syntax_hiliter.label.plain; var link_text_html = ig_syntax_hiliter.label.html; function format_text_code( text ) { var arr_html = []; var lines = text.split(/\n/); if( $.trim(lines[0]) == '' ) { lines.splice( 0, 1 ); } if( $.trim(lines[ (lines.length - 1) ]) == '' ) { lines.splice( (lines.length - 1), 1 ); } for( var i = 0; i < lines.length; i++ ) { arr_html.push( lines[i] ); } return arr_html.join("
"); } $('.syntax_hilite .toolbar .view-different').on( 'click', function(){ var grandpa_id = $(this).parent().parent().attr('id'); if( grandpa_id.indexOf('-') == -1 || grandpa_id.indexOf('-') == ( grandpa_id.length - 1 ) ) { return false; } var tmp = grandpa_id.split('-'); grandpa_id_num = tmp[ (tmp.length - 1) ]; tmp = null; if( ! html_sources[grandpa_id_num] ) { //store HTML source html_sources[grandpa_id_num] = $('#' + grandpa_id + ' div.code').html(); } if( ! text_sources[grandpa_id_num] ) { //store text source text_sources[grandpa_id_num] = $('#' + grandpa_id + ' div.code').text(); text_sources[grandpa_id_num] = iGeek.replace_all( '