Skip to content

Commit

Permalink
added modules static divs, turned off other thing
Browse files Browse the repository at this point in the history
  • Loading branch information
Collins committed Jun 10, 2015
1 parent a7c2725 commit 31348eb
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 34 deletions.
Binary file added images/facebook-blk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/twitter-blk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 50 additions & 29 deletions scripts/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var originalArticle;
var loadTime = new Date();
var baseUrl = "http://sites.localhost/code";
var modules;

// local storage stuff
(function() {
Expand All @@ -26,94 +27,114 @@ var baseUrl = "http://sites.localhost/code";

// insert modules
(function() {
var modules = [
modules = [
{
"name": "certificate",
"string": null
"string": null,
"tweet": "Something something click this interactive"
},
{
"name": "circuit",
"string": "A computer is a clock with benefits"
"string": "A computer is a clock with benefits",
"tweet": "Something something click this interactive"
},
{
"name": "crapplets",
"string": "soon called “crapplets”"
"string": "soon called “crapplets”",
"tweet": ""
},
{
"name": "debug",
"string": "I felt that each time the program crashed"
"string": "I felt that each time the program crashed",
"tweet": "Something something click this interactive"
},
{
"name": "gcd",
"string": "Euclid’s algorithm, for example"
"string": "Euclid’s algorithm, for example",
"tweet": ""
},
{
"name": "grabbag",
// "string": "standard library has functions"
"string": "standard library has functions",
"tweet": "Something something click this interactive"
},
{
"name": "keyboard",
"string": "strike a key on your keyboard"
"string": "strike a key on your keyboard",
"tweet": "Something something click this interactive"
},
{
"name": "languages",
"string": null
"string": null,
"tweet": ""
},
{
"name": "learninal",
"string": "Programming as a career can lead to a rewarding"
"string": "Programming as a career can lead to a rewarding",
"tweet": "Something something click this interactive"
},
{
"name": "livehtml",
"string": "To gather an e-mail address and a name"
"string": "To gather an e-mail address and a name",
"tweet": "Something something click this interactive"
},
{
"name": "maps",
"string": "By the time a language breaks through to the top 10 or 20",
"tweet": ""
},
// {
// "name": "maps",
// "string": "By the time a language breaks through to the top 10 or 20"
// },
{
"name": "mouse",
"string": "A mouse moves"
"string": "A mouse moves",
"tweet": ""
},
{
"name": "paperclip",
"string": null
"string": null,
"tweet": ""
},
{
"name": "paulbot",
"string": null
"string": null,
"tweet": ""
},
{
"name": "recirc",
"string": null
"string": null,
"tweet": ""
},
{
"name": "shoppingcart",
"string": null
"string": null,
"tweet": ""
},
{
"name": "text-diff",
"string": "In my opinion, version control"
"string": "In my opinion, version control",
"tweet": ""
},
{
"name": "tinder",
"string": "even if the code starts to look ugly"
"string": "even if the code starts to look ugly",
"tweet": "Something something click this interactive"
},
{
"name": "toc",
"string": null
"string": null,
"tweet": ""
},
{
"name": "tree",
"string": "Arbor Day"
"string": "Arbor Day",
"tweet": "Something something click this interactive"
}
];

modules.forEach(function(value, index) {
if(!value.string) return;
if($('[data-module="'+value.name+'"]').length !== 0) return;
$('p:contains("'+value.string+'")').after('<div data-module="'+value.name+'"></div>');
})
// modules.forEach(function(value, index) {
// if(!value.string) return;
// if($('[data-module="'+value.name+'"]').length !== 0) return;
// $('p:contains("'+value.string+'")').after('<div data-module="'+value.name+'"></div>');
// })
})();

jQuery(document).ready(function($) {
Expand Down
26 changes: 21 additions & 5 deletions scripts/share.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
function initShare() {
function initInnerShare() {
if (isTerminal) return

var fbInitialized = false;

var moduleid = "";
var codeurl = "http://www.bloomberg.com/graphics/2015-paul-ford-what-is-code/";
var codetext = "";

modules.forEach(function(module) {
if (module.tweet.length > 0) {
var codeShareDiv = d3.select("[data-module='"+module.name+"']").append("div.innsershare").attr("id","share-"+module.name);
var codeShareFb = codeShareDiv.append("div.facebook");
var codeShareTw = codeShareDiv.append("div.twitter");
}
});

var moduleByName = d3.nest()
.key(function(d){ return d.name })
.map(modules);

function shareData() {
var metaTags=document.getElementsByTagName("meta");
var data = {
Expand Down Expand Up @@ -41,11 +57,11 @@ function initShare() {
var that = {

assignButtons: function() {
Array.prototype.forEach.call(document.querySelectorAll('.share.link.facebook, #header-icon-fb'), function(el){
Array.prototype.forEach.call(document.querySelectorAll('.innershare.link.facebook'), function(el){
el.addEventListener('click', that.postToFacebook)
});

Array.prototype.forEach.call(document.querySelectorAll('.share.link.twitter, #header-icon-twitter'), function(el){
Array.prototype.forEach.call(document.querySelectorAll('.innershare.link.twitter'), function(el){
el.addEventListener('click', that.postToTwitter)
});

Expand All @@ -67,7 +83,7 @@ function initShare() {
postToFacebook: function() {
event.preventDefault()

var data = shareData();
// var data = shareData();
var link = (typeof purl=="string")? encodeURIComponent(purl) : encodeURIComponent(data.url);
var width = 570,
height = 620,
Expand Down Expand Up @@ -95,7 +111,7 @@ function initShare() {
postToTwitter: function() {
event.preventDefault()

var data = shareData();
// var data = shareData();
var tweetUrl = "https://twitter.com/share?url=" + encodeURIComponent(data.url) + "&text=" + encodeURIComponent(data.longTitle);
var opts = that.centerPopup(820, 440) + "scrollbars=1";
track("Twitter");
Expand Down

0 comments on commit 31348eb

Please sign in to comment.