Code Archive Skip to content Google About Google Privacy Terms
処理に時間がかかるけれども、一定時間は結果が変わらないような関数の結果をキャッシュしたい。 例えばgetElementsByTagName("*")なんかを頻繁に呼び出すようなコードがあったとして、結果をキャッシュしたいけれど画面描画が発生すると使えなくなってしまう。setTimeoutで0ミリ秒後にキャッシュを消す処理を入れておいて、画面描画と関係のある処理はタイマーで実行するような制約を付けてコードを書けばDOMが絡む処理の結果もキャッシュすることができる。というようなケースに使えるような気がする。 Function.prototype.timed_memoise = function(ms){ var self = this; ms = ms || 0; var memo = {}; var clear_q = false; function clear_cache(){memo={
asActionScript の関数を JavaScript から呼び出すときに、ExternalInterface.addCallback で関数を使うと便利なのですが、ここで公開された関数は apply, call, toString といったメソッドが定義されていません。実験した ActionScript はこんなの。要は draw 関数を ExternalInterface を使って公開してます。 package { import flash.display.*; import flash.external.ExternalInterface; public class ExtTest extends Sprite { public function ExtTest() { draw(0); ExternalInterface.addCallback("draw", draw);
※追記:あまりにも記事タイトルが適当すぎて我ながら日本語でおkと思ったのでタイトルを変えました。 http://labs.cybozu.co.jp/blog/kazuho/archives/2006/12/oo-settimeout.php http://blog.livedoor.jp/dankogai/archives/50714622.html このネタはmalaさんが1年半前に通過した地点なのである程度常識の部類かと思ってました。 でもdankogaiがわざわざやるってことは知らない人も多そうだし、malaさんが同じネタをまたやるようにも思えないので、ついでにLDRに現在使われてるFunction.prototype.laterとかを紹介してみる。 Function.prototype.later = function(ms){ var self = this; return fu
MTASC入門を兼ねてFlash / JavaScript Integration Kitのドキュメントに書いてあることそのままやってみます。actionscriptもmtascもよく知らないので基本的に手探りでやっています。動作確認はosx上のmtasc Ver.1.12, Firefox 1.5で行いました。 まずはmtasc側asソースを用意する。 flash2js.as class Application { static var app:Application; var proxy:JavaScriptProxy; var log:Function; function initDebugger():Void { _root.createTextField( "tf", 1, 0, 0, 100, 20 ); _root.tf.border = true; _root.tf.tex
Looking for information about Informa TechTarget products and services? The commercial homepage has moved. Visit Informa TechTarget News 01 Aug 2025 / Policy & regulation Trump urges top drugmakers to cut U.S. prescription drug costs Trump increases pressure on 17 of the world's largest drug makers to lower U.S. prescription drug prices in 60 days, ahead of proposed tariffs and pharmaceutical impo
Automatic colored rows - Example for BiteSize Standards テーブルの背景って次のイメージのように行ごとに交互に色分けされていると見やすいですね。 かといって、サーバサイドでアイテムを回して、1個1個設定するのも結構面倒だったりします。 リンク先のサンプルでは、JavaScriptを使って、trエレメントを探索し、交互にクラスを割り当てていくことで、自動でテーブルに色をつけてるようです。 これで、テーブルはシンプルにHTMLでコーディングでき、サーバサイドの技術なしで見やすいテーブルが作成できますね。
Update: id:reinyannyan:20060411:p1 に続きます getElementsByTagName の様なメソッドで得られた、配列ではない要素集合を配列のように扱いたい時に、prototype.js では "$A" という関数によってまず配列化する、という方法を用います。 これは非常に素晴らしい、便利な方法なんですが、集合の規模が大きくなると、それだけ配列化によるオーバーヘッドも大きなものになってしまいます。 そこで、仮にこのようなものを作ってみました。 // DOM Iterator var Domi = { each: function (collection, yield) { for (var i = 0; i < collection.length; i++) yield(collection[i]); } };べつに配列が欲しいわけじゃない、単純に ea
http://www.goodpic.com/mt/archives2/2006/02/ajax.html で紹介されてる通り、script.aculo.usは通常のロードではファイルサイズが100KBを超えます。しかし、それはフルでロードしたときの容量なのです。script.aculo.usはロードするパッケージを選ぶことができる*1ので必要な機能だけを選べば良いのです。例えば、たいていの場合はscript.aculo.usのeffects.jsだけしか使わなかったりするので <script src="/js/scriptaculous.js?load=effects" type="text/javascript"></script> とすればOK。これでファイルサイズは34KBに収まります。また、二つ以上のパッケージを選択したい場合は <script src="/js/scriptac
Roland pointed me to an article about the amount of Javascript on digg.com’s home page. Seems a few Digger’s found it interesting. Well here at Zimbra we’ve got tons of Javascript and CSS in our AJAX web app. I decided to try an experiment to see if the techniques we use for Zimbra, a rather large AJAX app would help a site like digg. First some background on Zimbra’s AJAX app and the techniques w
Looking for information about Informa TechTarget products and services? The commercial homepage has moved. Visit Informa TechTarget News 01 Aug 2025 / Policy & regulation Trump urges top drugmakers to cut U.S. prescription drug costs Trump increases pressure on 17 of the world's largest drug makers to lower U.S. prescription drug prices in 60 days, ahead of proposed tariffs and pharmaceutical impo
We are doing our best in order to restore the service as soon as possible. Thank you in advance for your understanding and patience.
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く