Menu

#125 Lesser Code, Faster Xoops

open
nobody
None
5
2012-09-25
2005-08-22
No

Xoops code: class/xoopsform/formdhtmltextarea.php (107-116)

I saw the generated code for color selection drop-down;
it is more than 19KB. See
http://xoops.biz/color/colors1.html

I changed the code by moving the looping logic to
client side; it is now less than 1KB. See
http://xoops.biz/color/colors2.html

See if you can take advantage of browser's CPU as well.

Cheers,

Discussion

  • wtravel

    wtravel - 2005-08-29

    Logged In: YES
    user_id=1099558

    http://xoops.biz/color/colors2.html does not work well in
    Firefox 1.06

    Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10)
    Gecko/20050716 Firefox/1.0.6

    All I see on pull down is the option "COLOR".

    Best wishes,

    Martijn

     
  • Sudhaker Raj

    Sudhaker Raj - 2005-08-30

    Logged In: YES
    user_id=635765

    Please check again. It was more than a year I did any JS work.

    Thanks,

     
  • Sudhaker Raj

    Sudhaker Raj - 2005-08-30

    Logged In: YES
    user_id=635765

    Don't forget to clear the CACHE.

     
  • wtravel

    wtravel - 2005-08-31

    Logged In: YES
    user_id=1099558

    It is working well now on my Firefox 1.06 and on my IE as
    well :-)

     
  • Skalpa Keo

    Skalpa Keo - 2005-09-21

    Logged In: YES
    user_id=882380

    Thanks :-)
    To be added during 2.3.x / 2.4.x development (which should
    start soon)
    Moved to "patches"

    var makeColorSelector = function(colorS) {
    var colorMap = ["00", "33", "66", "99", "CC", "FF"];
    for (var colorR = 0; colorR < colorMap.length; ++colorR) {
    for (var colorG = 0; colorG < colorMap.length; ++colorG) {
    for (var colorB = 0; colorB < colorMap.length; ++colorB) {
    var colorV = "#" + colorMap[colorR] +
    colorMap[colorG] + colorMap[colorB];
    // process color
    var colorO = document.createElement("OPTION");
    colorO.text = colorO.value = colorV;
    colorO.style.color = colorO.style.backgroundColor =
    colorV;
    colorS.options[colorS.length] = colorO;
    }
    }
    }
    };

     

Log in to post a comment.