Search
Other Sourcerer questions
Forum

Is js loaded?

Winfried Buijen's Avatar Winfried Buijen
Hi Peter,

How can I see, for instance in the ff-console, that js-source is loaded from the article?

To be more specific:
I have added a js-file with sourcerer in an article.
How to check that it is loaded in the front-end?

Thanks in advance!

Kind regards,
Winfried
Peter van Westen's Avatar Peter van Westen ADMIN
Check the html output of your site.
Please post a rating at the Joomla! Extensions Directory
Winfried Buijen's Avatar Winfried Buijen
I did, nothing is found there
Peter van Westen's Avatar Peter van Westen ADMIN
Then the js file is not loaded.

Must be something wrong with your syntax or js file.

Read: docs4.regularlabs.com/sourcerer/the-basi...tyles-and-javascript
Please post a rating at the Joomla! Extensions Directory
Andrea Malalana's Avatar Andrea Malalana
How to check that it is loaded in the front-end?

Well, test that it works.

Does it work? If it works, it's loaded.

If it doesn't work, it isn't loaded. Or there's a conflict.
In this latter case, share your code with us.
Winfried Buijen's Avatar Winfried Buijen
This is the sourcerer code in the articel:
{source js="/media/templates/site/cassiopeia/js/claimcontrol.js" defer="true"}{/source}

This is the file
<script type="text/javascript">
// 1. function switch Practice-Test
// 2. function perform rollDices
// 3. function perform selectFlags

// Definieer de variabelen
  var btn-switch = document.getElementById('btn-sw-practice-test');
  var btn-rolldices = document.getElementById('btn-throw-dices');
  var flag01 =  document.getElementById('claim-veld01');
  var flag02 =  document.getElementById('claim-veld02');
  var flag03 =  document.getElementById('claim-veld03');
  var flag04 =  document.getElementById('claim-veld04');
  var flag05 =  document.getElementById('claim-veld05');
  var flag06 =  document.getElementById('claim-veld06');
  var flag07 =  document.getElementById('claim-veld07');
  var flag08 =  document.getElementById('claim-veld08');
  var flag09 =  document.getElementById('claim-veld09');
  var flag10 =  document.getElementById('claim-veld10');
  var flag11 =  document.getElementById('claim-veld11');
  var flag12 =  document.getElementById('claim-veld12');
  var flag13 =  document.getElementById('claim-veld13');
  var flag14 =  document.getElementById('claim-veld14');
  var flag15 =  document.getElementById('claim-veld15');
  var flag16 =  document.getElementById('claim-veld16');
  var flag17 =  document.getElementById('claim-veld17');
  var flag18 =  document.getElementById('claim-veld18');
  var flag19 =  document.getElementById('claim-veld19');
  var flag20 =  document.getElementById('claim-veld20');
  var flag21 =  document.getElementById('claim-veld21');
  var flag22 =  document.getElementById('claim-veld22');
  var flag23 =  document.getElementById('claim-veld23');
  var flag24 =  document.getElementById('claim-veld24');
  var flag25 =  document.getElementById('claim-veld25');
  var flag26 =  document.getElementById('claim-veld26');
  var flag27 =  document.getElementById('claim-veld27');
  var flag28 =  document.getElementById('claim-veld28');
  var flag29 =  document.getElementById('claim-veld29');
  var flag30 =  document.getElementById('claim-veld30');
  var flag31 =  document.getElementById('claim-veld31');
  var flag32 =  document.getElementById('claim-veld32');
  var flag33 =  document.getElementById('claim-veld33');
  var flag34 =  document.getElementById('claim-veld34');
  var flag35 =  document.getElementById('claim-veld35');
  var flag36 =  document.getElementById('claim-veld36');

// 1. function test Practice-Test
  function switchPracticeTest {
   $echo 'Start switch Practice Test button.'
    
  }
