Error executing template "Designs/Swift/ItemPublisher/List/List.cshtml"
System.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Boolean'.
at CompiledRazorTemplates.Dynamic.RazorEngine_6bc6bb8940b5471db40be742306bcf34.ExecuteAsync()
at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader)
at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer)
at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) in /_/src/Application/Providers/Dynamicweb.Rendering.Providers.NetCore/Razor/RazorTemplateRenderingProvider.cs:line 99
at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) in C:\dwxa1\_w\1\s\src\Core\Dynamicweb.Core\Rendering\TemplateRenderingService.cs:line 21
at Dynamicweb.Rendering.Template.RenderRazorTemplate() in C:\dwxa1\_w\1\s\src\Core\Dynamicweb.Core\Rendering\Template.cs:line 749
1 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>
@using System.IO
@functions {
private List<string> GetTags(LoopItem item)
{
var tags = new List<string>();
foreach (var tag in item.GetLoop("ItemPublisher:Item.Tags.Options"))
{
if (tag.GetBoolean("ItemPublisher:Item.Tags.Option.IsSelected"))
{
tags.Add(tag.GetString("ItemPublisher:Item.Tags.Option.Label"));
}
}
return tags;
}
private string CreateCategory(string label, string theme)
{
var border = string.IsNullOrEmpty(theme) ? "--swift-border-color: rgba(var(--swift-foreground-color-rgb), .2);" : null;
var sticker = $"<span class=\"badge {theme}\" style=\"color: var(--swift-foreground-color); background-color: rgba(var(--swift-background-color-rgb), 1); {border} \">{label}</span>";
return sticker;
}
private string CreateSticker(string label)
{
string shape = Pageview.CurrentParagraph.Item["ArticleItemShape"] != null ? Pageview.CurrentParagraph.Item["ArticleItemShape"].ToString() : "boxed";
var sticker = $"<span class=\"badge fw-normal shadow-none\" style=\"border: 1px solid rgba(var(--swift-foreground-color-rgb), 0.2);\">{label}</span>";
return sticker;
}
private string GetTagStickers(LoopItem item)
{
var stickers = string.Empty;
if (item.GetString("ItemPublisher:Item.SystemName") == "Swift_Article")
{
var showTags = Pageview.CurrentParagraph.Item["ShowTags"] != null ? (Boolean)Pageview.CurrentParagraph.Item["ShowTags"] : false;
if (showTags && GetTags(item).Count >= 1)
{
stickers += "<div class=\"d-inline-flex flex-wrap gap-1\">";
foreach (var tag in GetTags(item))
{
stickers += CreateSticker(tag);
}
stickers += "</div>";
}
}
return stickers;
}
private string GetCategorySticker(LoopItem item)
{
var sticker = string.Empty;
if (item.GetString("ItemPublisher:Item.SystemName") == "Swift_Article")
{
var showListCategory = Pageview.CurrentParagraph.Item["ShowListCategory"] != null ? (Boolean)Pageview.CurrentParagraph.Item["ShowListCategory"] : false;
if (showListCategory)
{
sticker += "<div class=\"d-inline-flex flex-wrap gap-1\">";
sticker += CreateCategorySticker(GetCategory(Dynamicweb.Content.Services.Pages.GetPage(item.GetInteger("ItemPublisher:Item.Field.PageId")).ParentPageId), GetCategoryTheme(GetCategory(Dynamicweb.Content.Services.Pages.GetPage(item.GetInteger("ItemPublisher:Item.Field.PageId")).ParentPageId)));
sticker += "</div>";
}
}
return sticker;
}
private Dynamicweb.Frontend.PageInfoViewModel GetCategory(int categoryId)
{
var categoryParagraph = categoryId != 0 ? Dynamicweb.Content.Services.Pages.GetPage(categoryId) : null;
var category = categoryParagraph != null ? Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(categoryParagraph) : null;
return category;
}
private string CreateCategorySticker(Dynamicweb.Frontend.PageInfoViewModel category, string theme)
{
var sticker = category != null ? CreateCategory(category.Item?.GetString("Title"), theme) : null;
return sticker;
}
private string GetCategoryTheme(Dynamicweb.Frontend.PageInfoViewModel category)
{
var theme = category != null ? category.Item?.GetRawValueString("CoverTheme").ToString().Replace(" ", "").Trim().ToLower() : null;
return theme;
}
private string LiftOnHover()
{
bool liftOnHover = Pageview.CurrentParagraph.Item["LiftOnHover"] != null ? (Boolean)Pageview.CurrentParagraph.Item["LiftOnHover"] : false;
var lift = liftOnHover ? "lift" : null;
return lift;
}
private string ShadowOnHover()
{
bool shadowOnHover = Pageview.CurrentParagraph.Item["ShadowOnHover"] != null ? (Boolean)Pageview.CurrentParagraph.Item["ShadowOnHover"] : false;
var shadow = shadowOnHover ? "shadow-hover" : null;
return shadow;
}
private string GetPadding(string theme)
{
var padding = !string.IsNullOrEmpty(theme) ? "p-3" : null;
return padding;
}
private string GetGap(string theme)
{
var padding = string.IsNullOrEmpty(theme) ? "gap-3" : null;
return padding;
}
}
@{
bool showLoadMore = Pageview.CurrentParagraph.Item["ShowLoadMore"] != null ? (Boolean)Pageview.CurrentParagraph.Item["ShowLoadMore"] : false;
int maxItemsInList = !string.IsNullOrEmpty(Pageview.CurrentParagraph.Item["MaxItemsInList"].ToString()) ? Dynamicweb.Core.Converter.ToInt32(Pageview.CurrentParagraph.Item["MaxItemsInList"]) : 10;
var totalItems = GetInteger("ItemPublisher:Items.TotalCount");
var count = GetInteger("ItemPublisher:Items.Count");
var percent = count > 0 ? Convert.ToInt32(Math.Round(((double)count / totalItems) * 100, 0)) : 0;
var disableLoadMoreButton = count == totalItems ? true : false;
var loadMore = !disableLoadMoreButton ? $"onclick=\"document.querySelector('#PageSize_{Pageview.CurrentParagraph.ID}').value='{count + maxItemsInList}'; this.dispatchEvent(new window.Event('change', {{ bubbles: true }}))\"" : null;
var disabled = disableLoadMoreButton ? "disabled" : null;
var hasItems = GetBoolean("ItemPublisher:Items.Any");
string articleListLayout = Pageview.CurrentParagraph.Item["ArticleListLayout"] != null ? Pageview.CurrentParagraph.Item["ArticleListLayout"].ToString() : "grid";
string articleItemLayout = Pageview.CurrentParagraph.Item["ArticleItemLayout"] != null ? Pageview.CurrentParagraph.Item["ArticleItemLayout"].ToString() : string.Empty;
string orderReverseClass = articleItemLayout == "image-right" ? " order-first order-lg-last" : string.Empty;
string articleItemLayoutClass = string.Empty;
string titleFontSize = Pageview.CurrentParagraph.Item["TitleFontSize"] != null ? Pageview.CurrentParagraph.Item["TitleFontSize"].ToString() : string.Empty;
string gridSettings = Pageview.CurrentParagraph.Item["GridSettings"] != null ? Pageview.CurrentParagraph.Item["GridSettings"].ToString() : "4";
string carouselSettings = Pageview.CurrentParagraph.Item["CarouselSettings"] != null ? Pageview.CurrentParagraph.Item["CarouselSettings"].ToString() : "4";
bool showButton = Pageview.CurrentParagraph.Item["ShowButton"] != null ? (Boolean)Pageview.CurrentParagraph.Item["ShowButton"] : false;
string ratio = Pageview.CurrentParagraph.Item["ImageAspectRatio"] != null ? Pageview.CurrentParagraph.Item["ImageAspectRatio"].ToString() : string.Empty;
ratio = ratio != "0" ? ratio : string.Empty;
string ratioCssClass = ratio != string.Empty ? " ratio" : string.Empty;
string ratioVariable = ratio != string.Empty ? "style=\"--bs-aspect-ratio: " + ratio + "\"" : string.Empty;
string articleItemTheme = Pageview.CurrentParagraph.Item["ArticleItemTheme"] != null ? Pageview.CurrentParagraph.Item["ArticleItemTheme"].ToString().Replace(" ", "").Trim().ToLower() : string.Empty;
string articleItemShape = Pageview.CurrentParagraph.Item["ArticleItemShape"] != null ? Pageview.CurrentParagraph.Item["ArticleItemShape"].ToString() : "boxed";
string shapeClass = " rounded-0";
if (articleItemShape == "rounded")
{
shapeClass = " rounded-4";
}
string settingsClassGrid = string.Empty;
switch (gridSettings)
{
case "2":
settingsClassGrid = " grid-md-2";
break;
case "3":
settingsClassGrid = " grid-md-3";
break;
case "4":
settingsClassGrid = " grid-md-2 grid-lg-3 grid-xl-4";
break;
case "5":
settingsClassGrid = " grid-md-2 grid-lg-3 grid-xl-5";
break;
}
string gridWrapperStart = articleListLayout == "grid" ? $"<div class=\"article-list grid gap-4 grid-1{settingsClassGrid}\">" : null;
string gridWrapperEnd = articleListLayout == "grid" ? "</div>" : null;
bool hasListContext = Pageview.CurrentParagraph.Item["ListContext"] is object;
}
@if (hasItems || count > 0)
{
@(gridWrapperStart)
foreach (LoopItem item in GetLoop("ItemPublisher:Items.List"))
{
string title = !string.IsNullOrEmpty(item.GetString("ItemPublisher:Item.Title")) && !item.GetBoolean("ItemPublisher:Item.HideTitle") ? item.GetString("ItemPublisher:Item.Title") : string.Empty;
string coverTitle = !string.IsNullOrEmpty(item.GetString("ItemPublisher:Item.CoverTitle")) ? item.GetString("ItemPublisher:Item.CoverTitle") : string.Empty;
string coverImagePath = !string.IsNullOrEmpty(item.GetString("ItemPublisher:Item.CoverImage")) ? item.GetString("ItemPublisher:Item.CoverImage") : string.Empty;
bool hasFocalPoint = item.GetBoolean("ItemPublisher:Item.CoverImage.ImageHasFocalPoint");
int focalX = hasFocalPoint ? item.GetInteger("ItemPublisher:Item.CoverImage.FocalX") : 0;
int focalY = hasFocalPoint ? item.GetInteger("ItemPublisher:Item.CoverImage.FocalY") : 0;
int xPos = 100 - ((100 - focalX) / 2);
int yPos = ((100 - focalY) / 2);
string cssPosition = $"{xPos}% {yPos}%";
string summary = !string.IsNullOrEmpty(item.GetString("ItemPublisher:Item.Summary")) ? item.GetString("ItemPublisher:Item.Summary") : string.Empty;
string publishedDate = !string.IsNullOrEmpty(item.GetString("ItemPublisher:Item.PublishedDate")) && !item.GetBoolean("ItemPublisher:Item.HidePublishedDate") ? item.GetDate("ItemPublisher:Item.PublishedDate").ToShortDateString() : string.Empty;
string link = !string.IsNullOrEmpty(item.GetString("ItemPublisher:Item.Url")) ? item.GetString("ItemPublisher:Item.Url") : string.Empty;
string buttonLabel = !string.IsNullOrEmpty(item.GetString("ItemPublisher:Item.ButtonLabel")) ? item.GetString("ItemPublisher:Item.ButtonLabel") : string.Empty;
string iconPath = "/Files/Templates/Designs/Swift/Assets/icons/";
bool renderContentWrapper = true;
bool renderArticleInfoWrapper = true;
if (string.IsNullOrEmpty(title) && string.IsNullOrEmpty(summary) && string.IsNullOrEmpty(publishedDate) && item.GetInteger("ItemPublisher:Item.Author") == 0 && !showButton)
{
renderContentWrapper = false;
}
if (string.IsNullOrEmpty(publishedDate) && item.GetInteger("ItemPublisher:Item.Author") == 0)
{
renderArticleInfoWrapper = false;
}
switch (articleItemLayout)
{
case "image-left":
case "image-right":
articleItemLayoutClass = !string.IsNullOrEmpty(coverImagePath) && renderContentWrapper ? "flex-lg-row" : articleItemLayoutClass;
break;
}
string imageObjectFit = ratio != string.Empty ? "object-fit: cover;" : "object-fit: contain;";
string coverTheme = !string.IsNullOrEmpty(item.GetString("ItemPublisher:Item.CoverTheme")) ? item.GetString("ItemPublisher:Item.CoverTheme").Replace(" ", "").Trim().ToLower() : string.Empty;
string themeClass = string.Empty;
string coverImageWrapperClass = string.Empty;
if (!string.IsNullOrEmpty(coverTheme))
{
articleItemTheme = coverTheme;
}
if (articleItemTheme != string.Empty)
{
themeClass = " theme " + articleItemTheme;
}
// Exclude self from list - if list has context (Tags) and if is on same page
bool excludeSelf = item.GetInteger("ItemPublisher:Item.Field.PageId") == item.GetInteger("ItemPublisher:Global.PageId");
bool renderItem = true;
renderItem = hasListContext && excludeSelf ? renderItem = false : !hasListContext && !excludeSelf ? renderItem : renderItem;
if (renderItem)
{
<article class="card border-0 @(string.IsNullOrEmpty(themeClass) ? "gap-3" : null) @articleItemLayoutClass@(themeClass)@(shapeClass) overflow-hidden @LiftOnHover() @ShadowOnHover()" itemscope itemtype="https://schema.org/CreativeWork" style="background-color: var(--swift-background-color)">
@if (!string.IsNullOrEmpty(coverImagePath))
{
if (Path.GetExtension(coverImagePath).ToLower() == ".svg")
{
coverImageWrapperClass = !renderContentWrapper ? "d-flex justify-content-center align-items-center h-100 w-100 " : "w-100 ";
<a class="@(coverImageWrapperClass)@(orderReverseClass)" title="@title" href="@link" tabindex="-1">
<div class="d-flex justify-content-center align-items-center overflow-hidden@(ratioCssClass)" @ratioVariable>
@ReadFile(coverImagePath)
</div>
</a>
}
else
{
coverImageWrapperClass = articleItemLayout == "image-top" ? "position-relative" : $"col {orderReverseClass}";
coverImageWrapperClass += renderContentWrapper && articleItemLayout != "image-top" ? " col-lg-5" : string.Empty;
string figureClass = articleItemLayout == "image-top" ? ratioCssClass : "h-lg-100 ratio ratio-16x9";
ratioVariable = articleItemLayout == "image-top" ? ratioVariable : string.Empty;
<a class="@coverImageWrapperClass" title="@title" href="@link" tabindex="-1">
<figure class="overflow-hidden m-0 mx-auto @(figureClass)" @ratioVariable>
@{
coverImagePath = Dynamicweb.Context.Current.Server.UrlEncode(coverImagePath);
imageObjectFit = articleItemLayout != "image-top" ? "object-fit: cover" : imageObjectFit;
string imgSizeSelector = "50vw";
imgSizeSelector = gridSettings == "1" || carouselSettings == "1" ? "100vw" : imgSizeSelector;
imgSizeSelector = gridSettings == "2" || carouselSettings == "2" ? "50vw" : imgSizeSelector;
imgSizeSelector = gridSettings == "3" || carouselSettings == "3" ? "33vw" : imgSizeSelector;
imgSizeSelector = gridSettings == "4" || carouselSettings == "4" ? "25vw" : imgSizeSelector;
imgSizeSelector = gridSettings == "5" || carouselSettings == "5" ? "17vw" : imgSizeSelector;
string coverImagePathM = $"/Admin/Public/GetImage.ashx?image={coverImagePath}&width=640&format=webp";
string coverImagePathL = $"/Admin/Public/GetImage.ashx?image={coverImagePath}&width=960&format=webp";
string imagePathFallBack = coverImagePathM;
<img srcset="
@coverImagePathM 640w,
@coverImagePathL 960w"
src="@imagePathFallBack"
sizes="(min-width: 992px) @imgSizeSelector, 100vw"
loading="lazy"
decoding="async"
class="img-fluid image-zoom-lg-1-hover"
style="@imageObjectFit; object-position: @cssPosition;"
alt="@title">
}
</figure>
</a>
}
}
@if (renderContentWrapper)
{
<div class="col d-flex flex-column @GetPadding(themeClass)">
<div class="card-body p-0 d-flex flex-column gap-2">
@*Show tag stickers*@
@GetCategorySticker(item)
@if (!string.IsNullOrEmpty(title))
{
<a class="text-decoration-none text-decoration-underline-hover" href="@link">
<h3 class="@titleFontSize mb-0" itemprop="headline">@title</h3>
</a>
}
@if (!string.IsNullOrEmpty(summary))
{
<p class="m-0 opacity-75">@summary</p>
}
@*Show tag stickers*@
@GetTagStickers(item)
@if (showButton)
{
<div class="mt-auto">
@if (!string.IsNullOrEmpty(buttonLabel))
{
<a href="@link" class="text-start btn btn-link p-0">
@buttonLabel
<span class="icon-auto">
@ReadFile(iconPath + "arrow-right.svg")
</span>
</a>
}
else
{
<a href="@link" class="btn btn-link p-0 lh-1 text-start">
<span class="icon-auto">
@ReadFile(iconPath + "arrow-right.svg")
</span>
</a>
}
</div>
}
</div>
@if (renderArticleInfoWrapper)
{
<div class="card-footer p-0 pt-3 border-top-0">
<div class="d-flex align-items-center justify-content-between gap-3">
@if (item.GetInteger("ItemPublisher:Item.Author") != 0)
{
int authorID = item.GetInteger("ItemPublisher:Item.Author");
var author = Dynamicweb.Security.UserManagement.User.GetUserByID(authorID);
string authorImage = !string.IsNullOrEmpty(author?.Image) ? author.Image : string.Empty;
string authorImagePath = !string.IsNullOrEmpty(author?.Image) ? $"/Admin/Public/GetImage.ashx?image={author.Image}&width=24&height=24&Crop=0&format=webp" : string.Empty;
string authorName = !string.IsNullOrEmpty(author?.Name) ? authorName = author.Name : string.Empty;
string authorJobTitle = !string.IsNullOrEmpty(author?.JobTitle) ? authorJobTitle = author.JobTitle : string.Empty;
<div class="d-flex align-items-center gap-2 fs-8 opacity-75">
@if (!string.IsNullOrEmpty(authorImage))
{
<img class="img-fluid rounded-circle" src="@authorImagePath" loading="lazy" alt="@authorName" width="24" height="24">
}
else
{
<div class="d-flex align-items-center justify-content-center rounded-circle" style="background-color: rgba(var(--swift-foreground-color-rgb),.25)">
<div class="icon-2 p-1">
@ReadFile(iconPath + "user.svg")
</div>
</div>
}
<div class="d-flex flex-column lh-1">
@if (!string.IsNullOrEmpty(authorName))
{
<span itemprop="author">@authorName</span>
}
@if (!string.IsNullOrEmpty(authorJobTitle))
{
<span class="opacity-75">@authorJobTitle</span>
}
</div>
</div>
}
@if (!string.IsNullOrEmpty(publishedDate))
{
string articleDateTime = item.GetDate("ItemPublisher:Item.PublishedDate").Year + "-" + item.GetDate("ItemPublisher:Item.PublishedDate").Month + "-" + item.GetDate("ItemPublisher:Item.PublishedDate").Day;
<div class="d-flex align-items-center gap-1 fs-8 opacity-75">
<div class="icon-1">
@ReadFile(iconPath + "calendar.svg")
</div>
<time datetime="@articleDateTime" itemprop="datePublished">@publishedDate</time>
</div>
}
</div>
</div>
}
</div>
}
</article>
}
}
@* Placeholders (skeleton) *@
for (int i = 0; i < count; i++)
{
string imageWrapper = string.Empty;
string ratioString = ratioCssClass;
switch (articleItemLayout)
{
case "image-left":
case "image-right":
articleItemLayoutClass = " flex-lg-row";
imageWrapper = "col col-lg-5";
ratioString = string.Empty;
break;
}
<div class="htmx-indicator" aria-hidden="true" aria-disabled="true" aria-label="loading">
<div class="card placeholder-glow@(shapeClass) overflow-hidden@(articleItemLayoutClass)" style="background-color: var(--swift-background-color); border: 1px solid rgba(var(--swift-foreground-color-rgb), 0.2);">
<div class="@(imageWrapper) placeholder@(orderReverseClass)">
<div class="@(ratioString)" @ratioVariable></div>
</div>
<div class="col d-flex flex-column">
<div class="card-body">
<div class="mb-2">
<span class="placeholder col-2"></span>
</div>
<div class="h5 card-title">
<span class="placeholder col-6"></span>
<span class="placeholder col-2"></span>
</div>
<p class="card-text">
<span class="placeholder placeholder-sm col-2"></span>
<span class="placeholder placeholder-sm col-4"></span>
<span class="placeholder placeholder-sm col-4"></span>
<span class="placeholder placeholder-sm col-3"></span>
<span class="placeholder placeholder-sm col-6"></span>
<span class="placeholder placeholder-sm col-3"></span>
</p>
</div>
<div class="card-footer">
<div class="d-flex justify-content-between">
<span class="placeholder placeholder-sm col-2"></span>
<span class="placeholder placeholder-sm col-2"></span>
</div>
</div>
</div>
</div>
</div>
}
@(gridWrapperEnd)
@* Load more *@
if (Pageview.Page.Item.SystemName == "Swift_ArticleListPage" && showLoadMore && articleListLayout == "grid")
{
<div class="text-center pt-5">
<p class="fs-7 mb-3 opacity-75">@Translate("Showing") <span>@count</span> of <span>@totalItems</span> @Translate("items")</p>
<div class="progress mb-4 mx-auto" style="height:3px;max-width:300px; background-color:rgba(var(--swift-foreground-color-rgb), 0.2);">
<div class="progress-bar" role="progressbar" aria-label="Showing" style="width:@(percent)%;background-color:rgba(var(--swift-foreground-color-rgb), 1);" aria-valuenow="@(percent)" aria-valuemin="0" aria-valuemax="100"></div>
</div>
@if (!disableLoadMoreButton)
{
<div>
<input type="hidden" id="PageSize_@(Pageview.CurrentParagraph.ID)" name="PageSize" />
<label class="btn btn-primary @disabled" for="PageSize_@(Pageview.CurrentParagraph.ID)" @loadMore>@Translate("Load more")</label>
</div>
}
</div>
}
}
@if(!hasItems || count == 0)
{
string iconPath = "/Files/Templates/Designs/Swift/Assets/icons/";
<div class="grid grid-1" style="place-items: center;">
<span class="icon-7">
@ReadFile(iconPath + "filter.svg")
</span>
<h3 class="m-0">@Translate("No items found")</h3>
<p class="m-0 fs-7 text-center">@Translate("Sorry, that filter combination has no results.") <br> @Translate("Please try different criteria")</p>
<button type="button" aria-label="Clear filters" onclick="clearFilters(event)" class="mt-2 btn btn-secondary btn-sm d-flex align-items-center">
@Translate("Clear filters")
<span class="icon-2 ms-2">
@ReadFile(iconPath + "refresh-ccw.svg")
</span>
</button>
</div>
<script>
var clearFilters = (event) => {
const form = event.target.closest('form');
form.reset();
let elements = form.elements;
for (var i = 0, element; element = elements[i++];) {
switch (element.type) {
case "textarea":
case "hidden":
element.value = '';
break;
case "radio":
case "checkbox":
if (element.checked) {
element.checked = false;
}
break;
case "select-one":
element.selectedIndex = -1;
break;
default:
break;
}
}
form.dispatchEvent(new window.Event('change', { bubbles: true }))
}
</script>
}