razor 淘汰表

data-table.js
var mApp = mApp || {};

mApp.isDateTime = function(str) {
    return /\d{2}\.\d{2}\.\d{4}\s(\d{2}:\d{2}:\d{2}|\d{2}:\d{2})/.test(str);
};

mApp.changeDateFormat = function(d) {
    var r = d.match(/^\s*(\d+)\s*\.\s*(\d+)\s*\.\s*(\d+)(.*)$/);
    return r[3] + "-" + r[2] + "-" + r[1] + r[4];
};

mApp.numbersDeclaration = function (number, titles) {
    var cases = [2, 0, 1, 1, 1, 2];
    return titles[(number % 100 > 4 && number % 100 < 20) ? 2 : cases[(number % 10 < 5) ? number % 10 : 5]];
};

mApp.createNumericArray =  function (startIndex, len) {
    console.log(startIndex, len);
    var resultArray = [];

    for (var i = startIndex; i <= len; i++) {
        resultArray.push(i);
    }

    return resultArray;
};



(function () {
    var indexOf = [].indexOf || function (item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };

    window.DataTable = (function () {
        var primitiveCompare, pureComputed;

        pureComputed = ko.pureComputed || ko.computed;

        primitiveCompare = function (item1, item2) {
            if (item2 == null) {
                return item1 == null;
            } else if (item1 != null) {
                if (typeof item1 === 'boolean') {
                    return item1 === item2;
                } else {
                    return item1.toString().toLowerCase().indexOf(item2.toString().toLowerCase()) >= 0 || item1 === item2;
                }
            } else {
                return false;
            }
        };

        function DataTable(rows, options) {
            var serverSideOpts;
            if (!options) {
                if (!(rows instanceof Array)) {
                    options = rows;
                    rows = [];
                } else {
                    options = {};
                }
            }
            this.options = {
                recordWord: options.recordWord || 'record',
                recordWordPlural: options.recordWordPlural,
                recordWordPlural2: options.recordWordPlural2,
                sortDir: options.sortDir || 'asc',
                sortField: options.sortField || void 0,
                perPage: options.perPage || 15,
                filterFn: options.filterFn || void 0,
                unsortedClass: options.unsortedClass || '',
                descSortClass: options.descSortClass || '',
                ascSortClass: options.ascSortClass || ''
            };
            this.initObservables();
            if ((serverSideOpts = options.serverSidePagination) && serverSideOpts.enabled) {
                if (!(serverSideOpts.path && serverSideOpts.loader)) {
                    throw new Error("`path` or `loader` missing from `serverSidePagination` object");
                }
                this.options.paginationPath = serverSideOpts.path;
                this.options.resultHandlerFn = serverSideOpts.loader;
                this.options.afterLoadingCallback = serverSideOpts.callback || function () { };
                this.options.pagesDotted = serverSideOpts.pagesDotted;
                this.initWithServerSidePagination();
            } else {
                this.initWithClientSidePagination(rows);
            }
        }

        DataTable.prototype.initObservables = function () {
            this.sortDir = ko.observable(this.options.sortDir);
            this.sortField = ko.observable(this.options.sortField);
            this.perPage = ko.observable(this.options.perPage);
            this.currentPage = ko.observable(1);
            this.filter = ko.observable('');
            this.loading = ko.observable(false);
            return this.rows = ko.observableArray([]);
        };

        DataTable.prototype.initWithClientSidePagination = function (rows) {
            var _defaultMatch;
            this.filtering = ko.observable(false);
            this.filter.subscribe((function (_this) {
                return function () {
                    return _this.currentPage(1);
                };
            })(this));
            this.perPage.subscribe((function (_this) {
                return function () {
                    return _this.currentPage(1);
                };
            })(this));
            this.rows(rows);
            this.rowAttributeMap = pureComputed((function (_this) {
                return function () {
                    var attrMap, key, row;
                    rows = _this.rows();
                    attrMap = {};
                    if (rows.length > 0) {
                        row = rows[0];
                        for (key in row) {
                            if (row.hasOwnProperty(key)) {
                                attrMap[key.toLowerCase()] = key;
                            }
                        }
                    }
                    return attrMap;
                };
            })(this));
            this.filteredRows = pureComputed((function (_this) {
                return function () {
                    var filter, filterFn;
                    _this.filtering(true);
                    filter = _this.filter();
                    rows = _this.rows.slice(0);
                    if ((filter != null) && filter !== '') {
                        filterFn = _this.filterFn(filter);
                        rows = rows.filter(filterFn);
                    }
                    if ((_this.sortField() != null) && _this.sortField() !== '') {
                        rows.sort(function (a, b) {
                            var aVal, bVal;
                            aVal = ko.utils.unwrapObservable(a[_this.sortField()]);
                            bVal = ko.utils.unwrapObservable(b[_this.sortField()]);
                            if (typeof aVal === 'string') {
                                aVal = aVal.toLowerCase();
                            }
                            if (typeof bVal === 'string') {

                                bVal = bVal.toLowerCase();
                            }
                            if (mApp.isDateTime(aVal)) {
                                aVal = +new Date(mApp.changeDateFormat(aVal));
                            }
                            if (mApp.isDateTime(bVal)) {
                                bVal = +new Date(mApp.changeDateFormat(bVal));
                            }
                            if (_this.sortDir() === 'asc') {
                                if (aVal < bVal || aVal === '' || (aVal == null)) {
                                    return -1;
                                } else {
                                    if (aVal > bVal || bVal === '' || (bVal == null)) {
                                        return 1;
                                    } else {
                                        return 0;
                                    }
                                }
                            } else {
                                if (aVal < bVal || aVal === '' || (aVal == null)) {
                                    return 1;
                                } else {
                                    if (aVal > bVal || bVal === '' || (bVal == null)) {
                                        return -1;
                                    } else {
                                        return 0;
                                    }
                                }
                            }
                        });
                    } else {
                        rows;
                    }
                    _this.filtering(false);
                    return rows;
                };
            })(this)).extend({
                rateLimit: 50,
                method: 'notifyWhenChangesStop'
            });
            this.pagedRows = pureComputed((function (_this) {
                return function () {
                    var pageIndex, perPage;
                    pageIndex = _this.currentPage() - 1;
                    perPage = _this.perPage();
                    return _this.filteredRows().slice(pageIndex * perPage, (pageIndex + 1) * perPage);
                };
            })(this));
            this.pages = pureComputed((function (_this) {
                return function () {
                    return Math.ceil(_this.filteredRows().length / _this.perPage());
                };
            })(this));
            this.leftPagerClass = pureComputed((function (_this) {
                return function () {
                    if (_this.currentPage() === 1) {
                        return 'disabled';
                    }
                };
            })(this));
            this.rightPagerClass = pureComputed((function (_this) {
                return function () {
                    if (_this.currentPage() === _this.pages()) {
                        return 'disabled';
                    }
                };
            })(this));
            this.total = pureComputed((function (_this) {
                return function () {
                    return _this.filteredRows().length;
                };
            })(this));
            this.from = pureComputed((function (_this) {
                return function () {
                    return (_this.currentPage() - 1) * _this.perPage() + 1;
                };
            })(this));
            this.to = pureComputed((function (_this) {
                return function () {
                    var to;
                    to = _this.currentPage() * _this.perPage();
                    if (to > _this.total()) {
                        return _this.total();
                    } else {
                        return to;
                    }
                };
            })(this));
            this.recordsText = pureComputed((function (_this) {
                return function () {
                    var from, pages, recordWord, recordWordPlural, recordWordPlural2, to, total;
                    pages = _this.pages();
                    total = _this.total();
                    from = _this.from();
                    to = _this.to();
                    recordWord = _this.options.recordWord;
                    recordWordPlural = _this.options.recordWordPlural || recordWord + 's';
                    recordWordPlural2 = _this.options.recordWordPlural2 || recordWord + 's';
                    if (pages > 1) {
                        return from + " - " + to + " из " + total.toFloatStr(0, true) + " " + mApp.numbersDeclaration(total, [recordWord, recordWordPlural, recordWordPlural2]);

                    } else {
                        //return total + " " + (total > 1 || total === 0 ? recordWordPlural : recordWord);
                        return total + " " + (mApp.numbersDeclaration(total, [recordWord, recordWordPlural, recordWordPlural2]));
                    }
                };
            })(this));
            this.showNoData = pureComputed((function (_this) {
                return function () {
                    return _this.pagedRows().length === 0 && !_this.loading();
                };
            })(this));
            this.showLoading = pureComputed((function (_this) {
                return function () {
                    return _this.loading();
                };
            })(this));
            this.sortClass = (function (_this) {
                return function (column) {
                    return pureComputed(function () {
                        if (_this.sortField() === column) {
                            return 'sorted ' + (_this.sortDir() === 'asc' ? _this.options.ascSortClass : _this.options.descSortClass);
                        } else {
                            return _this.options.unsortedClass;
                        }
                    });
                };
            })(this);
            this.addRecord = (function (_this) {
                return function (record) {
                    return _this.rows.push(record);
                };
            })(this);
            this.removeRecord = (function (_this) {
                return function (record) {
                    _this.rows.remove(record);
                    if (_this.pagedRows().length === 0) {
                        return _this.prevPage();
                    }
                };
            })(this);
            this.replaceRows = (function (_this) {
                return function (rows) {
                    _this.rows(rows);
                    _this.currentPage(1);
                    return _this.filter(void 0);
                };
            })(this);
            _defaultMatch = function (filter, row, attrMap) {
                var key, val;
                return ((function () {
                    var results1;
                    results1 = [];
                    for (key in attrMap) {
                        val = attrMap[key];
                        results1.push(val);
                    }
                    return results1;
                })()).some(function (val) {
                    return primitiveCompare((ko.isObservable(row[val]) ? row[val]() : row[val]), filter);
                });
            };
            return this.filterFn = this.options.filterFn || (function (_this) {
                    return function (filterVar) {
                        var filter, ref, specials;
                        ref = [[], {}], filter = ref[0], specials = ref[1];
                        filterVar.split(' ').forEach(function (word) {
                            var words;
                            if (word.indexOf(':') >= 0) {
                                words = word.split(':');
                                return specials[words[0]] = (function () {
                                    switch (words[1].toLowerCase()) {
                                        case 'yes':
                                        case 'true':
                                            return true;
                                        case 'no':
                                        case 'false':
                                            return false;
                                        case 'blank':
                                        case 'none':
                                        case 'null':
                                        case 'undefined':
                                            return void 0;
                                        default:
                                            return words[1].toLowerCase();
                                    }
                                })();
                            } else {
                                return filter.push(word);
                            }
                        });
                        filter = filter.join(' ');
                        return function (row) {
                            var conditionals, key, val;
                            conditionals = (function () {
                                var results1;
                                results1 = [];
                                for (key in specials) {
                                    val = specials[key];
                                    results1.push((function (_this) {
                                        return function (key, val) {
                                            var rowAttr;
                                            if (rowAttr = _this.rowAttributeMap()[key.toLowerCase()]) {
                                                return primitiveCompare((ko.isObservable(row[rowAttr]) ? row[rowAttr]() : row[rowAttr]), val);
                                            } else {
                                                return false;
                                            }
                                        };
                                    })(this)(key, val));
                                }
                                return results1;
                            }).call(_this);
                            return (indexOf.call(conditionals, false) < 0) && (filter !== '' ? (row.match != null ? row.match(filter) : _defaultMatch(filter, row, _this.rowAttributeMap())) : true);
                        };
                    };
                })(this);
        };

        DataTable.prototype.initWithServerSidePagination = function () {
            var _gatherData, _getDataFromServer;
            _getDataFromServer = (function (_this) {
                return function (data, cb) {
                    var key, req, url, val;
                    url = _this.options.paginationPath + "?" + (((function () {
                            var results1;
                            results1 = [];
                            for (key in data) {
                                val = data[key];
                                results1.push((encodeURIComponent(key)) + "=" + (encodeURIComponent(val)));
                            }
                            return results1;
                        })()).join('&'));
                    /**@for abort*/
                    mApp.tableModelGetDataFromServer =  req = new XMLHttpRequest();
                    req.open('GET', url, true);
                    req.setRequestHeader('Content-Type', 'application/json');
                    req.onload = function () {
                        if (req.status >= 200 && req.status < 400) {
                            return cb(null, JSON.parse(req.responseText));
                        } else {
                            return cb(new Error("Error communicating with server"));
                        }
                    };
                    req.onerror = function () {
                        return cb(new Error("Error communicating with server"));
                    };
                    return req.send();
                };
            })(this);
            _gatherData = function (perPage, currentPage, filter, sortDir, sortField) {
                var data;
                data = {
                    perPage: perPage,
                    page: currentPage
                };
                if ((filter != null) && filter !== '') {
                    data.filter = filter;
                }
                if ((sortDir != null) && sortDir !== '' && (sortField != null) && sortField !== '') {
                    data.sortDir = sortDir;
                    data.sortBy = sortField;
                }
                return data;
            };
            this.filtering = ko.observable(false);
            this.pagedRows = ko.observableArray([]);
            this.numFilteredRows = ko.observable(0);
            this.filter.subscribe((function (_this) {
                return function () {
                    /**test*/
                    if (_this.options.pagesDotted) {
                        console.log("this.filter.subscribe");
                        _this.pagesDotted();
                    }
                    /**test*/
                    return _this.currentPage(1);
                };
            })(this));
            this.perPage.subscribe((function (_this) {
                return function () {
                    if (_this.options.pagesDotted) {
                        _this.pagesDotted();
                    }
                    return _this.currentPage(1);
                };
            })(this));
            ko.computed((function (_this) {
                return function () {
                    var data;
                    _this.loading(true);
                    _this.filtering(true);
                    data = _gatherData(_this.perPage(), _this.currentPage(), _this.filter(), _this.sortDir(), _this.sortField());
                    console.log("_getDataFromServer");
                    return _getDataFromServer(data, function (err, response) {
                        var results, total;
                        _this.loading(false);
                        _this.filtering(false);
                        if (err) {
                            return console.log(err);
                        }
                        //total = response.total, results = response.results;
                        total = response.total, results = response.value;
                        _this.numFilteredRows(total);

                        if (_this.options.pagesDotted /*&& !_this.pagesDottedArray().length*/) {
                            _this.pagesDotted();
                        }

                        let result;

                        if (!!results) {
                            result = _this.pagedRows(results.map(_this.options.resultHandlerFn));
                        }
                        _this.options.afterLoadingCallback();
                        return result;
                    });
                };
            })(this)).extend({
                rateLimit: 500,
                method: 'notifyWhenChangesStop'
            });
            this.pages = pureComputed((function (_this) {
                return function () {
                    return Math.ceil(_this.numFilteredRows() / _this.perPage());
                };
            })(this));

            this.pagesDottedArray = ko.observableArray();
            this.pagesDotted = pureComputed({
                read:(function (_this) {
                    return function () {
                        var pages = Math.ceil(_this.numFilteredRows() / _this.perPage());
                        console.log("pages:", pages);
                        return _this.pagesDottedArray(pages > 5 ? mApp.createNumericArray(1, 5) : mApp.createNumericArray(1, pages));
                    };
                })(this),
                write: function (value) {
                    (function(_this) {
                        _this.pagesDottedArray(value);
                    })(this);
                },
                owner:(function(_this) { return _this; })(this)
            });
            /**pages dotted*/
            this.leftPagerClass = pureComputed((function (_this) {
                return function () {
                    if (_this.currentPage() === 1) {
                        return 'disabled';
                    }
                };
            })(this));
            this.rightPagerClass = pureComputed((function (_this) {
                return function () {
                    if (_this.currentPage() === _this.pages()) {
                        return 'disabled';
                    }
                };
            })(this));
            this.from = pureComputed((function (_this) {
                return function () {
                    return (_this.currentPage() - 1) * _this.perPage() + 1;
                };
            })(this));
            this.to = pureComputed((function (_this) {
                return function () {
                    var to, total;
                    to = _this.currentPage() * _this.perPage();
                    if (to > (total = _this.numFilteredRows())) {
                        return total;
                    } else {
                        return to;
                    }
                };
            })(this));
            this.recordsText = pureComputed((function (_this) {
                return function () {
                    var from, pages, recordWord, recordWordPlural, recordWordPlural2, to, total;
                    pages = _this.pages();
                    total = _this.numFilteredRows();
                    from = _this.from();
                    to = _this.to();
                    recordWord = _this.options.recordWord;
                    recordWordPlural = _this.options.recordWordPlural || recordWord + 's';
                    recordWordPlural2 = _this.options.recordWordPlural2 || recordWord + 's';
                    if (pages > 1) {
                        return from + " - " + to + " из " + total.toFloatStr(0, true) + " " + mApp.numbersDeclaration(total, [recordWord, recordWordPlural, recordWordPlural2]);
                    } else {
                        //return total + " " + (total > 1 || total === 0 ? recordWordPlural : recordWord);
                        return total + " " + (mApp.numbersDeclaration(total, [recordWord, recordWordPlural, recordWordPlural2]));
                    }
                };
            })(this));
            this.showNoData = pureComputed((function (_this) {
                return function () {
                    return _this.pagedRows().length === 0 && !_this.loading();
                };
            })(this));
            this.showLoading = pureComputed((function (_this) {
                return function () {
                    return _this.loading();
                };
            })(this));
            this.sortClass = (function (_this) {
                return function (column) {
                    return pureComputed(function () {
                        if (_this.sortField() === column) {
                            return 'sorted ' + (_this.sortDir() === 'asc' ? _this.options.ascSortClass : _this.options.descSortClass);
                        } else {
                            return _this.options.unsortedClass;
                        }
                    });
                };
            })(this);
            this.addRecord = function () {
                throw new Error("#addRecord() not applicable with serverSidePagination enabled");
            };
            this.removeRecord = function () {
                throw new Error("#removeRecord() not applicable with serverSidePagination enabled");
            };
            this.replaceRows = function () {
                throw new Error("#replaceRows() not applicable with serverSidePagination enabled");
            };
            return this.refreshData = (function (_this) {
                return function () {
                    var data;
                    _this.loading(true);
                    _this.filtering(true);
                    data = _gatherData(_this.perPage(), _this.currentPage(), _this.filter(), _this.sortDir(), _this.sortField());
                    return _getDataFromServer(data, function (err, response) {
                        var results, total;
                        _this.loading(false);
                        _this.filtering(false);
                        if (err) {
                            return console.log(err);
                        }
                        //total = response.total, results = response.results;
                        total = response.total, results = response.value; 

                        _this.numFilteredRows(total);
                        let result = _this.pagedRows((results||[]).map(_this.options.resultHandlerFn));
                        _this.options.afterLoadingCallback();
                        return result;
                    });
                };
            })(this);
        };

        DataTable.prototype.toggleSort = function (field) {
            return (function (_this) {
                return function () {
                    _this.currentPage(1);
                    if (_this.sortField() === field) {
                        return _this.sortDir(_this.sortDir() === 'asc' ? 'desc' : 'asc');
                    } else {
                        _this.sortDir('asc');
                        return _this.sortField(field);
                    }
                };
            })(this);
        };

        DataTable.prototype.prevPage = function () {
            var page;
            page = this.currentPage();

            if (this.options.pagesDotted) {

                if (this.pagesDottedArray().indexOf(page) === 4 && page !== this.pages()) {
                    this.pagesDotted(window.mApp.createNumericArray(page - 1, page + 3 > this.pages() ? this.pages() : page + 3));
                }
                if (this.pagesDottedArray().indexOf(page) === 0 && page !== 1) {
                    //this.pagesDotted(window.mApp.createNumericArray(page - 3, page + 1));
                    this.pagesDotted(window.mApp.createNumericArray(page - 3 < 0 ? 1 : page - 3, page - 3 < 0 ? (this.pages() >= 5 ? 5 : this.pages()) : page + 1));
                }
            }
            if (page !== 1) {
                return this.currentPage(page - 1);
            }
        };

        DataTable.prototype.nextPage = function () {
            var page;
            page = this.currentPage();

            if (this.options.pagesDotted) {
                if (this.pagesDottedArray().indexOf(page) === 4 && page !== this.pages()) {
                    this.pagesDotted(window.mApp.createNumericArray(page - 1, page + 3 > this.pages() ? this.pages() : page + 3));
                }
                if (this.pagesDottedArray().indexOf(page) === 0 && page !== 1) {
                    this.pagesDotted(window.mApp.createNumericArray(page - 3, page + 1));
                }
            }
            if (page !== this.pages()) {
                return this.currentPage(page + 1);
            }
        };

        DataTable.prototype.gotoPage = function (page) {
            return (function (_this) {
                return function () {
                    return _this.currentPage(page);
                };
            })(this);
        };


        DataTable.prototype.updatePaging = function (extra) {
            return (function (_this) {
                return function () {
                    var page = !!extra ? extra : _this.currentPage();

                    /**@last*/
                    if (!!extra && extra === _this.pages()) {
                        return _this.pagesDotted(window.mApp.createNumericArray(_this.pages() - 4, _this.pages()));
                    }

                    /**@first*/
                    if (!!extra && extra === 1) {
                        return _this.pagesDotted(window.mApp.createNumericArray(1, 5));
                    }


                    if (_this.pagesDottedArray().indexOf(page) === 4 && page !== _this.pages()) {
                        return _this.pagesDotted(window.mApp.createNumericArray(page-1, page + 3 > _this.pages() ? _this.pages() : page + 3));
                    }


                    if (_this.pagesDottedArray().indexOf(page) === 0 && page !== 1) {
                        return _this.pagesDotted(window.mApp.createNumericArray(page - 3 < 0 ? 1 : page - 3, page - 3 < 0 ? (_this.pages() >= 5 ? 5 : _this.pages()) : page + 1));
                    }
                };
            })(this);
        };

        DataTable.prototype.pageClass = function (page) {
            return pureComputed((function (_this) {
                return function () {
                    if (_this.currentPage() === page) {
                        return 'active';
                    }
                };
            })(this));
        };

        return DataTable;

    })();

}).call(this);

