/** * User: inui@tci * Date: 12/02/21 * Time: 21:44 * To change this template use File | Settings | File Templates. */ /** * 登録情報一覧 */ var AnnouncerProcess = function () { this.initialize.apply(this, arguments); } AnnouncerProcess.prototype = { initialize: function (ctrlObj, id) { this._ctrlObj = ctrlObj; this._attacher = new EventListenerAttacher(); this._remover = new EventListenerRemover(); this._usrEvt = null; this._id = (typeof id != 'undefined') ? id : 0; this._listData = null; this._dataPath = './rss'; this._data = null; }, execute: function () { // load list html if (this._data == null) { this._usrEvt = new UsrEventHandler(); var reqObj = new RequestObj(this._dataPath+'/'+this._ctrlObj.get('dataName'), 'GET'); var httpReq = new HttpRequest(); httpReq.addEventListener(this._usrEvt.set(httpReq), this._dataLoadComp.curry(reqObj).bindFunc(this)); httpReq.execute(reqObj, this._usrEvt); } else { this._dataLoadComp(); } }, _dataLoadComp: function (reqObj, eventObj) { if (typeof reqObj != 'undefined') this._data = reqObj.get('receive'); this._listData = this._createDataObj(); this._ctrlObj.set('curYear', this._ctrlObj.get('toYear')); this._ctrlObj.set('curMonth', this._ctrlObj.get('toMonth')); this._ctrlObj.set('curDate', this._ctrlObj.get('toDate')); this._renderingCal(); }, _renderingCal: function() { // カレンダー if (document.getElementById('cal_area')) { var drawCalendar = new DrawCalendar(this._ctrlObj); document.getElementById('cal_area').innerHTML = drawCalendar.execute(this._listData); this._attacher.attachClickListenerById('calPrev', this._clickMove.curry('prev'), this); this._attacher.attachClickListenerById('calNext', this._clickMove.curry('next'), this); } }, _createDataObj: function () { var obj = new Array(); var lines = this._data.split("\n"); lines.pop(); var labelFlg = false; var labels = new Array(); var lineCnt = 0; for (var i = 0; i < lines.length; i++) { var args = lines[i].split("\t"); for (var j = 0; j < args.length; j++) { if (j == 0 && args[j] == 'id') { labelFlg = true; labels = new Array(); } else if (j == 0) { obj[lineCnt] = {}; } if (labelFlg === true) { labels.push(args[j]); } else { obj[lineCnt][labels[j]] = args[j]; } } if (labelFlg === false) lineCnt++; labelFlg = false; } return obj; }, _clickMove: function(mode, eventObj) { if (typeof eventObj != 'undefined') this._ctrlObj.get('interceptor').execute(eventObj); var mon = 0; var year = 0; if (mode == 'prev') { mon = Number(this._ctrlObj.get('curMonth')) - 1; year = Number(this._ctrlObj.get('curYear')); if (mon < 1) { mon = 12; year = year - 1; } } else if (mode == 'next') { mon = Number(this._ctrlObj.get('curMonth')) + 1; year = Number(this._ctrlObj.get('curYear')); if (mon > 12) { mon = 1; year = year + 1; } } this._ctrlObj.set('curYear', year); this._ctrlObj.set('curMonth', mon); this._removeEventHandlerList(); this._renderingCal(); }, _removeEventHandlerList: function() { if (document.getElementById('calPrev')) document.getElementById('calPrev').onclick = null; if (document.getElementById('calNext')) document.getElementById('calNext').onclick = null; }, _exception: function(errStr) { this._ctrlObj.get('exception').execute(errStr, false); } }