Perbezaan antara semakan-semakan "MediaWiki:Common.js"

Daripada Touhou Wiki.
Lompat ke: pandu arah, cari
(Mencipta laman baru dengan kandungan 'Sebarang JavaScript di sini akan dimuatkan untuk semua pengguna pada setiap pemuatan laman.: /*!-------------------------------------------------------...')
 
(Pembersihan kod CSS)
 
Baris 8: Baris 8:
 
-----------------------------------------------------------------------*/
 
-----------------------------------------------------------------------*/
 
var outdatedBrowser = function(options) {
 
var outdatedBrowser = function(options) {
 +
  //Variable definition (before ajax)
 +
  var outdated = document.getElementById("outdated");
  
 +
  // Default settings
 +
  this.defaultOpts = {
 +
    bgColor: '#f25648',
 +
    color: '#ffffff',
 +
    lowerThan: 'transform',
 +
    languagePath: ''
 +
  };
  
 
+
  if (options) {
     //Variable definition (before ajax)
+
     //assign css3 property to IE browser version
     var outdated = document.getElementById("outdated");
+
    if (options.lowerThan == 'IE8' || options.lowerThan == 'borderSpacing') {
 
+
      options.lowerThan = 'borderSpacing';
 
+
     } else if (options.lowerThan == 'IE9' || options.lowerThan == 'boxShadow') {
 
+
      options.lowerThan = 'boxShadow';
     // Default settings
+
     } else if (options.lowerThan == 'IE10' || options.lowerThan == 'transform' || options.lowerThan == '' || typeof options.lowerThan === "undefined") {
    this.defaultOpts = {
+
      options.lowerThan = 'transform';
        bgColor: '#f25648',
+
    } else if (options.lowerThan == 'IE11' || options.lowerThan == 'borderImage') {
        color: '#ffffff',
+
      options.lowerThan = 'borderImage';
        lowerThan: 'transform',
 
        languagePath: ''
 
 
     }
 
     }
 +
    //all properties
 +
    this.defaultOpts.bgColor = options.bgColor;
 +
    this.defaultOpts.color = options.color;
 +
    this.defaultOpts.lowerThan = options.lowerThan;
 +
    this.defaultOpts.languagePath = options.languagePath;
  
 +
    bkgColor = this.defaultOpts.bgColor;
 +
    txtColor = this.defaultOpts.color;
 +
    cssProp = this.defaultOpts.lowerThan;
 +
    languagePath = this.defaultOpts.languagePath;
 +
  } else {
 +
    bkgColor = this.defaultOpts.bgColor;
 +
    txtColor = this.defaultOpts.color;
 +
    cssProp = this.defaultOpts.lowerThan;
 +
    languagePath = this.defaultOpts.languagePath;
 +
  } //end if options
  
 +
  //Define opacity and fadeIn/fadeOut functions
 +
  var done = true;
  
    if (options) {
+
  function function_opacity(opacity_value) {
        //assign css3 property to IE browser version
+
    outdated.style.opacity = opacity_value / 100;
        if (options.lowerThan == 'IE8' || options.lowerThan == 'borderSpacing') {
+
    outdated.style.filter = 'alpha(opacity=' + opacity_value + ')';
            options.lowerThan = 'borderSpacing';
+
  }
        } else if (options.lowerThan == 'IE9' || options.lowerThan == 'boxShadow') {
 
            options.lowerThan = 'boxShadow';
 
        } else if (options.lowerThan == 'IE10' || options.lowerThan == 'transform' || options.lowerThan == '' || typeof options.lowerThan === "undefined") {
 
            options.lowerThan = 'transform';
 
        } else if (options.lowerThan == 'IE11' || options.lowerThan == 'borderImage') {
 
            options.lowerThan = 'borderImage';
 
        }
 
        //all properties
 
        this.defaultOpts.bgColor = options.bgColor;
 
        this.defaultOpts.color = options.color;
 
        this.defaultOpts.lowerThan = options.lowerThan;
 
        this.defaultOpts.languagePath = options.languagePath;
 
 
 
 
 
 
 
        bkgColor = this.defaultOpts.bgColor;
 
        txtColor = this.defaultOpts.color;
 
        cssProp = this.defaultOpts.lowerThan;
 
        languagePath = this.defaultOpts.languagePath;
 
    } else {
 
        bkgColor = this.defaultOpts.bgColor;
 
        txtColor = this.defaultOpts.color;
 
        cssProp = this.defaultOpts.lowerThan;
 
        languagePath = this.defaultOpts.languagePath;
 
    } //end if options
 
 
 
 
 
  
 +
  // function function_fade_out(opacity_value) {
 +
  //  function_opacity(opacity_value);
 +
  //  if (opacity_value == 1) {
 +
  //    outdated.style.display = 'none';
 +
  //    done = true;
 +
  //  }
 +
  // }
  
 
+
  function function_fade_in(opacity_value) {
     //Define opacity and fadeIn/fadeOut functions
+
     function_opacity(opacity_value);
    var done = true;
+
     if (opacity_value == 1) {
 
+
      outdated.style.display = 'block';
 
 
 
 
     function function_opacity(opacity_value) {
 
        outdated.style.opacity = opacity_value / 100;
 
        outdated.style.filter = 'alpha(opacity=' + opacity_value + ')';
 
 
     }
 
     }
 
+
     if (opacity_value == 100) {
 
+
      done = true;
 
 
    // function function_fade_out(opacity_value) {
 
    //    function_opacity(opacity_value);
 
    //     if (opacity_value == 1) {
 
    //        outdated.style.display = 'none';
 
    //        done = true;
 
    //    }
 
    // }
 
 
 
 
 
 
 
    function function_fade_in(opacity_value) {
 
        function_opacity(opacity_value);
 
        if (opacity_value == 1) {
 
            outdated.style.display = 'block';
 
        }
 
        if (opacity_value == 100) {
 
            done = true;
 
        }
 
 
     }
 
     }
 +
  }
  
 +
  //check if element has a particular class
 +
  // function hasClass(element, cls) {
 +
  //  return (' ' + element.className + ' ').indexOf(' ' + cls + ' ') > -1;
 +
  // }
  
 +
  var supports = ( function() {
 +
    var div = document.createElement('div');
 +
    var vendors = 'Khtml Ms O Moz Webkit'.split(' ');
 +
    var len = vendors.length;
  
     //check if element has a particular class
+
     return function(prop) {
    // function hasClass(element, cls) {
+
      if (prop in div.style) return true;
    //    return (' ' + element.className + ' ').indexOf(' ' + cls + ' ') > -1;
+
      prop = prop.replace(/^[a-z]/, function(val) {
    // }
+
        return val.toUpperCase();
 
+
      });
 
+
      while (len--) {
 
+
        if (vendors[len] + prop in div.style) {
    var supports = ( function() {
+
          return true;
        var div = document.createElement('div');
 
        var vendors = 'Khtml Ms O Moz Webkit'.split(' ');
 
        var len = vendors.length;
 
 
 
 
 
 
 
        return function(prop) {
 
            if (prop in div.style) return true;
 
 
 
 
 
 
 
            prop = prop.replace(/^[a-z]/, function(val) {
 
                return val.toUpperCase();
 
            });
 
 
 
 
 
 
 
            while (len--) {
 
                if (vendors[len] + prop in div.style) {
 
                    return true;
 
                }
 
            }
 
            return false;
 
        };
 
    } )();
 
 
 
 
 
 
 
    //if browser does not supports css3 property (transform=default), if does > exit all this
 
    if (!supports('' + cssProp + '')) {
 
        if (done && outdated.style.opacity !== '1') {
 
            done = false;
 
            for (var i = 1; i <= 100; i++) {
 
                setTimeout(( function(x) {
 
                    return function() {
 
                        function_fade_in(x);
 
                    };
 
                } )(i), i * 8);
 
            }
 
 
         }
 
         }
    } else {
+
      }
        return;
+
      return false;
     } //end if
+
     };
 +
  })();
  
 
+
  //if browser does not supports css3 property (transform=default), if does > exit all this
 
+
  if (!supports('' + cssProp + '')) {
    //Check AJAX Options: if languagePath == '' > use no Ajax way, html is needed inside <div id="outdated">
+
     if (done && outdated.style.opacity !== '1') {
     if (languagePath === ' ' || languagePath.length == 0) {
+
      done = false;
         startStylesAndEvents();
+
      for (var i = 1; i <= 100; i++) {
    } else {
+
         setTimeout(( function(x) {
         grabFile(languagePath);
+
          return function() {
 +
            function_fade_in(x);
 +
          };
 +
         } ) (i), i * 8);
 +
      }
 
     }
 
     }
 +
  } else {
 +
    return;
 +
  } //end if
  
 +
  //Check AJAX Options: if languagePath == '' > use no Ajax way, html is needed inside <div id="outdated">
 +
  if (languagePath === ' ' || languagePath.length == 0) {
 +
    startStylesAndEvents();
 +
  } else {
 +
    grabFile(languagePath);
 +
  }
  
 +
  //events and colors
 +
  function startStylesAndEvents() {
 +
    var btnClose = document.getElementById("btnCloseUpdateBrowser");
 +
    var btnUpdate = document.getElementById("btnUpdateBrowser");
  
     //events and colors
+
  //check settings attributes
     function startStylesAndEvents() {
+
     outdated.style.backgroundColor = bkgColor;
        var btnClose = document.getElementById("btnCloseUpdateBrowser");
+
  //way too hard to put !important on IE6
        var btnUpdate = document.getElementById("btnUpdateBrowser");
+
     outdated.style.color = txtColor;
 +
    outdated.children[0].style.color = txtColor;
 +
    outdated.children[1].style.color = txtColor;
  
 +
  //check settings attributes
 +
    btnUpdate.style.color = txtColor;
 +
  // btnUpdate.style.borderColor = txtColor;
 +
    if (btnUpdate.style.borderColor) {
 +
      btnUpdate.style.borderColor = txtColor;
 +
    }
 +
    btnClose.style.color = txtColor;
  
 +
  //close button
 +
    btnClose.onmousedown = function() {
 +
      outdated.style.display = 'none';
 +
      return false;
 +
    };
  
        //check settings attributes
+
  //Override the update button color to match the background color
        outdated.style.backgroundColor = bkgColor;
+
    btnUpdate.onmouseover = function() {
        //way too hard to put !important on IE6
+
      this.style.color = bkgColor;
        outdated.style.color = txtColor;
+
      this.style.backgroundColor = txtColor;
        outdated.children[0].style.color = txtColor;
+
    };
        outdated.children[1].style.color = txtColor;
+
    btnUpdate.onmouseout = function() {
 +
      this.style.color = txtColor;
 +
      this.style.backgroundColor = bkgColor;
 +
    };
 +
  } //end styles and events
  
 +
  // IF AJAX with request ERROR > insert english default
 +
  var ajaxEnglishDefault = '<h6>Pelayar internet anda sudah luput!</h6>'
 +
    + '<p>Sila kemas kini pelayar anda untuk lihat laman ini dengan tepat. <a id="btnUpdateBrowser" href="http://outdatedbrowser.com/">Kemas kini pelayar saya sekarang</a></p>'
 +
    + '<p class="last"><a href="#" id="btnCloseUpdateBrowser" title="Tutup">&times;</a></p>';
  
 
+
  //** AJAX FUNCTIONS - Bulletproof Ajax by Jeremy Keith **
        //check settings attributes
+
  function getHTTPObject() {
        btnUpdate.style.color = txtColor;
+
    var xhr = false;
        // btnUpdate.style.borderColor = txtColor;
+
    if (window.XMLHttpRequest) {
        if (btnUpdate.style.borderColor) {
+
      xhr = new XMLHttpRequest();
            btnUpdate.style.borderColor = txtColor;
+
    } else if (window.ActiveXObject) {
 +
      try {
 +
        xhr = new ActiveXObject("Msxml2.XMLHTTP");
 +
      } catch ( e ) {
 +
        try {
 +
          xhr = new ActiveXObject("Microsoft.XMLHTTP");
 +
        } catch ( e ) {
 +
          xhr = false;
 
         }
 
         }
        btnClose.style.color = txtColor;
+
      }
 
+
     }
 
+
     return xhr;
 
+
  }//end function
        //close button
 
        btnClose.onmousedown = function() {
 
            outdated.style.display = 'none';
 
            return false;
 
        };
 
 
 
 
 
 
 
        //Override the update button color to match the background color
 
        btnUpdate.onmouseover = function() {
 
            this.style.color = bkgColor;
 
            this.style.backgroundColor = txtColor;
 
        };
 
        btnUpdate.onmouseout = function() {
 
            this.style.color = txtColor;
 
            this.style.backgroundColor = bkgColor;
 
        };
 
     } //end styles and events
 
 
 
 
 
 
 
 
 
 
 
     // IF AJAX with request ERROR > insert english default
 
    var ajaxEnglishDefault = '<h6>Pelayar internet anda sudah luput!</h6>'
 
        + '<p>Sila kemas kini pelayar anda untuk lihat laman ini dengan tepat. <a id="btnUpdateBrowser" href="http://outdatedbrowser.com/">Kemas kini pelayar saya sekarang</a></p>'
 
        + '<p class="last"><a href="#" id="btnCloseUpdateBrowser" title="Tutup">&times;</a></p>';
 
 
 
 
 
 
 
 
 
 
 
    //** AJAX FUNCTIONS - Bulletproof Ajax by Jeremy Keith **
 
    function getHTTPObject() {
 
        var xhr = false;
 
        if (window.XMLHttpRequest) {
 
            xhr = new XMLHttpRequest();
 
        } else if (window.ActiveXObject) {
 
            try {
 
                xhr = new ActiveXObject("Msxml2.XMLHTTP");
 
            } catch ( e ) {
 
                try {
 
                    xhr = new ActiveXObject("Microsoft.XMLHTTP");
 
                } catch ( e ) {
 
                    xhr = false;
 
                }
 
            }
 
        }
 
        return xhr;
 
    }//end function
 
 
 
 
 
 
 
    function grabFile(file) {
 
        var request = getHTTPObject();
 
        if (request) {
 
            request.onreadystatechange = function() {
 
                displayResponse(request);
 
            };
 
            request.open("GET", file, true);
 
            request.send(null);
 
        }
 
        return false;
 
    } //end grabFile
 
 
 
 
 
 
 
    function displayResponse(request) {
 
        var insertContentHere = document.getElementById("outdated");
 
        if (request.readyState == 4) {
 
            if (request.status == 200 || request.status == 304) {
 
                insertContentHere.innerHTML = request.responseText;
 
            } else {
 
                insertContentHere.innerHTML = ajaxEnglishDefault;
 
            }
 
            startStylesAndEvents();
 
        }
 
        return false;
 
    }//end displayResponse
 
 
 
  
 +
  function grabFile(file) {
 +
    var request = getHTTPObject();
 +
    if (request) {
 +
      request.onreadystatechange = function() {
 +
        displayResponse(request);
 +
      };
 +
      request.open("GET", file, true);
 +
      request.send(null);
 +
    }
 +
    return false;
 +
  } //end grabFile
  
 +
  function displayResponse(request) {
 +
    var insertContentHere = document.getElementById("outdated");
 +
    if (request.readyState == 4) {
 +
      if (request.status == 200 || request.status == 304) {
 +
        insertContentHere.innerHTML = request.responseText;
 +
      } else {
 +
        insertContentHere.innerHTML = ajaxEnglishDefault;
 +
      }
 +
      startStylesAndEvents();
 +
    }
 +
    return false;
 +
  }//end displayResponse
 
////////END of outdatedBrowser function
 
////////END of outdatedBrowser function
 
};
 
};
Baris 270: Baris 210:
 
