1/** 2 * rewrite Contents 3 * 4 * usage: 5<script src="js/vendor/jquery.min.js"></script> 6<script src="js/rewritecontents.js"></script> 7 8<header class="rewrite-contents" data-contents="parts.html"></header> 9 10<script> 11$(function() { 12 // å ¨ class=rewrite-contents è¦ç´ ã«å¯¾ã㦠data-contents ã§æå®ããURLã®å å®¹ãæ¿å ¥ãã 13 rewriteContents.insert(); 14}); 15</script> 16 */ 17 18var rewriteContents = {}; 19rewriteContents.vars = { 20 isLoad : function(elm) { return true; }, // èªã¿è¾¼ãå¿ è¦ããããã©ãããå¤å®å¯è½ï¼å¿ è¦ãªããªã¼ãã¼ã©ã¤ããã¦ä½¿ãï¼ 21 22 dummy : "dummy" // æå¾ã®è¦ç´ ã« , ä»ããªãã®ãé¢åãªã ã:p 23}; 24 25rewriteContents.init = function(options) { 26 this.vars = $.extend(this.vars, options); 27}; 28rewriteContents.insert = function() { 29 var self = this; 30 31 // å ¨rewriteã«å¯¾ãã¦ãå¤å®ã true ãªãå®è¡ãã 32 $('.rewrite-contents').each( function() { 33 if (typeof self.vars.isLoad === "function" && self.vars.isLoad(this) === true) { 34 self.load(this); 35 } 36 }); 37}; 38rewriteContents.load = function(elm) { 39 var date = new Date(); 40 var url = $(elm).data("contents"); 41 if (!url) { return; } 42 url = url.replace(/\.\.\//, "", url); // ../ ã¯åé¤ 43 url += '?c='+ Math.floor(date.getTime() / 1000); // æ¡å¼µåå¾ã« ?YMD ã追å 44 $.get(url, function(contents) { 45 $(elm).html(contents); 46 g_dispatcher.trigger('rewriteContents_loaded', elm); 47 }); 48};
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.