Add possibility to set HTML element values (e.g. server and name) in the URL for the test web page.

Example: .../webrtc_test.html?server=foo

This simplifies when one has to close and re-open the browser several times or use different servers and names, since it can be stored as bookmarks instead of changing it manually every time.
Review URL: http://webrtc-codereview.appspot.com/339006

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1351 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
henrikg@webrtc.org 2012-01-09 08:19:15 +00:00
parent b0abbd353d
commit 267b877586
2 changed files with 18 additions and 4 deletions

View File

@ -39,3 +39,6 @@ See http://blog.chromium.org/2008/12/security-in-depth-local-web-pages.html
for more details on this topic. This can be overridden with the flag
--allow-file-access-from-files, in which case running it over the file://
URI scheme works.
Note 3: It's possible to specify the server and name in the url:
.../webrtc.html?server=my_server&name=my_name

View File

@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<!--
Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
Copyright (c) 2011-2012 The WebRTC project authors. All Rights Reserved.
Use of this source code is governed by a BSD-style license
that can be found in the LICENSE file in the root of the source
@ -45,6 +45,13 @@ var callState = 0; // 0 - Not started, 1 - Call ongoing
// General
function setElementValuesFromURL() {
window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi,
function(m, key, value) {
document.getElementById(key).value = unescape(value);
});
}
function toggleExtraButtons() {
document.getElementById("createPcBtn").hidden =
!document.getElementById("createPcBtn").hidden;
@ -466,7 +473,7 @@ function signIn() {
}
function connect() {
myName = document.getElementById("local").value.toLowerCase();
myName = document.getElementById("name").value.toLowerCase();
server = document.getElementById("server").value.toLowerCase();
if (myName.length == 0) {
alert("I need a name please.");
@ -515,7 +522,11 @@ function disconnect() {
// Window event handling
window.onload = getUserMedia;
window.onload = function() {
setElementValuesFromURL();
getUserMedia();
}
window.onbeforeunload = disconnect;
@ -553,7 +564,7 @@ page.<br>&nbsp;
</td>
</tr>
<tr>
<td>Name:</td><td><input type="text" id="local" size="30" value="name"/></td>
<td>Name:</td><td><input type="text" id="name" size="30" value="name"/></td>
</tr>
</table>
</td>