> Hello World !!!

     

@syaku

소셜네트워크 글 내보내기 : SNS


written by Seok Kyun. Choi. 최석균

"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>



posted syaku blog

Syaku Blog by Seok Kyun. Choi. 최석균.

http://syaku.tistory.com