### CSS Rule for Responsive Images Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/5/page.html Defines a CSS rule to ensure images within the template adapt to their container by setting their maximum width to 100%. This helps maintain layout integrity on various screen sizes. ```CSS img{ max-width: 100%; } ``` -------------------------------- ### WangMarket Page Template Example Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/3/newsimage_list.html This snippet shows a typical page template from the WangMarket project. It includes directives for header, top, page content, and footer, along with a conditional JavaScript include for news editing functionality. ```Templating Language {include=head} if(edit){ dynamicLoading.js("{resUrl}template/"+getTemplateId()+"/js/newsedit.js"); } {include=top} {siteColumn.name} ================= [{siteName}](index.html) > [{siteColumn.name}]({siteColumn.url}) {listItem} {include=page} {include=foot} ``` -------------------------------- ### JavaScript Variable for Contact Us Section Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/7/index.html Defines a JavaScript variable to store the HTML anchor ID for the 'Contact Us' section, used for navigation within the fullPage.js setup. ```JavaScript var pageTag_contactUs = '{siteColumn.id}'; //HTML描点,联系我们相关 [联系我们](#) ``` -------------------------------- ### JavaScript Initialization and Dynamic Resource Loading Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/5/common/head.html This script sets up essential global variables like `masterSiteUrl`, `edit` mode flag, and `attachmentFileUrl`. It then dynamically loads a template's `style.css` if the current page is not the homepage, and loads `styleedit.css` and `commonedit.js` specifically when in 'edit' mode. It relies on a `dynamicLoading` utility and `getTemplateId()` function, which are assumed to be defined elsewhere. ```JavaScript var masterSiteUrl = '{\_masterSiteUrl}';/*主站URL*/ var edit = 'controllerRegEditMode' == 'edit';/*是否是编辑模式下*/ var attachmentFileUrl = '{AttachmentFileUrl}'; /*附件url*/ var urlname = window.location.pathname.split('.')[0].toLowerCase(); if(urlname != '/index' && urlname != '/'){ dynamicLoading.css("{resUrl}template/"+getTemplateId()+"/style.css"); /*非首页将动态加载模版样式文件*/ } if(edit){ dynamicLoading.css("{resUrl}template/"+getTemplateId()+"/styleedit.css");/*加载编辑模式的CSS*/ dynamicLoading.js("{resUrl}js/admin/commonedit.js");/*加载编辑模式的js*/ } ``` -------------------------------- ### Initialize and Render Site Columns and Navigation Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/1/index.html This JavaScript function `initSiteColumnData` initializes and renders the site's column and navigation data. It compares `siteColumnRank` and `siteColumn` for consistency, then iterates through sorted column data to generate HTML for display and editing, including dynamic URLs based on column type. ```JavaScript //普通预览模式下点击上方的标题栏 function site_(){ } //首页不显示顶左侧的后退按钮 document.getElementById('topBlock_back').innerHTML=''; var addSiteColumnHTML = ''; var addSiteColumnHTMLedit = document.getElementById('columnList').innerHTML; /* 刚打开初始化栏目、导航的缓存数据 */ function initSiteColumnData() { /* 首先先判断排序跟栏目导航数据个数是否一样 */ if (siteColumnRank.langth != siteColumn.length) { var content = ''; var contentedit = ''; var topNavContent = ''; /* 先遍历排序数据,根据排序拿到栏目导航数据 */ for (var i = 0; i < siteColumnRank.length; i++) { var rank = siteColumnRank[i]; for (var j = 0; j < siteColumn.length; j++) { if (siteColumn[j]['id'] == siteColumnRank[i]) { var url = siteColumn[j]['url']; var type = siteColumn[j]['type']; switch (type) { case '1': /* 新闻 */ url = 'lc'+siteColumn[j]['id']+'_1.html'; break; case '2': /* 图文 */ url = 'lc'+siteColumn[j]['id']+'_1.html'; break; case '3': /* 独立页面 */ url = 'c'+siteColumn[j]['id']+'.html'; break; case '4': /* 留言板 */ break; case '5': /* 超链接 */ break; } contentedit = contentedit + '

