Jump to content

emehrkay

Staff Alumni
  • Posts

    1,214
  • Joined

  • Last visited

Posts posted by emehrkay

  1. I need a way to take html created with a wysiwyg editor and a few options (bkg image&color etc) and be able to print it as it was defined with the editor. All css stylings are lost when the user goes to print, so my solution would be to convert that html string into a GD image. I figure this shouldnt be too difficult as long as the style is inline with the html. I figured it would be useful for others so I would try to make it a generic lib. I just need some help identifying which gd functions would be needed to do what as I have never really used it before.

     

    Here is the process that I've thought out so far, tell me if I am missing anything and help me out in some areas

     

    [*]Define Defaults -- font, font size, font color, font bkg color, and image x y

    [*]Read and parse html string

    • this step will read each html element removing the style attribute and using the applicable defintions to style the element. ie <span style="background-color: #red;">test</span> would create a red box with test as the text. If the element doesnt have one of the default settings, use the default that was defined before.
    • The result would be an array with all of the elements' types and GD rules. array(array('type'=> 'text', 'value' => 'test' 'font_color' => '#red')) etc.

    [*]convert the findings on each element to the GD equivalent

    • in this step I would have to make it follow html rules as much as possible, all block level elements are treated as such etc

    [*]save the image to disk (possible stream in the future) and discard the resource

     

    functions/methods that id need

    [*]imagettfbbox

    [*]imagefilledrectangle

    [*]imagecreatetruecolor

    [*]imagecolorallocate

    [*]gd one that loads existing images (I cannot identify this)

    [*]hex to rgb and back

    [*]add on...

     

    Any suggestions? Does this already exist? Am I in over my head? HELP!

     

    I'll make it a google code project once I get something going (well, if it proves to be of any use)

     

    Thanks

     

  2. i didnt test this, but somehting like this should be made a sticky

     

    window.onload = function(){
        //collect your elements
        var div1 = document.getElementById('div_1_id'),
        div2 = document.getElementById('div_2_id'),
        select1 = document.getElementById('select_1'),
        select2 = document.getElementById('select_2');
        
        //store your elements in an object for easy reference later
        var element_collection = {
            1: div1,
            2: div2
        }
    
        //write simple show/hide function
        //same code as zanus' except the getElementBYId function isnt called twice each time it is run
        function showHideElement(show_element){
            for(var i in element_collection){
                var show = i == show_element ? 'block' : 'none';
                
                element_collection[i].style.display = show;
            }
        
            return true; //hey
        }
        
        //add events to all of your elements. im doing this the old school way
        select1.onChange = function(){
            var value = this.value;
            
            showHideElement(value); //ta-da very easy
            
        };
    };
    

  3. Finally picked up a 3GS yesterday, just waiting for my number to be ported from my previous network. Cool phone though, from what I have played with it so far - This is the first time I have used one before. The on-screen keyboard is surprisingly easy to type on, I might even go as far as saying it's easier than my Blackberry Bold that I switched from.

     

    I've had an iphone for a year now and early on i felt that if it had an extra row of keys for easy access to {} [] - <> ., i could write programs on it.

  4. I just feel as if Macs are for trendy hipsters who care more about looking cool. Also, the "it just works" catchphrase is annoying enough to make me hate anyone who even thinks about quoting it.

     

    Yes - you!

     

    I'm 28 and I have been [[re]in|un]stalling windows on various boxes since windows 95 -- I have a lot of history with that guy. It really took me getting a mac and using it for a few months to really consider saying "it just works." Of course it isnt perfect, but it is a breeze to use, and the fact that I have *nix under the hood makes for a good day.

     

    I'm excited about the OpenCl and grand central dispatch support (both open source), cool things are happening with that tech. http://www.engadget.com/2009/09/17/snow-leopards-grand-central-dispatch-and-opencl-boost-video-enc/

     

    I am a bit biased though as this is my desk (minus the air) 72YID.jpg (taken with an iphone)

  5. Looking through some of my old threads. I actually used one for about four months earlier this year. Great machine, very very light. When I first got it, I would think that I left it places because it felt like it wasnt in my bag.

     

    It did have a industrial design flaw though -- the screen's bevel sat flush on the keyboard area. this caused it to rub against the areas around the mouse button so it would leave markings on the palm rest

     

    ----[mouse button]----

     

    --- == markings

  6. Chaining in mootools is easy when dealing with the Fx namespace.

     

    Most of the Fx classes fire with a start method, so say you're using Fx.morph you'd do

     

    instance.start({
        'height': 300px
    }).chain(function(){
        //some other action
    });
    

     

    But mootools is pretty extendible  as you can add custom events. A lot of objects have an onComplete event, so when you initialize the object, you define it

     

    var x = new Fx.morph(element, {
        onComplete: function(){
            alert('done')
        },
        onStart: function(){
            alert('starting')
        }
    });
    

     

    In regards to pure OO MooTools is vastly superior to jQuery. Like the article says -- MooTools does everything jQuery does, but jQuery cannot do everything MooTool does.

     

    There are a lot of things that I do not like about jQuery. Why are methods like css() both getters and setters? The common way to code jQuery is to keep running selector after selector instead of creating a reference and using that.

     

    My advice is to learn MooTools, jQuery is simple after that

  7. Interesting.  The following statement is wrong, however:

     

    Also, for in loop will loop over the Array Object's methods as well, avoid it for arrays

     

    As the code below works without alerting out array methods:

     

    <html>
    <head>
       <title>Blah</title>
       <script type="text/javascript">
          window.onload = function(){
             var oArray = new Array();
    
             oArray["_KEN"] = "Enter";
             oArray["_K03"] = "Exit";
             oArray["_KHL"] = "Help";
    
             for (var key in oArray){
                alert("Key value is: " + key + " Value is: " + oArray[key]);
             }
          }
       </script>
    </head>
    
    <body></body>
    
    </html>

     

    Did you try this code in ALL browsers?

  8. Nightslyr - http://andrewdupont.net/2006/05/18/javascript-associative-arrays-considered-harmful/

     

    Also, for in loop will loop over the Array Object's methods as well, avoid it for arrays

     

    geudrik - your php function makes no sense to me. When you call the function, the ids array is set to an empty array. are the arguments id and name arrays?

     

    You can easily add to a javascript array using the push() method

     

    arr.push(value)

     

    What you want to do would work better with an object literal, like I said above.

     

    var obj = {};

    obj[id] = name;

     

    //use for in on the obj

    for(id in obj){

    //id is your id

    //obj[id] is your name

    }

     

  9. Is there any software that will allow me to view the status of my script while running or after it has run. Right now I just want to see the SESSION variables without having to implicity showing them in the browser.

     

    I use xDebug to see errors when they exist and I have it set to show POST/GET, function variable states, etc. I also use macGDBP to step through the code and I also use macCallGrind for profiling.

     

    I guess what I am asking for is sort of a live stack [back]trace -- if that exists.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.