소셜네트워크 글 내보내기 : SNS
728x90
반응형

"jQuery SNS 글 내보내기"
/**
* jQuery Syaku SNS Scrap ver 1.0.0
*
* Copyright (c) Seok Kyun. Choi. 최석균
* GNU Lesser General Public License
* http://www.gnu.org/licenses/lgpl.html
*
* registered date 2013-04-17
* http://syaku.tistory.com
*/
(function(jQuery) {
jQuery.syakuSnsScrap = {
FACEBOOK_URL : 'http://www.facebook.com/sharer.php?s=100',
TWITTER_URL : 'http://twitter.com/share',
ME2DAY_URL : 'http://me2day.net/plugins/post/new',
facebook : function(options) {
options = jQuery.extend(true , {
url : location.href, // 보낼 URL
title : null, // 보낼 제목
summary : null, // 보낼 내용
image : null, // 보낼 이미지
settings : 'toolbar=0, status=0, width=600, height=400' // 새창 옵션
}, options);
var url = options.url;
var title = options.title;
var summary = options.summary;
var image = options.image;
var settings = options.settings;
var query;
query += '&p[url]='+encodeURIComponent(url);
if (title != null) {
query += '&p[title]='+encodeURIComponent(title);
}
if (summary != null) {
query += '&p[summary]='+encodeURIComponent(summary);
}
if (image != null) {
query += '&p[image][0]='+encodeURIComponent(image);
}
var new_window = window.open(this.FACEBOOK_URL + query,'syakuSnsScrapFacebook', settings);
if (window.focus) { new_window.focus(); }
},
twitter : function(options) {
options = jQuery.extend(true , {
url : location.href, // 보낼 URL
title : null, // 보낼 제목
settings : 'toolbar=0, status=0, width=600, height=400' // 새창 옵션
}, options);
var url = options.url;
var title = options.title;
var settings = options.settings;
var RAND = Math.floor(Math.random()*10);
var query = '?nocache=' + RAND;
query += '&url='+encodeURIComponent(url);
if (title != null) {
query += '&text='+encodeURIComponent(title);
}
var new_window = window.open(this.TWITTER_URL + query,'syakuSnsScrapTwitter', settings);
if (window.focus) { new_window.focus(); }
},
me2day : function(options) {
options = jQuery.extend(true , {
url : location.href, // 보낼 URL
title : null, // 보낼 제목
tag : null, // 보낼 태그
settings : 'toolbar=0, status=0, width=600, height=400' // 새창 옵션
}, options);
var url = options.url;
var title = options.title;
var tag = options.tag;
var settings = options.settings;
var query = '?new_post[body]=';
if (title != null) {
query += '"' + encodeURIComponent(title) + '"';
}
if (url != null) {
query += ':' + encodeURIComponent(url);
}
if (tag != null) {
query += '&new_post[tags]='+encodeURIComponent(tag);
}
var new_window = window.open(this.ME2DAY_URL + query,'syakuSnsScrapMe2day', settings);
if (window.focus) { new_window.focus(); }
}
}
})(jQuery);
예제)
<a href="javascript:jQuery.syakuSnsScrap.twitter({ title : 'aaaaaaaa' });">트위터</a>
<a href="javascript:jQuery.syakuSnsScrap.facebook({ title : 'aaaaaaaa' });">페이스북</a>
<a href="javascript:jQuery.syakuSnsScrap.me2day({ title : 'aaaaaaaa' });">미투데이</a>
Syaku Blog by Seok Kyun. Choi. 최석균.

728x90
반응형
'개발노트 > jQuery' 카테고리의 다른 글
| SWFUpload + CKEditor4 or SmartEditor2 멀티 업로드 그리고 파일 에디터 연동 : 스마트에디터 , 위지윅에디터 (10) | 2013.06.20 |
|---|---|
| jQuery Action (ajax 전송 컨트롤러, 유효성검사, 데이타 변경, 인터셉터 이벤트) (2) | 2013.05.25 |
| jQuery Syaku Facebook API : 자바스크립트용 페이스북 API 연동 (15) | 2011.11.02 |
| jQuery syaku rolling slide : 자동 롤링 및 슬라드 플러그인 (8) | 2011.09.04 |