Number.prototype.toFloatStr = function (n, triads) {
    var s, d = 0, k, m;

    if (typeof (n) == 'number')
        if (n.isInt())
            if (n >= -6 && n <= 6) d = n;

    s = this.roundTo(d).toString().replace('.', ',');

    if (d > 0) {
        k = s.indexOf(',');
        if (k == -1)
            s += ',' + '0'.repeat(d);
        else
            s += '0'.repeat(d - (s.length - k - 1));
    }

    k = s.indexOf(',');
    if (k == -1) k = s.length;
    m = s.indexOf('-');
    if (m == -1)
        m = 0;
    else
        m = 1;

    if (triads)
        for (d = k - 3; d > m; d = d - 3) {
            s = s.substr(0, d) + ' ' + s.substr(d, s.length - d + 1);
        }

    return s;
};

Number.prototype.isInt = function (){
    return (Math.round(this) == this);
};

Number.prototype.roundTo = function (n){
    var x = 0;
    if (typeof (n) == 'number')
        if (n.isInt())
            if (n >= -6 && n <= 6) x = n;
    x = Math.pow(10, x);
    return Math.round(this * x) / x;
}
index.js
var Statistics = function () {
  var controller = this;

  this.strings = {};

  this.api = {
      list: {
          get: '/Statistics/Statistics/GetLegalData',
          setStatus: '/Statistics/Statistics/SetLegalStatus',
          loadNew: '/Statistics/Statistics/GetNewLegalData',
          search: '/Statistics/Statistics/SearchLegals',
          logSearch: '/Search/Search/LogSearch'
      },
      getDetails:'/'

  };

  this.actions = {
    list: {
        get: function () {
            $.get(controller.api.list.get, {page: 0, perPage: 200}).done(this.getDone);
        },
        getDone: function (response) {
            var rows = response.value.map(function (row) {
                return new controller.models.Company(row, model);
            });
        },
        loadNew: function () {
            $.get(controller.api.list.loadNew).done(function (response) {

                for (var i in response) {
                    if (response.value.hasOwnProperty(i)){
                        controller.ViewModel.table.rows.push(new controller.models.Company(response[i], model));
                    }
                }
            });
        },
        setStatus: function (legalId, status) {
            $.post(controller.api.list.setStatus, { legalId: legalId, value: status }).done(function (response) {
            });
        },
        filters:{
            get: function (type) {
                $.get(controller.api.list.get, type).done(controller.actions.list.getDone);
            }
        },
        search: function(string) {
            if (!string) {
              $('body').unhighlight();
              controller.ViewModel.table.filter('{}');
              controller.ViewModel.searchText = "";
            } else {
              controller.ViewModel.searchText = string;
              controller.ViewModel.table.filter(`{ text: ${string} }`);
            }
            // log search query
            $.get(controller.api.list.logSearch, {"whence": "МОШЕННИКИ", "text": string});
        }
    }
  };

  this.models = {
      Company: (function () {
          function Company(row, view) {
              var self = this;

              this.view = view;

              this.Id = row.Id;

              this.Classification = ko.observable(row.Classification);

              this.Name = ko.observable(row.Name || '');

              this.Inn = ko.observable(row.Inn || '');
              this.Ogrn = ko.observable(row.Ogrn || '');
              this.Okpo = ko.observable(row.Okpo || '');

              this.FactAdress = ko.observable(row.FactAdress || '');
              this.JurAddress = ko.observable(row.JurAddress || '');

              this.Head = ko.observable(row.Head || '');
              
              this.CheckReason = ko.observable(row.CheckReason || '');
              this.Info = ko.observable(row.Info || '');
              this.InfoSource = ko.observable(row.InfoSource || '');

              this.Phone = ko.observable(row.Phone || '');
              this.Bank = ko.observable(row.Bank || '');

              this.DateRegistration = ko.observable(
                moment(Number(row.DateRegistration.match(/\/Date\((-?\d+)\)\/$/)[1])).format('DD.MM.YYYY') || '');
          }
          return Company;
      })()
  };

  this.list = [];


  this.ViewModel = function () {

    var rows, tableOptions, _this = this;
    controller.ViewModel.searchText = '';

    tableOptions = {
        recordWord: 'правило',
        recordWordPlural: 'правила',
        recordWordPlural2: 'правил',
        sortDir: 'desc',
        sortField: 'DateCreated',
        perPage: 20,
        unsortedClass: "red-sunglo",
        ascSortClass: "fa fa-angle-up red-sunglo",
        descSortClass: "fa fa-angle-down red-sunglo",
        serverSidePagination: {
          enabled: true,
          path: "/Statistics/Statistics/GetLegalData",
          loader: response => new controller.models.Company(response, controller.model),
          pagesDotted: false,
          callback: () => {setTimeout(_ => $('table').highlight(controller.ViewModel.searchText), 1000);}
        }
    };

    rows = controller.list.map(function (row) {
        return new controller.models.Company(row, _this);
    });

    this.details = {
      Name: ko.observable(''),
      DateRegistration: ko.observable(''),
      Inn: ko.observable(''),
      Ogrn: ko.observable(''),
      WorkingStatus: ko.observable(''),
      JurAddress: ko.observable(''),
      Fio: ko.observable(''),
      Okved: ko.observable('')
    };

    this.loadNewDisable = ko.observable(false);

    this.filter = ko.observable('0');

    this.actions = {
        list:{
            loadNew: function () {
                controller.actions.list.loadNew();
                _this.loadNewDisable(true);
            },
            toActive: function () {
                //if (_this.filter() !== '0') {
                    _this.table.pagedRows.remove(this);
                //}

                controller.actions.list.setStatus(this.Id, 0);
            },
            toArchive: function () {
                //if (_this.filter() !== '0'){
                    _this.table.pagedRows.remove(this);
                //}

                controller.actions.list.setStatus(this.Id, 1);
            },
            toControl: function () {
                //if (_this.filter() !== '0'){
                    _this.table.pagedRows.remove(this);
               // }

                controller.actions.list.setStatus(this.Id, 2);
            },
            all:function () {
                _this.filter('0');

                controller.actions.list.get();
            }
        },
        getDetails:function(){
            var item = ko.toJS(this);

            _this.details.Name(item.Name||'');
            _this.details.DateRegistration(item.DateRegistration||'');
            _this.details.Inn(item.Inn||'');
            _this.details.Ogrn(item.Ogrn||'');
            _this.details.WorkingStatus(item.WorkingStatus||'');
            _this.details.JurAddress(item.JurAddress||'');
            _this.details.Fio(item.Fio||'');
            _this.details.Okved(item.Okved||'');


            $('#detail').modal('show');
        },
        filters:{
            /** @type {String} type all archived controlling */
            get: function (type, t) {

                _this.filter(t);
                _this.table.filter(`{ status: ${t} }`);
                //controller.actions.list.filters.get(type);
                // _this.table.refreshData();
            }
        }


    };

    this.table = new DataTable(rows, tableOptions);
    

    this.table.nextPage = function() {
      DataTable.prototype.nextPage.call(this);
      if(_this.searchText)
        setTimeout(_ => $('table').highlight(_this.searchText), 1000);
    }

    this.table.prevPage = function() {
      DataTable.prototype.prevPage.call(this);
      if(_this.searchText)
        setTimeout(_ => $('table').highlight(_this.searchText), 1000);
    }
    this.table.gotoPage = function(page) {
      if (page <= 0) return;

      DataTable.prototype.gotoPage.call(this, page)();
      if(_this.searchText)
        setTimeout(_ => $('table').highlight(_this.searchText), 1000);
    }

    window.model = this;
  };


  this.init = function () {
      controller.ViewModel = new controller.ViewModel();

      ko.applyBindings(controller.ViewModel, document.getElementById("vm"));

      // controller.actions.list.get();
  }




};

