Skip to content
This repository
Browse code

change to uglifyjs #3

  • Loading branch information...
commit c685b2204663dc30aba0eb3eac07b5a8883df794 1 parent 5ce5128
Haoliang Gao authored
2  Makefile
@@ -8,7 +8,7 @@ cat:
8 8
 	@echo "combine complete `pwd`/share.js"
9 9
 
10 10
 compile:
11  
-	@java -jar tools/compiler.jar --js share.js --js_output_file share.min.js
  11
+	@./node_modules/.bin/uglifyjs -o share.min.js share.js
12 12
 	@echo "compile complete `pwd`/share.min.js"
13 13
 
14 14
 server:
1  package.json
@@ -14,6 +14,7 @@
14 14
     },
15 15
     "devDependencies": {
16 16
         "swig": "*",
  17
+        "uglify-js": "*",
17 18
         "consolidate": "*",
18 19
         "mocha": "*",
19 20
         "mocha-phantomjs": "*",
6  share.min.js
... ...
@@ -1,5 +1 @@
1  
-(function(a){function j(b,d){if(h)$.each(b,d);else if(b&&b.length)for(var k=0,e=b.length;k<e;k++)d(k,b[k])}if(!a.Share){var h="undefined"!==typeof $&&$===jQuery,m=["service","title","url","pic"],g=a.Share={init:function(b,d){j(b,function(b,e){var i,a={};j(m,function(b,d){var c=e.getAttribute("data-"+d);c&&(a[d]=c)});i=a;var c=i;if(h)i=$.extend({},d,c);else{var l={},f;for(f in d)d.hasOwnProperty(f)&&(l[f]=d[f]);for(f in c)c.hasOwnProperty(f)&&(l[f]=c[f]);i=l}c=function(){window.open(g.parser(i.service,
2  
-i))};if(h)$(e).on("click",c);else e.addEventListener?e.addEventListener("click",c,!1):e.attachEvent&&e.attachEvent("onclick",c)})}};h&&($.fn.share=function(b){g.init(this,b)})}})(this);
3  
-(function(a){function j(a,g){var b=h[a];g||(g={});if(!a)throw Error("Should specify serviceId");if(!b)throw Error('"'+a+'" do not exist');return b.replace(/{{(.*?)}}/g,function(b,a){return g[a]?encodeURIComponent(g[a]):""})}var h={douban:"http://shuo.douban.com/!service/share?name={{title}}&href={{url}}&image={{pic}}",facebook:"http://www.facebook.com/sharer.php?t={{title}}&u={{url}}",kaixin:"http://www.kaixin001.com/repaste/bshare.php?rtitle={{title}}&rurl={{url}}",netease:"http://t.163.com/article/user/checkLogin.do?info={{title}}",
4  
-qq_t:"http://v.t.qq.com/share/share.php?title={{title}}&url={{url}}&pic={{pic}}",qq_zone:"http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?title={{title}}&url={{url}}&pics={{pic}}",renren:"http://share.renren.com/share/buttonshare.do?title={{title}}&link={{url}}",sina:"http://v.t.sina.com.cn/share/share.php?title={{title}}&url={{url}}&pic={{pic}}",twitter:"https://twitter.com/intent/tweet?text={{title}}&url={{url}}",sohu:"http://t.sohu.com/third/post.jsp?title={{title}}&url={{url}}&content=utf-8"};
5  
-"undefined"!==typeof module&&module.exports&&(module.exports=j);a.Share&&(a.Share.parser=j)})(this);
  1
+(function(global){if(global.Share)return;var supportJquery=typeof $!=="undefined"&&$===jQuery,supportParam=["service","title","url","pic"];var Share=global.Share={init:function(DOMList,options){each(DOMList,function(i,o){var data=getData(o);data=mix(options,data);bindEvent(o,"click",function(e){window.open(Share.parser(data.service,data))})})}};function each(arr,callback){if(supportJquery){$.each(arr,callback)}else{if(arr&&arr.length){for(var i=0,l=arr.length;i<l;i++){callback(i,arr[i])}}}}function mix(target,object){if(supportJquery){return $.extend({},target,object)}else{var t={};for(var i in target){if(target.hasOwnProperty(i)){t[i]=target[i]}}for(var i in object){if(object.hasOwnProperty(i)){t[i]=object[i]}}return t}}function getData(obj){var data={};each(supportParam,function(i,o){var a=obj.getAttribute("data-"+o);if(a)data[o]=a});return data}function bindEvent(elem,type,handler){if(supportJquery){$(elem).on(type,handler)}else{if(elem.addEventListener){elem.addEventListener(type,handler,false)}else if(elem.attachEvent){elem.attachEvent("on"+type,handler)}}}if(supportJquery){$.fn.share=function(options){Share.init(this,options)}}})(this);(function(global){var services={douban:"http://shuo.douban.com/!service/share?name={{title}}&href={{url}}&image={{pic}}",facebook:"http://www.facebook.com/sharer.php?t={{title}}&u={{url}}",kaixin:"http://www.kaixin001.com/repaste/bshare.php?rtitle={{title}}&rurl={{url}}",netease:"http://t.163.com/article/user/checkLogin.do?info={{title}}",qq_t:"http://v.t.qq.com/share/share.php?title={{title}}&url={{url}}&pic={{pic}}",qq_zone:"http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?title={{title}}&url={{url}}&pics={{pic}}",renren:"http://share.renren.com/share/buttonshare.do?title={{title}}&link={{url}}",sina:"http://v.t.sina.com.cn/share/share.php?title={{title}}&url={{url}}&pic={{pic}}",twitter:"https://twitter.com/intent/tweet?text={{title}}&url={{url}}",sohu:"http://t.sohu.com/third/post.jsp?title={{title}}&url={{url}}&content=utf-8"};function parser(serviceId,option){var service=services[serviceId];option||(option={});if(!serviceId){throw new Error("Should specify serviceId")}if(!service){throw new Error('"'+serviceId+'" do not exist')}return service.replace(/{{(.*?)}}/g,function(a,m){return option[m]?encodeURIComponent(option[m]):""})}if(typeof module!=="undefined"&&module.exports){module.exports=parser}if(global.Share){global.Share.parser=parser}})(this);
BIN  tools/compiler.jar
Binary file not shown

0 notes on commit c685b22

Please sign in to comment.
Something went wrong with that request. Please try again.