// 2. function rollDices()
  function rollDices {
   $echo 'Start switch roll Dices button.'
// red-dice = function rollDice()
// green-dice = function rollDice()
  var element = document.querySelector('.dot1');
  element.style.visibility = 'visible';

  var element = document.querySelector('.dot1');
  element.style.visibility = 'hidden';
  var element = document.querySelector('.dot2a');
  element.style.visibility = 'hidden';
  var element = document.querySelector('.dot2b');
  element.style.visibility = 'hidden';
  var element = document.querySelector('.dot4a');
  element.style.visibility = 'hidden';
  var element = document.querySelector('.dot4b');
  element.style.visibility = 'hidden';
  var element = document.querySelector('.dot6a');
  element.style.visibility = 'hidden';
  var element = document.querySelector('.dot6b');
  element.style.visibility = 'hidden';


var red-dice-value = rollDice();
// document.getElementById("red-dice").innerHTML = dice-value;
   $echo 'Start red Dice value calculation.'
    
    
switch(red-dice-value) {
  case 1:
    var element = document.querySelector('.rd-dot1');
    element.style.visibility = 'visible';
    break;
  case 2:
    var element = document.querySelector('.rd-dot2a');
    element.style.visibility = 'visible';
    var element = document.querySelector('.rd-dot2b');
    element.style.visibility = 'visible';
    break;
  case 3:
    var element = document.querySelector('.rd-dot1');
    element.style.visibility = 'visible';
    var element = document.querySelector('.rd-dot2a');
    element.style.visibility = 'visible';
    var element = document.querySelector('.rd-dot2b');
    element.style.visibility = 'visible';
    break;
  case 4:
    var element = document.querySelector('.rd-dot2a');
    element.style.visibility = 'visible';
    var element = document.querySelector('.rd-dot2b');
    element.style.visibility = 'visible';
    var element = document.querySelector('.rd-dot4a');
    element.style.visibility = 'visible';
    var element = document.querySelector('.rd-dot4b');
    element.style.visibility = 'visible';
    break;
  case 5:
    var element = document.querySelector('.rd-dot1');
    element.style.visibility = 'visible';
    var element = document.querySelector('.rd-dot2a');
    element.style.visibility = 'visible';
    var element = document.querySelector('.rd-dot2b');
    element.style.visibility = 'visible';
    var element = document.querySelector('.rd-dot4a');
    element.style.visibility = 'visible';
    var element = document.querySelector('.rd-dot4b');
    element.style.visibility = 'visible';
    break;
  case 6:
    var element = document.querySelector('.rd-dot2a');
    element.style.visibility = 'visible';
    var element = document.querySelector('.rd-dot2b');
    element.style.visibility = 'visible';
    var element = document.querySelector('.rd-dot4a');
    element.style.visibility = 'visible';
    var element = document.querySelector('.rd-dot4b');
    element.style.visibility = 'visible';
    var element = document.querySelector('.rd-dot6a');
    element.style.visibility = 'visible';
    var element = document.querySelector('.rd-dotb');
    element.style.visibility = 'visible';
    break;
  default:
    $echo 'No red value calculated.'
    break;
} 

var green-dice-value = rollDice();
// document.getElementById("green-dice").innerHTML = dice-value;
   $echo 'Start green Dice value calculation.'

switch(green-dice-value) {
  case 1:
    var element = document.querySelector('.gd-dot1');
    element.style.visibility = 'visible';
    break;
  case 2:
    var element = document.querySelector('.gd-dot2a');
    element.style.visibility = 'visible';
    var element = document.querySelector('.gd-dot2b');
    element.style.visibility = 'visible';
    break;
  case 3:
    var element = document.querySelector('.gd-dot1');
    element.style.visibility = 'visible';
    var element = document.querySelector('.gd-dot2a');
    element.style.visibility = 'visible';
    var element = document.querySelector('.gd-dot2b');
    element.style.visibility = 'visible';
    break;
  case 4:
    var element = document.querySelector('.gd-dot2a');
    element.style.visibility = 'visible';
    var element = document.querySelector('.gd-dot2b');
    element.style.visibility = 'visible';
    var element = document.querySelector('.gd-dot4a');
    element.style.visibility = 'visible';
    var element = document.querySelector('.gd-dot4b');
    element.style.visibility = 'visible';
    break;
  case 5:
    var element = document.querySelector('.gd-dot1');
    element.style.visibility = 'visible';
    var element = document.querySelector('.gd-dot2a');
    element.style.visibility = 'visible';
    var element = document.querySelector('.gd-dot2b');
    element.style.visibility = 'visible';
    var element = document.querySelector('.gd-dot4a');
    element.style.visibility = 'visible';
    var element = document.querySelector('.gd-dot4b');
    element.style.visibility = 'visible';
    break;
  case 6:
    var element = document.querySelector('.gd-dot2a');
    element.style.visibility = 'visible';
    var element = document.querySelector('.gd-dot2b');
    element.style.visibility = 'visible';
    var element = document.querySelector('.gd-dot4a');
    element.style.visibility = 'visible';
    var element = document.querySelector('.gd-dot4b');
    element.style.visibility = 'visible';
    var element = document.querySelector('.gd-dot6a');
    element.style.visibility = 'visible';
    var element = document.querySelector('.gd-dot6b');
    element.style.visibility = 'visible';
    break;
  default:
    $echo 'No green value calculated.'
	break;
} 

function rollDice{
   $echo 'Start rollDice function.'
rolled-dice = Math.floor(Math.random() * 5) + 1;
   $echo $rolled-dice
return rolled-dice;
}
</script>
Peter van Westen's Avatar Peter van Westen ADMIN
A js file should not contain a <script> tag.
Sorry, but it is beyond my support to explain how javascript works.
Please post a rating at the Joomla! Extensions Directory
Winfried Buijen's Avatar Winfried Buijen
Hi Peter,

I understand that this is beyond your support to explain how javascript works.
That is not what I need, I need to find out why my js is not loaded within the article.

I have the joomla site configured to show errors but there are none whatsoever.
I have tried both yes and no to skip lines from the /head but that makes no difference at all.

All I need to see is that the file is loaded.
So far I don't see that this is the case, therefor why does it not load?
Winfried Buijen's Avatar Winfried Buijen
By the way, I am using the PRO version.
I use the sourcerer button to insert the file or code into the article.
Peter van Westen's Avatar Peter van Westen ADMIN
Do you have this online so I can take a look?
Please post a rating at the Joomla! Extensions Directory
Winfried Buijen's Avatar Winfried Buijen
I tried some more.
When the code is inserted in the article, without using a file, it is loaded.
However it is not loaded when I use the following file: /media/templates/site/cassiopeia/js/claimcontrol.js

Should I not use the defer option?

Do you want it online with the file loaded or within the article as code?
Peter van Westen's Avatar Peter van Westen ADMIN
If you can reproduce this on an online environment. So a link to the article that contains the Sourcerer code.
Please post a rating at the Joomla! Extensions Directory
Winfried Buijen's Avatar Winfried Buijen
It is online: claim.games
But you have to login in the backend to see it

Confidential information:
(hidden)
Peter van Westen's Avatar Peter van Westen ADMIN
So where is the article on the frontend? where you have the {source} tags?
Please post a rating at the Joomla! Extensions Directory
Peter van Westen's Avatar Peter van Westen ADMIN
I found the article 'Oefenen' where you use the {source} tag.
I went to that article on the frontend, and looked in the html output.
The script is in the html output and is therefor being loaded.
<script src="/media/templates/site/cassiopeia/js/claimcontrol.js?..."  ...
Please post a rating at the Joomla! Extensions Directory
Winfried Buijen's Avatar Winfried Buijen
Thanks Peter, sorry for any inconvenience
Peter van Westen's Avatar Peter van Westen ADMIN
So in other words, my first reply:
Check the html output of your site.
Please post a rating at the Joomla! Extensions Directory
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription