clientui.php3 4.6 KB
Newer Older
Timothy Stack's avatar
 
Timothy Stack committed
1 2 3
<?php
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2000-2007 University of Utah and the Flux Group.
Timothy Stack's avatar
 
Timothy Stack committed
5 6 7 8 9 10 11 12 13 14 15 16 17
# All rights reserved.
#
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
);

18
PAGEHEADER("Experiment Creation GUI", $view);
Timothy Stack's avatar
 
Timothy Stack committed
19 20 21 22

#
# Only known and logged in users can do this.
#
23 24 25
$this_user = CheckLoginOrDie();
$uid       = $this_user->uid();
$isadmin   = ISADMIN();
Timothy Stack's avatar
 
Timothy Stack committed
26

27 28 29 30 31 32
#
# Verify page arguments.
#
$optargs = OptionalPageArguments("experiment", PAGEARG_EXPERIMENT,
				 "fallback",   PAGEARG_BOOLEAN);

Timothy Stack's avatar
 
Timothy Stack committed
33 34
?>

35 36
<h3>Note: See the Help menu for quickstart and tips</h3>

Timothy Stack's avatar
 
Timothy Stack committed
37 38 39 40 41 42
<div id="clientblock" name="clientblock"></div>

<script language='JavaScript'>

<?php

43 44 45 46
if (isset($experiment)) {
  $pid = $experiment->pid();
  $eid = $experiment->eid();
  
Timothy Stack's avatar
 
Timothy Stack committed
47 48 49 50
  echo "var pid = '$pid';\n";
  echo "var eid = '$eid';\n";
}
else {
51 52
  unset($pid);
  unset($eid);
Timothy Stack's avatar
 
Timothy Stack committed
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 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 166 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
  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");
param.setAttribute("value", "<?php echo $HTTP_COOKIE_VARS[$TBAUTHCOOKIE]?>");
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?>">
    <param name="auth" value="<?php echo $HTTP_COOKIE_VARS[$TBAUTHCOOKIE]?>">
    <?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
# 
194
PAGEFOOTER($view);
Timothy Stack's avatar
 
Timothy Stack committed
195
?>