//event listener: DOM ready
 
//event listener: DOM ready
 
function addLoadEvent(func) {
 
function addLoadEvent(func) {
    var oldonload = window.onload;
+
  var oldonload = window.onload;
    if (typeof window.onload != 'function') {
+
  if (typeof window.onload != 'function') {
        window.onload = func;
+
    window.onload = func;
    } else {
+
  } else {
        window.onload = function() {
+
    window.onload = function() {
            if (oldonload) {
+
      if (oldonload) {
                oldonload();
+
        oldonload();
            }
+
      }
            func();
+
      func();
        }
 
 
     }
 
     }
 +
  }
 
}
 
}
 
//call plugin function after DOM ready
 
//call plugin function after DOM ready
 
addLoadEvent(function(){
 
addLoadEvent(function(){
    outdatedBrowser({
+
  outdatedBrowser({
        bgColor: '#f25648',
+
    bgColor: '#f25648',
        color: '#ffffff',
+
    color: '#ffffff',
        lowerThan: 'transform',
+
    lowerThan: 'transform',
        languagePath: ''
+
    languagePath: ''
    })
+
  })
 
});
 
});

Semakan semasa pada 04:21, 23 Mei 2018

/* Sebarang JavaScript di sini akan dimuatkan untuk semua pengguna pada setiap pemuatan laman. */
/*!--------------------------------------------------------------------
JAVASCRIPT "Outdated Browser"
Version:    1.1.2 - 2015
author:     Burocratik
website:    http://www.burocratik.com
* @preserve
-----------------------------------------------------------------------*/
var outdatedBrowser = function(options) {
  //Variable definition (before ajax)
  var outdated = document.getElementById("outdated");

  // Default settings
  this.defaultOpts = {
    bgColor: '#f25648',
    color: '#ffffff',
    lowerThan: 'transform',
    languagePath: ''
  };

  if (options) {
    //assign css3 property to IE browser version
    if (options.lowerThan == 'IE8' || options.lowerThan == 'borderSpacing') {
      options.lowerThan = 'borderSpacing';
    } else if (options.lowerThan == 'IE9' || options.lowerThan == 'boxShadow') {
      options.lowerThan = 'boxShadow';
    } else if (options.lowerThan == 'IE10' || options.lowerThan == 'transform' || options.lowerThan == '' || typeof options.lowerThan === "undefined") {
      options.lowerThan = 'transform';
    } else if (options.lowerThan == 'IE11' || options.lowerThan == 'borderImage') {
      options.lowerThan = 'borderImage';
    }
    //all properties
    this.defaultOpts.bgColor = options.bgColor;
    this.defaultOpts.color = options.color;
    this.defaultOpts.lowerThan = options.lowerThan;
    this.defaultOpts.languagePath = options.languagePath;

    bkgColor = this.defaultOpts.bgColor;
    txtColor = this.defaultOpts.color;
    cssProp = this.defaultOpts.lowerThan;
    languagePath = this.defaultOpts.languagePath;
  } else {
    bkgColor = this.defaultOpts.bgColor;
    txtColor = this.defaultOpts.color;
    cssProp = this.defaultOpts.lowerThan;
    languagePath = this.defaultOpts.languagePath;
  } //end if options

  //Define opacity and fadeIn/fadeOut functions
  var done = true;

  function function_opacity(opacity_value) {
    outdated.style.opacity = opacity_value / 100;
    outdated.style.filter = 'alpha(opacity=' + opacity_value + ')';
  }

  // function function_fade_out(opacity_value) {
  //   function_opacity(opacity_value);
  //   if (opacity_value == 1) {
  //     outdated.style.display = 'none';
  //     done = true;
  //   }
  // }

  function function_fade_in(opacity_value) {
    function_opacity(opacity_value);
    if (opacity_value == 1) {
      outdated.style.display = 'block';
    }
    if (opacity_value == 100) {
      done = true;
    }
  }

  //check if element has a particular class
  // function hasClass(element, cls) {
  //   return (' ' + element.className + ' ').indexOf(' ' + cls + ' ') > -1;
  // }

  var supports = ( function() {
    var div = document.createElement('div');
    var vendors = 'Khtml Ms O Moz Webkit'.split(' ');
    var len = vendors.length;

    return function(prop) {
      if (prop in div.style) return true;
      prop = prop.replace(/^[a-z]/, function(val) {
        return val.toUpperCase();
      });
      while (len--) {
        if (vendors[len] + prop in div.style) {
          return true;
        }
      }
      return false;
    };
  })();

  //if browser does not supports css3 property (transform=default), if does > exit all this
  if (!supports('' + cssProp + '')) {
    if (done && outdated.style.opacity !== '1') {
      done = false;
      for (var i = 1; i <= 100; i++) {
        setTimeout(( function(x) {
          return function() {
            function_fade_in(x);
          };
        } ) (i), i * 8);
      }
    }
  } else {
    return;
  } //end if

  //Check AJAX Options: if languagePath == '' > use no Ajax way, html is needed inside <div id="outdated">
  if (languagePath === ' ' || languagePath.length == 0) {
    startStylesAndEvents();
  } else {
    grabFile(languagePath);
  }

  //events and colors
  function startStylesAndEvents() {
    var btnClose = document.getElementById("btnCloseUpdateBrowser");
    var btnUpdate = document.getElementById("btnUpdateBrowser");

  //check settings attributes
    outdated.style.backgroundColor = bkgColor;
  //way too hard to put !important on IE6
    outdated.style.color = txtColor;
    outdated.children[0].style.color = txtColor;
    outdated.children[1].style.color = txtColor;

  //check settings attributes
    btnUpdate.style.color = txtColor;
  // btnUpdate.style.borderColor = txtColor;
    if (btnUpdate.style.borderColor) {
      btnUpdate.style.borderColor = txtColor;
    }
    btnClose.style.color = txtColor;

  //close button
    btnClose.onmousedown = function() {
      outdated.style.display = 'none';
      return false;
    };

  //Override the update button color to match the background color
    btnUpdate.onmouseover = function() {
      this.style.color = bkgColor;
      this.style.backgroundColor = txtColor;
    };
    btnUpdate.onmouseout = function() {
      this.style.color = txtColor;
      this.style.backgroundColor = bkgColor;
    };
  } //end styles and events

  // IF AJAX with request ERROR > insert english default
  var ajaxEnglishDefault = '<h6>Pelayar internet anda sudah luput!</h6>'
    + '<p>Sila kemas kini pelayar anda untuk lihat laman ini dengan tepat. <a id="btnUpdateBrowser" href="http://outdatedbrowser.com/">Kemas kini pelayar saya sekarang</a></p>'
    + '<p class="last"><a href="#" id="btnCloseUpdateBrowser" title="Tutup">&times;</a></p>';

  //** AJAX FUNCTIONS - Bulletproof Ajax by Jeremy Keith **
  function getHTTPObject() {
    var xhr = false;
    if (window.XMLHttpRequest) {
      xhr = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
      try {
        xhr = new ActiveXObject("Msxml2.XMLHTTP");
      } catch ( e ) {
        try {
          xhr = new ActiveXObject("Microsoft.XMLHTTP");
        } catch ( e ) {
          xhr = false;
        }
      }
    }
    return xhr;
  }//end function

  function grabFile(file) {
    var request = getHTTPObject();
    if (request) {
      request.onreadystatechange = function() {
        displayResponse(request);
      };
      request.open("GET", file, true);
      request.send(null);
    }
    return false;
  } //end grabFile

  function displayResponse(request) {
    var insertContentHere = document.getElementById("outdated");
    if (request.readyState == 4) {
      if (request.status == 200 || request.status == 304) {
        insertContentHere.innerHTML = request.responseText;
      } else {
        insertContentHere.innerHTML = ajaxEnglishDefault;
      }
      startStylesAndEvents();
    }
    return false;
  }//end displayResponse
////////END of outdatedBrowser function
};

//event listener: DOM ready
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}
//call plugin function after DOM ready
addLoadEvent(function(){
  outdatedBrowser({
    bgColor: '#f25648',
    color: '#ffffff',
    lowerThan: 'transform',
    languagePath: ''
  })
});