Monday, January 7, 2013

Problem with code

So it's 2:30am and I've been working on several parts of HC Plus. Maybe I'm just sleep-deprived but I can't seem to get this code to work:

$(document).ready(function() {
var div = $("

");
var image = $('.postbody img');
image.appendTo(div);
image.detach();
image.hide();
var button = document.createElement("input");
    button.setAttribute("type","button");
    button.setAttribute("value","Image");
    button.setAttribute("class","button2 btnlite");
    $(button).click(function (){
    $(image).toggle();
     });
div.appendTo($('.postbody'));
button.appendTo($(this));

});
On another note, the GUI for HC Plus is coming along slowly. Bit of a learning curve understanding some of these new methods and callback functions. Help from other coders is helping me to learn a lot.

I also managed to tweak the image resizer for HC Plus. new code:
// Image Resize
function imageResize(){
$('.postbody img')
for (i=0; i<$(this).length; i++) {
if ($(this).style.maxWidth >= '400' + 'px' || $(this).style == undefined)    {
    $('cssText').css($(this), "{ max-width: 500px; height: auto;}");
    $(this)[i].addEventListener('click', function(event) {
        if (event.currentTarget.style.Maxwidth == 'none')
            event.currentTarget.style.maxWidth = '400' + 'px';
            else
            event.currentTarget.style.maxWidth = 'none';    }, false);

        } 
    }
}

I'm so out of practice it's pathetic. 


No comments:

Post a Comment