Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

ScriptUtil.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. var currentExecutingScript = require("current-executing-script");
  2. /**
  3. * Implements utility functions which facilitate the dealing with scripts such
  4. * as the download and execution of a JavaScript file.
  5. */
  6. var ScriptUtil = {
  7. /**
  8. * Loads a script from a specific source.
  9. *
  10. * @param src the source from the which the script is to be (down)loaded
  11. * @param async true to asynchronously load the script or false to
  12. * synchronously load the script
  13. * @param prepend true to schedule the loading of the script as soon as
  14. * possible or false to schedule the loading of the script at the end of the
  15. * scripts known at the time
  16. * @param relativeURL whether we need load the library from url relative
  17. * to the url that lib-jitsi-meet was loaded. Useful when sourcing the
  18. * library from different location than the app that is using it
  19. */
  20. loadScript: function (src, async, prepend, relativeURL) {
  21. var d = document;
  22. var tagName = 'script';
  23. var script = d.createElement(tagName);
  24. var referenceNode = d.getElementsByTagName(tagName)[0];
  25. script.async = async;
  26. if (relativeURL) {
  27. // finds the src url of the current loaded script
  28. // and use it as base of the src supplied argument
  29. var scriptEl = currentExecutingScript();
  30. if(scriptEl) {
  31. var scriptSrc = scriptEl.src;
  32. var baseScriptSrc
  33. = scriptSrc.substring(0, scriptSrc.lastIndexOf('/') + 1);
  34. if (scriptSrc && baseScriptSrc)
  35. src = baseScriptSrc + src;
  36. }
  37. }
  38. script.src = src;
  39. if (prepend) {
  40. referenceNode.parentNode.insertBefore(script, referenceNode);
  41. } else {
  42. referenceNode.parentNode.appendChild(script);
  43. }
  44. }
  45. };
  46. module.exports = ScriptUtil;