' + siteColumn[j]['name'] + '
'+ '
填充内容
'+ '
栏目属性
'+ '
'; content = content + '

' + siteColumn[j]['name'] + '
'+ '
'; //topNavContent = topNavContent + ''+siteColumn[j]['name']+''; break; } } } document.getElementById('columnList').innerHTML = content{edit}+addSiteColumnHTML{edit}; } else { alert('栏目导航排序规则跟数据不一致!'); } } initSiteColumnData(); ``` -------------------------------- ### Initialize and Render Site Columns/Navigation Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/2/index.html This function `initSiteColumnData` initializes and renders the site's columns or navigation links. It compares the column ranking data (`siteColumnRank`) with the actual column data (`siteColumn`) to ensure consistency. It then iterates through the ranked columns, constructs URLs based on column type (news, image-text, independent page, message board, hyperlink), and generates HTML for both preview and edit modes, including content and attribute update buttons. ```JavaScript var addSiteColumnHTML = ''; var addSiteColumnHTMLedit = document.getElementById('columnList').innerHTML; /* 刚打开初始化栏目、导航的缓存数据 */ function initSiteColumnData() { /* 首先先判断排序跟栏目导航数据个数是否一样 */ if (siteColumnRank.langth != siteColumn.length) { var content = ''; var contentedit = ''; var topNavContent = ''; /* 先遍历排序数据,根据排序拿到栏目导航数据 */ for (var i = 0; i < siteColumnRank.length; i++) { var rank = siteColumnRank[i]; for (var j = 0; j < siteColumn.length; j++) { if (siteColumn[j]['id'] == siteColumnRank[i]) { var url = siteColumn[j]['url']; var type = siteColumn[j]['type']; switch (type) { case '1': /* 新闻 */ url = 'lc'+siteColumn[j]['id']+'_1.html'; break; case '2': /* 图文 */ url = 'lc'+siteColumn[j]['id']+'_1.html'; break; case '3': /* 独立页面 */ url = 'c'+siteColumn[j]['id']+'.html'; break; case '4': /* 留言板 */ break; case '5': /* 超链接 */ break; } contentedit = contentedit + '

' + siteColumn[j]['name'] + '
'+ '
填充内容
'+ '
栏目属性
'+ '
'; content = content + '

' + siteColumn[j]['name'] + '
'+ '
'; break; } } } document.getElementById('columnList').innerHTML = content{edit}+addSiteColumnHTML{edit}; } else { alert('栏目导航排序规则跟数据不一致!'); } } initSiteColumnData(); ``` -------------------------------- ### JavaScript Initialization and Dynamic Resource Loading Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/3/common/head.html This JavaScript snippet initializes global variables such as `masterSiteUrl`, a boolean `edit` flag indicating if the page is in edit mode, and `attachmentFileUrl`. It then dynamically loads the template's main CSS file if the current page is not the homepage. Furthermore, if the `edit` flag is true, it loads additional CSS and JavaScript files specifically for the administrative editing environment. ```JavaScript var masterSiteUrl = '{\_masterSiteUrl}';/*主站URL*/ var edit = 'controllerRegEditMode' == 'edit';/*是否是编辑模式下*/ var attachmentFileUrl = '{AttachmentFileUrl}'; /*附件url*/ var urlname = window.location.pathname.split('.')\[0\].toLowerCase(); if(urlname != '/index' && urlname != '/'){ dynamicLoading.css("{resUrl}template/"+getTemplateId()+"/style.css"); /*非首页将动态加载模版样式文件*/ } if(edit){ dynamicLoading.css("{resUrl}template/"+getTemplateId()+"/styleedit.css");/*加载编辑模式的CSS*/ dynamicLoading.js("{resUrl}js/admin/commonedit.js");/*加载编辑模式的js*/ } ``` -------------------------------- ### News Item Display Template Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/3/module/newsimage_list_item.html This template defines the visual structure for presenting a single news item. It utilizes placeholders such as {siteName}, {news.titlepic}, {news.url}, {news.title}, {news.addtime}, and {news.intro} to dynamically populate content from a news data object. The snippet formats the news title and introduction as clickable links, and includes an image and timestamp. ```Template [![{siteName}]({news.titlepic})]({news.url}) [{news.title}]({news.url}) {news.addtime} [{news.intro}]({news.url}) ``` -------------------------------- ### Fullpage.js Initialization and Configuration Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/7/index.html Initializes the fullPage.js library on the '#fullpage' element with various configuration options. These options control section colors, navigation arrows, content centering, scrolling speed, anchor links, and keyboard navigation, among others, to create a full-screen scrolling website experience. ```JavaScript $(document).ready(function() { $('#fullpage').fullpage({ sectionsColor:['#CDE7D5','#FF8932','#275D8B','#06C8D2'], //控制每个section的背景颜色 controlArrow:true, //是否隐藏左右滑块的箭头(默认为true) verticalCentered: true, //内容是否垂直居中(默认为true) css3: true, //是否使用 CSS3 transforms 滚动(默认为false) resize:false, //字体是否随着窗口缩放而缩放(默认为false) scrolllingSpeed:1000, //滚动速度,单位为毫秒(默认为700) anchors:['indexBigImage','imageList','aboutUs','contactUs'], //定义锚链接(值不能和页面中任意的id或name相同,尤其是在ie下,定义时不需要加#) lockAnchors:false, //是否锁定锚链接,默认为false。设置weitrue时,锚链接anchors属性也没有效果。 loopBottom:false, //滚动到最底部后是否滚回顶部(默认为false) loopTop:false, //滚动到最顶部后是否滚底部 loopHorizontal:false,//左右滑块是否循环滑动 autoScrolling:true, // 是否使用插件的滚动方式,如果选择 false,则会出现浏览器自带的滚动条 scrollBar:false,//是否显示滚动条,为true是一滚动就是一整屏 fixedElements:".logo", //固定元素 menu:"header", keyboardScrolling:true, //是否使用键盘方向键导航(默认为true) keyboardScrolling:true, //页面是否循环滚动(默认为false) navigation:true, //是否显示项目导航(默认为false) navigationTooltips:["首页",pageName_2,pageName_3,"联系我们"],//项目导航的 tip navigationColor:'#fff', //项目导航的颜色 slidesNavigation:true, }); }); ``` -------------------------------- ### Template Structure and Content Includes Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/1/page.html Defines the foundational structure of a web page using template directives. It includes common sections like 'head', 'top' navigation, and 'foot' (footer) via include statements, and designates a '{text}' placeholder for the main content area. ```Template {include=head} {include=top} {text} {include=foot} ``` -------------------------------- ### Initialize Wangmarket Variables and Conditionally Load Resources Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/7/common/head.html This JavaScript snippet initializes global variables such as the master site URL, attachment file URL, and a flag indicating if the page is in edit mode. It then dynamically loads template-specific CSS files for non-homepage views and additional CSS/JavaScript files specifically for the edit mode, ensuring resources are loaded only when needed. ```JavaScript var masterSiteUrl = '{\_masterSiteUrl}';/*主站URL*/ var edit = 'controllerRegEditMode' == 'edit';/*是否是编辑模式下*/ var attachmentFileUrl = '{AttachmentFileUrl}'; /*附件url*/ var urlname = window.location.pathname.split('.')[0].toLowerCase(); if(urlname != '/index' && urlname != '/'){ dynamicLoading.css("{resUrl}template/"+getTemplateId()+"/style.css"); /*非首页将动态加载模版样式文件*/ } if(edit){ dynamicLoading.css("{resUrl}template/"+getTemplateId()+"/styleedit.css");/*加载编辑模式的CSS*/ dynamicLoading.js("{resUrl}js/admin/commonedit.js");/*加载编辑模式的js*/ } ``` -------------------------------- ### Templated News/Product List Item Structure Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/7/index.html An HTML template snippet demonstrating how to display a list item, likely for news or products. It includes an image, title, introduction, and a link, all dynamically populated by a templating engine using placeholders like `{news.title}` and `{news.url}`. ```HTML/Templating * [![{news.title}]({news.titlepic}) {news.title} {news.intro} ]({news.url}) ``` -------------------------------- ### JavaScript Frontend Initialization and Script Loading Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/5/common/top.html This JavaScript code snippet initializes frontend elements by clearing a specific DOM element (`columnList`) for SEO purposes and conditionally setting the display style of a banner (`banner`) based on a `site['mShowBanner']` flag. Furthermore, it dynamically loads either `headeredit.js` or `header.js` from the template directory, depending on the global `edit` variable, which likely indicates an editing mode. ```JavaScript document.getElementById('columnList').innerHTML = '';/*清空不让有利于SEO的描述文字显示,免得网速慢时效果差*/ document.getElementById("banner").style.display = site['mShowBanner'] == '1'? '':'none';/*如不显示,直接让其隐藏*/ if(edit){ dynamicLoading.js("{resUrl}template/"+getTemplateId()+"/js/headeredit.js"); }else{ dynamicLoading.js("{resUrl}template/"+getTemplateId()+"/js/header.js"); } ``` -------------------------------- ### Include Template Sections Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/3/index.html These snippets demonstrate how to include common template sections like headers, footers, and top navigation into a page using a custom templating syntax. ```HTML Template {include=head} {include=top} {include=foot} ``` -------------------------------- ### Wangmarket Page Template Layout and Includes Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/7/news_list.html This snippet displays the complete structure of a typical page template in the xnx3/wangmarket system. It shows how various sections are included using `{include=}` directives, how dynamic site information is rendered via `{siteColumn.name}` and `{siteName}` variables, and how a JavaScript file is conditionally loaded based on an 'edit' flag. ```Templating Language {include=head} if(edit){ dynamicLoading.js("{resUrl}template/"+getTemplateId()+"/js/newsedit.js"); } {include=top} {siteColumn.name} ================= [{siteName}](index.html) > [{siteColumn.name}]({siteColumn.url}) {listItem} {include=page} {include=foot} ``` ```JavaScript if(edit){ dynamicLoading.js("{resUrl}template/"+getTemplateId()+"/js/newsedit.js"); } ``` -------------------------------- ### News Item Display Template Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/7/module/newsimage_list_item.html This template snippet defines the structure for displaying a single news item. It includes an image (linked to the news URL), the news title (also linked), the publication time, and an introduction (also linked). It uses placeholder variables like {siteName}, {news.titlepic}, {news.title}, {news.url}, {news.addtime}, and {news.intro}. ```Template [![{siteName}]({news.titlepic})]({news.url}) [{news.title}]({news.url}) {news.addtime} [{news.intro}]({news.url}) ``` -------------------------------- ### Initialize Website Name and Banner Display Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/1/index.html This JavaScript snippet initializes the website's title from `site['name']` and dynamically generates the banner content based on `site['mShowBanner']` and `carouselList` data. It supports both a clickable and non-clickable banner display, with an edit mode. ```JavaScript /* 网站名字 */ document.getElementById('title').innerHTML = site['name']; /* 顶部Banner */ if(site['mShowBanner'] == '1'){ var carouselContent = ''; var carouselContentedit = ''; for(var c=0;c'; carouselContent = carouselContent + '
  • '; //点击修改 carouselContentedit = carouselContentedit + '
  • '; } document.getElementById('banner').innerHTML = '"; }else{ document.getElementById('banner').innerHTML = ''; } ``` -------------------------------- ### Declare Global Configuration Variables in JavaScript Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/2/common/head.html This snippet defines several global JavaScript variables used for site configuration. It includes a timestamp, URLs for OSS (Object Storage Service) and the master site, a resource path for CDN assets, and a boolean flag to indicate if the page is in edit mode. ```JavaScript //当前的时间戳 var time = new Date().getTime(); //设置OSSUtil.url var OSSUrl = '{AttachmentFileUrl}'; //主站URL var masterSiteUrl = '{masterSiteUrl}'; //CDN资源文件主URL var resPath = '{AttachmentFileUrl}'; //是否是编辑模式下 var edit = '{edit}' == 'edit'; ``` -------------------------------- ### JavaScript Dynamic CSS and JavaScript Loader Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/1/common/head.html Provides a `dynamicLoading` object with `css` and `js` methods to programmatically inject stylesheet and script tags into the document's ``. This utility is essential for loading resources on demand, with CSS files including a timestamp for cache busting. ```JavaScript //动态加载js、css文件 var dynamicLoading = { css: function(path){ if(!path || path.length === 0){ throw new Error('argument "path" is required !'); } var head = document.getElementsByTagName('head')[0]; var link = document.createElement('link'); link.href = path+'?v='+time; link.rel = 'stylesheet'; link.type = 'text/css'; head.appendChild(link); }, js: function(path){ if(!path || path.length === 0){ throw new Error('argument "path" is required !'); } var head = document.getElementsByTagName('head')[0]; var script = document.createElement('script'); script.src = path; script.type = 'text/javascript'; head.appendChild(script); } } ``` -------------------------------- ### JavaScript Dynamic Resource Loading and Variable Initialization Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/6/common/head.html This JavaScript snippet initializes global variables such as the master site URL, an 'edit' mode flag, and an attachment file URL. It then dynamically loads template-specific CSS if the current page is not the homepage. Additionally, it loads specific CSS and JavaScript files when the application is in 'edit' mode, enhancing the user interface for content management. ```JavaScript var masterSiteUrl = '{\_masterSiteUrl}';/*主站URL*/ var edit = 'controllerRegEditMode' == 'edit';/*是否是编辑模式下*/ var attachmentFileUrl = '{AttachmentFileUrl}'; /*附件url*/ var urlname = window.location.pathname.split('.')[0].toLowerCase(); if(urlname != '/index' && urlname != '/'){ dynamicLoading.css("{resUrl}template/"+getTemplateId()+"/style.css"); /*非首页将动态加载模版样式文件*/ } if(edit){ dynamicLoading.css("{resUrl}template/"+getTemplateId()+"/styleedit.css");/*加载编辑模式的CSS*/ dynamicLoading.js("{resUrl}js/admin/commonedit.js");/*加载编辑模式的js*/ } ``` -------------------------------- ### Initialize Page Elements and Dynamically Load Header Scripts Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/6/common/top.html This JavaScript snippet performs several frontend initialization tasks. It clears the inner HTML of the 'columnList' element to prevent SEO-unfriendly descriptive text from appearing during slow network conditions. It also controls the visibility of the 'banner' element based on the 'mShowBanner' property from the 'site' object. Finally, it dynamically loads either 'headeredit.js' or 'header.js' based on the 'edit' variable, likely for different user contexts (e.g., editing mode vs. regular view). ```JavaScript document.getElementById('columnList').innerHTML = '';/*清空不让有利于SEO的nav描述文字显示,免得网速慢时效果差*/ document.getElementById("banner").style.display = site['mShowBanner'] == '1'? '':'none';/*如不显示,直接让其隐藏*/ if(edit){ dynamicLoading.js("{resUrl}template/"+getTemplateId()+"/js/headeredit.js"); }else{ dynamicLoading.js("{resUrl}template/"+getTemplateId()+"/js/header.js"); } ``` -------------------------------- ### CSS for Responsive Images Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/2/page.html Ensures images within the content are responsive by setting their maximum width to 100% of their parent container, preventing overflow on smaller screens and adapting to various device sizes. ```CSS img{ max-width: 100%; } ``` -------------------------------- ### Site Information Navigation Functions Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/4/index.html Defines JavaScript functions for navigating to the site information page (`site_edit`) and a placeholder function (`site_`) for general site interactions. The `site_edit` function redirects the user to the master site's information page with specific site and client parameters. ```JavaScript function site_edit(){ window.location.href='{masterSiteUrl}site/info.do?siteid={siteId}&client=wap'; } function site_(){ } ``` -------------------------------- ### Wangmarket Page Template Structure Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/5/index.html This snippet demonstrates the basic layout and dynamic content placeholders used in Xnx3 Wangmarket web page templates. It includes references to header/footer includes, site column navigation, and news article display, utilizing a custom templating syntax. ```HTML Template {include=head} {include=top} [{siteColumn.name}](c{siteColumn.id}.html) [更多>>](c{siteColumn.id}.html) ![LOGO]({news.titlepic}) 这是关于我们的内容了是关于 [{siteColumn.name}](lc{siteColumn.id}_1.html) [更多>>](lc{siteColumn.id}_1.html) [{news.title}]({news.url}) [{siteColumn.name}](lc{siteColumn.id}_1.html) [更多>>](lc{siteColumn.id}_1.html) [![{news.title}]({news.titlepic}) {news.title} ]({news.url}) {include=foot} ``` -------------------------------- ### Displaying News and Site Information using Wangmarket Template Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/6/module/newsimage_list_item.html This snippet demonstrates how to display news articles and site-related information within the Wangmarket content management system using its proprietary templating syntax. It relies on 'news' and 'siteName' objects/variables being available in the template context, which are expected to contain properties like 'titlepic', 'url', 'title', 'addtime', and 'intro'. The output renders HTML links and text based on the provided data. ```Wangmarket Template [![{siteName}]({news.titlepic})]({news.url}) [{news.title}]({news.url}) {news.addtime} [{news.intro}]({news.url}) ``` -------------------------------- ### News Article Display Template Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/5/module/news_list_item.html This template snippet illustrates the structure for rendering news article information, including its title, URL, publication timestamp, and an introductory summary. It utilizes placeholder syntax to dynamically embed data from a 'news' object. ```Template [{news.title}]({news.url}) {news.addtime} [{news.intro}]({news.url}) ``` -------------------------------- ### Displaying News Item Template Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/5/module/newsimage_list_item.html This template snippet is designed for the /xnx3/wangmarket system to render a news article. It utilizes Markdown-like syntax for images and links, alongside custom placeholders (e.g., {news.title}, {news.url}) to dynamically insert content such as the site name, news title, featured image, publication date, and an introductory summary. The snippet structures the display to make each element clickable, leading to the full news article. ```Markdown Template [![{siteName}]({news.titlepic})]({news.url}) [{news.title}]({news.url}) {news.addtime} [{news.intro}]({news.url}) ``` -------------------------------- ### Dynamic Site Column Links Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/3/index.html This snippet shows how to generate dynamic links for site columns, displaying the column name and linking to its respective page. It also includes a 'More' link for navigation. ```HTML Template [{siteColumn.name}](c{siteColumn.id}.html) [更多>>](c{siteColumn.id}.html) [{siteColumn.name}](lc{siteColumn.id}_1.html) [更多>>](lc{siteColumn.id}_1.html) ``` -------------------------------- ### Dynamically Load JavaScript File Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/2/index.html This line of code dynamically loads the `wap.js` script from a specified resource URL. This is typically used for loading additional JavaScript functionalities after the initial page load. ```JavaScript dynamicLoading.js("{resUrl}js/wap.js"); ``` -------------------------------- ### Initialize Site Column and Navigation Data Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/4/index.html This core JavaScript function initializes and renders the site's column and navigation data. It first validates the consistency between column ranking and data, then iterates through ranked columns to construct dynamic HTML for both normal and edit modes, handling different column types (news, image-text, independent page, message board, hyperlink) and their respective URLs. It also includes buttons for content filling and column property updates in edit mode. ```JavaScript var addSiteColumnHTML = ''; var addSiteColumnHTMLedit = document.getElementById('columnList').innerHTML; function initSiteColumnData() { if (siteColumnRank.langth != siteColumn.length) { var content = ''; var contentedit = ''; var topNavContent = ''; for (var i = 0; i < siteColumnRank.length; i++) { var rank = siteColumnRank[i]; for (var j = 0; j < siteColumn.length; j++) { if (siteColumn[j]['id'] == siteColumnRank[i]) { var url = siteColumn[j]['url']; var type = siteColumn[j]['type']; switch (type) { case '1': url = 'lc'+siteColumn[j]['id']+'_1.html'; break; case '2': url = 'lc'+siteColumn[j]['id']+'_1.html'; break; case '3': url = 'c'+siteColumn[j]['id']+'.html'; break; case '4': break; case '5': break; } contentedit = contentedit + '

    ' + siteColumn[j]['name'] + '
    '+ '
    填充内容
    '+ '
    栏目属性
    '+ '
    '; content = content + '

    ' + siteColumn[j]['name'] + '
    '+ '
    '; break; } } } document.getElementById('columnList').innerHTML = content{edit}+addSiteColumnHTML{edit}; } else { alert('栏目导航排序规则跟数据不一致!'); } } initSiteColumnData(); ``` -------------------------------- ### Templated About Us Section Link and Content Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/7/index.html An HTML template snippet for an 'About Us' section, including a link to a detailed page and placeholder content. It also shows an image dynamically sourced from `news.titlepic` and a 'More' link. ```HTML/Templating [{siteColumn.name}](c{siteColumn.id}.html) ![LOGO]({news.titlepic}) 这是关于我们的内容了是关于 [更多>>](c{siteColumn.id}.html) ``` -------------------------------- ### Display News Image and Title Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/3/index.html These snippets illustrate how to display an image associated with news content, using `news.titlepic` as the source, and how to link the image and title to the full news article using `news.url`. ```HTML Template ![LOGO]({news.titlepic}) [![{news.title}]({news.titlepic}) {news.title} ]({news.url}) ``` -------------------------------- ### Basic Page Template Structure Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/6/newsimage_list.html This snippet outlines the basic structure of a web page template, including common sections like head, top, content list item, main page content, and foot. It uses custom `{include=...}` directives for modularity and placeholders like `{siteColumn.name}` and `{siteName}` for dynamic content and breadcrumbs. ```Custom Template {include=head} {include=top} {siteColumn.name} ================= [{siteName}](index.html) > [{siteColumn.name}]({siteColumn.url}) {listItem} {include=page} {include=foot} ``` -------------------------------- ### JavaScript Utility Functions for Web Page Configuration Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/4/common/head.html This snippet defines global variables such as `time`, `OSSUrl`, `masterSiteUrl`, `resPath`, and `edit`. It also includes utility functions like `setTitle` for updating the page title, `dynamicLoading` for asynchronously loading CSS and JavaScript files, and `getTemplateId` for retrieving the current template ID. These functions are crucial for dynamic content and styling in a web application, especially in a templating environment. ```JavaScript var time=new Date().getTime(); var OSSUrl = '{AttachmentFileUrl}'; var masterSiteUrl = '{masterSiteUrl}'; var resPath = '{AttachmentFileUrl}'; var edit = '{edit}' == 'edit'; function setTitle(t){ document.getElementById('title').innerHTML = t; } var dynamicLoading = { css: function(path){ if(!path || path.length === 0){ throw new Error('argument "path" is required !'); } var head = document.getElementsByTagName('head')[0]; var link = document.createElement('link'); link.href = path+'?v='+time; link.rel = 'stylesheet'; link.type = 'text/css'; head.appendChild(link); }, js: function(path){ if(!path || path.length === 0){ throw new Error('argument "path" is required !'); } var head = document.getElementsByTagName('head')[0]; var script = document.createElement('script'); script.src = path; script.type = 'text/javascript'; head.appendChild(script); } } function getTemplateId(){ if(typeof(site) != "undefined"){ return site['templateId']; }else{ return '1'; } } dynamicLoading.css("{resUrl}template/"+getTemplateId()+"/style.css"); if(edit){ dynamicLoading.css("{resUrl}template/"+getTemplateId()+"/styleedit.css"); } ``` -------------------------------- ### Dynamic CSS and JavaScript Loader Utility in JavaScript Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/2/common/head.html This JavaScript utility, `dynamicLoading`, provides methods to asynchronously load CSS stylesheets and JavaScript files into the document's head. It ensures that required resources are loaded dynamically, with CSS files being cache-busted using a timestamp. ```JavaScript //动态加载js、css文件 var dynamicLoading = { css: function(path){ if(!path || path.length === 0){ throw new Error('argument "path" is required !'); } var head = document.getElementsByTagName('head')[0]; var link = document.createElement('link'); link.href = path+'?v='+time; link.rel = 'stylesheet'; link.type = 'text/css'; head.appendChild(link); }, js: function(path){ if(!path || path.length === 0){ throw new Error('argument "path" is required !'); } var head = document.getElementsByTagName('head')[0]; var script = document.createElement('script'); script.src = path; script.type = 'text/javascript'; head.appendChild(script); } } ``` -------------------------------- ### Conditionally Load Header JavaScript Files Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/3/common/top.html This JavaScript snippet dynamically loads a specific header script based on the boolean value of the `edit` variable. If `edit` is true, it loads `headeredit.js`; otherwise, it loads `header.js`. This pattern enables different functionalities or UI behaviors depending on whether the page is in an editing mode or a standard viewing mode. ```JavaScript if(edit){ dynamicLoading.js("{resUrl}template/"+getTemplateId()+"/js/headeredit.js"); }else{ dynamicLoading.js("{resUrl}template/"+getTemplateId()+"/js/header.js"); } ``` -------------------------------- ### Wangmarket Page Template Includes and Placeholders Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/6/news_list.html This snippet illustrates the basic structure of a Wangmarket page template. It uses `{include=...}` directives to embed common sections like head, top, page, and foot. Placeholders like `{siteColumn.name}`, `{siteName}`, and `{listItem}` are used to dynamically inject content such as site column names, site names, and list items, forming a breadcrumb navigation. ```Templating Language {include=head} {include=top} {siteColumn.name} ================= [{siteName}](index.html) > [{siteColumn.name}]({siteColumn.url}) {listItem} {include=page} {include=foot} ``` -------------------------------- ### Dynamically Set Image Source for 'img_back' Element Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/4/common/top.html This JavaScript code retrieves an HTML element by its ID 'img_back' and sets its 'src' attribute. The image path is constructed dynamically by concatenating a base resource URL ('{resUrl}'), a fixed template path, a template identifier obtained from the 'getTemplateId()' function, and the image filename 'back.png'. This pattern is common for loading template-specific assets. ```javascript document.getElementById("img_back").src='{resUrl}template/'+getTemplateId()+'/image/back.png'; ``` -------------------------------- ### Populate Site Title and Manage Banner Display Source: https://github.com/xnx3/wangmarket/blob/master/src/main/resources/static/template/4/index.html This JavaScript code populates the site's title from the `site` object and dynamically manages the display of the banner. It iterates through a `carouselList` to set the background image of the document body if `mShowBanner` is enabled, otherwise, the banner is cleared. ```JavaScript document.getElementById('title').innerHTML = site['name']; if(site['mShowBanner'] == '1'){ var carouselContent = ''; var carouselContentedit = ''; for(var c=0;c [{siteColumn.name}]({siteColumn.url}) {listItem} {include=page} {include=foot} ```