/*
* Ext JS Library 2.1
* Copyright(c) 2006-2008, Ext JS, LLC.
* licensing@extjs.com
*
* http://extjs.com/license
*/
FeedWindow = function() {
this.feedUrl = new Ext.form.ComboBox({
id: 'feed-url',
fieldLabel: '[로그아웃 상태] RSS 주소를 입력해주세요',
emptyText: 'http://여기에 RSS 피드주소를 입력해주세요.',
width: 450,
validationEvent: false,
validateOnBlur: false,
msgTarget: 'under',
triggerAction: 'all',
displayField: 'url',
mode: 'local',
listeners:{
valid: this.syncShadow,
invalid: this.syncShadow,
scope: this
},
tpl: new Ext.XTemplate(
''),
store: new Ext.data.SimpleStore({
fields: ['url', 'text'],
data : this.defaultFeeds
})
});
this.form = new Ext.FormPanel({
labelAlign:'top',
items:this.feedUrl,
border: false,
bodyStyle:'background:transparent;padding:10px;'
});
FeedWindow.superclass.constructor.call(this, {
title: '피드 추가',
iconCls: 'feed-icon',
id: 'add-feed-win',
autoHeight: true,
width: 500,
resizable: false,
plain:true,
modal: true,
y: 100,
autoScroll: true,
closeAction: 'hide',
buttons:[{
text: '추가하기',
handler: this.onAdd,
scope: this
},{
text: '취 소',
handler: this.hide.createDelegate(this, [])
}
,{
text: '로그인하기',
handler: this.goLogin
}
],
items: this.form
});
this.addEvents({add:true});
}
Ext.extend(FeedWindow, Ext.Window, {
defaultFeeds : [
['http://rss.allblog.net/TodayBestPosts.xml', '올블로그 오늘의 추천글'],
['http://bloggernews.media.daum.net/general/rss', '블로거뉴스 전체 인기글'],
['http://www.zdnet.co.kr/services/rss/news/rss2.0_utf-8.htm', 'ZDNet Korea IT소식'],
['http://www.hani.co.kr/rss/', '인터넷 한겨례 주요뉴스'],
['http://www.inews24.com/rss/rss_inews.xml', '아이뉴스24 IT뉴스'],
['http://paper.sirini.net/feed/', 'sirini 추천 RSS'],
['http://sirini.net/blog/rss.php', 'SIRINI`s Blog']
],
show : function(){
if(this.rendered){
this.feedUrl.setValue('');
}
FeedWindow.superclass.show.apply(this, arguments);
},
onAdd: function() {
this.el.mask('피드 유효성 검사중...', 'x-mask-loading');
var url = this.feedUrl.getValue();
Ext.Ajax.request({
url: 'feed-proxy.php',
params: {feed: url, isNew: 1},
success: this.validateFeed,
failure: this.markInvalid,
scope: this,
feedUrl: url
});
},
goLogin: function() {
Ext.MessageBox.confirm('Confirm', '시리니넷에 로그인하지 않은 상태입니다.
'+
'이 상태에서 RSS추가시 리더기가 계속 기억하지 않습니다.
계속 기억하도록 먼저 시리니넷에 로그인 하시겠습니까?
(※ Yes 를 클릭하시면 sirini.net 으로 페이지가 완전히 이동됩니다.)',
function(btn) {
if(btn == "yes") location.href = 'http://sirini.net';
});
},
markInvalid : function(){
this.feedUrl.markInvalid('입력하신 주소는 RSS 피드 주소가 아닙니다.');
this.el.unmask();
},
validateFeed : function(response, options){
var dq = Ext.DomQuery;
var url = options.feedUrl;
try{
var xml = response.responseXML;
var channel = xml.getElementsByTagName('channel')[0];
if(channel){
var text = dq.selectValue('title', channel, url);
var description = dq.selectValue('description', channel, 'No description available.');
this.el.unmask();
this.hide();
return this.fireEvent('validfeed', {
url: url,
text: text,
description: description
});
}
}catch(e){
}
this.markInvalid();
}
});