var sc = new Statistics();

sc.init();

// input filter setup
$("#filter-submit")
.click(function () {
    var string = $('#filter-input').val();
    sc.actions.list.search(string);
});

$('#filter-input').keyup(function(event) {
   if(event.keyCode == 13){
        $("#filter-submit").click();
    }
}).focus();
Index.cshtml
@using Project.Helpers

@{
    ViewBag.Title = Html.T(""); 
}

<link rel="stylesheet" type="text/css" href="~/Content/Control/styles.css"/>

<div class="center-col page-content-js default-font">
    
    <div class="padding">
        
        <div class="s-row">
            <div class="" id="vm">
                
                <div class="b-filters row">
                    <div class="b-filters-left col-md-10">
                        <a data-bind="css:{'f-sel': filter() === '0'}, click:actions.filters.get.bind(null, {lgStatus: 0}, '0')" href="javascript:void(0)">@Html.T("C.SecOfficer.All")</a>
                        <a data-bind="css:{'f-sel': filter() === '2'}, click:actions.filters.get.bind(null, {lgStatus: 2}, '2')" href="javascript:void(0)">@Html.T("C.SecOfficer.UnderControl")</a>
                        <a data-bind="css:{'f-sel': filter() === '1'}, click:actions.filters.get.bind(null, {lgStatus: 1}, '1')" href="javascript:void(0)">@Html.T("C.SecOfficer.InArchive")</a>
                    </div>
                    <div class="b-filters-right col-md-2">
                        <button data-bind="disable:loadNewDisable, click:actions.list.loadNew" 
                           class="s-float_r btn purple filter-submit-btn">@Html.T("C.SecOfficer.Refresh")</button>
                    </div>
                </div>
        
                <div class="b-control-table">
                    <div data-bind="with: table">
                        <!-- BEGIN Portlet PORTLET-->
                        <div class="portlet light">
                            <div class="portlet-title s-mb_0i">
                              
                                <ul data-bind="visible: pages() > 1" class="pagination pagination-sm s-ml_10i">
                                    <li data-bind="css: leftPagerClass, click: prevPage">
                                        <a href="#"><i class="fa fa-angle-left"></i></a>
                                    </li>
                                    <li data-bind="visible:currentPage() > 1">
                                        <a href="#" data-bind="click:gotoPage(1)">
                                            <i class="fa fa-angle-double-left"></i>
                                        </a>
                                    </li>
                                    <li class="s-p_0i" data-bind="">
                                        <input class="paging-input" data-bind="textInput: currentPage" type="text"/>
                                    </li>
                                    <li data-bind="visible:currentPage() < pages()">
                                        <a href="#" data-bind="click:gotoPage(pages())">
                                            <i class="fa fa-angle-double-right"></i>
                                        </a>
                                    </li>
                                    <li data-bind="css: rightPagerClass, click: nextPage">
                                        <a href="#"><i class="fa fa-angle-right"></i></a>
                                    </li>
                                </ul>
                                <div class="s-float_r s-ta_r s-p_18_0">
                                    <div class="s-float_l s-mr_17">
                                        <input id="filter-input" class="form-control s-transparent w362 query-input" placeholder = @Html.T("C.SearchPage.AddSearchTerms") />
                                    </div>
                                    <button id="filter-submit" type="submit" class="s-float_r btn purple filter-submit-btn">
                                        <span style="margin-right: 3px;" class="spinner"><i class="fa fa-spin fa-refresh"></i></span>
                                        @Html.T("C.SearchPage.Search")
                                    </button>

                                </div>
                                <div class="actions">
                                </div>
                            </div>
                            <div class="portlet-body s-p_0i">
                                <div class="">
                                    <table class="table table-striped table-condensed table-hover table-bordered">
                                        <thead>
                                        <tr>
                                            <th style="width: 145px;" class="s-sortable" data-bind="click: toggleSort('Classification')">
                                                <div class="s-sort-element-wrapper">
                                                    @Html.T("C.SecOfficer.Classification")
                                                    <i class="s-sort-element" data-bind="css: sortClass('Classification')"></i>
                                                </div>
                                            </th>
                                            <th class="s-sortable s-fs_12i" data-bind="click: toggleSort('Name')">
                                                <div class="s-sort-element-wrapper">
                                                    @Html.T("C.SecOfficer.CompanyName")
                                                    <i class="s-sort-element" data-bind="css: sortClass('Name')"></i>
                                                </div>
                                            </th>
                                            <th class="s-sortable s-fs_12i" data-bind="click: toggleSort('Bank')">
                                                <div class="s-sort-element-wrapper">
                                                    @Html.T("C.SecOfficer.BankName")
                                                    <i class="s-sort-element" data-bind="css: sortClass('Bank')"></i>
                                                </div>
                                            </th>
                                            <th class="s-sortable s-fs_12i /*s-ta_c*/" data-bind="click: toggleSort('Inn')">
                                                <div class="s-sort-element-wrapper">
                                                    @Html.T("C.SecOfficer.Inn")
                                                    <i class="s-sort-element" data-bind="css: sortClass('Inn')"></i>
                                                </div>
        
                                            </th>
                                            <th class="s-sortable s-fs_12i" data-bind="click: toggleSort('Ogrn')">
                                                <div class="s-sort-element-wrapper">
                                                    @Html.T("C.SecOfficer.Ogrn")
                                                    <i class="s-sort-element" data-bind="css: sortClass('Ogrn')"></i>
                                                </div>
                                            </th>
                                            <th class="s-sortable s-fs_12i" data-bind="click: toggleSort('DateRegistration')">
                                                <div class="s-sort-element-wrapper">
                                                    @Html.T("C.SecOfficer.RegDate")
                                                    <i class="s-sort-element" data-bind="css: sortClass('DateRegistration')"></i>
                                                </div>
                                            </th>
                                            <th class="s-sortable s-fs_12i" data-bind="click: toggleSort('InfoSource')">
                                                <div class="s-sort-element-wrapper">
                                                    @Html.T("C.SecOfficer.InfoSource")
                                                    <i class="s-sort-element" data-bind="css: sortClass('InfoSource')"></i>
                                                </div>
                                            </th>
                                            <th style="display:none" class="s-sortable s-fs_12i" data-bind="click: toggleSort('FocusHref')">
                                                <div class="s-sort-element-wrapper">
                                                    @Html.T("C.SecOfficer.URLSource")
                                                    <i class="s-sort-element" data-bind="css: sortClass('FocusHref')"></i>
                                                </div>
                                            </th>
                                            <th style="width: 300px;" class="s-sortable s-fs_12i"></th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr class="s-display_n" data-bind="visible: showNoData">
                                            <td colspan="8" class="s-ta_c">
                                                @Html.T("C.SecOfficer.NoData")
                                            </td>
                                        </tr>
                                        <tr data-bind="visible: showLoading">
                                            <td colspan="8" class="s-ta_c">
                                                <i data-bind="css: {'icon-spin': showLoading}" class="fa fa-spin font-blue fa-circle-o-notch s-fix-loader"></i>
                                                @Html.T("C.SecOfficer.Loading")
                                            </td>
                                        </tr>
                                        <!-- ko foreach: {data: pagedRows, as: '$row'} -->
                                        <tr data-bind="click:$root.getDetails">
                                            <td class="s-ta_c">
                                                <!-- ko if: $row.Classification() === 0 -->
                                                <div class="b-classification green"></div>
                                                <!-- /ko -->
        
                                                <!-- ko if: $row.Classification() === 1 -->
                                                <div class="b-classification yellow"></div>
                                                <!-- /ko -->
        
                                                <!-- ko if: $row.Classification() === 2 -->
                                                <div class="b-classification red"></div>
                                                <!-- /ko -->
                                            </td>
                                            <td data-bind="">
                                                <a data-bind="text: $row.Name, click:$root.actions.getDetails" 
                                                   href="javascript:void(0)"></a>
                                            </td>
                                            <td data-bind="text: $row.Bank"></td>
                                            <td data-bind="text: $row.Inn"></td>
                                            <td data-bind="text: $row.Ogrn"></td>
                                            <td data-bind="text: $row.DateRegistration"></td>
                                            <td data-bind="text: $row.InfoSource"></td>
                                            <td style="display:none">
                                                <a data-bind="attr:{'href':$row.FocusHref}" href="/" target="_blank">
                                                    <!-- ko text: "Ссылка" --><!-- /ko -->
                                                </a>
        
                                            </td>
        
        
                                            <td class="s-ta_c" data-bind="">
                                                <!-- ko ifnot:$root.filter() === '0' -->
                                                <a data-bind="click:$root.actions.list.toActive"
                                                   href="javascript:void(0)" class="btn-success btn-sm">@Html.T("C.SecOfficer.Active")</a>
                                                <!-- /ko -->

                                                <!-- ko ifnot:$root.filter() === '1' -->
                                                <a data-bind="click:$root.actions.list.toArchive"
                                                   href="javascript:void(0)" class="btn-primary btn-sm">@Html.T("C.SecOfficer.ToArchive")</a>
                                                <!-- /ko -->
                                                
                                                <!-- ko ifnot:$root.filter() === '2' -->
                                                <a data-bind="click:$root.actions.list.toControl"
                                                   href="javascript:void(0)" class="btn-danger btn-sm s-red">@Html.T("C.SecOfficer.Control")</a>
                                                <!-- /ko -->
                                            </td>
                                        </tr>
                                        <!-- /ko -->
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                            <div class="clear">
                            </div>
                        </div>
                        <!-- END Portlet PORTLET-->
                    </div>
                </div>
        
        
                <!-- global -->
                <div class="modal fade" id="detail" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                    <div class="modal-dialog modal-lg">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
                                <h4 class="modal-title">@Html.T("C.SecOfficer.CompanyDetails")</h4>
                            </div>
                            <div class="modal-body">
                                <div class="s-mb_9">
                                    <strong>@Html.T("C.SecOfficer.Company"):</strong>
                                    <span data-bind="text:$root.details.Name"></span>
                                </div>
                                
                                <div class="s-mb_9">
                                    <strong>@Html.T("C.SecOfficer.RegDate"):</strong>
                                    <span data-bind="text:$root.details.DateRegistration"></span>
                                </div>
                                
                                <div class="s-mb_9">
                                    <strong>@Html.T("C.SecOfficer.Inn"):</strong>
                                    <span data-bind="text:$root.details.Inn"></span>
                                </div>
                                
                                <div class="s-mb_9">
                                    <strong>@Html.T("C.SecOfficer.Ogrn"):</strong>
                                    <span data-bind="text:$root.details.Ogrn"></span>
                                </div>
                                
                                <div class="s-mb_9">
                                    <strong>@Html.T("C.SecOfficer.Status"):</strong>
                                    <span data-bind="text:$root.details.WorkingStatus"></span>
                                </div>
                                
                                <div class="s-mb_9">
                                    <strong>@Html.T("C.SecOfficer.Address"):</strong>
                                    <span data-bind="text:$root.details.JurAddress"></span>
                                </div>
                                
                                <div class="s-mb_9">
                                    <strong>@Html.T("C.SecOfficer.Position"):</strong>
                                    <span>@Html.T("C.SecOfficer.Director")</span>
                                </div>
                                
                                <div class="s-mb_9">
                                    <strong>@Html.T("C.SecOfficer.Name")</strong>
                                    <span data-bind="text:$root.details.Fio"></span>
                                </div>
                                
                                <div class="s-mb_9">
                                    <strong>@Html.T("C.SecOfficer.OkvedBase"):</strong>
                                    <span data-bind="text:$root.details.Okved"></span>
                                </div>
                                
                                <div class="s-mb_9">
                                    <strong>@Html.T("C.SecOfficer.InnMessages"):</strong>
                                    <a href="/" target="_blank" data-bind="attr:{'href':('/Blacklist/Search/ViewEntityPosts?enName='+ $root.details.Inn() +'&entType=8')}, text:$root.details.Inn"></a>
                                </div>
                                
                                <div class="s-mb_9">
                                    <strong>@Html.T("C.SecOfficer.OgrnMessages"):</strong>
                                    <a href="/" target="_blank" data-bind="attr:{'href':('/Blacklist/Search/ViewEntityPosts?enName='+ $root.details.Ogrn() +'&entType=9')}, text:$root.details.Ogrn"></a>
                                </div>
                                
                                <div class="s-mb_9">
                                    <strong>@Html.T("C.SecOfficer.Info"):</strong>
                                    <span></span>
                                </div>

                            </div>
    
                        </div>
                        <!-- /.modal-content -->
                    </div>
                    <!-- /.modal-dialog -->
                </div>
                <!-- global -->
        
            </div>
        </div>
    </div>
