Resize

JS$RESIZE (JS)



/* Copyright Jürgen Reule 2010-2023 */
   
function error() {
  return true;
}
function resizeImage() {
   
    w =  image2.width;
    h =  image2.height;
   
    if  (w > 31
    &&   h > 31) {
         maxWidth  = 0;
         maxWidth2 = 0;
         resizeImage2();
    }
    else resizeTimeout =
     window.setTimeout('resizeImage()', 1);
}
function resizeImage2() {
   
         window.onorientationchange = resizeImage2;
         window.clearTimeout(resizeTimeout);
         resizeImage3(2000);
}
function resizeImage3(count) {
   
    if (count <= 0) return;
   
    maxWidthConst  = 664;
    maxWidth       = windowWidth() - 36;
   
    if (!isTouch())  maxWidth =
                     maxWidth - 12;
   
    if (maxWidth   > maxWidthConst)
        maxWidth   = maxWidthConst;
   
    if (maxWidth2 != maxWidth) {
        maxWidth2  = maxWidth;
   
        w = image2.width;  w1 = w;
        h = image2.height; h1 = h;
   
        if (w1 > maxWidth) {
            w1 = maxWidth;
            h1 = maxWidth * h/w;
        }
        if (image1.style) {
            image1.style.width = '';
            image1.style.height = '';
            image1.style.maxWidth = '';
            image1.style.maxHeight = '';
        }
        image1.width  = Math.round(w1);
        image1.height = Math.round(h1);
   
    if (image1.src != image2.src)
        image1.src  = image2.src;
    }
    if (isTouch())  count--;
    resizeTimeout = window.setTimeout('resizeImage3('+count+')', 1);
}
function isTouch() {
   
 return (navigator.userAgent.indexOf('Mobile') >= 0
     ||  navigator.userAgent.indexOf('Android') >= 0
     ||  navigator.userAgent.indexOf('PlayBook') >= 0
     ||  navigator.userAgent.indexOf('BlackBerry') >= 0
     ||  navigator.userAgent.indexOf('Opera Mobi') >= 0
     ||  navigator.userAgent.indexOf('Opera Mini') >= 0
     ||  navigator.userAgent.indexOf('IEMobile') >= 0
     ||  navigator.userAgent.indexOf('Tablet') >= 0
     ||  navigator.userAgent.indexOf('Phone') >= 0
     ||  navigator.userAgent.indexOf('iPhone') >= 0
     ||  navigator.userAgent.indexOf('iPod') >= 0
     ||  navigator.userAgent.indexOf('iPad') >= 0
     ||  navigator.userAgent.indexOf('webOS') >= 0
     ||  navigator.userAgent.indexOf('wOS') >= 0);
}
function windowWidth() {
   
     if (window.innerWidth)
  return window.innerWidth;
   
     if (document.body
     &&  document.body.clientWidth)
  return document.body.clientWidth;
   
     if (document.documentElement
     &&  document.documentElement.clientWidth)
  return document.documentElement.clientWidth;
   
  return 0;
}
function windowHeight() {
   
     if (window.innerHeight)
  return window.innerHeight;
   
     if (document.body
     &&  document.body.clientHeight)
  return document.body.clientHeight;
   
     if (document.documentElement
     &&  document.documentElement.clientHeight)
  return document.documentElement.clientHeight;
   
  return 0;
}
window.onerror = error;
   
if (document.images
&&  document.getElementById) {
   
    if (navigator.userAgent.indexOf('iCab') >= 0
    ||  navigator.userAgent.indexOf('MSIE') >= 0
    ||  navigator.userAgent.indexOf('NetFront/') >= 0) {
   
        if (document.getElementById
        &&  document.getElementById('resize')
        &&  document.getElementById('resize').src)
scriptsrc = document.getElementById('resize').src;
   
        scriptname = scriptsrc.substring(0,
                     scriptsrc.lastIndexOf('.js'));
   
        wayback    = scriptname.indexOf('js_'); if (wayback >= 0)
        scriptname = scriptname.substring(0,wayback) + 'im_' +
                     scriptname.substring(3+wayback);
   
                 if (scriptname) {
   
                     image1 = document.images[document.images.length-1];
                     image2 = new Image();
   
                     if (typeof(image2.width) == 'number') {
   
                          image2.src = image1.src;
                          image1.src = scriptname + '.gif';
                          image1.width = 0;
                          image1.height = 0;
                     }
                     else image2 = image1;
   
                     resizeTimeout =
                 window.setTimeout('resizeImage()', 100);
                 }
    }
}

83 ms | Kontakt | Information | Aibo-Bar © 2005-2024