Что означает «Предупреждение: игнорирование пустого тега» в выводе geany? - PullRequest
0 голосов
/ 25 ноября 2018

Я работаю на Debian Stretch, только один файл JavaScript появляется такой подсказкой.Например:

$ geany
geany: Warning: ignoring null tag in /path/to/magic.js


$ aptitude show geany
Package: geany                           
Version: 1.29-1
State: installed
Automatically installed: no
Priority: optional
Section: devel
Maintainer: Geany Packaging Team <pkg-geany-team@lists.alioth.debian.org>
Architecture: i386
Uncompressed Size: 3,600 k
Depends: libatk1.0-0 (>= 1.12.4), libc6 (>= 2.15), libcairo2 (>= 1.8.0), libfontconfig1 (>= 2.11), libfreetype6 (>= 2.2.1), libgcc1 (>= 1:3.0), libgdk-pixbuf2.0-0 (>= 2.22.0),
         libglib2.0-0 (>= 2.41.1), libgtk2.0-0 (>= 2.22.0), libpango-1.0-0 (>= 1.18.0), libpangocairo-1.0-0 (>= 1.14.0), libpangoft2-1.0-0 (>= 1.14.0), libstdc++6 (>= 5.2),
         geany-common (= 1.29-1)
Suggests: libvte9, doc-base
Breaks: geany-plugins-common (< 0.21)
Provides: geany-abi-71, geany-api-230
Description: fast and lightweight IDE
 Geany is a small and lightweight integrated development environment. It was developed to provide a small and fast IDE, which has only a few dependencies from other packages. It
 is using only the GTK2 toolkit and therefore you need only the GTK2 runtime libraries to run Geany. 

 The basic features of Geany are: 
 * syntax highlighting 
 * code completion 
 * auto completion of constructs like if, for and while, XML and HTML 
 * call tips 
 * folding 
 * many supported filetypes like C, Java, PHP, HTML, Python, Perl, Pascal 
 * symbol lists 
 * embedded terminal emulation
Homepage: http://www.geany.org
Tags: devel::editor, devel::ide, implemented-in::c, interface::graphical, interface::x11, role::program, uitoolkit::gtk, use::editing, works-with::software:source,
      works-with::text, works-with::unicode, x11::application

файл magic.js:

/*
  >>> Text to Speech Supported Languages <<<
  Afrikaans, Albanian, Aragonese, Armenian, Bulgarian, Cantonese, Catalan, Croatian, 
  Czech, Danish, Dutch, English, Esperanto, Estonian, Farsi, Finnish, French, Georgian, 
  German, Greek, Hindi, Hungarian, Icelandic, Indonesian, Irish, Italian, Kannada, 
  Kurdish, Latvian, Lithuanian, Lojban, Macedonian, Malaysian, Malayalam, Mandarin, 
  Nepalese, Norwegian, Polish, Portuguese, Punjabi, Romanian, Russian, Serbian, Slovak, 
  Spanish, Swahili, Swedish, Tamil, Turkish, Vietnamese, Welsh.
*/

var TKK_TIMER = null, NOTIFICATION_UPDATE = false;

const languagesNoVoice = [
  "az","eu","be","bn","bg","ceb","et","tl","gl","ka","gu","ha","iw","hmn","ig","ga","jw","kn",
  "km","lo","lt","ms","mt","mi","mr","mn","ne","fa","pa","sl","so","te","uk","ur","yi","yo","zu"
];

var _links = function (i) {
  var _arr = ["https://translate.google.cn/translate_a/single?client=t&sl=auto", "https://translate.google.cn/translate_tts?ie=UTF-8&q="];
  return _arr[i];
};

window.setTimeout(function () {
  var version = config.welcome.version;
  if (version !== app.version()) {
    if (app.loadReason === "install" || app.loadReason === "startup") {
      if (config.welcome.open) {
        app.tab.open(config.welcome.url + "?version=" + app.version() + (version ? "&p=" + version + "&type=upgrade" : "&type=install"));
      }
      config.welcome.version = app.version();
    }
  }
}, config.welcome.timeout);