</div>

@section Scripts{
    @Scripts.Render("~/Scripts/knockout/knockout-3.4.2.js")
    @Scripts.Render("~/Scripts/moment.js")
    @Scripts.Render("~/Scripts/knockout/data-table.js")
    @Scripts.Render("~/Scripts/Control/index.js")
    @Scripts.Render("~/Scripts/Control/word-highlighter.js")
}

razor Popup Duyuru MVC

Popup Duyuru MVC

Popup_Duyuru_MVC.cshtml
@RenderSection("popup", required: false)
@section Popup {
<!-- Popup overlay -->
@if (ViewBag.duyuru != null)
{
    Duyuru duyuru = ViewBag.duyuru;

    <div id="global_overlay">
        <div class="popup">
            @MvcHtmlString.Create(duyuru.Detay)
            <div class="close"></div>
        </div>
    </div>

}
}

razor Mvc验证消息

Mvc验证消息

Mvc_Validate_Message.cshtml
ModelState.AddModelError("loginValide", "<label class='alert alert-danger'>Kullanıcı adı veya şifre yanlıştır.</label>");
return View(model);

@Html.Raw(HttpUtility.HtmlDecode(Html.ValidationMessage("loginValide").ToHtmlString()))

@Html.TextBoxFor(m => m.Email, new { @class = "form-control" , @required = "required" })
@Html.ValidationMessageFor(m=>m.Email, "", new { @class = "text-danger" })

