blob: 63437f545cc5299768a9a767d7a8d394849e2311 [file] [log] [blame]
<!DOCTYPE html>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at
Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
<html lang="en">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<link rel="stylesheet" href="style/layout.css?0.11.0" type="text/css">
<link rel="stylesheet" href="style/jquery-ui-1.8.11.custom.css" type="text/css">
<script src="script/json2.js"></script>
<script src="script/sha1.js"></script>
<script src="script/jquery.js"></script>
<script src="script/jquery.couch.js"></script>
<script src="script/jquery.dialog.js"></script>
<script src="script/futon.js"></script>
<script src="script/jquery-ui-1.10.4.custom.min.js"></script>
$(document).ready(function() {
var allDatabases;
$("fieldset input[type=radio]").click(function() {
var radio = this;
var fieldset = $(this).parents("fieldset").get(0);
$("input[type=text]", fieldset).each(function() {
this.disabled = radio.value == "local";
if (!this.disabled) this.focus();
$('.local', fieldset).each(function() {
this.disabled = radio.value == "remote";
if (!this.disabled) this.focus();
var getDatabases = function() {
success: function(dbs) {
allDatabases = dbs.sort();
$("fieldset select").each(function() {
var select = this;
$.each(dbs, function(idx, dbName) {
select.selectedIndex = 0;
$('#to_name').autocomplete({ source: dbs });
$("button#swap").click(function() {
var fromName = $("#source select").val();
$("#source select").val($("#target select").val());
$("#target select").val(fromName);
var fromUrl = $("#source input[type=text]").val();
$("#source input[type=text]").val($("#target input[type=text]").val());
$("#target input[type=text]").val(fromUrl);
var fromType = $("#source input[type=radio]").filter(function() {
return this.checked;
var toType = $("#target input[type=radio]").filter(function() {
return this.checked;
$("#source input[value=" + toType + "]").click();
$("#target input[value=" + fromType + "]").click();
return false;
$("button#replicate").click(function() {
$("#records tbody.content").empty();
var targetIsLocal = $('#to_local:checked').length > 0;
var source = $("#from_local")[0].checked ? $("#from_name").val() : $("#from_url").val();
var target = targetIsLocal ? $("#to_name").val() : $("#to_url").val();
var repOpts = {};
if (targetIsLocal && $.inArray(target, allDatabases) < 0) {
if(!confirm('This will create a database named '+target+'. Ok?')) {
else {
repOpts.create_target = true;
if ($("#continuous")[0].checked) {
repOpts.continuous = true;
if ($("#doc_ids").val()){
try {
var doc_ids = JSON.parse($("#doc_ids").val());
if ($.isArray(doc_ids)) {
repOpts.doc_ids = doc_ids;
} else {
$("#records tbody.footer td")
.text('Invalid format! Should be: ["doc1", "doc2", ...]');
return false;
} catch (e) {
$("#records tbody.footer td")
.text('Invalid format! Should be: ["doc1", "doc2", ...]');
return false;
$.couch.replicate(source, target, {
success: function(resp) {
if ( resp.history == null || resp._local_id) {
.appendTo("#records tbody.content");
$("#records tbody tr").removeClass("odd").filter(":odd").addClass("odd");
$("#records tbody.footer td")
.text((resp._local_id)? "Continuous replication" :
"Named document replication");
} else {
$.each(resp.history, function(idx, record) {
.appendTo("#records tbody.content");
$("#records tbody tr").removeClass("odd").filter(":odd").addClass("odd");
$("#records tbody.footer td").text("Replication session " + resp.session_id);
if (repOpts.create_target) {
}, repOpts);
<body><div id="wrap">
<a href="index.html">Overview</a>
<div id="content">
<form id="replicator">
<fieldset id="source">
<legend>Replicate changes from:</legend>
<input type="radio" id="from_local" name="from_type" value="local" checked>
<label for="from_local">Local Database: </label>
<select id="from_name" name="from_name" class="local"></select>
<input type="radio" id="from_to_remote" name="from_type" value="remote">
<label for="from_to_remote">Remote database: </label>
<input type="text" id="from_url" name="from_url" size="30" value="http://" disabled>
<p class="swap"><button id="swap" tabindex="99"></button></p>
<fieldset id="target">
<input type="radio" id="to_local" name="to_type" value="local" checked>
<label for="to_local">Local database: </label>
<input type="text" id="to_name" name="to_name" class="local"></select>
<input type="radio" id="to_remote" name="to_type" value="remote">
<label for="to_remote">Remote database: </label>
<input type="text" id="to_url" name="to_url" size="30" value="http://" disabled>
<p class="actions">
<label style="float: left; padding-left: 5px">Document IDs: <input type="text" id="doc_ids" name="doc_ids" size="25" value=""></label>
<label><input type="checkbox" name="continuous" value="continuous" id="continuous"> Continuous</label>
<button id="replicate" type="button">Replicate</button>
<table id="records" class="listing" cellspacing="0">
<caption>Replication History</caption>
<tbody class="content"></tbody>
<tbody class="footer"><tr>
<td colspan="4">No replication</td>