<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ゆーすけぶろぐ &#187; JavaScript</title>
	<atom:link href="http://yusukezzz.net/blog/archives/tag/javascript/feed" rel="self" type="application/rss+xml" />
	<link>http://yusukezzz.net/blog</link>
	<description>yusukezzz&#039;s weblog... ぷろぐらむとか ruby, android, java, thinkpad, milestone2</description>
	<lastBuildDate>Sat, 10 Mar 2012 17:22:54 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Chromeで位置情報取得</title>
		<link>http://yusukezzz.net/blog/archives/1656</link>
		<comments>http://yusukezzz.net/blog/archives/1656#comments</comments>
		<pubDate>Wed, 09 Dec 2009 16:16:03 +0000</pubDate>
		<dc:creator>yusukezzz</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[geolocation]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://yusukezzz.net/blog/?p=1656</guid>
		<description><![CDATA[先日、Firefoxで位置情報を取得するnavigator.geolocationを紹介しましたが、それのChrome版です ＃Chrome版というか、呼び出しているAPIはFirefoxと同等なので結果も全く同じになり [...]]]></description>
			<content:encoded><![CDATA[<p>先日、Firefoxで位置情報を取得するnavigator.geolocationを紹介しましたが、それのChrome版です<br />
＃Chrome版というか、呼び出しているAPIはFirefoxと同等なので結果も全く同じになります<br />
windowsのでは動きましたがLinux版では動きませんでした；</p>
<pre class="brush: jscript; title: ; notranslate">
// これをロードしとく
&lt;script type=&quot;text/javascript&quot; src=&quot;http://code.google.com/intl/ja/apis/gears/gears_init.js&quot;&gt;&lt;/script&gt;

// browserに応じて使い分け
var geo;
// for firefox and mobile safari
if(navigator.geolocation)
  geo = navigator.geolocation;
// for google chrome(win) and Chrome Lite(Android)
else if(window.google &amp;&amp; google.gears)
  geo = google.gears.factory.create('beta.geolocation');
if(geo)
  geo.getCurrentPosition(-省略-);
else
  alert('geolocation disabled...');
</pre>
]]></content:encoded>
			<wfw:commentRss>http://yusukezzz.net/blog/archives/1656/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GoogleMapsAPI V3</title>
		<link>http://yusukezzz.net/blog/archives/1641</link>
		<comments>http://yusukezzz.net/blog/archives/1641#comments</comments>
		<pubDate>Thu, 26 Nov 2009 13:41:22 +0000</pubDate>
		<dc:creator>yusukezzz</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[googlemaps]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://yusukezzz.net/blog/archives/1641</guid>
		<description><![CDATA[今更ながらver3が存在することを知りました； ver2.xと比べて大分シンプルになったようです 最大の違いはiPhoneやandroid向けにも最適化されている点です Map V3 Tutorial &#8211; G [...]]]></description>
			<content:encoded><![CDATA[<p>今更ながらver3が存在することを知りました；<br />
ver2.xと比べて大分シンプルになったようです<br />
最大の違いはiPhoneやandroid向けにも最適化されている点です</p>
<p><a href="http://code.google.com/intl/ja/apis/maps/documentation/v3/introduction.html" taget="_blank">Map V3 Tutorial &#8211; Google Maps JavaScript API V3 &#8211; Google Code</a><br />
<a href="http://code.google.com/intl/ja/apis/maps/documentation/v3/reference.html" taget="_blank">Google Maps API V3 Reference &#8211; Google Maps JavaScript API V3 &#8211; Google Code</a></p>
<p>毎度のごとく仕様はかなり変わっているので、<br />
とりあえずチュートリアルとリファレンスを読んで勉強し直そうと思います</p>
]]></content:encoded>
			<wfw:commentRss>http://yusukezzz.net/blog/archives/1641/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>navigator.geolocation.getCurrentPositionのキャッシュ時間</title>
		<link>http://yusukezzz.net/blog/archives/1640</link>
		<comments>http://yusukezzz.net/blog/archives/1640#comments</comments>
		<pubDate>Thu, 19 Nov 2009 06:15:56 +0000</pubDate>
		<dc:creator>yusukezzz</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://yusukezzz.net/blog/archives/1640</guid>
		<description><![CDATA[con_mameさんに教えて頂きました navigator.geolocation.getCurrentPositionの結果はキャッシュされていて、 navigator.geolocation.getCurrentPo [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://twitter.com/con_mame/statuses/5850486865" target="_blank">con_mame</a>さんに教えて頂きました<br />
navigator.geolocation.getCurrentPositionの結果はキャッシュされていて、<br />
navigator.geolocation.getCurrentPosition(onSuccess, onError, options);<br />
のoptionsにmaximumAgeをミリ秒単位で指定すると、<br />
その時間が経過したときにキャッシュが破棄されます（0だと毎回取得し直す）<br />
他にもtimeoutの指定も出来るようです</p>
]]></content:encoded>
			<wfw:commentRss>http://yusukezzz.net/blog/archives/1640/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ブラウザで位置情報取得</title>
		<link>http://yusukezzz.net/blog/archives/1560</link>
		<comments>http://yusukezzz.net/blog/archives/1560#comments</comments>
		<pubDate>Sat, 03 Oct 2009 19:25:59 +0000</pubDate>
		<dc:creator>yusukezzz</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://yusukezzz.net/blog/archives/1560</guid>
		<description><![CDATA[Firefox 3.5 からは、位置情報通知機能 (Geolocation API) が標準搭載に &#8211; Cirius Lab. ブログ 凄く簡単に出来ました！ ただし精度はイマイチ…普通の家庭用Wifiだし、 [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://lab.cirius.co.jp/blog/2009/07/firefox-35-geolocation-api.php" target="_blank">Firefox 3.5 からは、位置情報通知機能 (Geolocation API) が標準搭載に &#8211; Cirius Lab. ブログ</a></p>
<p>凄く簡単に出来ました！<br />
ただし精度はイマイチ…普通の家庭用Wifiだし、しょうがないか；<br />
iPhoneでも同じコードで動くらしいのでtouchでも動くと期待<br />
大学や公衆無線LANなら多分位置情報を持ってると思うので、今度試してみようと思います</p>
]]></content:encoded>
			<wfw:commentRss>http://yusukezzz.net/blog/archives/1560/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>windowサイズ変更時の処理</title>
		<link>http://yusukezzz.net/blog/archives/1548</link>
		<comments>http://yusukezzz.net/blog/archives/1548#comments</comments>
		<pubDate>Wed, 16 Sep 2009 07:02:17 +0000</pubDate>
		<dc:creator>yusukezzz</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[googlemaps]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://yusukezzz.net/blog/archives/1548</guid>
		<description><![CDATA[最近googleMapsAPIで地図を使った研究をしているのですが、 windowサイズを変えたり、ページ下段にFirebugを表示した際に要素のサイズを変える処理が欲しくなりました javascriptではonload [...]]]></description>
			<content:encoded><![CDATA[<p>最近googleMapsAPIで地図を使った研究をしているのですが、<br />
windowサイズを変えたり、ページ下段にFirebugを表示した際に要素のサイズを変える処理が欲しくなりました<br />
javascriptではonload（ページ読み込み時のイベント）や、<br />
onresize（ページ領域変更時のイベント）が用意されています<br />
これらを使ったサンプルがこちら（Firefox3.5でしか試してません）<br />
id=map_elementをページの半分にだけ表示します</p>
<pre class="brush: jscript; title: ; notranslate">
window.onload = function(){
  //コメント部はgoogleMapsAPIを使用している場合
  //mapの初期化処理は省略
  //map = new GMap2($(&quot;map_element&quot;));
  setHalfSize();
}
window.onresize = function(){
  //var center = map.getCenter();
  //var point = new GLatLng(center.lat(), center.lng());
  setHalfSize();
  //checkResizeを呼んでサイズ変更をAPIに通知しておくと、その後の移動を宜しくやってくれる
  //map.checkResize();
  //map.panTo(point);
}
function setHalfSize(){
  $('map_element').style.width = innerWidth / 2;
  $('map_element').style.height = innerHeight;
}
</pre>
<p>ようはページ読み込み時とページ内領域サイズ変更時にサイズがfitするような処理を仕込めばいいことになります<br />
<s>googleMapsの場合は中心位置もサイズに合わせて維持させてやると使いやすくなると思います</s><br />
<a href="http://slightlyblue.com/blog/2006/08/googlemapscheckresize_1.html" target="_blank">blog@slightlyblue: GoogleMapsブラウザリサイズ時のイベント処理でcheckResizeする！</a><br />
を参考にmapの中央位置をリサイズ後も維持出来るようにしました</p>
]]></content:encoded>
			<wfw:commentRss>http://yusukezzz.net/blog/archives/1548/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>prototype.jsで特定要素を配列で取得する</title>
		<link>http://yusukezzz.net/blog/archives/1399</link>
		<comments>http://yusukezzz.net/blog/archives/1399#comments</comments>
		<pubDate>Thu, 04 Jun 2009 12:28:30 +0000</pubDate>
		<dc:creator>yusukezzz</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://yusukezzz.net/blog/archives/1399</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: jscript; title: ; notranslate">
//全ての画像要素
images = $$(&quot;img&quot;);
alert(images[0].src);

//id、classで絞込み
field = $$('div#loginForm .field input');
alert(field[0].value);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://yusukezzz.net/blog/archives/1399/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TalkLineにPostするためのLDR用GreasemonkeyScript</title>
		<link>http://yusukezzz.net/blog/archives/1300</link>
		<comments>http://yusukezzz.net/blog/archives/1300#comments</comments>
		<pubDate>Mon, 20 Apr 2009 06:40:34 +0000</pubDate>
		<dc:creator>yusukezzz</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[greasemonkey]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://yusukezzz.dyndns.org/blog/archives/1300</guid>
		<description><![CDATA[TalkLineという自作マイクロブログにLDRからPostするためのGreasemonkeyScript LDRで用意されてるくっつける用のメソッドでinputを用意し、GM_xmlhttpRequestでpostして [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://133.78.124.70/" target="_blank">TalkLine</a>という自作マイクロブログにLDRからPostするためのGreasemonkeyScript</p>
<pre class="brush: jscript; title: ; notranslate">
// ==UserScript==
// @name           TalkLineForm
// @namespace      http://yusukezzz.dyndns.org/
// @description    TalkLine post form for Livedoor Reader
// @include        http://reader.livedoor.com/*
// ==/UserScript==

(function(){
	var w = (typeof unsafeWindow == 'undefined') ? window : unsafeWindow;
	var description = 'TalkLine post form for Livedoor Reader';
	$client = 'TalkLineForm for LDR';

	w.myfunc = function(url, title){
		$status = document.getElementById('status_' + url);
		window.setTimeout(function(){
			GM_xmlhttpRequest({
				method: 'POST',
				headers: {'Content-type': 'application/x-www-form-urlencoded'},
				url: 'http://133.78.124.70/post/',
				data: 'status=' + encodeURIComponent($status.value) + '&amp;title=' + encodeURIComponent(title) + '&amp;url=' + encodeURIComponent(url) + '&amp;client=' + $client,
				onload: function(responseDetails) {
					if(responseDetails.responseText != 'success') alert('Failed');
					else $status.value = '';
				}
			});
		}, 0);
	}

	w.entry_widgets.add('talkline_form', function(feed, item){
		var url = item.link.replace(/#/g,'%23');
		var title = item.title
		return [
			'&lt;img src=&quot;http://133.78.124.70/favicon.ico&quot;&gt;',
			'&lt;input type=&quot;text&quot; id=&quot;status_', url ,'&quot; value=&quot;&quot;/&gt;',
			'&lt;input type=&quot;submit&quot; id=&quot;btn_', url ,'&quot; value=&quot;post&quot; onclick=&quot;myfunc(\'', url,'\',\'', title ,'\')&quot;/&gt;',
		].join('');
	}, description);
})();
</pre>
<p>LDRで用意されてるくっつける用のメソッドでinputを用意し、GM_xmlhttpRequestでpostしています<br />
GM_xmlhttpRequestでPOSTメソッドを使うには<br />
headers: {&#8216;Content-type&#8217;: &#8216;application/x-www-form-urlencoded&#8217;}<br />
が必要です<br />
また、Railsならば受け取るアクションでXSS対策のトークンチェックを無効化、又は対応させる必要があります<br />
（この辺のセキュリティ対策は正直良く分かってません）</p>
<p>GM_xmlhttpRequestをwindow.setTimeoutでラップしてあるのはセキュリティ上の配慮のようです<br />
詳細は良く分かりません＞＜</p>
<p>キーボードショートカットや投稿されてるpostを表示させたり、まだまだ弄る余地はいくらでもありますが、<br />
とりあえずこれでLDRからPost出来るようになったので、後はLDRだけに留まらず、通常サイトからのpost＆twitterへのクロスポストに対応させたいと思います</p>
]]></content:encoded>
			<wfw:commentRss>http://yusukezzz.net/blog/archives/1300/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GreasemonkeyScript作るのに参考にしたサイト</title>
		<link>http://yusukezzz.net/blog/archives/1288</link>
		<comments>http://yusukezzz.net/blog/archives/1288#comments</comments>
		<pubDate>Mon, 13 Apr 2009 14:02:42 +0000</pubDate>
		<dc:creator>yusukezzz</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[greasemonkey]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://yusukezzz.dyndns.org/blog/?p=1288</guid>
		<description><![CDATA[LivedoorReaderに何かくっつけてXML HTTP Requestしたくなった 最速インターフェース研究会 :: livedoor Readerに何かくっつけるGreasemonkeyの書き方 いまさらだけどG [...]]]></description>
			<content:encoded><![CDATA[<p>LivedoorReaderに何かくっつけてXML HTTP Requestしたくなった</p>
<p><a href="http://la.ma.la/blog/diary_200610182325.htm" target="_blank">最速インターフェース研究会 :: livedoor Readerに何かくっつけるGreasemonkeyの書き方</a></p>
<p><a href="http://d.hatena.ne.jp/Cherenkov/20081206/p1" target="_blank">いまさらだけどGM_logの使い方。console.logも使えるようになった！ &#8211; Cherenkovの暗中模索にっき</a></p>
<p><a href="http://diveintogreasemonkey.org/api/gm_xmlhttprequest.html" target="_blank">GM_xmlhttpRequest [Dive Into Greasemonkey]</a></p>
<p><a href="http://www.sukechan.net/archives/tag/greasemonkey/page/2/" target="_blank">Greasemonkey &#8211; sukechan.net</a></p>
<p><a href="http://d.hatena.ne.jp/edvakf/20090319/1237479596" target="_blank">LDR/Fastladderで各記事を表示時に動的にアレコレする方法 &#8211; by edvakf in hatena</a></p>
<p><a href="http://www.ohmiyapatriots.com/blog/category/greasemonkey/" target="_blank">Greasemonkey</a></p>
<p><a href="http://wiki.greasespot.net/0.7.20080121.0_compatibility" target="_blank">0.7.20080121.0 compatibility &#8211; GreaseSpot</a></p>
<p>この辺見てLivedoorReaderのページからGM_xmlhttpRequestするところまでは出来た<br />
後はサーバでそれを受け取って処理すれば初期の構想は実現出来そうだ<br />
今度しっかりまとめたい</p>
]]></content:encoded>
			<wfw:commentRss>http://yusukezzz.net/blog/archives/1288/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>今日のまとめ</title>
		<link>http://yusukezzz.net/blog/archives/1127</link>
		<comments>http://yusukezzz.net/blog/archives/1127#comments</comments>
		<pubDate>Mon, 02 Mar 2009 17:33:16 +0000</pubDate>
		<dc:creator>yusukezzz</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://yusukezzz.dyndns.org/blog/?p=1127</guid>
		<description><![CDATA[ResourceCompressorをAjax化すべく奮闘していました 色々はまって大変な時間を消費した…orz]]></description>
			<content:encoded><![CDATA[<p>ResourceCompressorをAjax化すべく奮闘していました</p>
<pre class="brush: ruby; title: ; notranslate">
# ディレクトリのファイル数を取得
Dir.glob('path/to/files/*.{js,css}').length
# ファイルサイズ取得
File::stat(file).size # int
File::stat(file).size.to_s # string
# パスからファイル名取得
File.basename(path, ignore_ext)
</pre>
<pre class="brush: jscript; title: ; notranslate">
// 正規表現
matches = str.match(regexp);
// 置換
result = str.replace(regexp, newString);
</pre>
<p>色々はまって大変な時間を消費した…orz</p>
]]></content:encoded>
			<wfw:commentRss>http://yusukezzz.net/blog/archives/1127/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MacのFirefoxでマウスジェスチャ</title>
		<link>http://yusukezzz.net/blog/archives/1038</link>
		<comments>http://yusukezzz.net/blog/archives/1038#comments</comments>
		<pubDate>Fri, 13 Feb 2009 11:47:24 +0000</pubDate>
		<dc:creator>yusukezzz</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://yusukezzz.dyndns.org/blog/?p=1038</guid>
		<description><![CDATA[Adobe Illustratorを使う必要性が出てきたのでまたMacを借りました そして前も陥った問題として、「マウスジェスチャには右クリックを使う」という世界の常識？があります Macのトラックパッドは右クリックでド [...]]]></description>
			<content:encoded><![CDATA[<p>Adobe Illustratorを使う必要性が出てきたのでまたMacを借りました<br />
そして前も陥った問題として、「マウスジェスチャには右クリックを使う」という世界の常識？があります<br />
Macのトラックパッドは右クリックでドラッグするのにControlキー＋クリックしなければいけません<br />
ドラッグ中このキーを押し続けるのは辛いものがあり、常用には耐えません<br />
そこで、右クリックを他の操作で代用できないか？と考えました<br />
たどり着いた結論はuserChrome.jsの使用です（userChrome.jsは以前にも取り上げてますね）<br />
自分はCtrlキーを押しながらマウスカーソルを動かすことでマウスジェスチャとして認識するように設定しました<br />
（Ctrlキーが使えなくなっても右クリック自体は2本指タップで出来るので）<br />
使用したスクリプトは<a href="http://mozilla.zeniko.ch/userchrome.js.html">こちら</a>のもの<br />
SampleCodeのExtension replacementsのところにあります</p>
<p>改変したのは以下の通り</p>
<pre class="brush: jscript; title: ; notranslate">
//mousedown、mouseupをkeydown、keyupに
28.     [&quot;keydown&quot;, &quot;mousemove&quot;, &quot;keyup&quot;, ...
//caseの条件もkeydownへ true（Ctrlキー押下）だったらジェスチャ開始
39. case &quot;keydown&quot;:
40.         if (aEvent.ctrlKey == true)
//keyupにcase条件変更
52. case &quot;keyup&quot;:
</pre>
<p>保存してFirefox再起動<br />
以上で完了</p>
]]></content:encoded>
			<wfw:commentRss>http://yusukezzz.net/blog/archives/1038/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