razor 从节点列表中解析主页面列表 - 通过检查顶层p中的其他节点来查找节点的最本地版本

从节点列表中解析主页面列表 - 通过检查顶级父文件夹中具有相同SynchronisationSourceMasterContentID的其他节点来查找节点的最本地版本。注意:确保通过勾选项目设置>项目>元数据中的框来输出SynchronisationSourceMasterContentID。然后强制这个实际输出你需要创建一个新页面并批准它等。它应该最终打球:)

ResolvingSynchronisedNodes.cshtml
@functions {

  public ContentNode ResolveSynchedLink(ContentNode link)
  {
     
     // if this a synched link then change path to the most local synched version 
      if (link.Data.SynchronisationSourceMasterContentID >= 0)
      {
          int masterPageContentID = link.Data.SynchronisationSourceMasterContentID;
          
          // get all nodes in current nodes parent node where masterPageContentID = masterPageContentID
          foreach (ContentNode navItem in CurrentNode.Parent.AncestorAtDepth(1).Descendants().Where(wP => wP.IsWebPage && wP.Data.SynchronisationSourceMasterContentID == masterPageContentID).OrderBy(wP => wP.MenuOrder))
          {
              return navItem;
          }
      }


     return link;
  }

}

razor 一个模仿我们的本地视图菜单控件的功能的剃刀视图,但输出语义标记和类,允许更容易和

