memo.xight.org

JavaScript

2010-01-08 Fri

Google Maps jQuery Plugin - jQueryでGoogle Mapsを簡単に扱えるプラグイン

- Summary
jQueryでGoogle Mapsを簡単に扱えるプラグイン。

- Sample code

$(document).ready(function() {
  $('selector').googleMaps({
    latitude: 49.26063518364422,
    longitude: -123.15673828125
  });
});


- Reference
Shawn Mayzes - Google Maps jQuery Plugin
http://www.mayzes.org/googlemaps.jquery.html

- via
IDEA*IDEA - 2010-01-08 - jQueryでGoogle Mapsを簡単に扱えるようになるプラグイン『Google Maps jQuery Plugin』
http://www.ideaxidea.com/archives/2010/01/jquery_google_maps.html

2009-12-24 Thu

jsLaTeX - 数式を出力できるjQueryプラグイン

- Summary
TeX形式で記述した数式を画像として出力するjQueryプラグイン。

指定したクラス内のテキストを、以下のURLにリクエストしているようだ。
http://latex.codecogs.com/gif.latex

- Sample

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script src="jquery.jslatex.js"></script>
<script>
$(function () {
    $(".latex").latex();
});
</script>
 
<div class="latex">
    \int_{0}^{\pi}\frac{x^{4}\left(1-x\right)^{4}}{1+x^{2}}dx =\frac{22}{7}-\pi
</div>


jsLaTeXの出力

- Reference
Knowledge-aholic: jsLaTeX: A jQuery plugin to directly embed LaTeX into your website or blog
http://knowledge-aholic.blogspot.com/2009/12/jslatex-jquery-plugin-to-directly-embed.html

CODECOGS
http://www.codecogs.com/

- via
複雑な数式を出力したい際に使えるjQueryプラグイン「jsLaTeX」:phpspot開発日誌
http://phpspot.org/blog/archives/2009/12/jqueryjslatex.html

2009-11-26 Thu

ページを自動スクロールするBookmarklet

- Summary
ディスプレイを眺めながら、単純作業をするときのお共に。

高速バージョン

javascript:var%20wN2scRl;Sa5gNA9k=new%20Function('clearTimeout(wN2scRl)');document.onmousedown=Sa5gNA9k;Sa5gNA9k();void(wN2scRl=setInterval('if(pageYOffset%3Cdocument.height-innerHeight)%7Bwindow.scrollBy(0,2)%7Delse%7BSa5gNA9k()%7D',50))


ゆっくりバージョン
javascript:var%20wN2scRl;Sa5gNA9k=new%20Function('clearTimeout(wN2scRl)');document.onmousedown=Sa5gNA9k;Sa5gNA9k();void(wN2scRl=setInterval('if(pageYOffset%3Cdocument.height-innerHeight)%7Bwindow.scrollBy(0,1)%7Delse%7BSa5gNA9k()%7D',50))


- Reference
Going My Way - 2004-03-23 - ページを自動スクロールするBookmarklet
http://kengo.preston-net.com/archives/001239.shtml

2009-09-30 Wed

Internet Explorer で HTML5 を表示する JavaScript

- Summary
html5doctor.com は HTML5で記述されているが、Internet Explorer 8で閲覧しても表示される。
これは、 html5shiv を利用しているため。

- Source

<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->



- Reference
html5shiv - Project Hosting on Google Code
http://code.google.com/p/html5shiv/

HTML5 enabling script
http://remysharp.com/2009/01/07/html5-enabling-script/

Remy Sharp (rem) on Twitter
http://twitter.com/rem

HTML5 Doctor, helping you implement HTML5 today
http://html5doctor.com/

HTML5.JP
http://html5.jp/

2007-07-09 Mon

w3voiceIM.js - 音声認識テキスト入力Javascriptライブラリ

- Summary
一行追加するだけで,Webページの上のテキスト入力フォームに
音声認識機能を追加できるJavascriptライブラリ.

- Reference
音声認識テキスト入力Javascriptライブラリ w3voiceIM.js
http://w3voice.jp/engine/

- via
スラッシュドット ジャパン | 全てのフォームに音声認識機能を!
http://slashdot.jp/article.pl?sid=07/07/09/0715202

2006-11-28 Tue

URLParser - JavaScriptのURLパーサークラス

- Summary

var p = new Poly9.URLParser('http://user:password@poly9.com/pathname?arguments=1#fragment');
 
/* OUT *
p.getHost() == 'poly9.com'
p.getProtocol() == 'http'
p.getPathname() == '/pathname'
p.getQuerystring() == 'arguments=1'
p.getFragment() == 'fragment'
p.getUsername() == 'user'
p.getPassword() == 'password'
*/
 
p.setURL('another.url.com');
 
/* OUT *
p.getHost() == 'another.url.com'
p.getProtocol() == ''
*/


- Reference
URLParser - Public code - Trac
https://code.poly9.com/trac/wiki/URLParser

- via
phpspot開発日誌 - 2006-11-27 - JavaScriptから使える便利なURLパーサークラス「URLParser」
http://phpspot.org/blog/archives/2006/11/javascripturlur.html

2006-11-19 Sun

JavaScriptファイルを圧縮して読み込ませる

- Summary
JavaScriptファイル自体を gzip で圧縮して読み込ませれば良い.

<script type="text/javascript" src="prototype.js.gz"></script>


- 圧縮されたJavaScriptがSafariで読み込めない問題
圧縮したJavaScriptファイルの拡張子を .jgz とし,
mod_rewriteで .jgz へのアクセスを .js にリダイレクト.

RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ".*Safari.*" [OR]
RewriteCond %{HTTP:Accept-Encoding} !gzip
RewriteRule (.*)\.jgz$ $1\.js [L]
 
AddType "text/javascript;charset=UTF-8" .jgz
AddEncoding gzip .jgz


- Reference
亜細亜の蛾 - 2006-11-16 - prototype.jsを10KBにする方法
http://asiamoth.com/mt/archives/2006-11/16_2331.php

こぶたのラッパ : 世界の片隅で.jgzと言ってみる
http://smil.exblog.jp/4650470/

2006-10-08 Sun

Link Indicator - 外部リンクの判別とページ内リンクを視覚的に表現するJavaScriptライブラリ

- Summary

アンカーに付けられたtarget属性の判別とページ内リンクを視覚的に明示する仕組みを提供する補助スクリプト


- Reference
Link Indicator
http://serennz.cool.ne.jp/sb/sp/linkindicator/index_ja.html

- via
caramel*vanilla - 2006-10-08 - ページ内リンクをわかりやすくするJavaScript
http://caramel-tea.com/2006/10/link_javascript/