already moved to different project
|
|
@ -1,385 +0,0 @@
|
|||
<% long now = System.currentTimeMillis(); %>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta http-equiv='cache-control' content='no-cache'>
|
||||
<meta http-equiv='expires' content='0'>
|
||||
<meta http-equiv='pragma' content='no-cache'>
|
||||
<link rel="stylesheet" href="css/main.css" type="text/css" />
|
||||
|
||||
<!-- Common libraries -->
|
||||
<script type="text/javascript" src="scripts/json2.js"></script>
|
||||
<script type="text/javascript" src="../scripts/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="../scripts/jquery-ui.custom.min.js"></script>
|
||||
<script type="text/javascript" src="../scripts/date.js"></script>
|
||||
<script type="text/javascript" src="../scripts/jquery.cookies.js"></script>
|
||||
<script type="text/javascript" src="../scripts/jquery.timers.js"></script>
|
||||
<script type="text/javascript" src="../scripts/jquery.md5.js"></script>
|
||||
|
||||
<!-- cloud.com scripts -->
|
||||
<script type="text/javascript" src="scripts/cloudkit.js?t=<%=now%>"></script>
|
||||
<script type="text/javascript" src="scripts/cloudkit.hosts.js?t=<%=now%>"></script>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
|
||||
|
||||
<title>myCloud</title>
|
||||
</head>
|
||||
<body>
|
||||
<!-- Host template -->
|
||||
<div class="db_gridrows" id="host_template" style="display:none">
|
||||
<div class="db_gridcolumns" style="width:20%;">
|
||||
<div class="db_gridcelltitles" id="hostname"></div>
|
||||
</div>
|
||||
<div class="db_gridcolumns" style="width:15%;">
|
||||
<div class="db_gridcelltitles green" id="state"></div>
|
||||
</div>
|
||||
<div class="db_gridcolumns" style="width:15%;">
|
||||
<div class="db_gridcelltitles" id="ip"></div>
|
||||
</div>
|
||||
<div class="db_gridcolumns" style="width:20%;">
|
||||
<div class="db_gridcelltitles" id="version"></div>
|
||||
</div>
|
||||
<div class="db_gridcolumns" style="width:20%;">
|
||||
<div class="db_gridcelltitles" id="disconnected"></div>
|
||||
</div>
|
||||
<div class="db_gridcolumns" style="width:10%;">
|
||||
<a class="db_statistics_icon" href="#" id="host_details"></a>
|
||||
<a class="db_delete_icon" style="margin-left:25px" href="#" id="host_delete"></a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- End Host template -->
|
||||
|
||||
<div id="main" style="display:none">
|
||||
<div id="dialog_overlay" style="display:none;">
|
||||
<div class="overlay_black"></div>
|
||||
|
||||
<!-- Statitics overlay starts here-->
|
||||
<div class="overlay_dialogbox" id="dialog_host_details" style="display:none;">
|
||||
<div class="overlay_dialogbox_contentarea">
|
||||
<div class="overlay_dialogbox_titlearea"><h2>Host Details</h2></div>
|
||||
<div class="overlay_dialogbox_content">
|
||||
<div class="db_stats_gridbox">
|
||||
<div class="db_stats_gridrow ">
|
||||
<div class="db_stats_gridcolumns" style="width:48%;">
|
||||
<div class="db_stats_gridcelltitles">Host GUID: </div>
|
||||
</div>
|
||||
<div class="db_stats_gridcolumns" style="width:50%;">
|
||||
<div class="db_stats_gridcelltitles"><strong id="host_id"></strong></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="db_stats_gridrow ">
|
||||
<div class="db_stats_gridcolumns" style="width:48%;">
|
||||
<div class="db_stats_gridcelltitles">Added Date: </div>
|
||||
</div>
|
||||
<div class="db_stats_gridcolumns" style="width:50%;">
|
||||
<div class="db_stats_gridcelltitles"><strong id="host_added"></strong></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="db_stats_gridrow ">
|
||||
<div class="db_stats_gridcolumns" style="width:48%;">
|
||||
<div class="db_stats_gridcelltitles">CPU Total: </div>
|
||||
</div>
|
||||
<div class="db_stats_gridcolumns" style="width:50%;">
|
||||
<div class="db_stats_gridcelltitles"><strong id="host_cpu_total">4 x 2.40 GHZ</strong></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="db_stats_gridrow ">
|
||||
<div class="db_stats_gridcolumns" style="width:48%;">
|
||||
<div class="db_stats_gridcelltitles">CPU Allocated:</div>
|
||||
</div>
|
||||
<div class="db_stats_gridcolumns" style="width:50%;">
|
||||
<div class="db_stats_gridcelltitles"><strong id="host_cpu_allocated">20.83%</strong></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="db_stats_gridrow ">
|
||||
<div class="db_stats_gridcolumns" style="width:48%;">
|
||||
<div class="db_stats_gridcelltitles">CPU Used: </div>
|
||||
</div>
|
||||
<div class="db_stats_gridcolumns" style="width:50%;">
|
||||
<div class="db_stats_gridcelltitles"><strong id="host_cpu_used">0.04%</strong></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="db_stats_gridrow ">
|
||||
<div class="db_stats_gridcolumns" style="width:48%;">
|
||||
<div class="db_stats_gridcelltitles">Memory Total:</div>
|
||||
</div>
|
||||
<div class="db_stats_gridcolumns" style="width:50%;">
|
||||
<div class="db_stats_gridcelltitles"><strong id="host_mem_total">3.09 GB</strong></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="db_stats_gridrow ">
|
||||
<div class="db_stats_gridcolumns" style="width:48%;">
|
||||
<div class="db_stats_gridcelltitles">Memory Allocated:</div>
|
||||
</div>
|
||||
<div class="db_stats_gridcolumns" style="width:50%;">
|
||||
<div class="db_stats_gridcelltitles"><strong id="host_mem_allocated">2.63 GB</strong></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="db_stats_gridrow ">
|
||||
<div class="db_stats_gridcolumns" style="width:48%;">
|
||||
<div class="db_stats_gridcelltitles">Memory Used:</div>
|
||||
</div>
|
||||
<div class="db_stats_gridcolumns" style="width:50%;">
|
||||
<div class="db_stats_gridcelltitles"><strong id="host_mem_used">2.63 GB</strong></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="db_stats_gridrow ">
|
||||
<div class="db_stats_gridcolumns" style="width:48%;">
|
||||
<div class="db_stats_gridcelltitles">Network Read:</div>
|
||||
</div>
|
||||
<div class="db_stats_gridcolumns" style="width:50%;">
|
||||
<div class="db_stats_gridcelltitles"><strong id="host_net_read">4338950879.03 TB</strong></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="db_stats_gridrow ">
|
||||
<div class="db_stats_gridcolumns" style="width:48%;">
|
||||
<div class="db_stats_gridcelltitles">Network Write:</div>
|
||||
</div>
|
||||
<div class="db_stats_gridcolumns" style="width:50%;">
|
||||
<div class="db_stats_gridcelltitles"><strong id="host_net_sent">4352955092.25 TB</strong></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="overlay_dialogbox_confirmationbox">
|
||||
<div class="overlay_dialogbox_confirmationbuttonbox">
|
||||
<div class="overlay_dialog_button" id="dialog_ok">OK</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Statitics overlay ends here-->
|
||||
|
||||
<!-- Delete overlay starts here-->
|
||||
<div class="overlay_dialogbox" style="display:none;" id="dialog_delete_host">
|
||||
<div class="overlay_dialogbox_contentarea">
|
||||
<div class="overlay_dialogbox_titlearea"><h2>Confirmation</h2></div>
|
||||
<div class="overlay_dialogbox_content">
|
||||
<p>Please confirm that you want to remove the host, <strong id="hostname"></strong>, from your cloud.</p>
|
||||
</div>
|
||||
|
||||
<div class="overlay_dialogbox_confirmationbox">
|
||||
<div class="overlay_dialogbox_confirmationbuttonbox">
|
||||
<a href="#" id="dialog_cancel">Cancel</a>
|
||||
<div class="overlay_dialog_button" id="dialog_confirm">Confirm</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Delete overlay ends here-->
|
||||
</div>
|
||||
<div id="header">
|
||||
<div class="logo"></div>
|
||||
<div class="user_links"><p><span id="header_username"></span></p><p><a href="#" id="header_logout">Logout</a></p></div>
|
||||
</div>
|
||||
<div class="main_contentbg">
|
||||
<div class="db_gridcontainer">
|
||||
<div class="db_gridcontainer_topbox">
|
||||
<div class="db_gridcontainer_topbox_left">
|
||||
<h2>myCloud</h2>
|
||||
<div id="search_panel" class="db_grid_searchbox">
|
||||
<div class="db_grid_searchicon"></div>
|
||||
<input id="search_input" class="text" type="text" />
|
||||
<a id="clear_search_button" class="db_grid_search_closeicon" href="#" style="display:none;"></a>
|
||||
</div>
|
||||
<div id="refresh_button" class="db_gridcontainer_refreshbox"><a href="#"> Refresh </a></div>
|
||||
</div>
|
||||
<div class="db_gridcontainer_topbox_right">
|
||||
<div class="db_grid_tabbox">
|
||||
<div class="db_grid_tabs on" id="tab_hosts">Hosts</div>
|
||||
</div>
|
||||
<div class="db_grid_tabbox">
|
||||
<div class="db_grid_tabs off" id="tab_docs">Getting Started</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="db_tabcontent" id="tab_hosts_content" style="display:block;">
|
||||
<div class="db_gridbox">
|
||||
<div class="db_gridrows header">
|
||||
<div class="db_gridcolumns header" style="width:20%;">
|
||||
<div class="db_gridcelltitles header">Name</div>
|
||||
</div>
|
||||
<div class="db_gridcolumns header" style="width:15%;">
|
||||
<div class="db_gridcelltitles header">State</div>
|
||||
</div>
|
||||
<div class="db_gridcolumns header" style="width:15%;">
|
||||
<div class="db_gridcelltitles header">IP Address</div>
|
||||
</div>
|
||||
<div class="db_gridcolumns header" style="width:20%;">
|
||||
<div class="db_gridcelltitles header">Version</div>
|
||||
</div>
|
||||
<div class="db_gridcolumns header" style="width:20%;">
|
||||
<div class="db_gridcelltitles header">Last Disconnected</div>
|
||||
</div>
|
||||
<div class="db_gridcolumns header" style="width:10%;">
|
||||
<div class="db_gridcelltitles header">Actions</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="db_maingrid">
|
||||
<!--Reminder for completing registrtaion starts here-->
|
||||
<div class="db_gridmsgbox" style="display:none;" id="registration_complete_container">
|
||||
<div class="db_gridmsgbox_content">
|
||||
<p>
|
||||
You have successfully added your first compute node. Please complete your registration process by clicking here: <a id="registration_complete_link" href='#'>Complete Registration</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<!--Reminder for completing registrtaion ends here-->
|
||||
<div id="host_container">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="db_grid_navigationpanel">
|
||||
<div class="db_gridb_paginationbox"><p>Page <span id="page_number">N</span></p></div>
|
||||
<div class="db_gridb_navbox">
|
||||
<a id="prev_page_button" href="#">Prev</a>
|
||||
<a id="next_page_button" href="#">Next</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="db_tabcontent" id="tab_docs_content" style="display:none;">
|
||||
<div class="db_gridbox">
|
||||
<div class="db_gridrows header">
|
||||
<div class="db_gridcolumns header" style="width:70%;">
|
||||
<div class="db_gridcelltitles header"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="db_maingrid">
|
||||
<div class="dbinstruction_contentarea">
|
||||
<div class="dbinstruction_submenubox">
|
||||
<div class="dbinstruction_submenubox_content">
|
||||
<ul>
|
||||
<li><a href="#gettingstarted">Getting Started</a></li>
|
||||
<li><a href="#managehost">Managing Your Hosts</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="getting_started"><a name="gettingstarted"></a>
|
||||
<h3>Getting Started</h3>
|
||||
<div class="db_downlaodbox">
|
||||
<p>Your zone token is: <strong id="zone_token"></strong></p>
|
||||
<a class="db_instructiondownlaodbutton" href="#">Download Installer</a>
|
||||
</div>
|
||||
|
||||
<h4>Contents</h4>
|
||||
<p>Cloud.com's <a href="http://cloud.com/products/cloud-computing-software">CloudStack</a> agent + RightScale's <a href="http://support.rightscale.com/06-FAQs/FAQ_0178_-_What_is_inside_of_a_RightImage%3F">RightImage</a> + README</p>
|
||||
|
||||
<h4>System requirements</h4>
|
||||
<div class="dbinstruction_bulletbox">
|
||||
<ul>
|
||||
<li>One or more computer hosts capable of running the software. See <a href="http://linuxhcl.com/">Linux Hardware Compatibility List</a>.</li>
|
||||
<li>Ubuntu 10.04 LTS installed on each machine. Available at <a href="http://releases.ubuntu.com/">Ubuntu Releases</a>.</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<h4>Adding a New Host</h4>
|
||||
<p>To add a new host, install the CloudStack agent software on it.</p>
|
||||
<div class="dbinstruction_bulletbox">
|
||||
<ol>
|
||||
<li>Click the Download button to get the CloudKit installation bundle.</li>
|
||||
<li>Log in as root to the host machine where you want to install the software.
|
||||
The machine must have <a href="http://releases.ubuntu.com/">Ubuntu 10.04 LTS</a> installed.
|
||||
</li>
|
||||
<li>Place the CloudKit installation bundle on the host and untar.
|
||||
<div class="dbinstruction_bulletbox_codebox"># tar xzf <Installer file name>.tar.gz</div>
|
||||
</li>
|
||||
<li>Run the installer.
|
||||
<div class="dbinstruction_bulletbox_codebox"># cd <Directory of extracted installer></div>
|
||||
<div class="dbinstruction_bulletbox_codebox"># sudo ./install.sh</div>
|
||||
</li>
|
||||
<li>At the prompt, type A to install the agent. Installation can take a few minutes.
|
||||
When installation is finished, a message like "Agent installation is completed" appears.</li>
|
||||
<li>After the agent installation finishes, run the setup script.</li>
|
||||
<div class="dbinstruction_bulletbox_codebox"># sudo mycloud-setup-agent</div>
|
||||
<li>For Management Server address, use the default if it is not localhost, or input the IP address provided to you by
|
||||
Cloud.com. Currently the only Management Server IP being provided is 192.168.130.223.</li>
|
||||
<li>When prompted, paste in the zone token for your cloud. You can find it at the top of this page.
|
||||
The zone token is a unique code that identifies your cloud. You will need it throughout the lifetime of your cloud.
|
||||
</li>
|
||||
<li>Provide the name of the network interface you want to use, or (typically) accept the default.
|
||||
</li>
|
||||
<li>When the "Installation complete!" message appears, confirm that the new host appears in the Hosts tab of the <a href="http://216.38.159.3:8080/client/cloudkit/login.jsp ">CloudKit administration UI</a>.
|
||||
You can also run this command on the host to be sure the cloud-agent software is running:
|
||||
<div class="dbinstruction_bulletbox_codebox"># sudo service cloud-agent status</div>
|
||||
</li>
|
||||
<li>Click <a id="registration_complete_doc_link" href='#'>Complete Registration</a>.
|
||||
The new host is automatically registered with RightScale as part of your CloudKit cloud.</p>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<p><strong>You're ready to start using your new host!</strong></p>
|
||||
<h4>More Information</h4>
|
||||
<p style="margin-top:5px;"><a href="#">RightScale's CoudKit docs (title and URL: TBD)</a></p>
|
||||
</div>
|
||||
|
||||
<div id="managing_host">
|
||||
|
||||
<h3>Managing Your Hosts</h3>
|
||||
<a name="managehost"></a>
|
||||
<p>Use the Hosts tab of the CloudKit administration UI to view host status or delete hosts.</p>
|
||||
<p>(Want to do more than view or delete? To add a host, click the Installer tab. For other cloud management tasks, <a href="#">RightScale UI</a>.)</p>
|
||||
|
||||
|
||||
<div class="dbinstruction_bulletbox">
|
||||
<ul>
|
||||
<li><strong>Host Name</strong>: IP address or fully-qualified DNS name of the host</li>
|
||||
<li><strong>State:</strong></li>
|
||||
<li style="margin-left:15px; display:inline;">Connecting: Request to connect to the cloud has been received and the host is attempting to comply</li>
|
||||
<li style="margin-left:15px; display:inline;">Up: Host is connected and operational in the cloud</li>
|
||||
<li style="margin-left:15px; display:inline;">Down: Host is connected but not operational</li>
|
||||
<li style="margin-left:15px; display:inline;">Disconnected: Host is not connected to the cloud</li>
|
||||
<li style="margin-left:15px; display:inline;">Updating: State of the host is in transition</li>
|
||||
<li style="margin-left:15px; display:inline;">PrepareForMaintenance: Request to put the host into maintenance mode has been received</li>
|
||||
<li style="margin-left:15px; display:inline;">ErrorInMaintenance: Action taken during maintenance mode has failed</li>
|
||||
<li style="margin-left:15px; display:inline;">CancelMaintenance: Request to abandon maintenance activity and restore host to previous condition has been received</li>
|
||||
<li style="margin-left:15px; display:inline;">Maintenance: Host is in maintenance mode and is not available for new VM instances</li>
|
||||
<li style="margin-left:15px; display:inline;">Alert: Error condition exists on the host and requires attention</li>
|
||||
<li style="margin-left:15px; display:inline;">Removed: Request to delete the host has been received</li>
|
||||
<li><strong>Version</strong>: Version of CloudKit software installed on the host</li>
|
||||
<li><strong>Last Disconnected</strong>: Timestamp recording any prior disconnection of the host from the cloud</li>
|
||||
<li><strong>Action</strong></li>
|
||||
<li style="margin-left:15px; display:inline;"><a class="db_statistics_icon" style="margin:-5px 5px 0 0;"></a> Statistic Icon: Click to display resource usage statistics for troubleshooting and tuning</li>
|
||||
<li style="margin-left:15px; display:inline;"><a class="db_delete_icon" style="margin:-5px 5px 0 0;"></a>Delete Icon: Click to delete host; a confirmation dialog will be displayed</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<h4>Adding a New Host</h4>
|
||||
<p style="margin-top:5px;">To add a new host, install the CloudStack agent software on it. Click the Getting Started tab and follow the <a href="#gettingstarted">installation steps</a>.</p>
|
||||
|
||||
<h4>More Information</h4>
|
||||
<p style="margin-top:5px;"><a href="#">RightScale's CoudKit docs (title and URL: TBD)</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="footer">
|
||||
<div class="footer_left"><p>© 2006-2011 RightScale, Inc. All rights reserved. RightScale is a registered trademark of RightScale, Inc. </p></div>
|
||||
<div class="footer_right">
|
||||
<a class="poweredby" href="http://cloud.com/"></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 263 B |
|
Before Width: | Height: | Size: 175 B |
|
Before Width: | Height: | Size: 712 B |
|
Before Width: | Height: | Size: 707 B |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 267 B |
|
Before Width: | Height: | Size: 222 B |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 413 B |
|
Before Width: | Height: | Size: 407 B |
|
Before Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 4.8 KiB |
|
Before Width: | Height: | Size: 131 B |
|
Before Width: | Height: | Size: 423 B |
|
Before Width: | Height: | Size: 612 B |
|
Before Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 391 B |
|
Before Width: | Height: | Size: 615 B |
|
Before Width: | Height: | Size: 55 B |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 475 B |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 652 B |
|
Before Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 334 B |
|
Before Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 336 B |
|
Before Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 126 B |
|
Before Width: | Height: | Size: 126 B |
|
Before Width: | Height: | Size: 531 B |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 362 B |
|
Before Width: | Height: | Size: 159 B |
|
Before Width: | Height: | Size: 137 B |
|
Before Width: | Height: | Size: 135 B |
|
Before Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 45 B |
|
|
@ -1,53 +0,0 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>Untitled Document</title>
|
||||
<link rel="stylesheet" href="css/main.css" type="text/css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="main">
|
||||
<div id="header">
|
||||
<div class="logo"></div>
|
||||
</div>
|
||||
<div class="main_contentbg">
|
||||
<div class="login_box">
|
||||
<div class="login_box_top"></div>
|
||||
<div class="login_box_mid">
|
||||
<h2>Login to Cloud.com Account</h2>
|
||||
<div class="login_formbox">
|
||||
<form action="#" method="post">
|
||||
<ul>
|
||||
<li>
|
||||
<label for="username">Username</label>
|
||||
<input type="text" class="text" />
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<label for="username">Password</label>
|
||||
<input type="text" class="text" />
|
||||
</li>
|
||||
</ul>
|
||||
<div class="login_submitbox">
|
||||
<input class="login_button" type="submit" value="" />
|
||||
<a href="#">Cancel</a>
|
||||
</div>
|
||||
</form>
|
||||
<div class="login_errormsgbox" style="display:none;">
|
||||
<p>Error msg will appear here</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="login_box_bot"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="footer">
|
||||
<div class="footer_left"><p>© 2006-2011 RightScale, Inc. All rights reserved. RightScale is a registered trademark of RightScale, Inc. </p></div>
|
||||
<div class="footer_right">
|
||||
<a class="poweredby" href="http://cloud.com/"></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
<% long now = System.currentTimeMillis(); %>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta http-equiv='cache-control' content='no-cache'>
|
||||
<meta http-equiv='expires' content='0'>
|
||||
<meta http-equiv='pragma' content='no-cache'>
|
||||
<link rel="stylesheet" href="css/main.css" type="text/css" />
|
||||
|
||||
<!-- Common libraries -->
|
||||
<script type="text/javascript" src="scripts/json2.js"></script>
|
||||
<script type="text/javascript" src="../scripts/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="../scripts/jquery-ui.custom.min.js"></script>
|
||||
<script type="text/javascript" src="../scripts/date.js"></script>
|
||||
<script type="text/javascript" src="../scripts/jquery.cookies.js"></script>
|
||||
<script type="text/javascript" src="../scripts/jquery.timers.js"></script>
|
||||
<script type="text/javascript" src="../scripts/jquery.md5.js"></script>
|
||||
|
||||
<!-- cloud.com scripts -->
|
||||
<script type="text/javascript" src="scripts/cloudkit.js?t=<%=now%>"></script>
|
||||
<script type="text/javascript" src="scripts/cloudkit.login.js?t=<%=now%>"></script>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
|
||||
|
||||
<title>myCloud - Login</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="loginmain" style="display:none">
|
||||
<div class="login_box">
|
||||
<div class="login_box_top">
|
||||
<div class="login_logo"></div>
|
||||
</div>
|
||||
<div class="login_box_mid">
|
||||
<h2>Login to your myCloud Account</h2>
|
||||
<div id="login_form" class="login_formbox">
|
||||
<form>
|
||||
<ul>
|
||||
<li>
|
||||
<label for="username">Username</label>
|
||||
<input type="text" class="text" id="login_username"/>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<label for="password">Password</label>
|
||||
<input type="password" class="text" id="login_password"/>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="login_submitbox">
|
||||
<div class="login_button" value="" id="login_submit" ></div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
<div id="login_error" class="login_errormsgbox" style="display:none;">
|
||||
<p>Your username/password does not match our records.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="login_box_bot"></div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
$(document).ready(function() {
|
||||
});
|
||||
|
|
@ -1,287 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
function convertBytes(bytes) {
|
||||
if (bytes < 1024 * 1024) {
|
||||
return (bytes / 1024).toFixed(2) + " KB";
|
||||
} else if (bytes < 1024 * 1024 * 1024) {
|
||||
return (bytes / 1024 / 1024).toFixed(2) + " MB";
|
||||
} else if (bytes < 1024 * 1024 * 1024 * 1024) {
|
||||
return (bytes / 1024 / 1024 / 1024).toFixed(2) + " GB";
|
||||
} else {
|
||||
return (bytes / 1024 / 1024 / 1024 / 1024).toFixed(2) + " TB";
|
||||
}
|
||||
}
|
||||
|
||||
function convertHz(hz) {
|
||||
if (hz == null)
|
||||
return "";
|
||||
|
||||
if (hz < 1000) {
|
||||
return hz + " MHZ";
|
||||
} else {
|
||||
return (hz / 1000).toFixed(2) + " GHZ";
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
if (g_loginResponse == null) {
|
||||
logout();
|
||||
return;
|
||||
}
|
||||
|
||||
// setup dialog
|
||||
var dialog = $("#dialog_overlay");
|
||||
dialog.find("#dialog_cancel, #dialog_ok").bind("click", function(event) {
|
||||
dialog.hide();
|
||||
});
|
||||
dialog.find("#dialog_confirm").bind("click", function(event) {
|
||||
var id = $(this).data("hostid");
|
||||
$.ajax({
|
||||
data: createURL("command=deleteHost&id="+id),
|
||||
success: function(json) {
|
||||
$("#host_"+id).slideUp("slow", function() {
|
||||
$(this).remove();
|
||||
});
|
||||
}
|
||||
});
|
||||
dialog.hide();
|
||||
});
|
||||
|
||||
// setup host template and container
|
||||
var hostTemplate = $("#host_template");
|
||||
var hostContainer = $("#host_container");
|
||||
|
||||
hostContainer.bind("click", function(event) {
|
||||
var $container = $(this);
|
||||
var target = $(event.target);
|
||||
var targetId = target.attr("id");
|
||||
|
||||
switch (targetId) {
|
||||
case "host_details" :
|
||||
var details = dialog.find("#dialog_host_details").show();
|
||||
dialog.find("#dialog_delete_host").hide();
|
||||
var jsonObj = target.data("jsonObj");
|
||||
|
||||
details.find("#host_id").text(jsonObj.id);
|
||||
details.find("#host_cpu_total").text((jsonObj.cpuspeed == null)? "": (jsonObj.cpunumber + "x" + convertHz(jsonObj.cpuspeed)));
|
||||
details.find("#host_cpu_allocated").text((jsonObj.cpuallocated == null)? "": jsonObj.cpuallocated);
|
||||
details.find("#host_cpu_used").text((jsonObj.cpuused == null)? "": jsonObj.cpuused);
|
||||
details.find("#host_mem_total").text((jsonObj.memorytotal == null)? "": convertBytes(jsonObj.memorytotal));
|
||||
details.find("#host_mem_allocated").text((jsonObj.memoryallocated == null)? "": convertBytes(jsonObj.memoryallocated));
|
||||
details.find("#host_mem_used").text((jsonObj.memeoryused == null)? "": convertBytes(jsonObj.memeoryused));
|
||||
details.find("#host_net_read").text((jsonObj.networkkbsread == null)? "": convertBytes(jsonObj.networkkbsread * 1024));
|
||||
details.find("#host_net_sent").text((jsonObj.networkkbswrite == null)? "": convertBytes(jsonObj.networkkbswrite *1024));
|
||||
|
||||
if (jsonObj.created != null) {
|
||||
var created = new Date();
|
||||
created.setISO8601(jsonObj.created);
|
||||
details.find("#host_added").text(created.format("m/d/Y H:i:s"));
|
||||
}
|
||||
else {
|
||||
details.find("#host_added").text("");
|
||||
}
|
||||
dialog.show();
|
||||
break;
|
||||
case "host_delete" :
|
||||
dialog.find("#dialog_host_details").hide();
|
||||
dialog.find("#dialog_delete_host").show();
|
||||
var jsonObj = target.data("jsonObj");
|
||||
dialog.find("#hostname").text(jsonObj.name);
|
||||
dialog.find("#dialog_confirm").data("hostid", jsonObj.id);
|
||||
dialog.show();
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
var page = 1;
|
||||
var midmenuItemCount = 13;
|
||||
function listHosts() {
|
||||
if(page > 1)
|
||||
$("#prev_page_button").show();
|
||||
else
|
||||
$("#prev_page_button").hide();
|
||||
|
||||
var cmdString = "command=listHosts&type=Routing"+"&pagesize="+midmenuItemCount+"&page="+page;
|
||||
var searchInput = $("#search_panel").find("#search_input").val();
|
||||
if (searchInput != null && searchInput.length > 0)
|
||||
cmdString += ("&keyword="+searchInput);
|
||||
|
||||
$.ajax({
|
||||
data: createURL(cmdString),
|
||||
success: function(json) {
|
||||
hostContainer.empty();
|
||||
$("#page_number").text(page);
|
||||
var hosts = json.listhostsresponse.host;
|
||||
if (hosts != null && hosts.length >0) {
|
||||
if(hosts.length >= midmenuItemCount)
|
||||
$("#next_page_button").show();
|
||||
else
|
||||
$("#next_page_button").hide();
|
||||
|
||||
for (var i = 0; i < hosts.length; i++) {
|
||||
var host = hosts[i];
|
||||
var template = hostTemplate.clone(true).attr("id", "host_"+host.id);
|
||||
template.find("#host_details").data("jsonObj", host);
|
||||
template.find("#host_delete").data("jsonObj", host);
|
||||
template.find("#hostname").text(host.name);
|
||||
template.find("#ip").text(host.ipaddress);
|
||||
template.find("#version").text(host.version);
|
||||
|
||||
if (host.disconnected != null) {
|
||||
var disconnected = new Date();
|
||||
disconnected.setISO8601(host.disconnected);
|
||||
template.find("#disconnected").text(disconnected.format("m/d/Y H:i:s"));
|
||||
}
|
||||
var state = host.state;
|
||||
template.find("#state").text(state);
|
||||
if (state == 'Up') {
|
||||
template.find("#state").removeClass("red").addClass("green");
|
||||
}
|
||||
else {
|
||||
template.find("#state").removeClass("green").addClass("red");
|
||||
}
|
||||
hostContainer.append(template.show());
|
||||
}
|
||||
}
|
||||
else {
|
||||
$("#next_page_button").hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// *** Setup tab clicks (begin) ***
|
||||
$("#tab_hosts").bind("click", function(event) {
|
||||
$(this).removeClass("off").addClass("on");
|
||||
$("#tab_docs").removeClass("on").addClass("off");
|
||||
$("#tab_docs_content").hide();
|
||||
$("#tab_hosts_content").show();
|
||||
$("#search_input").val("");
|
||||
$("#search_panel").show();
|
||||
page = 1; //reset pagination to the first page
|
||||
listHosts();
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#tab_docs").bind("click", function(event) {
|
||||
$(this).removeClass("off").addClass("on");
|
||||
$("#tab_hosts").removeClass("on").addClass("off");
|
||||
$("#tab_hosts_content").hide();
|
||||
$("#tab_docs_content").show();
|
||||
$("#search_panel").hide();
|
||||
|
||||
$.ajax({
|
||||
data: createURL("command=listZones&domainid="+g_loginResponse.domainid), // Setup zone key
|
||||
success: function(json) {
|
||||
var zones = json.listzonesresponse.zone;
|
||||
if (zones != null && zones.length >0) {
|
||||
$("#zone_token").text(zones[0].zonetoken);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
// *** Setup tab clicks (end) ***
|
||||
|
||||
// *** Pagination (begin) ***
|
||||
$("#tab_hosts_content").find("#prev_page_button").bind("click", function(event){
|
||||
page--
|
||||
listHosts();
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#tab_hosts_content").find("#next_page_button").bind("click", function(event){
|
||||
page++
|
||||
listHosts();
|
||||
return false;
|
||||
});
|
||||
// *** Pagination (begin) ***
|
||||
|
||||
// *** Search (begin) ***
|
||||
$("#search_input").bind("keypress", function(event) {
|
||||
if(event.keyCode == keycode_Enter) {
|
||||
page = 1; //reset pagination to the first page
|
||||
listHosts();
|
||||
}
|
||||
else {
|
||||
$("#clear_search_button").show();
|
||||
}
|
||||
return true;
|
||||
});
|
||||
$("#clear_search_button").bind("click", function(event){
|
||||
$("#search_input").val("");
|
||||
page = 1; //reset pagination to the first page
|
||||
listHosts();
|
||||
$(this).hide();
|
||||
return false;
|
||||
});
|
||||
// *** Search (end) ***
|
||||
|
||||
// *** Refresh button (begin) ***
|
||||
$("#refresh_button").bind("click", function(event){
|
||||
listHosts();
|
||||
return false;
|
||||
});
|
||||
// *** Refresh button (end) ***
|
||||
|
||||
var oneHostUp = false;
|
||||
var atLeastOneHost = false;
|
||||
$.ajax({
|
||||
data: createURL("command=listHosts&type=Routing"),
|
||||
success: function(json) {
|
||||
hostContainer.empty();
|
||||
var hosts = json.listhostsresponse.host;
|
||||
if (hosts != null && hosts.length >0) {
|
||||
atLeastOneHost = true;
|
||||
for (var i = 0; i < hosts.length; i++) {
|
||||
var host = hosts[i];
|
||||
if (host.state == 'Up') {
|
||||
oneHostUp = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (g_loginResponse.registered == "false") {
|
||||
if (!atLeastOneHost) {
|
||||
$("#tab_docs").click();
|
||||
}
|
||||
else if (oneHostUp) {
|
||||
$("#registration_complete_link").attr("href","https://my.rightscale.com/cloud_registrations/my_cloud/cloud_stack/new?callback_url="+encodeURIComponent("http://216.38.159.3:8080/client/cloudkit/complete?token="+g_loginResponse.registrationtoken));
|
||||
$("#registration_complete_container").show();
|
||||
$("#tab_hosts").click();
|
||||
}
|
||||
else {
|
||||
$("#tab_hosts").click();
|
||||
}
|
||||
}
|
||||
else {
|
||||
$("#registration_complete_container").hide();
|
||||
$("#tab_hosts").click();
|
||||
}
|
||||
|
||||
$("#registration_complete_doc_link").attr("href","https://my.rightscale.com/cloud_registrations/my_cloud/cloud_stack/new?callback_url="+encodeURIComponent("http://216.38.159.3:8080/client/cloudkit/complete?token="+g_loginResponse.registrationtoken));
|
||||
$("#main").show();
|
||||
});
|
||||
|
||||
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
var g_loginResponse = null;
|
||||
$.urlParam = function(name){ var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href); if (!results) { return 0; } return results[1] || 0;}
|
||||
|
||||
function logout() {
|
||||
window.location='/client/cloudkit/login.jsp';
|
||||
g_loginResponse = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
var url = $.urlParam("loginUrl");
|
||||
if (url != undefined && url != null && url.length > 0) {
|
||||
url = unescape("/client/api?"+url);
|
||||
$.ajax({
|
||||
url: url,
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
g_loginResponse = json.loginresponse;
|
||||
$("#registration_complete_link").attr("href","https://my.rightscale.com/cloud_registrations/cloudkit/new?callback_url="+encodeURIComponent("http://localhost:8080/client/cloudkit/complete?token="+g_loginResponse.registrationtoken));
|
||||
},
|
||||
error: function() {
|
||||
logout();
|
||||
},
|
||||
beforeSend: function(XMLHttpRequest) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
logout();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
$.urlParam = function(name){ var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href); if (!results) { return 0; } return results[1] || 0;}
|
||||
|
||||
$(document).ready(function() {
|
||||
var url = $.urlParam("loginUrl");
|
||||
if (url != undefined && url != null && url.length > 0) {
|
||||
// single signon process
|
||||
url = unescape("/client/api?"+url);
|
||||
$.ajax({
|
||||
url: url,
|
||||
dataType: "json",
|
||||
async: false,
|
||||
type: "POST",
|
||||
success: function(json) {
|
||||
login(json);
|
||||
},
|
||||
error: function() {
|
||||
logout();
|
||||
},
|
||||
beforeSend: function(XMLHttpRequest) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$("#loginmain").show();
|
||||
|
||||
$("#login_submit").click("click", function(event) {
|
||||
var username = escape($("#login_username").val());
|
||||
var password = $.md5($("#login_password").val());
|
||||
var domain = escape("/"+username+"_domain");
|
||||
$.ajax({
|
||||
url: "/client/api?command=login&response=json&username="+username+"&password="+password+"&domain="+domain,
|
||||
dataType: "json",
|
||||
async: false,
|
||||
type: "POST",
|
||||
success: function(json) {
|
||||
$("#login_error").hide();
|
||||
login(json);
|
||||
},
|
||||
error: function(XMLHttpRequest) {
|
||||
$("#login_password").val("");
|
||||
$("#login_error").show();
|
||||
$("#login_username").focus();
|
||||
},
|
||||
beforeSend: function(XMLHttpRequest) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#login_form").keypress(function(event) {
|
||||
if(event.keyCode == keycode_Enter) {
|
||||
$("#login_submit").click();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
@ -1,480 +0,0 @@
|
|||
/*
|
||||
http://www.JSON.org/json2.js
|
||||
2011-02-23
|
||||
|
||||
Public Domain.
|
||||
|
||||
NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
|
||||
|
||||
See http://www.JSON.org/js.html
|
||||
|
||||
|
||||
This code should be minified before deployment.
|
||||
See http://javascript.crockford.com/jsmin.html
|
||||
|
||||
USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
|
||||
NOT CONTROL.
|
||||
|
||||
|
||||
This file creates a global JSON object containing two methods: stringify
|
||||
and parse.
|
||||
|
||||
JSON.stringify(value, replacer, space)
|
||||
value any JavaScript value, usually an object or array.
|
||||
|
||||
replacer an optional parameter that determines how object
|
||||
values are stringified for objects. It can be a
|
||||
function or an array of strings.
|
||||
|
||||
space an optional parameter that specifies the indentation
|
||||
of nested structures. If it is omitted, the text will
|
||||
be packed without extra whitespace. If it is a number,
|
||||
it will specify the number of spaces to indent at each
|
||||
level. If it is a string (such as '\t' or ' '),
|
||||
it contains the characters used to indent at each level.
|
||||
|
||||
This method produces a JSON text from a JavaScript value.
|
||||
|
||||
When an object value is found, if the object contains a toJSON
|
||||
method, its toJSON method will be called and the result will be
|
||||
stringified. A toJSON method does not serialize: it returns the
|
||||
value represented by the name/value pair that should be serialized,
|
||||
or undefined if nothing should be serialized. The toJSON method
|
||||
will be passed the key associated with the value, and this will be
|
||||
bound to the value
|
||||
|
||||
For example, this would serialize Dates as ISO strings.
|
||||
|
||||
Date.prototype.toJSON = function (key) {
|
||||
function f(n) {
|
||||
// Format integers to have at least two digits.
|
||||
return n < 10 ? '0' + n : n;
|
||||
}
|
||||
|
||||
return this.getUTCFullYear() + '-' +
|
||||
f(this.getUTCMonth() + 1) + '-' +
|
||||
f(this.getUTCDate()) + 'T' +
|
||||
f(this.getUTCHours()) + ':' +
|
||||
f(this.getUTCMinutes()) + ':' +
|
||||
f(this.getUTCSeconds()) + 'Z';
|
||||
};
|
||||
|
||||
You can provide an optional replacer method. It will be passed the
|
||||
key and value of each member, with this bound to the containing
|
||||
object. The value that is returned from your method will be
|
||||
serialized. If your method returns undefined, then the member will
|
||||
be excluded from the serialization.
|
||||
|
||||
If the replacer parameter is an array of strings, then it will be
|
||||
used to select the members to be serialized. It filters the results
|
||||
such that only members with keys listed in the replacer array are
|
||||
stringified.
|
||||
|
||||
Values that do not have JSON representations, such as undefined or
|
||||
functions, will not be serialized. Such values in objects will be
|
||||
dropped; in arrays they will be replaced with null. You can use
|
||||
a replacer function to replace those with JSON values.
|
||||
JSON.stringify(undefined) returns undefined.
|
||||
|
||||
The optional space parameter produces a stringification of the
|
||||
value that is filled with line breaks and indentation to make it
|
||||
easier to read.
|
||||
|
||||
If the space parameter is a non-empty string, then that string will
|
||||
be used for indentation. If the space parameter is a number, then
|
||||
the indentation will be that many spaces.
|
||||
|
||||
Example:
|
||||
|
||||
text = JSON.stringify(['e', {pluribus: 'unum'}]);
|
||||
// text is '["e",{"pluribus":"unum"}]'
|
||||
|
||||
|
||||
text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
|
||||
// text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
|
||||
|
||||
text = JSON.stringify([new Date()], function (key, value) {
|
||||
return this[key] instanceof Date ?
|
||||
'Date(' + this[key] + ')' : value;
|
||||
});
|
||||
// text is '["Date(---current time---)"]'
|
||||
|
||||
|
||||
JSON.parse(text, reviver)
|
||||
This method parses a JSON text to produce an object or array.
|
||||
It can throw a SyntaxError exception.
|
||||
|
||||
The optional reviver parameter is a function that can filter and
|
||||
transform the results. It receives each of the keys and values,
|
||||
and its return value is used instead of the original value.
|
||||
If it returns what it received, then the structure is not modified.
|
||||
If it returns undefined then the member is deleted.
|
||||
|
||||
Example:
|
||||
|
||||
// Parse the text. Values that look like ISO date strings will
|
||||
// be converted to Date objects.
|
||||
|
||||
myData = JSON.parse(text, function (key, value) {
|
||||
var a;
|
||||
if (typeof value === 'string') {
|
||||
a =
|
||||
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
|
||||
if (a) {
|
||||
return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
|
||||
+a[5], +a[6]));
|
||||
}
|
||||
}
|
||||
return value;
|
||||
});
|
||||
|
||||
myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
|
||||
var d;
|
||||
if (typeof value === 'string' &&
|
||||
value.slice(0, 5) === 'Date(' &&
|
||||
value.slice(-1) === ')') {
|
||||
d = new Date(value.slice(5, -1));
|
||||
if (d) {
|
||||
return d;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
});
|
||||
|
||||
|
||||
This is a reference implementation. You are free to copy, modify, or
|
||||
redistribute.
|
||||
*/
|
||||
|
||||
/*jslint evil: true, strict: false, regexp: false */
|
||||
|
||||
/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
|
||||
call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
|
||||
getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
|
||||
lastIndex, length, parse, prototype, push, replace, slice, stringify,
|
||||
test, toJSON, toString, valueOf
|
||||
*/
|
||||
|
||||
|
||||
// Create a JSON object only if one does not already exist. We create the
|
||||
// methods in a closure to avoid creating global variables.
|
||||
|
||||
var JSON;
|
||||
if (!JSON) {
|
||||
JSON = {};
|
||||
}
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
function f(n) {
|
||||
// Format integers to have at least two digits.
|
||||
return n < 10 ? '0' + n : n;
|
||||
}
|
||||
|
||||
if (typeof Date.prototype.toJSON !== 'function') {
|
||||
|
||||
Date.prototype.toJSON = function (key) {
|
||||
|
||||
return isFinite(this.valueOf()) ?
|
||||
this.getUTCFullYear() + '-' +
|
||||
f(this.getUTCMonth() + 1) + '-' +
|
||||
f(this.getUTCDate()) + 'T' +
|
||||
f(this.getUTCHours()) + ':' +
|
||||
f(this.getUTCMinutes()) + ':' +
|
||||
f(this.getUTCSeconds()) + 'Z' : null;
|
||||
};
|
||||
|
||||
String.prototype.toJSON =
|
||||
Number.prototype.toJSON =
|
||||
Boolean.prototype.toJSON = function (key) {
|
||||
return this.valueOf();
|
||||
};
|
||||
}
|
||||
|
||||
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
|
||||
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
|
||||
gap,
|
||||
indent,
|
||||
meta = { // table of character substitutions
|
||||
'\b': '\\b',
|
||||
'\t': '\\t',
|
||||
'\n': '\\n',
|
||||
'\f': '\\f',
|
||||
'\r': '\\r',
|
||||
'"' : '\\"',
|
||||
'\\': '\\\\'
|
||||
},
|
||||
rep;
|
||||
|
||||
|
||||
function quote(string) {
|
||||
|
||||
// If the string contains no control characters, no quote characters, and no
|
||||
// backslash characters, then we can safely slap some quotes around it.
|
||||
// Otherwise we must also replace the offending characters with safe escape
|
||||
// sequences.
|
||||
|
||||
escapable.lastIndex = 0;
|
||||
return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
|
||||
var c = meta[a];
|
||||
return typeof c === 'string' ? c :
|
||||
'\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
|
||||
}) + '"' : '"' + string + '"';
|
||||
}
|
||||
|
||||
|
||||
function str(key, holder) {
|
||||
|
||||
// Produce a string from holder[key].
|
||||
|
||||
var i, // The loop counter.
|
||||
k, // The member key.
|
||||
v, // The member value.
|
||||
length,
|
||||
mind = gap,
|
||||
partial,
|
||||
value = holder[key];
|
||||
|
||||
// If the value has a toJSON method, call it to obtain a replacement value.
|
||||
|
||||
if (value && typeof value === 'object' &&
|
||||
typeof value.toJSON === 'function') {
|
||||
value = value.toJSON(key);
|
||||
}
|
||||
|
||||
// If we were called with a replacer function, then call the replacer to
|
||||
// obtain a replacement value.
|
||||
|
||||
if (typeof rep === 'function') {
|
||||
value = rep.call(holder, key, value);
|
||||
}
|
||||
|
||||
// What happens next depends on the value's type.
|
||||
|
||||
switch (typeof value) {
|
||||
case 'string':
|
||||
return quote(value);
|
||||
|
||||
case 'number':
|
||||
|
||||
// JSON numbers must be finite. Encode non-finite numbers as null.
|
||||
|
||||
return isFinite(value) ? String(value) : 'null';
|
||||
|
||||
case 'boolean':
|
||||
case 'null':
|
||||
|
||||
// If the value is a boolean or null, convert it to a string. Note:
|
||||
// typeof null does not produce 'null'. The case is included here in
|
||||
// the remote chance that this gets fixed someday.
|
||||
|
||||
return String(value);
|
||||
|
||||
// If the type is 'object', we might be dealing with an object or an array or
|
||||
// null.
|
||||
|
||||
case 'object':
|
||||
|
||||
// Due to a specification blunder in ECMAScript, typeof null is 'object',
|
||||
// so watch out for that case.
|
||||
|
||||
if (!value) {
|
||||
return 'null';
|
||||
}
|
||||
|
||||
// Make an array to hold the partial results of stringifying this object value.
|
||||
|
||||
gap += indent;
|
||||
partial = [];
|
||||
|
||||
// Is the value an array?
|
||||
|
||||
if (Object.prototype.toString.apply(value) === '[object Array]') {
|
||||
|
||||
// The value is an array. Stringify every element. Use null as a placeholder
|
||||
// for non-JSON values.
|
||||
|
||||
length = value.length;
|
||||
for (i = 0; i < length; i += 1) {
|
||||
partial[i] = str(i, value) || 'null';
|
||||
}
|
||||
|
||||
// Join all of the elements together, separated with commas, and wrap them in
|
||||
// brackets.
|
||||
|
||||
v = partial.length === 0 ? '[]' : gap ?
|
||||
'[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' :
|
||||
'[' + partial.join(',') + ']';
|
||||
gap = mind;
|
||||
return v;
|
||||
}
|
||||
|
||||
// If the replacer is an array, use it to select the members to be stringified.
|
||||
|
||||
if (rep && typeof rep === 'object') {
|
||||
length = rep.length;
|
||||
for (i = 0; i < length; i += 1) {
|
||||
if (typeof rep[i] === 'string') {
|
||||
k = rep[i];
|
||||
v = str(k, value);
|
||||
if (v) {
|
||||
partial.push(quote(k) + (gap ? ': ' : ':') + v);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
// Otherwise, iterate through all of the keys in the object.
|
||||
|
||||
for (k in value) {
|
||||
if (Object.prototype.hasOwnProperty.call(value, k)) {
|
||||
v = str(k, value);
|
||||
if (v) {
|
||||
partial.push(quote(k) + (gap ? ': ' : ':') + v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Join all of the member texts together, separated with commas,
|
||||
// and wrap them in braces.
|
||||
|
||||
v = partial.length === 0 ? '{}' : gap ?
|
||||
'{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' :
|
||||
'{' + partial.join(',') + '}';
|
||||
gap = mind;
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
// If the JSON object does not yet have a stringify method, give it one.
|
||||
|
||||
if (typeof JSON.stringify !== 'function') {
|
||||
JSON.stringify = function (value, replacer, space) {
|
||||
|
||||
// The stringify method takes a value and an optional replacer, and an optional
|
||||
// space parameter, and returns a JSON text. The replacer can be a function
|
||||
// that can replace values, or an array of strings that will select the keys.
|
||||
// A default replacer method can be provided. Use of the space parameter can
|
||||
// produce text that is more easily readable.
|
||||
|
||||
var i;
|
||||
gap = '';
|
||||
indent = '';
|
||||
|
||||
// If the space parameter is a number, make an indent string containing that
|
||||
// many spaces.
|
||||
|
||||
if (typeof space === 'number') {
|
||||
for (i = 0; i < space; i += 1) {
|
||||
indent += ' ';
|
||||
}
|
||||
|
||||
// If the space parameter is a string, it will be used as the indent string.
|
||||
|
||||
} else if (typeof space === 'string') {
|
||||
indent = space;
|
||||
}
|
||||
|
||||
// If there is a replacer, it must be a function or an array.
|
||||
// Otherwise, throw an error.
|
||||
|
||||
rep = replacer;
|
||||
if (replacer && typeof replacer !== 'function' &&
|
||||
(typeof replacer !== 'object' ||
|
||||
typeof replacer.length !== 'number')) {
|
||||
throw new Error('JSON.stringify');
|
||||
}
|
||||
|
||||
// Make a fake root object containing our value under the key of ''.
|
||||
// Return the result of stringifying the value.
|
||||
|
||||
return str('', {'': value});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// If the JSON object does not yet have a parse method, give it one.
|
||||
|
||||
if (typeof JSON.parse !== 'function') {
|
||||
JSON.parse = function (text, reviver) {
|
||||
|
||||
// The parse method takes a text and an optional reviver function, and returns
|
||||
// a JavaScript value if the text is a valid JSON text.
|
||||
|
||||
var j;
|
||||
|
||||
function walk(holder, key) {
|
||||
|
||||
// The walk method is used to recursively walk the resulting structure so
|
||||
// that modifications can be made.
|
||||
|
||||
var k, v, value = holder[key];
|
||||
if (value && typeof value === 'object') {
|
||||
for (k in value) {
|
||||
if (Object.prototype.hasOwnProperty.call(value, k)) {
|
||||
v = walk(value, k);
|
||||
if (v !== undefined) {
|
||||
value[k] = v;
|
||||
} else {
|
||||
delete value[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return reviver.call(holder, key, value);
|
||||
}
|
||||
|
||||
|
||||
// Parsing happens in four stages. In the first stage, we replace certain
|
||||
// Unicode characters with escape sequences. JavaScript handles many characters
|
||||
// incorrectly, either silently deleting them, or treating them as line endings.
|
||||
|
||||
text = String(text);
|
||||
cx.lastIndex = 0;
|
||||
if (cx.test(text)) {
|
||||
text = text.replace(cx, function (a) {
|
||||
return '\\u' +
|
||||
('0000' + a.charCodeAt(0).toString(16)).slice(-4);
|
||||
});
|
||||
}
|
||||
|
||||
// In the second stage, we run the text against regular expressions that look
|
||||
// for non-JSON patterns. We are especially concerned with '()' and 'new'
|
||||
// because they can cause invocation, and '=' because it can cause mutation.
|
||||
// But just to be safe, we want to reject all unexpected forms.
|
||||
|
||||
// We split the second stage into 4 regexp operations in order to work around
|
||||
// crippling inefficiencies in IE's and Safari's regexp engines. First we
|
||||
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
|
||||
// replace all simple value tokens with ']' characters. Third, we delete all
|
||||
// open brackets that follow a colon or comma or that begin the text. Finally,
|
||||
// we look to see that the remaining characters are only whitespace or ']' or
|
||||
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
|
||||
|
||||
if (/^[\],:{}\s]*$/
|
||||
.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
|
||||
.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
|
||||
.replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
|
||||
|
||||
// In the third stage we use the eval function to compile the text into a
|
||||
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
|
||||
// in JavaScript: it can begin a block or an object literal. We wrap the text
|
||||
// in parens to eliminate the ambiguity.
|
||||
|
||||
j = eval('(' + text + ')');
|
||||
|
||||
// In the optional fourth stage, we recursively walk the new structure, passing
|
||||
// each name/value pair to a reviver function for possible transformation.
|
||||
|
||||
return typeof reviver === 'function' ?
|
||||
walk({'': j}, '') : j;
|
||||
}
|
||||
|
||||
// If the text is not JSON parseable, then a SyntaxError is thrown.
|
||||
|
||||
throw new SyntaxError('JSON.parse');
|
||||
};
|
||||
}
|
||||
}());
|
||||