1/** 2 * ç½å®³æ å ±é ä¿¡ã·ã¹ãã 飿ºã®jQueryãã©ã°ã¤ã³ã 3 * ã»HTMLã«ç½å®³æ å ±ãåãè¾¼ã 4 * 5 * @version 01-00 6 * @since 01-00 7 * 8 */ 9(function($) { 10 11 /** 12 * PCãã¼ã¸ç¨ã®ç½å®³æ å ±ãåãè¾¼ã 13 */ 14 $.fn.webalertEmbedPc = function(options, parentObj) { 15 var defaults = { 16 // ãã¼ã¿ã®è¡¨ç¤ºé åã®ID 17 dataEmbedId : 'webalert_info_list', 18 // ãã¼ã¿ã®URL 19 jsonDataUrl : '/webalert/data.json', 20 // ãã¼ã0ä»¶ã®å ´åãé åã表示ãããã©ãã 21 isDisplayNoData : true, 22 // ãã¼ã¿èªã¿è¾¼ã¿æã«å¤±æããã¨ãã«ã表示ãããã©ããã 23 isDisplayFailLoadData : false, 24 // ãã¼ã¿ã®è¡¨ç¤ºä»¶æ° 25 maxCount : 5, 26 // ãã¼ã¿ã0ä»¶ã®ã¨ãã®ã¡ãã»ã¼ã¸ 27 noDataMessage : 'ç¾å¨ç·æ¥æ å ±ã¯ããã¾ããã', 28 // ä¸è¦§ãã¼ã¸ã®ãªã³ã¯ã®ID 29 listLinkId : 'webalert_list_link', 30 // ä¸è¦§ãã¼ã¸ã®URL 31 listLinkUrl : '/webalert/list_pc.html' 32 } 33 34 var config = $.extend(defaults, options); 35 36 var myObj = this; 37 if(parentObj != undefined && parentObj != null) { 38 // ã¹ãã¼ããã©ã³ã®å ´åã¯ãPCç¨ãå¼ã³åºãã¦ããã®ã§ããªãã¸ã§ã¯ãããã¨ãªãã 39 myObj = parentObj; 40 } 41 42 $.ajax({ 43 type : 'GET', 44 url : config.jsonDataUrl, 45 dataType : "json", 46 cache : false, 47 success : function(data) { 48 // åãè¾¼ã¿å ã®DOMã®IDã§è¨å®ããã 49 var divObj_embed = $(myObj).find("#" + config.dataEmbedId); 50 if(divObj_embed == undefined || divObj_embed == null) { 51 console.log('not found data embeded DOM id = ' + config.dataEmbedId); 52 return; 53 } 54 55 // ä¸è¦§ãã¼ã¸ã¸ã®ãªã³ã¯è¨å® 56 var listLinkObj = $(myObj).find('#' + config.listLinkId); 57 if(listLinkObj != undefined && listLinkObj != null) { 58 $(listLinkObj).attr('href', config.listLinkUrl); 59 } 60 61 // ç½å®³æ å ±ãã¼ã¿ã®ãã¼ã¿ã®ä»¶æ° 62 var dataLength = data.length; 63 64 // ç½å®³æ å ±ã0ä»¶ã®å ´å 65 if (dataLength == 0) { 66 if (config.isDisplayNoData) { 67 //0ä»¶ã®å ´åã®ã¡ãã»ã¼ã¸ãåãè¾¼ã 68 var errorObj = $('<p>').addClass('webalert_warn').text(config.noDataMessage); 69 $(divObj_embed).append(errorObj); 70 71 } else { 72 //表示é åå ¨ä½ã®DOMèªä½ãé表示ã«ããã 73 $(myObj).hide(); 74 } 75 return; 76 } 77 78 // 表示ããä»¶æ°ã®æ±ºå® 79 var count = (dataLength < config.maxCount) ? dataLength : config.maxCount; 80 if(config.maxCount <= 0) { 81 count = dataLength; 82 } 83 84 //ç½å®³æ å ±ãä¸ä»¶ãã¤ã§åãè¾¼ã 85 for (var i = 0; i < count; i++) { 86 var itemInfo = $('<p>').addClass('webalert_info_item').html(data[i].html_content); 87 $(divObj_embed).append(itemInfo); 88 89 } 90 91 }, 92 93 error : function(xhr, status, error) { 94 // xhr.status : 404 95 // xhr.statusText : Not Found 96 // status = error 97 // error.message : ... 98 99 if(!config.isDisplayFailLoadData) { 100 // ãã¼ã¿èªã¿è¾¼ã¿æã«è¡¨ç¤ºããªãå ´å 101 $(myObj).hide(); 102 return; 103 } 104 105 //åãè¾¼ã¿å ã®DOMã®IDã§è¨å®ããã 106 var divObj_embed = $("#" + config.dataEmbedId); 107 var errorObj = $('<p>').addClass('webalert_error'); 108 109 if(xhr.status == 404) { 110 $(errorObj).text('ç½å®³æ å ±ãã¼ã¿ãã¡ã¤ã«ãè¦ã¤ããã¾ããã'); 111 } else { 112 $(errorObj).text('ç½å®³æ å ±ãã¼ã¿ãã¡ã¤ã«ã®èªã¿è¾¼ã¿ã«å¤±æãã¾ããã'); 113 } 114 $(divObj_embed).append(errorObj); 115 116 // ä¸è¦§ãã¼ã¸ã¸ã®ãªã³ã¯è¨å® 117 var listLinkObj = $(myObj).find('#' + config.listLinkId); 118 if(listLinkObj != null) { 119 $(listLinkObj).attr('href', config.listLinkUrl); 120 121 } 122 123 return; 124 } 125 }); 126 } 127 128 /** 129 * ã¹ãã¼ããã©ã³ç¨ã«ç½å®³æ å ±ãåãè¾¼ãã 130 */ 131 $.fn.webalertEmbedSmph = function(options) { 132 133 var defaults = { 134 // ä¸è¦§ãã¼ã¸ã®URL 135 listLinkUrl : '/webalert/list_smph.html' 136 } 137 var config = $.extend(defaults, options); 138 return $.fn.webalertEmbedPc(config, this); 139 140 } 141}(jQuery));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.