Sunday, August 5, 2012

Chrome? GTFO


jQuery

So I changed templates, and that caused jQuery to disappear. Fortunately, adding it again is of course as easy as changing templates was, all I did was load up the template source and add the following line right after the opening tag:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>

At first I added it right before the closing body tag as I read somewhere that was considered best practice, but that obviously didn't work since the scripts I add in each post are executed before the browser reaches that point. So if I want to be able to put jQuery in my posts, I have to load it somewhere before the element with the id "main", which is where Google puts posts (I think).

Having Google host jQuery makes life so much easier. I only wonder if getting underscore.js will be as simple; because I don't think Google hosts that too.

CSS shit

Yeah, right now I'm working on a pretty shitty problem. I'm trying to make the style for a block of code that I can use here in this blog. However, the overflow-x property doesn't seem to be working correctly. I try to set it to overflow-x: auto, but it still breaks the text. Here is the style (in the code block itself):

.code { font-family: courier; font-size: 10pt; background-color: #ffa; max-width: 40em; max-height: 20em; overflow-x: auto; white-space: pre; margin: 0 auto; }

And here is a test that shows it breaks lines (the text is a single line which contains no linebreaks):

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

scripttest

Something on this blog uses jQuery, because I certainly didn't load it. Maybe I'll inspect the source and see if I can spot where it comes from. I wish underscore.js was here as well though, I love that library. Although it isn't too important for a small test like this. Underscore is more useful at work, where we deal with tables and lists of dicts and lists and objects and so on.

$(document).ready(function() { var lbls = ['btn', 'hei', 'lol', 'lel', ':3', ';)', 'rofl']; $('#testBtn').on('click', function(ev) { var curr = parseInt($(ev.target).attr('data-lbl-id'), 10); var next = curr < lbls.length - 1 ? curr + 1 : 0; $(ev.target).html(lbls[next]); $(ev.target).attr('data-lbl-id', next); alert('you pressed the ' + lbls[curr] + ' button'); }); });