模仿我们的本地视图菜单控件的功能的剃刀视图,但输出语义标记和类,允许更容易和更灵活的样式

LocalViewMenuC#.cshtml
@using Contensis.Framework.Web
@using Contensis.Framework.Web.Search

<ul class="sys_menu">
@{
    AppContext.Current.Page.Scripts.RegisterJQuery();
	if(CurrentNode != null) {
      //This will be replaced by a function in future releases
      var currentFolder = CurrentNode.Parent;
      var currentDepth = CurrentNode.Parent.Depth;
  
      var test = CurrentNode.Data.MD_Description;
      for(int i=1; i<currentDepth; i++){
          var currentAncestor = CurrentNode.Parent.AncestorAtDepth(i);
          foreach (var aPage in currentAncestor.Children<ContentNode>().Where(aP => aP.IsHomePage == true && aP.IncludeInMenu == true && aP.IsWebPage == true ).OrderBy(aP => aP.MenuOrder)){
              <li><a href="@aPage.Path" title="@aPage.Title">@aPage.Parent.MenuName</a></li>
          }
      }
  
      foreach (var page in currentFolder.Children<ContentNode>().Where(p => p.IsHomePage == true && p.IncludeInMenu == true && p.IsWebPage == true && p.Depth <= CurrentNode.Depth)){
          if(CurrentNode.Depth == page.Depth) {
              <li class="sys_current-folder"><a href="@page.Path" title="@page.Title">@page.Parent.MenuName</a>
              <ul class="sys_sub-menu">
              @foreach (var subPage in CurrentNode.Parent.Children<ContentNode>().Where(sP => sP.IsHomePage == false && sP.IncludeInMenu == true && sP.IsWebPage == true).OrderBy(sP => sP.MenuOrder)) {
                  //If the currnet node matches the current node in the loop add current page class
                  //Otherwise, output link as normal
                  if(subPage.ID == CurrentNode.ID) {
                      <li class="sys_selected"><a href="@subPage.Path" title="@subPage.Title">@subPage.MenuName</a></li> 
                      }else {
                          <li><a href="@subPage.Path" title="@subPage.Title">@subPage.MenuName</a></li> 
                      }
                  }
              </ul>
              </li>
          }
		}
	}else {
    	<h1>CurrentNode is Null</h1>
	}
}

</ul>

