| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- /*¸ßÁÁÎı¾±ê×¢*/
- function Fill(data) {
- var highlightArr = [];
- clearHighlight();
- $.each(data, function (i, item) {
- if (typeof (item.HightCode) != 'undefined' && item.HightCode != null && item.HightCode != "") {
- var highlightItem = $('span[id=' + item.HightCode + ']').eq(0);
- if (highlightItem.length > 0) {
- var hitCode = highlightItem.attr('hitCode');
- if (hitCode) {
- highlightItem.attr('hitCode', hitCode + "|" + item.SourceCode);
- }
- else {
- highlightItem.attr('hitCode', item.SourceCode);
- }
- highlightArr.push(highlightItem);
- }
- }
- else if (typeof (item.SourceCode) == 'undefined' || item.SourceCode == null || item.SourceCode != "") {
- var highlightItem = $('span[kcode*=' + item.SourceCode + ']:first');
- if (highlightItem.length > 0) {
- var hitCode = highlightItem.attr('hitCode');
- if (hitCode) {
- highlightItem.attr('hitCode', hitCode + "|" + item.SourceCode);
- }
- else {
- highlightItem.attr('hitCode', item.SourceCode);
- }
- highlightArr.push(highlightItem);
- }
- }
- $.each(highlightArr, function (i, item) {
- if (item.attr('flag') == 'word') {
- bindEvent(item.attr('iskeyklg', 'true').addClass('wordStyle'), true);
- }
- else if (item.attr('flag') == 'phrase') {
- if (item != null && item.attr('separate') != null) {
- $("span[separate=" + item.attr('separate') + "]").attr('iskeyklg', 'true').addClass('phraseStyle');
- bindEvent(item, true);
- }
- else {
- bindEvent(item.attr('iskeyklg', 'true').addClass('phraseStyle'), true);
- if ($(item).parent().attr('iskeyklg') == 'true' && $(item).parent().attr('flag') == 'phrase') $(item).addClass('border1')
- }
- }
- else if (item.attr('flag') == 'sentence') {
- if (item.attr('iskeyklg') == 'true') return;
- bindEvent(item.attr('iskeyklg', 'true').addClass('sentenceStyle')
- .before('<img src="file:///android_asset/js/sentenceIco.png" class="sentImagcs">'), true);
- }
- });
- });
- }
- function clearHighlight() {
- $('span.klg-selected').removeClass('klg-selected');
- $('span[iskeyklg="true"]').each(function (i, item) {
- $(item).removeAttr('hitCode');
- $(item).attr('iskeyklg', 'false');
- if ($(item).attr('flag') == 'word') {
- $(item).removeClass('wordStyle').unbind();
- }
- else if ($(item).attr('flag') == 'phrase') {
- $(item).removeClass().unbind();
- }
- else if ($(item).attr('flag') == 'sentence') {
- $(item).removeClass('sentenceStyle').unbind();
- $(item).prev().filter('img.sentImagcs').remove();
- }
- })
- }
- function bindEvent(ele, opt) {
- if (opt) {
- var className = '';
- if (ele.hasClass('phraseStyle'))
- className = 'phraseStyle';
- else if (ele.hasClass('wordStyle'))
- className = 'wordStyle';
- else if (ele.hasClass('sentenceStyle'))
- className = 'sentenceStyle';
- switch (className) {
- case 'phraseStyle':
- if (ele.attr('separate') != null) {
- $("span[separate=" + ele.attr('separate') + "]").unbind().bind({
- 'click': function (e) {
- e.stopPropagation();
- //plugin.call(code);
- //alert($(this).attr("hitCode"));
- var sHCode = $(this).attr("shcode");
- if (sHCode != 1) {
- test($(this).attr("hitCode"));
- }
- }
- });
- }
- case 'wordStyle':
- ele.unbind().bind({
- 'click': function (e) {
- e.stopPropagation();
- //plugin.call(code);
- //alert($(this).attr("hitCode"));
- var sHCode = $(this).attr("shcode");
- if (sHCode != 1) {
- test($(this).attr("hitCode"));
- }
- }
- });
- break;
- case 'sentenceStyle':
- ele.unbind().bind({
- 'click': function (e) {
- e.stopPropagation();
- //plugin.call(code);
- //alert($(this).attr("hitCode"));
- var sHCode = $(this).attr("shcode");
- if (sHCode != 1) {
- test($(this).attr("hitCode"));
- }
- }
- }).prev().filter('.sentImagcs').unbind().bind({
- 'click': function (e) {
- e.stopPropagation();
- //plugin.call(code);
- //alert($(this).attr("hitCode"));
- var sHCode = $(this).attr("shcode");
- if (sHCode != 1) {
- test($(this).next().attr("hitCode"));
- }
- }
- });
- break;
- }
- }
- else {
- ele.unbind();
- }
- }
- function test(code) {
- //alert(code);
- cancelBubble();
- plugin.call(code);
- }
|