The purpose of JavaScript Linker is to process HTML/JavaScript code base to prepare code for deployment by reducing file size, create source code documentation, obfuscate source code to protect intellectual property, and help gather source code metrics for source code analysis & improvements.
インストールが少しめんどう。
2.0 Requirements
1. JDK 1.5.x installed with JAVA_HOME pointing to that JDK.
2. You will need Apache Ant 1.6.x installed with ANT_HOME set.
お目当ての
Janitor - unused function removal via dependency analysis
Janitor task is used to strip out unused functions from the JavaScript source code. Janitor performs a static code analysis constructing a function call graph for all global functions. Entry points are also calculated from all source files that have imported after processing the Dojo require statements. Every function not reachable from the graph is considered unused and gets removed.
class GLatLngBounds
A GLatLngBounds instance represents a rectangle in geographical coordinates, including one that crosses the 180 degrees meridian.
そのひとつのmethod、extendが使えます。
extend(latlng)
Enlarges this rectangle such that it contains the given point. In longitude direction, it is enlarged in the smaller of the two possible ways. If both are equal, it is enlarged at the eastern boundary.
さらにGMap2のgetBoundsZoomLevelってmethod。
getBoundsZoomLevel(bounds)
Returns the zoom level at which the given rectangular region fits in the map view. The zoom level is computed for the currently selected map type. If no map type is selected yet, the first on the list of map types is used.
javascriptコードはこんな。
List[0] = self.createMarker( 0, new GLatLng( 35.678084480, 139.76313114 ) );
List[1] = self.createMarker( 1, new GLatLng( 35.66278800541137 , 139.7543442249298 ) );
List[2] = self.createMarker( 2, new GLatLng( 35.67073730876408 , 139.76759433746338 ) );
List[3] = self.createMarker( 3, new GLatLng( 35.65085384825412 , 139.7745680809021 ) );
List[4] = self.createMarker( 4, new GLatLng( 35.668497289125376 , 139.75984811782837 ) );
self.initZoom();
中略
createMarker : function( num, point ) {
var letter = Letter.getNext();
var ic = new GIcon(baseIcon);
ic.image = "img/icons/icon"+letter+".png";
var marker = new GMarker(point, { icon: ic});
map.addOverlay( marker );
return marker;
},
initZoom : function(){
var gb;
var first = 1;
for( var index in List ){
var marker = List[index];
if( first ){
gb = new GLatLngBounds( marker.getPoint(), marker.getPoint() );
first = 0;
}else{
var point = marker.getPoint();
gb.extend( point );
}
}
map.setCenter( gb.getCenter(), map.getBoundsZoomLevel( gb ) );
}
そもそもToDoに求められる要件ってなんだろう?
・ToDoリストを一望できること
・一望できる範囲に内容、〆切、重要度、状態が含まれること
・重要度順、〆切順などで並べ替え、見栄えの区別ができること
・ToDo項目毎に詳細を書き込めること
・完了後に完了済としてどこかに保存できること
・How to make it doneを書き込めること
・どこからでもアクセスできること
こんなもん?
<textarea id="cart_jst" style="display:none;">
Hello ${customer.first} ${customer.last}.<br/>
Your shopping cart has ${products.length} item(s):
<table>
<tr><td>Name</td><td>Description</td>
<td>Price</td><td>Quantity & Alert</td></tr>
{for p in products}
<tr><td>${p.name|capitalize}</td><td>${p.desc}</td>
<td>$${p.price}</td><td>${p.quantity} : ${p.alert|default:""|capitalize}</td>
</tr>
{forelse}
<tr><td colspan="4">No products in your cart.</tr>
{/for}
</table>
{if customer.level == "gold"}
We love you! Please check out our Gold Customer specials!
{else}
Become a Gold Customer by buying more stuff here.
{/if}
</textarea>
<textarea id="template" style="display:none">
<% context.list.each(function(pair){%>
The value of <%= pair.name %> is: <%= pair.value%>
<% }) %>
</textarea>
選びがたいですが、
simple is best. ということでlyase_viewでちょっと遊んでみようと思います。
2006/07/29 追記
lyase_view使って遊んで見た結果、こんなものできました。
javascriptテンプレートエンジン使用例:
・旬レシピ
・Flickr Color Selectr
prev:
if (anchor.getAttribute('href') && (relAttribute.toLowerCase().match('lightbox')))
aft:
if (anchor.getAttribute('href') &&
( (relAttribute.toLowerCase().match('lightbox'))
|| (anchor.getAttribute('href').match(/.+(jpg|gif|png)$/i)) ) )
line.330辺りを
prev:
// if image is NOT part of a set..
if((imageLink.getAttribute('rel') == 'lightbox'))
{
// add single image to imageArray
imageArray.push(new Array(imageLink.getAttribute('href'), imageLink.getAttribute('titl')));
} else{
// if image is part of a set..
// loop through anchors, find other images in set, and add them to imageArray
for (var i=0; i<anchors.length; i++){
var anchor = anchors[i];
if (anchor.getAttribute('href') && (anchor.getAttribute('rel') == imageLink.getAttribute('rel')))
{
imageArray.push(new Array(anchor.getAttribute('href'), anchor.getAttribute('title')));
}
}
imageArray.removeDuplicates();
while(imageArray[imageNum][0] != imageLink.getAttribute('href')) { imageNum++;}
}
aft:
// if image is part of a set..
if( (imageLink.getAttribute('rel') != null) && (imageLink.getAttribute('rel') != 'lightbox' ) && (imageLink.getAttribute('rel').toLowerCase().match('lightbox')) )
{
// loop through anchors, find other images in set, and add them to imageArray
for (var i=0; i<anchors.length; i++)
{
var anchor = anchors[i];
if (anchor.getAttribute('href') && (anchor.getAttribute('rel') == imageLink.getAttribute('rel')))
{
imageArray.push(new Array(anchor.getAttribute('href'), anchor.getAttribute('title')));
}
}
imageArray.removeDuplicates();
while(imageArray[imageNum][0] != imageLink.getAttribute('href')) { imageNum++;}
}
else
{
// if image is NOT part of a set..
// add single image to imageArray
imageArray.push(new Array(imageLink.getAttribute('href'), imageLink.getAttribute('title')));
}