extension = "php"; finalExtension = "jpeg"; ///////////////////////////////////////////////// ///////////////////////////////////////////////// loadedText = "0.00"; ///////////////////////////////////////////////// ///////////////////////////////////////////////// sizex = 180; sizey = 180; square = 250000; paletteColors = 255; hue = 0; saturation = 255; lightness = 127; selectedColor = new Array( ); selectedColor.r = 255; selectedColor.g = 0; selectedColor.b = 0; clickOffsetLeft = 0; clickOffsetTop = 0; function scrollpos(dir){ if (dir=="left") return (window.pageXOffset)? pageXOffset : document.compatMode && document.compatMode!="BackCompat"? document.documentElement.scrollLeft : document.body.scrollLeft else return (window.pageYOffset)? pageYOffset : document.compatMode && document.compatMode!="BackCompat"? document.documentElement.scrollTop : document.body.scrollTop } function Action (e) { if(!e) e = window.event; obj = e.target || e.srcElement; var way; clickedColorbox ( obj ); ///////////////////////////////////////////////// ///////////////////////////////////////////////// if ( obj.id == "png" ) { if( obj.checked ) { finalExtension = "png"; } } if ( obj.id == "jpg" ) { if( obj.checked ) { finalExtension = "jpeg"; } } ///////////////////////////////////////////////// ///////////////////////////////////////////////// if ( obj.id.substr( 0, 1 ) == "c" ) { if( parseInt( obj.id.substr( 1 ) ) > 0 ) { choosenColor = parseInt( obj.id.substr( 1 ) ); setColorboxBorder ( choosenColor ); } } if ( obj.id == "palette1" ){ var palOff = getOffset( getobj( "palette1" ) ); clickx = e.clientX - palOff.offsetLeft + scrollpos("left") + 1 - clickOffsetLeft; clicky = e.clientY - palOff.offsetTop + scrollpos("top") + 1 - clickOffsetTop; //alert(e.clientX+" "+palOff.offsetLeft + " "+scrollpos("left") + " "+clickOffsetLeft) if( clickx < 0 ) clickOffsetLeft += clickx; if( clicky < 0 ) clickOffsetTop += clicky; clickx = e.clientX - palOff.offsetLeft + scrollpos("left") + 1 - clickOffsetLeft; clicky = e.clientY - palOff.offsetTop + scrollpos("top") + 1 - clickOffsetTop; //alert(clickx+" "+clicky) //alert(e.clientX+" "+palOff.offsetLeft + " "+scrollpos("left") + " "+clickOffsetLeft) hue = ( clickx / sizex ) * paletteColors; saturation = ( 1 - clicky / sizey ) * paletteColors; selectedColor = getColor( hue, saturation, lightness ); refreshSubPalette ( hue, saturation ); refreshValues ( choosenColor ); refreshPreview ( 0 ); changeColorboxBackground( choosenColor ); } } function subAction (e) { if(!e) e = window.event; var palOff = getOffset( getobj( "palette2" ) ); clickz = e.clientX - palOff.offsetLeft + scrollpos("left") + 1 - clickOffsetLeft; if( clickz < 0 ) clickOffsetLeft += clickz; clickz = e.clientX - palOff.offsetLeft + scrollpos("left") + 1 - clickOffsetLeft; lightness = ( 1 - clickz / sizex ) * paletteColors; selectedColor = getColor( hue, saturation, lightness ); refreshValues ( choosenColor ); refreshPreview ( 0 ); changeColorboxBackground( choosenColor ); } function refreshSubPalette( hue, saturation ) { getobj( "palette2" ).src = "images/palette.php?hue=" + hue + "&saturation=" + saturation + "&rn=" + Math.random( ); } function clickedColorbox ( obj ) { if ( obj.id.substr ( 0, obj.id.length - 1 ) == "colorbox" ) { choosenColor = obj.id.substr ( obj.id.length - 1 ); } setColorboxBorder ( choosenColor ); } function setColor ( choosenColor, str ) { if ( choosenColor > -1 ) getobj( 'c' + choosenColor ).value = str; } function getColor( hue, saturation, lightness ) { currCol = new Array( ); col = new Array(); col[0] = Array(255,0,0); col[1] = Array(255,255,0); col[2] = Array(0,255,0); col[3] = Array(0,255,255); col[4] = Array(0,0,255); col[5] = Array(255,0,255); col[6] = Array(255,0,0); var size = Math.round( paletteColors / 6 ); var white = paletteColors; var gray = Math.round( paletteColors / 2 ); var black = 0; currentPart = Math.floor( hue / size ); currentOffset = hue - currentPart * size; currCol.r = Math.round( col[ currentPart ][ 0 ] * ( 1 - currentOffset / size ) + col[ currentPart + 1 ][0] * ( currentOffset / size ) ); currCol.g = Math.round( col[ currentPart ][ 1 ] * ( 1 - currentOffset / size ) + col[ currentPart + 1 ][1] * ( currentOffset / size ) ); currCol.b = Math.round( col[ currentPart ][ 2 ] * ( 1 - currentOffset / size ) + col[ currentPart + 1 ][2] * ( currentOffset / size ) ); currCol.r = Math.round( currCol.r * ( saturation / paletteColors ) + gray * ( 1 - saturation / paletteColors ) ); currCol.g = Math.round( currCol.g * ( saturation / paletteColors ) + gray * ( 1 - saturation / paletteColors ) ); currCol.b = Math.round( currCol.b * ( saturation / paletteColors ) + gray * ( 1 - saturation / paletteColors ) ); if( lightness > 128 ) { var light = lightness - 128 currCol.r = Math.round( currCol.r * ( 1 - 2 * light / paletteColors ) + white * ( 2 * light / paletteColors ) ); currCol.g = Math.round( currCol.g * ( 1 - 2 * light / paletteColors ) + white * ( 2 * light / paletteColors ) ); currCol.b = Math.round( currCol.b * ( 1 - 2 * light / paletteColors ) + white * ( 2 * light / paletteColors ) ); } else { currCol.r = Math.round( currCol.r * ( 2 * lightness / paletteColors ) + black * ( 1 - 2 * lightness / paletteColors ) ); currCol.g = Math.round( currCol.g * ( 2 * lightness / paletteColors ) + black * ( 1 - 2 * lightness / paletteColors ) ); currCol.b = Math.round( currCol.b * ( 2 * lightness / paletteColors ) + black * ( 1 - 2 * lightness / paletteColors ) ); } return currCol; } function setColorboxBorder ( choosenColor ) { for ( var i = 1; i < 5; i++ ) { getobj( 'colorbox' + i ).style.border = "1px #000 solid"; } getobj( 'colorbox' + choosenColor ).style.border = "1px #f00 solid"; } getobj = function ( objName ) { return document.getElementById( objName ); } function changeColorboxBackground( ) { for ( var i = 1; i < 5; i++ ) { getobj( 'colorbox' + i ).style.backgroundColor = "#" + getobj( 'c' + i ).value; getobj( 'colorbox' + i ).style.color = "#" + getobj( 'c' + i ).value; } } var pageunloaded; //CUSTOM CODE function refreshPreview( newWindow ) { if( newWindow ) { w = getobj( 'x' ).value; h = getobj( 'y' ).value; } else { w = 100; h = 100; } string = "gradient." + extension + "?label=745b52404f494759575f&way=" + gradType + "&x=" + w + "&y=" + h + "&c1=" + getobj('c1').value + "&c2=" + getobj('c2').value + "&c3=" + getobj('c3').value + "&c4=" + getobj('c4').value+ "&e=.jpg"; ////////////////////////////////////////////// ////////////////////////////////////////////// //str2 = "image.php?label=745b52404f494759575f&way=" + gradType + "&x=" + w + "&y=" + h + "&c1=" + c1.value + "&c2=" + c2.value + "&c3=" + c3.value + "&c4=" + c4.value+ "&e=.jpg&ext=" + finalExtension; if( newWindow ) { if( typeof wind == "undefined" || wind.closed == true || pageunloaded==1) { pageunloaded=0; wind = window.open( "image.php" , "wind" ); } code = 'if( typeof wind != "undefined" && !wind.closed ) {'; code += 'if( wind.document.getElementById( "GradientImage" ) ) {'; code += ' wind.document.getElementById( "GradientImage" ).src = "' + string + '&ext=' + finalExtension + '";'; code += ' wind.document.getElementById( "GradientImageType" ).innerHTML = "' + finalExtension + '";'; code += ' loadText( string + "&included=yes&ext=' + finalExtension + '" );'; code += ' clearInterval( refresher ); '; code += ' } '; code += '} else {'; code += 'clearInterval( refresher );'; code += '}'; refresher = setInterval( code, 500 ); ///////////////////////////////////////////////// ///////////////////////////////////////////////// } else { getobj('image').src = string + "&ext=jpeg"; } } function refreshValues( choosenColor ) { var base = "0123456789ABCDEF"; red = '' + base.charAt( Math.floor( selectedColor.r / 16 ) ) + base.charAt( selectedColor.r - Math.floor( selectedColor.r / 16 ) * 16 ); green = '' + base.charAt( Math.floor( selectedColor.g / 16 ) ) + base.charAt( selectedColor.g - Math.floor( selectedColor.g / 16 ) * 16 ); blue = '' + base.charAt( Math.floor( selectedColor.b / 16 ) ) + base.charAt( selectedColor.b - Math.floor( selectedColor.b / 16 ) * 16 ); setColor ( choosenColor, red + green + blue ); } function keyAction( e ) { if(!e) e = window.event; obj = e.target || e.srcElement; if (obj.tagName!="INPUT") return if( obj.id.substr( 0, 1 ) == "c" ) { choosenColor = obj.id.substr ( obj.id.length - 1 ); setColorboxBorder ( choosenColor ); if( obj.value.length == 6 ) { try { changeColorboxBackground( choosenColor ); refreshPreview( 0 ); } catch( err ) { obj.value = "000000"; } } } } function getFullSized( ) { refreshPreview( 1 ); } function bottompairtoogle(num){ //CUSTOM FUCTION TO TOOGLE VISIBILITY OF BOTTOM PAIR FIELDS var showorhide=(num==3)? "visible" : "hidden" document.getElementById("bottompair1").style.visibility=showorhide document.getElementById("bottompair2").style.visibility=showorhide } function setWay ( num ) { bottompairtoogle(num) gradType = num; for( var colNumber = 1; colNumber <= 4; colNumber++ ) { for( var wayNumber = 1; wayNumber <= 3; wayNumber++ ) { objId = "c" + colNumber + "way" + wayNumber; getobj( objId ).style.display = "none"; } objId = "c" + colNumber + "way" + num; getobj( objId ).style.display = "block"; } refreshPreview ( 0 ); } function getOffset( obj ) { if( typeof obj != "object" ) return 0; var offsetX = 0; var offsetY = 0; var tmpObj = obj; var customoffset=document.all && !window.opera? obj.parentNode : obj.offsetParent; while(customoffset) { offsetX += obj.offsetLeft; offsetY += obj.offsetTop; obj = document.all && !window.opera? obj.parentNode : obj.offsetParent; customoffset=document.all && !window.opera? obj.parentNode : obj.offsetParent; } var tmp = new Array( ); tmp [ 'offsetLeft' ] = offsetX; tmp [ 'offsetTop' ] = offsetY; return tmp; } //////////////////////////////////////////// //////////////////////////////////////////// bridge = 0; /* function loadText( locat ) { if( window.ActiveXObject ) { bridge = new ActiveXObject( "Microsoft.XMLHTTP" ); } if( window.XMLHttpRequest ) { bridge = new window.XMLHttpRequest; } try { bridge.onreadystatechange = parseResponse; bridge.open( "GET", locat, true ); bridge.send( 0 ); } catch( err ) { } } */ function loadText(locat) { if (window.XMLHttpRequest) // if Mozilla, Safari etc bridge = new XMLHttpRequest() else if (window.ActiveXObject){ // if IE try { bridge = new ActiveXObject("Msxml2.XMLHTTP") } catch (e){ try{ bridge = new ActiveXObject("Microsoft.XMLHTTP") } catch (e){} } } else return false bridge.onreadystatechange = parseResponse; bridge.open('GET', locat, true) //get page synchronously bridge.send(0) } function parseResponse( ) { try { if( bridge.readyState == 4 ) { if( bridge.status == 200 ) { loadedText = bridge.responseText; wind.document.getElementById( "GradientImageSize" ).innerHTML = loadedText; } } } catch( err ) { } } //////////////////////////////////////////// //////////////////////////////////////////// choosenColor = 1; gradType = 1; setColorboxBorder ( choosenColor ); changeColorboxBackground( ); setWay ( 1 ); getobj( "Start" ).onclick = getFullSized; getobj( "palette2" ).onclick = subAction; document.body.onclick = Action; document.body.onkeyup = keyAction;