• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

AAC Loading favicon on ZnoteAAC

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
1,470
Solutions
27
Reaction score
844
Location
Santiago - Chile
GitHub
ralke23
Twitch
ralke23
Hi! I need to ask, how do I add favicon to ZnoteAAC? I am using Uniform Server too. My layout is based in this [Znote AAC] old school layout (https://otland.net/threads/znote-aac-old-school-layout.248475/) At the moment I tried to add this in header.php
PHP:
 <link rel="icon" type="image/png" href="layout/favicon.png">
other try was
PHP:
<link href="layout/favicon.ico" rel="icon" type="image/x-icon" />
and also
PHP:
<link rel="icon" type="image/png" href="layout/favicon.png">
Then reload with Ctrl+F5 to clear cache, but didn't work.

Here's a link I saw, that maybe could be usefull to fix this

Any other tips to achieve this? Thanks in advance!
 
Last edited:
Solution
Solved. I could load the favicon by using this .js script.

favicon.js
Code:
/**
 * A class for finding a website’s favicon URL, if any. Requires a context, like
 * a browser extension, that allows cross-origin requests.
 * <br />
 * <br />
 * Copyright 2012, 2013 Disconnect, Inc.
 * <br />
 * <br />
 * This Source Code Form is subject to the terms of the Mozilla Public License,
 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
 * obtain one at <a
 * href="https://mozilla.org/MPL/2.0/">https://mozilla.org/MPL/2.0/</a>.
 * <br />
 * @constructor
 * @param {string} [alt] A default favicon URL, absolute or relative.
 * @author <a href="https://github.com/byoogle">Brian...
Solved. I could load the favicon by using this .js script.

favicon.js
Code:
/**
 * A class for finding a website’s favicon URL, if any. Requires a context, like
 * a browser extension, that allows cross-origin requests.
 * <br />
 * <br />
 * Copyright 2012, 2013 Disconnect, Inc.
 * <br />
 * <br />
 * This Source Code Form is subject to the terms of the Mozilla Public License,
 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
 * obtain one at <a
 * href="https://mozilla.org/MPL/2.0/">https://mozilla.org/MPL/2.0/</a>.
 * <br />
 * @constructor
 * @param {string} [alt] A default favicon URL, absolute or relative.
 * @author <a href="https://github.com/byoogle">Brian Kennish</a>
 */
function Favicon(alt) {
  /**
   * Fetches the default favicon URL.
   * @return {string} An absolute or relative URL.
   */
  this.getAlt = function() { return alt; };

  /**
   * Mungs the default favicon URL.
   * @param  {string}  alt An absolute or relative URL.
   * @return {Favicon}     The favicon object.
   */
  this.setAlt = function(newAlt) {
    alt = newAlt;
    return this;
  };

  /**
   * Finds a favicon URL.
   * @param  {string}           url      A website’s absolute URL or hostname.
   * @param  {function(string)} callback A continuation, to execute when the
   *                                     method completes, that takes a favicon
   *                                     URL.
   * @return {Favicon}                   The favicon object.
   */
  this.get = function(url, callback) {
    var favicon = this.getAlt();
    if (typeof favicon != undeclared) callback(favicon);

    var id = setInterval(function() {
      if (typeof jQuery != undeclared) {
        clearInterval(id);

        if (url.indexOf('/') + 1) {
          anchor.href = url;
          url = anchor.hostname;
        }

        var domain = url.slice(url.indexOf('.') + 1);
        var successful;

        for (var i = 0; i < protocolCount; i++) {
          for (var j = -1; j < subdomainCount; j++) {
            for (var k = 0; k < pathCount; k++) {
              favicon =
                  protocols[i] + (j + 1 ? subdomains[j] + domain : url) +
                      paths[k];

              jQuery.get(favicon, function(data, status, xhr) {
                var type = xhr.getResponseHeader('Content-Type');

                if (!successful && type && type.indexOf('image/') + 1 && data) {
                  successful = true;
                  callback(favicon);
                }
              }).bind(favicon);
            }
          }
        }
      }
    }, 100);

    return this;
  };

  var version = '1.3.0';
  var protocols = ['http://'];
  var subdomains = ['', 'www.'];
  var paths = ['/favicon.ico'];
  var protocolCount = protocols.length;
  var subdomainCount = subdomains.length;
  var pathCount = paths.length;
  var anchor = document.createElement('a');
  var undeclared = 'undefined';

  if (typeof jQuery == undeclared) {
    var script = document.createElement('script');
    script.setAttribute('type', 'text/javascript');
    script.setAttribute('src', 'vendor/jquery-2.2.0.min.js');
    script.onload = function() { jQuery.noConflict(); };
    document.head.appendChild(script);
  }

  return this;
}

Then call the script on header.php by placing this line on the file
Code:
<script src="layout/favicon.js"></script>

Regards!
 
Solution
Really? Javascript to load an favicon? ;)

That's completely not needed.

Did you try like this?

Code:
<link rel="icon" href="/layout/favicon.png">

Thanks for answering @slaw :). I tried that but never worked, loaded using ctrl + f5 to refresh cache and still don't that's why I applied this alternative method. I thought it was weird too, but when I reached the desired outcome with .js I just be good with the result. By using .js for this should I be careful with some kind of error? Regards!
 
Back
Top