PageSourceSearch

https://www.city.kumamoto.jp/dynamic/bousai/common/js/layoutadjustment.js

js city.kumamoto.jp collected 2026-10-02 02:30:20 UTC 3,114 bytes, 109 lines download raw bytes

1
2
3jQuery.noConflict();
4var narrowScreen = false;
5var idx = 0;
6jQuery(window).on('load resize', function() {
7    var windowWidth = window.innerWidth;
8    if (windowWidth < 768) {
9        narrowScreen = true;
10    } else {
11        narrowScreen = false;
12    }
13
14    if (narrowScreen) {
15		
16	  	jQuery(function(){
17	  		var cls, maxIndex;
18
19            if (jQuery('.templateForTwoImages').length){
20		  		cls = ".templateForTwoImages";
21		  		maxIndex = 2;
22		  		if (jQuery(cls).attr("data-layout") != "vertical") {
23		  		    idx += funcVertical(cls, maxIndex);
24		  		}
25		  	}
26            if (jQuery('.templateForThreeImages').length){
27		  		cls = ".templateForThreeImages";
28		  		maxIndex = 3;
29		  		if (jQuery(cls).attr("data-layout") != "vertical") {
30		  		    idx += funcVertical(cls, maxIndex);
31		  		}
32		  	}
33	  	});
34	  	
35	  	narrowScreen = false;
36	  	
37    } else {
38	    jQuery(function () {
39	        var cls;
40
41            if (jQuery('.templateForTwoImages').length) {
42	            cls = ".templateForTwoImages";
43	            funcHorizontal(cls);
44	        }
45            if (jQuery('.templateForThreeImages').length) {
46	            cls = ".templateForThreeImages";
47	            funcHorizontal(cls);
48	        }
49	    });
50	    
51	    narrowScreen = true;
52	}
53});
54
55//c•À‚тɕϊ·
56function funcVertical(cls, maxindex) {
57    
58
59        for (var ix = 0; ix < jQuery(cls).length ; ix++) {
60            tbl = jQuery(cls)[ix];
61            tbl.id = 'tblVertical' + (idx + ix);
62            jQuery(tbl).attr("data-layout", "vertical");
63            var tid = "#tblVertical" + (idx + ix);
64            jQuery(tid + " tr").addClass("temptr");
65            jQuery(tid + " thead," + tid + " tbody").children().unwrap();
66            jQuery(tid + " tr:first td," + tid + " tr:first th").each(function () {
67                tds = jQuery(this).index() + 1;
68                jQuery(tid).append("<tr />");
69                jQuery(tid + " tr.temptr").each(function () {
70                    jQuery(tid).append("<tr>");
71                    jQuery(tid + " tr:eq(" + jQuery(this).index() + ") > :nth-child(" + tds + ")").clone(true).appendTo(tid + " tr:last");
72                    jQuery(tid).append("<tr />");
73                });
74            });
75            jQuery(tid + " tr.temptr").remove();
76        }
77        jQuery(function () {
78            jQuery(cls + " tr:empty").remove();
79        });
80        
81
82    return ix;
83}
84
85//‰¡•À‚тɕϊ·
86function funcHorizontal(cls) {
87    var strRow1 = "";
88    var strRow2 = "";
89    var verticalTable = jQuery('[data-layout ="vertical"]');
90
91
92    jQuery(verticalTable).each(function () {
93        var tmp = jQuery(this).find("tbody tr");
94        var tmpLen = tmp.length;
95        for (var i = 0; i < tmpLen; i++) {
96            var tmp2 = tmp[i];
97            if (i % 2 == 0) {
98                strRow1 += jQuery(tmp2).html();
99            } else {
100                strRow2 += jQuery(tmp2).html();
101            }
102        }
103        jQuery(this).find("tbody").replaceWith("<tr>" + strRow1 + "</tr>" + "<tr>" + strRow2 + "</tr>");
104        strRow1 = "";
105        strRow2 = "";
106        jQuery(this).removeAttr("data-layout");
107    })
108    
109}

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.