razor A-Z列表(c#) - 需要一些工作,但基础知识在那里

A-Z列表(c#) - 需要一些工作,但基础知识在那里

a-z.cshtml
@using Contensis.Framework.Web
@using Contensis.Framework.Web.Search

@{
    var jobItemsQuery = Query.Where("SC_T_ID").IsEqualTo("-2356380").OrderBy("Property_Title").Ascending; /* Template and ordering */
    var jobItems = new NodeFinder().Find(jobItemsQuery);
    var utils = new CMS_API.Common.BaseUtilities();
    string alphabet = "abcdefghijklmnopqrstuvwxyz"; /* alphabet! - there are better ways to do this, however it seems overcomplicated and this is just simple. */
    string letter = Request.QueryString["letter"]; 
   
    if (String.IsNullOrEmpty(letter)) 
    {
        letter = "A";
    }
}

<div class="sys_AtoZIndex">
    @foreach(char c in alphabet.ToUpper())
    {
       
       var test = from i in jobItems where i.Data.Title.ToString().StartsWith(c.ToString()) select i;
       if (test.Count() > 0)
       {
            <a href="/careers/careers-home.aspx?letter=@c">@c</a>
       }
       else
       {
           <span class="sys_AtoZEmpty">@c</span>
       }
    }
</div>

    
<div class="sys_AtoZTable">

    <div class="sys_AtoZTableHeader">
        <div class="sys_AtoZCell">
            Job
        </div>
        <div class="sys_AtoZCell sys_industryAZ">
            Industry
        </div>
        <div class="sys_AtoZCell">
            Sector
        </div>
    </div>
    
    
    @foreach(var jobItem in jobItems) 

    {
            string titles = jobItem.Data.Title.ToString();
            if (titles.StartsWith(letter.ToUpper()))
        {
        
            var sectorFolderQuery = Query.Where("Property_TopFolderId").IsEqualTo("165948").And("SC_T_ID").IsEqualTo("-2002576").And("Property_Title").StartsWith(jobItem.Data.CareerIndustries.ToString().ToLower().Substring(0,5));
            var sectorFolders = new NodeFinder().Find(sectorFolderQuery);
            var sectorFolder = sectorFolders[0];
            
            <div class="sys_AtoZTableRow">
                <div class="sys_AtoZCell">
                    @jobItem.Data.Title 
                </div>
                <div class="sys_AtoZCell sys_industryAZ">
                    <a href="@sectorFolder.Parent.Path">@if (jobItem.Data.CareerIndustries.length>-1){ @jobItem.Data.CareerIndustries }</a> 
                </div>
                <div class="sys_AtoZCell">
                    <a href="@sectorFolder.Parent.Parent.Path">@sectorFolder.Parent.Parent.MenuName</a>
                </div>
            </div>
        
        } else { 
            
        }
    }

</div>

razor 活动日历旋转木马为未来12个月的活动 - 二手carouFredSel.js

活动日历旋转木马为未来12个月的活动 - 二手carouFredSel.js

slider-init.js
    // This initiates the carousel(s)
    
    $(".sys_forwardLkMonth.January").carouFredSel({width: "186px",height: "192px",circular: false,infinite: false,items: {minimum: 1,width: 186,height: 192},align: "left",scroll: "linear",auto: false,prev: ".sys_back.January",next: ".sys_forth.January",anchorBuilder   : false, filter : ".sys_forward-event"});
    $(".sys_forwardLkMonth.February").carouFredSel({width: "186px",height: "192px",circular: false,infinite: false,items: {minimum: 1,width: 186,height: 192},align: "left",scroll: "linear",auto: false,prev: ".sys_back.February ",next: ".sys_forth.February",anchorBuilder   : false, filter : ".sys_forward-event"});
    $(".sys_forwardLkMonth.March").carouFredSel({width: "186px",height: "192px",circular: false,infinite: false,items: {minimum: 1,width: 186,height: 192},align: "left",scroll: "linear",auto: false,prev: ".sys_back.March ",next: ".sys_forth.March",anchorBuilder   : false, filter : ".sys_forward-event"});
    $(".sys_forwardLkMonth.April").carouFredSel({width: "186px",height: "192px",circular: false,infinite: false,items: {minimum: 1,width: 186,height: 192},align: "left",scroll: "linear",auto: false,prev: ".sys_back.April ",next: ".sys_forth.April",anchorBuilder   : false, filter : ".sys_forward-event"});
    $(".sys_forwardLkMonth.May").carouFredSel({width: "186px",height: "192px",circular: false,infinite: false,items: {minimum: 1,width: 186,height: 192},align: "left",scroll: "linear",auto: false,prev: ".sys_back.May ",next: ".sys_forth.May",anchorBuilder   : false, filter : ".sys_forward-event"});
    $(".sys_forwardLkMonth.June").carouFredSel({width: "186px",height: "192px",circular: false,infinite: false,items: {minimum: 1,width: 186,height: 192},align: "left",scroll: "linear",auto: false,prev: ".sys_back.June ",next: ".sys_forth.June",anchorBuilder   : false, filter : ".sys_forward-event"});
    $(".sys_forwardLkMonth.July").carouFredSel({width: "186px",height: "192px",circular: false,infinite: false,items: {minimum: 1,width: 186,height: 192},align: "left",scroll: "linear",auto: false,prev: ".sys_back.July ",next: ".sys_forth.July",anchorBuilder   : false, filter : ".sys_forward-event"});
    $(".sys_forwardLkMonth.August").carouFredSel({width: "186px",height: "192px",circular: false,infinite: false,items: {minimum: 1,width: 186,height: 192},align: "left",scroll: "linear",auto: false,prev: ".sys_back.August ",next: ".sys_forth.August",anchorBuilder   : false, filter : ".sys_forward-event"});
    $(".sys_forwardLkMonth.September").carouFredSel({width: "186px",height: "192px",circular: false,infinite: false,items: {minimum: 1,width: 186,height: 192},align: "left",scroll: "linear",auto: false,prev: ".sys_back.September ",next: ".sys_forth.September",anchorBuilder   : false, filter : ".sys_forward-event"});
    $(".sys_forwardLkMonth.October").carouFredSel({width: "186px",height: "192px",circular: false,infinite: false,items: {minimum: 1,width: 186,height: 192},align: "left",scroll: "linear",auto: false,prev: ".sys_back.October ",next: ".sys_forth.October",anchorBuilder   : false, filter : ".sys_forward-event"});
    $(".sys_forwardLkMonth.November").carouFredSel({width: "186px",height: "192px",circular: false,infinite: false,items: {minimum: 1,width: 186,height: 192},align: "left",scroll: "linear",auto: false,prev: ".sys_back.November ",next: ".sys_forth.November",anchorBuilder   : false, filter : ".sys_forward-event"});
    $(".sys_forwardLkMonth.December").carouFredSel({width: "186px",height: "192px",circular: false,infinite: false,items: {minimum: 1,width: 186,height: 192},align: "left",scroll: "linear",auto: false,prev: ".sys_back.December ",next: ".sys_forth.December",anchorBuilder   : false, filter : ".sys_forward-event"});
    
    
    // This links the tab links to the container elements for that particular month
    $("li a.caroufredsel").each(function(n) {
        $(this).attr("href", "#item"+n);
    });
    
    $(".sys_forwardLkMonth").each(function(n) {
        $(this).attr("id", "item"+n);
    });
    
    // Tabbed months.
    
    $("div.sys_forwardLkMonth").hide()
    $('div.sys_forwardLkMonth:first').show().addClass('sys_active');
    $('div.sys_forwardLkMonth:first').parent().parent().show();
    $('#dateList li:first-child a').addClass('sys_selected');
    
        // This adds and removes classes where needed
    $('#dateList li a').click(function(){
        $('#dateList li a').removeClass('sys_selected');
        $(this).addClass('sys_selected');
        var currentTab = $(this).attr('href');
        $('div.sys_forwardLkMonth').hide().removeClass('active');
        $('div.sys_forwardLkMonth').parent().parent().hide();
        $(currentTab).show().addClass('sys_active');
        $(currentTab).parent().parent().show();
        return false;
    });
 
EventsCalandarCarousel.cshtml
@using Contensis.Framework.Web
@using Contensis.Framework.Web.Search

@{
    /* We'll start by getting the current month */
    var currentMonth = DateTime.Now.ToString("MMM");
    
    /* Now, we'll get the template by ID for the events records */
    var eventsQuery = Query.Where("SC_T_ID").IsEqualTo("-212");
    var eventItems = new NodeFinder().Find(eventsQuery);
    var currentDate = DateTime.Today;
    var thisMonth = DateTime.Now.ToString("MMM");
}

<div class="sys_forwardlook sys_clearfix">
    <a class=" sys_btn sys_btnsmall sys_btnorange" href="/Whats-Happening/event-listings.aspx"> See full calendar </a>
    <h2>Forward look </h2>
    <div class="sys_forward-months">
        <ul id="dateList">
        
        
        @{<!-- Loops through the months and drops them -->
                DateTime now = DateTime.Now;
            
                for (int i = 0; i < 12; i++)
                {
                    <li id="@now.ToString("MMMM")"><a href="#" class="caroufredsel">@now.ToString("MMM")</a></li>
                  now = now.AddMonths(1);
            	}
        }
        
        </ul>
    </div>   
    
       <div  id="fwdLk">
            <!-- Gets the events, groups them by month and places them into the appropriate container elements -->
    @{
            DateTime theNow = DateTime.Now;
        
            for (int i = 0; i < 12; i++)
            {
               
                var currentEvents = eventItems.Where(eA => eA.Data.StartDate.Month == theNow.Month && eA.Data.enddate >= theNow && eA.Data.StartDate <= theNow.AddMonths(12)).OrderBy(eA => eA.Data.StartDate);
                   
                var theMonth = theNow.ToString("MMMM");
                <div class="sys_slideInnerWrap">
                
                    <div class="sys_back @theMonth">
                        @if(currentEvents.Count() >= 4) {
                            <a href="#"><img src="/SiteElements/img/arrowleftwhitelarge.png" width="24" height="24"  alt=""/></a>
                        }
                    </div>
              
                 @if(currentEvents.Count() == 0) {
                    <div class="sys_forwardLkMonth @theMonth"><h5 class="sys_forward-event-title sys_forward-event-title-noresults">Sorry, there are no events in @theMonth</h5></div>
                 }
                 else {
                <div class="sys_forwardLkMonth @theMonth">
                    
                 @foreach(var eventItem in currentEvents) 
                 {
                    var eventDate = eventItem.Data.StartDate.ToString("ddd d MMMM, yyyy ");
                    var eventMonth = eventItem.Data.StartDate.ToString("MMMM");
                 
                                <div class="sys_forward-event">
                                    <p class="sys_forward-event-date">@eventDate</p>
                                    <h5 class="sys_forward-event-title"><a href="@eventItem.Path" title="@eventItem.Title">@eventItem.Title</a></h5>
                                    <p>@eventItem.Data.Description</p>
                                </div>

                 }
                    
                  </div>
                  }
               
                    <div class="sys_forth @theMonth">
                        @if(currentEvents.Count() >= 4) {
                            <a href="#"><img src="/SiteElements/img/arrowrightwhitelarge.png" width="24" height="24"  alt=""/></a>
                        }
                   </div>       
              
                
               </div>
               
                theNow = theNow.AddMonths(1);
                
        	}
        }
        </div>

    
</div>

<script src="/SiteElements/js/forwardLookSlider.js"></script>

razor 链接到当前顶级文件夹下的列表模板的新闻类别列表。

链接到当前顶级文件夹下的列表模板的新闻类别列表。

NewsCatList.cshtml
@using Contensis.Framework.Web
@using Contensis.Framework.Web.Search
 
@{
    // This could use the GetByKey() method instead.
    var node = CurrentContext.Taxonomy.GetByPath("StructuredContent/newscategories/", TaxonomySortOrder.Alphabetical);
    
    var listingPath = "";
    
    string topFolderId = CurrentNode.Data.Property_TopFolderId.ToString();
    var query = Query.Where("Property_TopFolderId").IsEqualTo(topFolderId).And("SC_T_ID").IsEqualTo("-154");
    var sectionNewsNode = new NodeFinder().Find(query);
    
    if(sectionNewsNode.Count > 0) {
        listingPath = sectionNewsNode[0].Path;
    }else{
        listingPath = "/test/news/news-listings.aspx";
    }
   
}



 
<ul class="sys_simpleListMenu">
@foreach (var childNode in node.Children)
    {
        <li><a href="@listingPath?TaxonomyKey=@childNode.Key">@childNode.Value</a></li>
    }
</ul>

razor 使用超链接内容类型文件夹设置的顶级菜单剃刀。允许某些用户组进行受限编辑。还有数据attr

使用超链接内容类型文件夹设置的顶级菜单剃刀。允许某些用户组进行受限编辑。还具有目标节点ID的数据属性,用于ajax mega菜单。

TopMenuFromFolder.cshtml
@using Contensis.Framework.Web;
@using Contensis.Framework.Web.Search


<ul id="menu" class="sys_navbar">
    <li class="sys_topnav"><a class="sys_home" href="/" title="Home"><img src="/SiteElements/img/homeicon.png" width="23" height="48" alt="Home" /></a></li>
    @{
        var query = Query.Where("Property_F_ID").IsEqualTo("48"); // Add ID of folder to target here
        var pages = new NodeFinder().Find(query);
        var linkClass = "";
        
        FolderNode topFolder = null;
        if(CurrentNode.Parent.Depth > 1) {
            topFolder = CurrentNode.Parent.AncestorAtDepth(1);
        }else{
            topFolder = CurrentNode.Parent;
        }
        
        foreach(var node in pages.Where(np => np.IncludeInMenu && np.Path.Length > 1).OrderBy(p => p.MenuOrder))
        {
        
            ContentNode MenuItemNode = null;
            MenuItemNode = (ContentNode)new NodeFactory().Load(@node.Path);
        
            //Get the folder node for the current page in the loop
            FolderNode pageTopFolder = null;   
            if(MenuItemNode.Parent.Depth > 1) {
                pageTopFolder = MenuItemNode.Parent.AncestorAtDepth(1);
            }else{
                 pageTopFolder = MenuItemNode.Parent;
            }
            
            if(pageTopFolder.ID == topFolder.ID) {
                linkClass = "sys_nav-item" + " sys_selected";
            }else{
                linkClass = "sys_nav-item";
            }
         
             
        
            if(node is ContentNode)
            {
                ContentNode content = (ContentNode)node;        
               
      
            
                    if(node.Data.MD_NoDropdown == false && node.Data.MD_Portals == false)
                    {
                        <li class="sys_topnav sys_topnavDropdown"><a href="@node.Path" class="@linkClass" data-ajax-menu-path="/SiteElements/Menu/ajaxMenu.aspx?folder=@MenuItemNode.Parent.ID">@node.Title</a>
                            <div class="sys_dropdown">
                            </div>
                        </li>
                    }
                    else if(node.Data.MD_Portals == true && node.Data.MD_NoDropdown == false)
                    {
                        <li class="sys_topnav sys_topnavDropdownPortals"><a href="@node.Path" class="@linkClass" data-ajax-menu-path="@node.Path">@node.Title</a>
                            <div class="sys_dropdown">
                            </div>
                        </li>
                    }
                    else {
                        <li class="sys_topnav"><a href="@node.Path" class="@linkClass" data-ajax-menu-path="/SiteElements/Menu/ajaxMenu.aspx?folder=@MenuItemNode.Parent.ID">@node.Title</a></li>
                    }
                    
             
            
            
            }
        }
    }
    
    

</ul>

razor 具有多个类别的事件列表项模板

具有多个类别的事件列表项模板

EventsListItemTemplate.cshtml
<h2 class="sys_subitem-heading sys_events-subheading"><a href="@CurrentNode.Path">@CurrentNode.Title</a></h2>
            
            <div class="sys_subitem-summary sys_events-summary">
                @if(CurrentNode.Data.Property_TaxonomyCategories.ToString() != ""){
                    string[] eventCategoriesTax = CurrentNode.Data.Property_TaxonomyCategories.ToString().Split(',');
                    string lastCategory = eventCategoriesTax[eventCategoriesTax.Length - 1];
                    string eventCategoriesString = "";
                    
                    foreach (string eventCategory in eventCategoriesTax) {
                        if(eventCategory.Contains("0/4/11/12")) {
                            var currentTaxNode = CurrentContext.Taxonomy.GetByKey(eventCategory.Replace(",",""));
                            if(currentTaxNode != null) {
                                var eventCategoryUrl = "?TaxonomyKey=" + currentTaxNode.Key;
                                if (eventCategory.Contains(lastCategory)) {
                                    eventCategoriesString += "<a href=\""+ @eventCategoryUrl +"\">" + currentTaxNode.Value + "</a>";
                                }else{
                                    eventCategoriesString += "<a href=\""+ @eventCategoryUrl +"\">" + currentTaxNode.Value + "</a>, ";
                                }
                            }
                        }
                    }                   
                    <div class="sys_events-category">@Html.Raw(eventCategoriesString)</div>
                }
            
                <dl>
          		<dt class="sys_events-time">Date</dt>
                    <dd class="sys_events-time">@CurrentNode.Data.StartDate.ToString("d/M/yyyy")</dd>
                    <dt class="sys_events-time">Time</dt>
                    <dd class="sys_events-time">@CurrentNode.Data.StartDate.ToString("HH:MM") - @CurrentNode.Data.EndDate.ToString("HH:MM")</dd>
                    @if(CurrentNode.Data.Location.ToString() != ""){
                        <dt class="sys_events-location">Location: </dt>
                        <dd class="sys_events-location">@CurrentNode.Data.Location</dd>          
                    }
                </dl>
            </div>