Skip to content

Commit

Permalink
[svn r886] DecafbadRecaffeinated: Making a snapshot checkin of tweaks…
Browse files Browse the repository at this point in the history
… made recently
  • Loading branch information
deusx committed Nov 27, 2007
1 parent efdd29d commit 1b17bb4
Show file tree
Hide file tree
Showing 9 changed files with 5,312 additions and 36 deletions.
2 changes: 2 additions & 0 deletions 00-project.txt
@@ -1,4 +1,6 @@
00-project.txt
html/js/main.js
html/js/dom.js
html/css/main.css
templates/archives-day.html
templates/archives-month.html
Expand Down
12 changes: 12 additions & 0 deletions html/css/main.css
Expand Up @@ -132,6 +132,15 @@ form .buttons .first { margin-left: 17ex; }
.skin-dev2 .hfeed .hentry a:hover.permalink-small {
background-color: #888;
}
.skin-dev2 .hfeed .hentry ul {
}
.skin-dev2 .hfeed .hentry ul li {
list-style-type: square;
margin-left: 2em;
padding-left: 1em;
padding-bottom: 0.5em;
text-indent: -1em;
}
.skin-dev2 .comments {
white-space: nowrap;
}
Expand Down Expand Up @@ -260,6 +269,9 @@ form .buttons .first { margin-left: 17ex; }
font-style: italic;
margin: 0.5em 0 0.5em 0;
}
.skin-dev2 .hfeed .entry-bookmark .entry-content ul li {
font-style: italic;
}
.skin-dev2 .hfeed .entry-code {
background-image: url(../img/developpers-icons/Terminal.png);
background-color: #ccc;
Expand Down
2 changes: 1 addition & 1 deletion html/js/dom.js
Expand Up @@ -17,7 +17,7 @@ Decafbad.DOM = (function() {
"LABEL", "TEXTAREA", "FORM", "STRONG", "SELECT", "OPTION",
"OPTGROUP", "LEGEND", "FIELDSET", "P", "UL", "OL", "LI", "DL",
"DT", "DD", "TD", "TR", "THEAD", "TBODY", "TFOOT", "TABLE", "TH",
"INPUT", "SPAN", "A", "DIV", "IMG"
"INPUT", "SPAN", "A", "DIV", "IMG", "EMBED", "PARAM"
],

/**
Expand Down
84 changes: 82 additions & 2 deletions html/js/main.js
Expand Up @@ -67,6 +67,7 @@ Decafbad.Main = (function() {
YAHOO.log("onload", "debug");

this.injectHaloscanCommentLinks();
this.injectVideoPlayers();

},

Expand All @@ -78,10 +79,45 @@ Decafbad.Main = (function() {
},

/**
*
* Find video entries in the page and inject video players where appropriate.
*/
injectHaloscanCommentLinks: function() {
injectVideoPlayers: function() {
YAHOO.log("Injecting video players...");
var entries = $D.getElementsByClassName('entry-video', 'li', 'bd');
forEach(entries, function(entry) {

var content = $D.getElementsByClassName('entry-content', '*', entry)[0];
var title = $D.getElementsByClassName('entry-title', '*', entry)[0];
var link = title.getElementsByTagName('a')[0];
var href = link.href;

if (/youtube.com/.test(href)) {

YAHOO.log("Found YouTube video at "+href);
var vid = this.parseQueryString(href)['v'];
var new_div = DIV();
content.appendChild(new_div);
new_div.innerHTML = '<object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/'+encodeURIComponent(vid)+'&rel=1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/'+encodeURIComponent(vid)+'&rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>'

} else if (/(mpg|mov)$/.test(href)) {

YAHOO.log("Found QT video at "+href);
var new_div = DIV();
content.appendChild(new_div);
new_div.innerHTML = '<OBJECT classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="455" height="355" codebase="http://www.apple.com/qtactivex/qtplugin.cab"><param name="src" value="'+href+'"><param name="autoplay" value="true"><param name="controller" value="true"><param name="loop" value="true"><EMBED src="'+href+'" width="455" height="355" autoplay="true" controller="true" loop="true" pluginspage="http://www.apple.com/quicktime/download/"></EMBED></OBJECT>';

}

// TODO: Google video, Yahoo! video, etal

}, this);
},

/**
* Find permalinks in the page and inject HaloScan comment links.
*/
injectHaloscanCommentLinks: function() {
YAHOO.log("Injecting Haloscan comment links...");
var permalinks = $D.getElementsByClassName('permalink','a','bd');
forEach(permalinks, function(permalink) {

Expand Down Expand Up @@ -137,6 +173,50 @@ Decafbad.Main = (function() {
return comment_link;
},

/**
* Accept a URL or query string and return a hash of query string vars.
* see: http://www.safalra.com/web-design/javascript/parsing-query-strings/
*/
parseQueryString: function(queryString) {

// define an object to contain the parsed query data
var result = {};

// if a query string wasn't specified, use the query string from the URI
if (queryString == undefined){
queryString = location.search ? location.search : '';
} else if (queryString.indexOf('?') != -1) {
queryString = queryString.substring(queryString.indexOf('?') + 1);
}

// remove the leading question mark from the query string if it is present
if (queryString.charAt(0) == '?') queryString = queryString.substring(1);

// replace plus signs in the query string with spaces
queryString = queryString.replace('+', ' ');

// split the query string around ampersands and semicolons
var queryComponents = queryString.split(/[&;]/g);

// loop over the query string components
for (var i = 0; i < queryComponents.length; i++){

// extract this component's key-value pair
var keyValuePair = queryComponents[i].split('=');
var key = decodeURIComponent(keyValuePair[0]);
var value = decodeURIComponent(keyValuePair[1]);

// update the parsed query data with this component's key-value pair
if (!result[key]) result[key] = [];
result[key].push((keyValuePair.length == 1) ? '' : value);

}

// return the parsed query data
return result;

},

EOF:null
};

Expand Down

0 comments on commit 1b17bb4

Please sign in to comment.