Description: Separate and deduplicate JavaScript configuration
 Isolating config parts of JavaScript code simplifies initial setup
 and eases migration to newer release of Janus.
 .
 This also consistently applies variables "token" and "apisecret"
 in example code
 when defined in config file.
Author: Jonas Smedegaard <dr@jones.dk>
Last-Update: 2020-07-13
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/html/admin.html
+++ b/html/admin.html
@@ -8,6 +8,7 @@
 <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>
 <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js"></script>
 <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootbox.js/5.4.0/bootbox.min.js"></script>
+<script type="text/javascript" src="adminconfig.js"></script>
 <script type="text/javascript" src="admin.js"></script>
 <script>
 	$(function() {
--- a/html/admin.js
+++ b/html/admin.js
@@ -1,17 +1,3 @@
-//
-// This 'server' variable we use to contact the Admin/Monitor backend is
-// constructed in this example pretty much as we do in all the demos, so
-// refer to the guidelines there with respect to absolute vs. relative
-// paths and the like.
-//
-var server = null;
-if(window.location.protocol === 'http:')
-	server = "http://" + window.location.hostname + ":7088/admin";
-else
-	server = "https://" + window.location.hostname + ":7889/admin";
-// If you don't want the page to prompt you for a password, insert it here
-var secret = "";
-
 var session = null;		// Selected session
 var handle = null;		// Selected handle
 
--- /dev/null
+++ b/html/adminconfig.js
@@ -0,0 +1,13 @@
+//
+// This 'server' variable we use to contact the Admin/Monitor backend is
+// constructed in this example pretty much as we do in all the demos, so
+// refer to the guidelines there with respect to absolute vs. relative
+// paths and the like.
+//
+var server = null;
+if(window.location.protocol === 'http:')
+	server = "http://" + window.location.hostname + ":7088/admin";
+else
+	server = "https://" + window.location.hostname + ":7889/admin";
+// If you don't want the page to prompt you for a password, insert it here
+var secret = "";
--- a/html/audiobridgetest.js
+++ b/html/audiobridgetest.js
@@ -42,10 +42,8 @@
 				{
 					server: server,
 					iceServers: iceServers,
-					// Should the Janus API require authentication, you can specify either the API secret or user token here too
-					//		token: "mytoken",
-					//	or
-					//		apisecret: "serversecret",
+					token: token,
+					apisecret: apisecret,
 					success: function() {
 						// Attach to AudioBridge plugin
 						janus.attach(
--- a/html/devicetest.js
+++ b/html/devicetest.js
@@ -179,10 +179,8 @@
 				{
 					server: server,
 					iceServers: iceServers,
-					// Should the Janus API require authentication, you can specify either the API secret or user token here too
-					//		token: "mytoken",
-					//	or
-					//		apisecret: "serversecret",
+					token: token,
+					apisecret: apisecret,
 					success: function() {
 						// Attach to EchoTest plugin
 						janus.attach(
--- a/html/echotest.js
+++ b/html/echotest.js
@@ -55,10 +55,8 @@
 				{
 					server: server,
 					iceServers: iceServers,
-					// Should the Janus API require authentication, you can specify either the API secret or user token here too
-					//		token: "mytoken",
-					//	or
-					//		apisecret: "serversecret",
+					token: token,
+					apisecret: apisecret,
 					success: function() {
 						// Attach to EchoTest plugin
 						janus.attach(
--- a/html/nosiptest.js
+++ b/html/nosiptest.js
@@ -32,10 +32,8 @@
 				{
 					server: server,
 					iceServers: iceServers,
-					// Should the Janus API require authentication, you can specify either the API secret or user token here too
-					//		token: "mytoken",
-					//	or
-					//		apisecret: "serversecret",
+					token: token,
+					apisecret: apisecret,
 					success: function() {
 						// Attach to NoSIP plugin as a caller
 						janus.attach(
--- a/html/recordplaytest.js
+++ b/html/recordplaytest.js
@@ -44,10 +44,8 @@
 				{
 					server: server,
 					iceServers: iceServers,
-					// Should the Janus API require authentication, you can specify either the API secret or user token here too
-					//		token: "mytoken",
-					//	or
-					//		apisecret: "serversecret",
+					token: token,
+					apisecret: apisecret,
 					success: function() {
 						// Attach to Record&Play plugin
 						janus.attach(
--- a/html/screensharingtest.js
+++ b/html/screensharingtest.js
@@ -48,10 +48,8 @@
 				{
 					server: server,
 					iceServers: iceServers,
-					// Should the Janus API require authentication, you can specify either the API secret or user token here too
-					//		token: "mytoken",
-					//	or
-					//		apisecret: "serversecret",
+					token: token,
+					apisecret: apisecret,
 					success: function() {
 						// Attach to VideoRoom plugin
 						janus.attach(
--- a/html/siptest.js
+++ b/html/siptest.js
@@ -34,10 +34,8 @@
 				{
 					server: server,
 					iceServers: iceServers,
-					// Should the Janus API require authentication, you can specify either the API secret or user token here too
-					//		token: "mytoken",
-					//	or
-					//		apisecret: "serversecret",
+					token: token,
+					apisecret: apisecret,
 					success: function() {
 						// Attach to SIP plugin
 						janus.attach(
--- a/html/streamingtest.js
+++ b/html/streamingtest.js
@@ -33,10 +33,8 @@
 				{
 					server: server,
 					iceServers: iceServers,
-					// Should the Janus API require authentication, you can specify either the API secret or user token here too
-					//		token: "mytoken",
-					//	or
-					//		apisecret: "serversecret",
+					token: token,
+					apisecret: apisecret,
 					success: function() {
 						// Attach to Streaming plugin
 						janus.attach(
--- a/html/textroomtest.js
+++ b/html/textroomtest.js
@@ -31,10 +31,8 @@
 				{
 					server: server,
 					iceServers: iceServers,
-					// Should the Janus API require authentication, you can specify either the API secret or user token here too
-					//		token: "mytoken",
-					//	or
-					//		apisecret: "serversecret",
+					token: token,
+					apisecret: apisecret,
 					success: function() {
 						// Attach to TextRoom plugin
 						janus.attach(
--- a/html/videocalltest.js
+++ b/html/videocalltest.js
@@ -37,10 +37,8 @@
 				{
 					server: server,
 					iceServers: iceServers,
-					// Should the Janus API require authentication, you can specify either the API secret or user token here too
-					//		token: "mytoken",
-					//	or
-					//		apisecret: "serversecret",
+					token: token,
+					apisecret: apisecret,
 					success: function() {
 						// Attach to VideoCall plugin
 						janus.attach(
--- a/html/videoroomtest.js
+++ b/html/videoroomtest.js
@@ -43,10 +43,8 @@
 				{
 					server: server,
 					iceServers: iceServers,
-					// Should the Janus API require authentication, you can specify either the API secret or user token here too
-					//		token: "mytoken",
-					//	or
-					//		apisecret: "serversecret",
+					token: token,
+					apisecret: apisecret,
 					success: function() {
 						// Attach to VideoRoom plugin
 						janus.attach(
--- a/html/voicemailtest.js
+++ b/html/voicemailtest.js
@@ -30,10 +30,8 @@
 				{
 					server: server,
 					iceServers: iceServers,
-					// Should the Janus API require authentication, you can specify either the API secret or user token here too
-					//		token: "mytoken",
-					//	or
-					//		apisecret: "serversecret",
+					token: token,
+					apisecret: apisecret,
 					success: function() {
 						// Attach to VoiceMail plugin
 						janus.attach(
--- a/html/vp9svctest.js
+++ b/html/vp9svctest.js
@@ -35,10 +35,8 @@
 				{
 					server: server,
 					iceServers: iceServers,
-					// Should the Janus API require authentication, you can specify either the API secret or user token here too
-					//		token: "mytoken",
-					//	or
-					//		apisecret: "serversecret",
+					token: token,
+					apisecret: apisecret,
 					success: function() {
 						// Attach to VideoRoom plugin
 						janus.attach(
--- a/html/multiopus.js
+++ b/html/multiopus.js
@@ -47,10 +47,8 @@
 				{
 					server: server,
 					iceServers: iceServers,
-					// Should the Janus API require authentication, you can specify either the API secret or user token here too
-					//		token: "mytoken",
-					//	or
-					//		apisecret: "serversecret",
+					token: token,
+					apisecret: apisecret,
 					success: function() {
 						// Attach to EchoTest plugin
 						janus.attach(
--- a/html/e2etest.js
+++ b/html/e2etest.js
@@ -43,10 +43,8 @@
 				{
 					server: server,
 					iceServers: iceServers,
-					// Should the Janus API require authentication, you can specify either the API secret or user token here too
-					//		token: "mytoken",
-					//	or
-					//		apisecret: "serversecret",
+					token: token,
+					apisecret: apisecret,
 					success: function() {
 						// Attach to EchoTest plugin
 						janus.attach(
--- a/html/canvas.js
+++ b/html/canvas.js
@@ -51,10 +51,8 @@
 				{
 					server: server,
 					iceServers: iceServers,
-					// Should the Janus API require authentication, you can specify either the API secret or user token here too
-					//		token: "mytoken",
-					//	or
-					//		apisecret: "serversecret",
+					token: token,
+					apisecret: apisecret,
 					success: function() {
 						// Attach to EchoTest plugin
 						janus.attach(
--- a/html/mvideoroomtest.js
+++ b/html/mvideoroomtest.js
@@ -43,10 +43,8 @@
 				{
 					server: server,
 					iceServers: iceServers,
-					// Should the Janus API require authentication, you can specify either the API secret or user token here too
-					//		token: "mytoken",
-					//	or
-					//		apisecret: "serversecret",
+					token: token,
+					apisecret: apisecret,
 					success: function() {
 						// Attach to video room test plugin
 						janus.attach(
--- a/html/virtualbg.js
+++ b/html/virtualbg.js
@@ -52,10 +52,8 @@
 				{
 					server: server,
 					iceServers: iceServers,
-					// Should the Janus API require authentication, you can specify either the API secret or user token here too
-					//		token: "mytoken",
-					//	or
-					//		apisecret: "serversecret",
+					token: token,
+					apisecret: apisecret,
 					success: function() {
 						// Attach to EchoTest plugin
 						janus.attach(
--- a/html/webaudio.js
+++ b/html/webaudio.js
@@ -51,15 +51,9 @@
 			janus = new Janus(
 				{
 					server: server,
-					// No "iceServers" is provided, meaning janus.js will use a default STUN server
-					// Here are some examples of how an iceServers field may look like to support TURN
-					// 		iceServers: [{urls: "turn:yourturnserver.com:3478", username: "janususer", credential: "januspwd"}],
-					// 		iceServers: [{urls: "turn:yourturnserver.com:443?transport=tcp", username: "janususer", credential: "januspwd"}],
-					// 		iceServers: [{urls: "turns:yourturnserver.com:443?transport=tcp", username: "janususer", credential: "januspwd"}],
-					// Should the Janus API require authentication, you can specify either the API secret or user token here too
-					//		token: "mytoken",
-					//	or
-					//		apisecret: "serversecret",
+					iceServers: iceServers,
+					token: token,
+					apisecret: apisecret,
 					success: function() {
 						// Attach to EchoTest plugin
 						janus.attach(
--- a/html/settings.js
+++ b/html/settings.js
@@ -80,3 +80,8 @@
 // janus.js will fallback to the Google STUN server by default:
 //
 var iceServers = null;
+
+// Should the Janus API require authentication, you can specify either the API secret or user token here too
+//		token: "mytoken",
+//	or
+//		apisecret: "serversecret",