var TTSToken = function (a) {
  var k = "", cb = "&", Gf = "=", jd = ".", $b = "+-a^+6", t = "a", Yb = "+", Zb = "+-3^+b+-f";
  sM = function (a) {return function () {return a}},
  tM = function (a, b) {
    for (var c = 0; c < b.length - 2; c += 3) {
      var d = b.charAt(c + 2), d = d >= t ? d.charCodeAt(0) - 87 : Number(d), d = b.charAt(c + 1) == Yb ? a >>> d : a << d;
      a = b.charAt(c) == Yb ? a + d & 4294967295 : a ^ d
    }
    return a
  },
  uM = null;
  /*  */
  var b;
  if (null !== uM) b = uM;
  else {
    b = sM(String.fromCharCode(84));
    var c = sM(String.fromCharCode(75));
    b = [b(), b()];
    b[1] = c();
    b = (uM = config.tts.TKK || k) || k;
  }
  /*  */
  var d = sM(String.fromCharCode(116)), c = sM(String.fromCharCode(107)), d = [d(), d()];
  d[1] = c();
  c = cb + d.join(k) + Gf;
  d = b.split(jd);
  b = Number(d[0]) || 0;
  for (var e = [], f = 0, g = 0; g < a.length; g++) {
    var m = a.charCodeAt(g);
    128 > m ? e[f++] = m : (2048 > m ? e[f++] = m >> 6 | 192 : (55296 == (m & 64512) && g + 1 < a.length && 56320 == (a.charCodeAt(g + 1) & 64512) ? (m = 65536 + ((m & 1023) << 10) + (a.charCodeAt(++g) & 1023), e[f++] = m >> 18 | 240, e[f++] = m >> 12 & 63 | 128) : e[f++] = m >> 12 | 224, e[f++] = m >> 6 & 63 | 128), e[f++] = m & 63 | 128)
  }
  /*  */
  a = b;
  for (f = 0; f < e.length; f++) a += e[f], a = tM(a, $b);
  a = tM(a, Zb);
  a ^= Number(d[1]) || 0;
  0 > a && (a = (a & 2147483647) + 2147483648);
  a %= 1E6;
  return (a.toString() + jd + (a ^ b));
};

var splitString = function (str, n) {
  var result = [];
  if (n) {
    var words = str.split(/\s+/g), tmp = [], count = 0;
    for (var i = 0; i < words.length; i++) {
      tmp.push(words[i]); count++;
      if (count == n || i == words.length - 1) {
        result.push(tmp.join(" "));
        tmp = [], count = 0; /* reset */
      }
    }
  } else result.push(str);
  /*  */
  return result;
};

var startHTML5Voice = function (obj) {
  var text = obj.text.split(/\. |\; |\u060c | \? | \! | \: | \n/g), _tmp = [];
  for (var i = 0; i < text.length; i++) {
    var subtext = splitString(text[i], null);
    for (var j = 0; j < subtext.length; j++) {
      if (subtext[j].length) {
        _tmp.push(subtext[j]);
      }
    }
  }
  text = _tmp;
  /*  */
  app.content_script.send("language-support", "true", true);
  app.content_script.send("start-voice", {"url": obj.url, "text": text});
};

var textToSpeech = function (text, lang, url) {
  var audioUrl = [], audioText = [];
  for (var i = 0; i < text.length; i++) {
    var subtext = splitString(text[i], 52); /* 13 words max */
    for (var j = 0; j < subtext.length; j++) {
      if (subtext[j].length) {
        var _tmp = subtext[j];
        txt = encodeURIComponent(_tmp);
        var _url = _links(1) + txt + "&tl=" + lang + "&total=1&idx=0&textlen=" + _tmp.length + "&tk=" + TTSToken(_tmp) + "&client=t";
        audioUrl.push(_url);
        audioText.push(subtext[j]);
      }
    }
  }
  app.content_script.send("audio-text", audioText, true);
  app.content_script.send("start-voice", {"url": url, "text": audioUrl});
};

app.content_script.receive("GTTS-TKK", function (e) {
  if (e) config.tts.TKK = e;
  if (!NOTIFICATION_UPDATE) return;
  app.notification("Text-to-Speech (TTS)", e ? "DONE!, you can now close 'translate.google.cn' tab." : "Error! Google TTS API needs to be upgraded. Please use HTML5 Speech API for now (see options page)");
  NOTIFICATION_UPDATE = false;
});

var getSourceLang = function (text, callback) {
  text = text.trim();
  text = text.toLowerCase();
  text = encodeURIComponent(text);
  var url = _links(0) + '&tl=en' + '&hl=en&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&dt=at&dt=sw&ie=UTF-8&oe=UTF-8&ssel=0&tsel=0&tk=' + TTSToken(decodeURIComponent(text)) + '&q=' + text;
  console.log(url)
  app.HttpRequest(url, null, null, function (r) { 
    if (r) {
      var _result = r.replace(/\,{2}/g, ',null,').replace(/\,{2}/g, ',null,').replace(/\[\,/g, "[null,");    
      if (_result) {
        var arr = [];
        try {arr = JSON.parse(_result)} catch (e) {}
        if (arr && arr.length) {
          if (arr[2]) callback(arr[2]);
          else if (arr[8] && arr[8][0] && arr[8][0][0]) callback(arr[8][0][0]);
          else callback('en');
        }
      }
    }
    else callback(null);
  });
};

var startGoogleVoice = function (obj) {
  var text = obj.text.split(/\. |\, |\; |\u060c |\?|\!|\: |\n/g);
  getSourceLang(text[0], function (lang) {
    if (lang) {
      for (var k = 0; k < languagesNoVoice.length; k++) {
        if (languagesNoVoice[k] === lang) {
          app.content_script.send("language-support", "false", true);
          return;
        }
      }
      textToSpeech(text, lang, obj.url);
      app.content_script.send("language-support", "true", true);
    } else {
      if (TKK_TIMER) window.clearTimeout(TKK_TIMER);
      TKK_TIMER = window.setTimeout(function () {
        app.notification("Text-to-Speech (TTS)", "The Addon is updating Google TTS data from 'translate.google.cn', please wait...");
        app.tab.open("https://translate.google.cn/");
        NOTIFICATION_UPDATE = true;
      }, 1000);
    }
  });
};

var sendOptionsToPage = function () {
  var obj = {
    "isBubbleIcon": config.settings.isBubbleIcon,
    "isTextSelection": config.settings.selection,
    "showHighlight": config.settings.showHighlight,
    "enableInputArea": config.settings.enableInputArea,
    "placeholderIconShow": config.settings.placeholderIconShow,
    "placeholderIconTime": config.settings.placeholderIconTime,
  };
  /*  */
  app.content_script.send("options-response", obj, true); /* true: send to all tabs */
};

app.content_script.receive("start-voice", function (obj) {
  if (config.settings.method === "google") startGoogleVoice(obj);
  else if (config.settings.method === "html5") {
    if (obj.html5) startHTML5Voice(obj);
    else {
      app.notification("Text-to-Speech (TTS)", 'To enable HTML5 TTS API in Firefox please go to "about:config" page and search for "webspeech" keyword. \n Once you find "media.webspeech.synth.enabled" item, right-click on it and click "Toggle" to enable it.');
    }
  }
});

app.content_script.receive("show-notification", function (code) {
  if (code === '1') {
    app.notification("Text-to-Speech (TTS)", "You have reached the limit of Google text-to-speech API for the current session, \n please wait for few seconds or reload the page to continue. \n Alternatively, you can enable HTML5 TTS API to continue (please see the options page for more details.)");
  }
  if (code === '2') {
   app.notification("Text-to-Speech (TTS)", "An error has occurred due to HTML5 TTS API bug, please restart the Browser and try again. To prevent this error, please avoid pausing the audio when a sentence is close to its end.");
  }
  if (code === '3') {
    app.notification("Text-to-Speech (TTS)", "An error has occurred due to HTML5 TTS API bug, please restart the Browser and try again. To prevent this error, please avoid canceling the audio (i.e. reloading the page) before it ends.");
  }
});

app.options.receive("tts-method", function (method) {
  config.settings.method = method;
  app.notification("Text-to-Speech (TTS)", "Please reload Tab(s) for the API setting to take effect. Note: in order to enable HTML5 TTS API in Firefox please go to 'about:config' page and search for 'webspeech' keyword. Once you find 'media.webspeech.synth.enables' item, right-click on it and click 'Toggle' to enable it.");
});

app.options.receive("changed", function (o) {
  config.set(o.pref, o.value);
  app.options.send("set", {"pref": o.pref, "value": config.get(o.pref)});
  sendOptionsToPage();
});

app.content_script.receive("options-request", sendOptionsToPage);
app.options.receive("get-tts-method", function () {app.options.send("set-tts-method", config.settings.method)});
app.options.receive("get", function (pref) {app.options.send("set", {"pref": pref, "value": config.get(pref)})});
app.content_script.receive("init", function () {app.content_script.send("init", {"method": config.settings.method})});
...