clientui.php3 5.27 KB
Newer Older
1 2
<?php
#
3
# Copyright (c) 2000-2013 University of Utah and the Flux Group.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# 
# {{{EMULAB-LICENSE
# 
# This file is part of the Emulab network testbed software.
# 
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# 
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
# 
# }}}
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
#
require("defs.php3");

#
# Define a stripped-down view of the web interface - less clutter
#
$view = array(
    'hide_banner' => 1,
    'hide_sidebar' => 1,
    'hide_copyright' => 1
);

#
# Only known and logged in users can do this.
#
38 39 40
$this_user = CheckLoginOrDie();
$uid       = $this_user->uid();
$isadmin   = ISADMIN();
41

42 43 44 45 46 47
#
# Verify page arguments.
#
$optargs = OptionalPageArguments("experiment", PAGEARG_EXPERIMENT,
				 "fallback",   PAGEARG_BOOLEAN);

48 49

PAGEHEADER("Experiment Creation GUI", $view);
50 51
?>

52 53
<h3>Note: See the Help menu for quickstart and tips</h3>

54 55 56 57 58 59
<div id="clientblock" name="clientblock"></div>

<script language='JavaScript'>

<?php

60 61 62 63
if (isset($experiment)) {
  $pid = $experiment->pid();
  $eid = $experiment->eid();
  
64 65 66 67
  echo "var pid = '$pid';\n";
  echo "var eid = '$eid';\n";
}
else {
68 69
  unset($pid);
  unset($eid);
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
  echo "var pid = '';\n";
  echo "var eid = '';\n";
}

?>

/* @return The innerHeight of the window. */
function ml_getInnerHeight() {
    var retval;

    if (self.innerHeight) {
	// all except Explorer
	retval = self.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientHeight) {
	// Explorer 6 Strict Mode
	retval = document.documentElement.clientHeight;
    }
    else if (document.body) {
	// other Explorers
	retval = document.body.clientHeight;
    }

    return retval;
}

function resize() {
    var w_newWidth,w_newHeight;
    var w_maxWidth=1600, w_maxHeight=1200;

    if (navigator.appName.indexOf('Microsoft') != -1) {
        w_newWidth=document.body.clientWidth;
        w_newHeight=document.body.clientHeight;
    } else {
        var netscapeScrollWidth=15;

        w_newWidth=window.innerWidth-netscapeScrollWidth;
        w_newHeight=window.innerHeight-netscapeScrollWidth;
    }

    if (w_newWidth>w_maxWidth)
        w_newWidth=w_maxWidth;
    if (w_newHeight>w_maxHeight)
        w_newHeight=w_maxHeight;

    w_newWidth -= 75;
    w_newHeight -= 140;
    document.client.setOuterSize(w_newWidth, w_newHeight);
    document.client.width = w_newWidth;
    document.client.height = w_newHeight;

    window.scroll(0,0);
}

    var w_newWidth,w_newHeight;
    var w_maxWidth=1600, w_maxHeight=1200;

    if (navigator.appName.indexOf('Microsoft') != -1) {
        w_newWidth=document.body.clientWidth;
    } else {
        var netscapeScrollWidth=15;

        w_newWidth=window.innerWidth-netscapeScrollWidth;
    }

    w_newHeight = ml_getInnerHeight();
    if (w_newWidth>w_maxWidth)
        w_newWidth=w_maxWidth;
    if (w_newHeight>w_maxHeight)
        w_newHeight=w_maxHeight;

    w_newWidth -= 75;
    w_newHeight -= 140;

    if (w_newHeight<650)
        w_newHeight = 650;

app = document.createElement("applet");
app.setAttribute("width", w_newWidth);
app.setAttribute("height", w_newHeight);
app.setAttribute("archive", "netlab-client.jar");
app.setAttribute("code", "thinlet.AppletLauncher.class");
app.setAttribute("MAYSCRIPT", "MAYSCRIPT");

param = document.createElement("param");
param.setAttribute("name", "class");
param.setAttribute("value", "net.emulab.netlab.client.NetlabClient");
app.appendChild(param);

param = document.createElement("param");
param.setAttribute("name", "uid");
param.setAttribute("value", "<?php echo $uid?>");
app.appendChild(param);

param = document.createElement("param");
param.setAttribute("name", "auth");
166
param.setAttribute("value", "<?php echo $_COOKIE[$TBAUTHCOOKIE]?>");
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
app.appendChild(param);

if (pid != "" && eid != "") {
  param = document.createElement("param");
  param.setAttribute("name", "pid");
  param.setAttribute("value", pid);
  app.appendChild(param);

  param = document.createElement("param");
  param.setAttribute("name", "eid");
  param.setAttribute("value", eid);
  app.appendChild(param);
}

cb = document.getElementById("clientblock");
cb.appendChild(app);

window.onResize = resize;
window.onLoad = resize;
</script>

<?php if (isset($fallback)): ?>
<applet code='thinlet.AppletLauncher.class'
            archive='netlab-client.jar'
            width='800' height='600'
            alt='You need java to run this applet'>
    <param name="class" value="net.emulab.netlab.client.NetlabClient">
    <param name="uid" value="<?php echo $uid?>">
195
    <param name="auth" value="<?php echo $_COOKIE[$TBAUTHCOOKIE]?>">
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
    <?php if (isset($pid)): ?>
    <param name='pid' value='{$pid}'>
    <?php endif; ?>
    <?php if (isset($eid)): ?>
    <param name='eid' value='{$eid}'>
    <?php endif; ?>
</applet>
<?php endif; ?>

</body>
</html>
<?php
#
# Standard Testbed Footer
# 
211
PAGEFOOTER($view);
212
?>