diff --git a/README.md b/README.md new file mode 100644 index 0000000..c74b125 --- /dev/null +++ b/README.md @@ -0,0 +1,37 @@ +# socialCountBadge + +## Install +``` +bower install --save socialCountBadge +``` + +Add to the index.html: +```html + + + + + +``` + +Declare the badges variable: +```html + +``` diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..7510114 --- /dev/null +++ b/bower.json @@ -0,0 +1,17 @@ +{ + "name": "socialCountBadge", + "main": "socialCountBadge.js", + "authors": [ + "arnaucode " + ], + "description": "", + "license": "MIT", + "homepage": "https://arnaucode.com", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ] +} diff --git a/img/hackernews.png b/img/hackernews.png new file mode 100644 index 0000000..364507e Binary files /dev/null and b/img/hackernews.png differ diff --git a/img/reddit.png b/img/reddit.png new file mode 100644 index 0000000..8a2aeeb Binary files /dev/null and b/img/reddit.png differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..58d25c1 --- /dev/null +++ b/index.html @@ -0,0 +1,41 @@ + + + + socialCountBadge - demo + + + + + + + +
+ + + + + + + + + + + diff --git a/socialCountBadge.css b/socialCountBadge.css new file mode 100644 index 0000000..a19753e --- /dev/null +++ b/socialCountBadge.css @@ -0,0 +1,10 @@ +.scc_badge { + border-radius: 50%; + background-color: #000; + color: #fff; + display: inline-block; + padding-left: 8px; + padding-right: 8px; + text-align: center; + margin-left: -10px; +} diff --git a/socialCountBadge.js b/socialCountBadge.js new file mode 100644 index 0000000..0fd0d5a --- /dev/null +++ b/socialCountBadge.js @@ -0,0 +1,42 @@ + + + +function get(badge) { + var result = null; + var url = badge.url; + var callback = badge.callback; + $.get(url, callback); +} + +function parseHN(data) { + console.log(data); + badges.hn.count = data.score; + dataToBadge(badges.hn); +} +function parseReddit(data) { + console.log(data); + badges.reddit.count = data[0].data.children[0].data.ups; + dataToBadge(badges.reddit); +} +function dataToBadge(badge) { + console.log(badge); + var html = ""; + html += ""; + html += ""; + html += "" + badge.count + ""; + html += " "; + document.getElementById("socialCountBadge").innerHTML += html; +} + +function socialCountBadge_init() { + //create htmk badges + + + + //get badges data + get(badges.hn) + get(badges.reddit) + +} + +var html = "";