183 lines
7.0 KiB
Plaintext
183 lines
7.0 KiB
Plaintext
@model EDAViewer.Models.EdaHtmlDiff
|
|
@{
|
|
ViewBag.Title = "EDA HTML Diff";
|
|
string idForm = "Form";
|
|
string idSubmit = "Submit";
|
|
string idUp = "Up";
|
|
string idRoot = "Root";
|
|
string idRefresh = "Refresh";
|
|
string background = "Background"; //Background
|
|
string viewEdaHtmlDiff = "ViewEdaHtmlDiff"; //ViewEdaHtmlDiff
|
|
string actionNameForForm = nameof(EDAViewer.Controllers.HomeController.ViewEdaHtmlDiff);
|
|
string actionNameForList = nameof(EDAViewer.Controllers.HomeController.GetDirectoriesOrFiles);
|
|
string homeController = nameof(EDAViewer.Controllers.HomeController).Replace("Controller", string.Empty);
|
|
}
|
|
|
|
<div class="jumbotron">
|
|
<h1>@(ViewBag.Message)</h1>
|
|
</div>
|
|
<div>
|
|
@Html.Raw(ViewBag.Diff)
|
|
<hr />
|
|
@Html.Raw(ViewBag.OldText)
|
|
<hr />
|
|
@Html.Raw(ViewBag.NewText)
|
|
<hr />
|
|
<div style="min-height:44px;">
|
|
<button id="@(idRoot)" style="margin-left: 50px; margin-bottom:10px" class="btn btn-info">Root Directory</button>
|
|
<button id="@(idUp)" style="margin-left: 50px; margin-bottom:10px" class="btn btn-info">Up Directory</button>
|
|
<button id="@(idRefresh)" style="margin-left: 50px; margin-bottom:10px" class="btn btn-info">Refresh List</button>
|
|
</div>
|
|
@using (Html.BeginForm(actionNameForForm, homeController, FormMethod.Post, new { id = idForm }))
|
|
{
|
|
@Html.AntiForgeryToken();
|
|
@Html.ValidationSummary(true);
|
|
@Html.HiddenFor(m => m.user_name)
|
|
@Html.HiddenFor(m => m.machine_name)
|
|
@Html.HiddenFor(m => m.now_ticks)
|
|
@Html.HiddenFor(m => m.PathAndFileName)
|
|
@Html.HiddenFor(m => m.Paths)
|
|
<p>
|
|
@Html.LabelFor(m => m.CurrentPath)
|
|
@Html.DropDownListFor(m => m.CurrentPath, new SelectList(Enumerable.Empty<SelectListItem>()), htmlAttributes: new { style = "min-width:600px" })
|
|
@Html.ValidationMessageFor(m => m.CurrentPath)
|
|
</p>
|
|
<p>
|
|
@Html.LabelFor(m => m.FileName)
|
|
@Html.TextBoxFor(m => m.FileName, htmlAttributes: new { style = "min-width:600px" })
|
|
@Html.ValidationMessageFor(m => m.FileName)
|
|
</p>
|
|
<br />
|
|
<input type="submit" value="Save" id="@(idSubmit)" class="btn btn-default" />
|
|
}
|
|
</div>
|
|
<div class="navbar-collapse collapse">
|
|
<ul class="nav navbar-nav">
|
|
<li>@Html.RouteLink("View EDA HTML Diff", new { action = viewEdaHtmlDiff, controller = homeController })</li>
|
|
<li>@Html.RouteLink("Background Invoke EDA DCP Plans Timer Change", new { action = background, controller = homeController, invoke_eda_dcp = 100 })</li>
|
|
</ul>
|
|
</div>
|
|
@section scripts {
|
|
<script>
|
|
//
|
|
function getEncodedLastPath() {
|
|
var encodedPath;
|
|
var control = "@(nameof(Model.Paths))";
|
|
encodedPath = $("#" + control).val().substr(0, $("#" + control).val().lastIndexOf("|"));
|
|
$("#" + control).val(encodedPath)
|
|
encodedPath = encodeURIComponent($("#" + control).val());
|
|
return encodedPath;
|
|
}
|
|
//
|
|
function getEncodedCurrentPath() {
|
|
var encodedPath;
|
|
var control = "@(nameof(Model.CurrentPath))";
|
|
var pathSelected = $("#" + control).val();
|
|
if (pathSelected == null) {
|
|
encodedPath = "";
|
|
}
|
|
else {
|
|
$("#@(nameof(Model.FileName))").val($("#" + control + " option:selected").text());
|
|
$("#@(nameof(Model.PathAndFileName))").val(pathSelected);
|
|
encodedPath = encodeURIComponent(pathSelected);
|
|
}
|
|
return encodedPath;
|
|
}
|
|
//
|
|
function setList(prefix, encodedPath, upDirectory) {
|
|
var actionName = prefix + "@(actionNameForList)?path=" + encodedPath + "&upDirectory=" + upDirectory + "&filter=";
|
|
$('select').empty();
|
|
$("#@(idUp)").hide();
|
|
$("#@(idRoot)").hide();
|
|
$("#@(idRefresh)").hide();
|
|
$("#@(nameof(Model.CurrentPath))").hide();
|
|
//
|
|
$.ajax({
|
|
url: actionName,
|
|
type: "GET",
|
|
contentType: "application/json; charset=utf-8",
|
|
datatype: JSON,
|
|
success: function (result) {
|
|
if (result.length > 7000) {
|
|
setList("../", encodedPath, upDirectory);
|
|
}
|
|
else {
|
|
var control = "@(nameof(Model.CurrentPath))";
|
|
$(result).each(function (index, value) {
|
|
$("#" + control).append($("<option></option>").val(value.value).html(value.text));
|
|
});
|
|
console.log("results lenght {" + result.length + "}");
|
|
if (result.length == 1) {
|
|
console.log("selecting first option");
|
|
$("select#elem").attr('selectedIndex', 0);
|
|
console.log("selected first option");
|
|
}
|
|
$("#@(nameof(Model.CurrentPath))").show();
|
|
$("#@(idRefresh)").show();
|
|
$("#@(idRoot)").show();
|
|
$("#@(idUp)").show();
|
|
}
|
|
},
|
|
error: function (data) {
|
|
console.log(data);
|
|
},
|
|
always: function (data) {
|
|
$("#@(nameof(Model.CurrentPath))").show();
|
|
$("#@(idRefresh)").show();
|
|
$("#@(idRoot)").show();
|
|
$("#@(idUp)").show();
|
|
}
|
|
});
|
|
}
|
|
$(document).ready(function () {
|
|
//
|
|
console.log("ready!");
|
|
//
|
|
$("#@(idRefresh)").click(function (e) {
|
|
$('#message').html('');
|
|
var encodedPath = getEncodedCurrentPath();
|
|
setList("", encodedPath, false);
|
|
});
|
|
//
|
|
$("#@(idUp)").click(function (e) {
|
|
$('#message').html('');
|
|
var encodedPath = getEncodedLastPath();
|
|
setList("", encodedPath, true);
|
|
});
|
|
//
|
|
$("#@(idRoot)").click(function (e) {
|
|
$('#message').html('');
|
|
var encodedPath = "";
|
|
setList("", encodedPath, false);
|
|
});
|
|
//
|
|
$("#@(idSubmit)").click(function (e) {
|
|
//$("#@(idSubmit)").hide();
|
|
//e.preventDefault();
|
|
});
|
|
//
|
|
$("select").change(function () {
|
|
var str = "";
|
|
$("select option:selected").each(function () {
|
|
str += $(this).text() + " ";
|
|
});
|
|
console.debug(str);
|
|
if (str.length > 0) {
|
|
var control = "@(nameof(Model.CurrentPath))";
|
|
var encodedPath = getEncodedCurrentPath();
|
|
if (encodedPath.length > 0) {
|
|
var pathsValue =$("#@(nameof(Model.Paths))").val();
|
|
$("#@(nameof(Model.Paths))").val(pathsValue + "|" + $("#" + control).val());
|
|
}
|
|
setList("", encodedPath, false);
|
|
}
|
|
}).change();
|
|
//
|
|
$("#@(idForm)").removeAttr("novalidate");
|
|
//
|
|
setList("", encodeURIComponent("@(Model.CurrentPath.Replace(@"\",@"\\"))"), false);
|
|
//
|
|
});
|
|
</script>
|
|
}
|