約 480 行を含むプロトタイプ ファイル全体を jQuery に変換しようとしていました。プロトタイプ ライブラリは使用しません。
オンラインで変換するものを手に入れましたが、 それが機能するのはごく少数のようです。しかし、彼は多くのヒントを与えてくれました。
私の疑問は、開始方法ですか?スタックオーバーフローを参照すると、非常に多くの情報が得られました...プロトタイプからjqueryに完全に変更する場合、「プロトタイプ」という単語を使用する必要がありますか? ? 例:jqueryのプロトタイプ - スタックオーバーフロー
var buildAShop = Class.create();
buildAShop.prototype = {
initialize: function (parameters) {
var params = parameters.evalJSON(); // passing json object so we can add more variables from jsp if needed.
this.scheduleSearchAjax = null; // keep track of the latest scheduleSearch ajax call to ensure only the last one gets displayed.
this.intrastitialContent = null; // store the intrastial content from the page so all HTML is in the jsp page.
// create controller object for all shops and their info
this.shopObj = {currentShop: params.selectedShopNumber,
shopNumbers: params.shopNumbers,
shopNumbersForSelectedSlices: params.shopNumbersForSelectedSlices};
for (var i = 0; i < params.shopNumbers.length; i++) {
var thisShopDiv = $(params.shopNumbers[i].toString());
var thisShopHeader = thisShopDiv.getFirstElementByClassName('shopHeader');
// observe the shop header for changing shops and highlighting the 'tab'
Event.observe(thisShopHeader, 'click', this.switchShop.bindAsEventListener(this, params.shopNumbers[i]));
Event.observe(thisShopHeader, 'mouseover', this.hoverHeader.bindAsEventListener(this, thisShopHeader, 'on'));
Event.observe(thisShopHeader, 'mouseout', this.hoverHeader.bindAsEventListener(this, thisShopHeader, 'off'));
// initialize this shopSet
this.initShopSet(thisShopDiv, params.shopNumbers[i], params.shopNames[i]);
};
},
// initializes a shop set
initShopSet: function (thisShopDiv, shopId, shopName) {
this.shopObj[shopId] = {};
var flt = this.shopObj[shopId];
ここではコード全体を示していません。