$(function () { var dataBinder = new DataEntity({ Title: "#sysName", Footer: "#sysFoot" }); $('button[data-method]').on('click', function (e) { var $this = $(this); var data = {}; switch ($this.attr('data-method')) { case 'footer': data = dataBinder.get(); $.bc({ url: Settings.url, data: { name: '网站页脚', code: data.Footer, category: '网站设置' }, title: '保存网站页脚', method: "post", callback: function (result) { if (result) $('#websiteFooter').text(data.Footer); } }); break; case 'title': data = dataBinder.get(); $.bc({ url: Settings.url, data: { name: '网站标题', code: data.Title, category: '网站设置' }, title: '保存网站标题', method: "post", callback: function (result) { if (result) $('#websiteTitle').text(data.Title); } }); break; case 'css': var cssDefine = $css.val(); $.bc({ url: Settings.url, data: { name: '使用样式', code: cssDefine, category: '当前样式' }, title: '保存网站样式', method: "post", callback: function (result) { if (result) { window.setTimeout(function () { window.location.reload(true); }, 1000); } } }); break; } }); var $sortable = $('#sortable'); var $refresh = $('a[data-method="refresh"]'); var listCacheUrl = function (options) { $refresh.addClass('fa-spin'); options = $.extend({ clear: false }, options); $sortable.html(''); $.bc({ url: Settings.url, autoFooter: true, callback: function (urls) { if (urls && $.isArray(urls)) { $.each(urls, function (index, item) { if (options.clear) options.url = item.Url + "?cacheKey=*"; else options.url = item.Url; $.bc({ url: options.url, cors: !item.Self, autoFooter: true, callback: function (result) { if ($.isArray(result)) { var html = '
{2}{0}{3}
{6}
'; var content = result.sort(function (x, y) { return x.Key > y.Key ? 1 : -1; }).map(function (ele) { return $.format(html, ele.Interval / 1000, ele.Key, ele.Desc, ele.Value, $.format(item.Url, ele.Key), item.Self, ele.ElapsedSeconds); }).join(''); var cache = $('
'); cache.append($.format('
{0}
', item.Desc)); cache.append(content); $sortable.append(cache); $sortable.find('[data-toggle="tooltip"]').tooltip(); } } }); }); } $refresh.removeClass('fa-spin'); } }); }; $('a[data-method]').on('click', function (e) { e.preventDefault(); e.stopPropagation(); var $this = $(this).tooltip('hide'); var options = {}; switch ($this.attr('data-method')) { case 'clear': options.clear = true; break; case 'refresh': break; } listCacheUrl(options); }).last().trigger('click'); $sortable.on('click', '.btn', function () { var $this = $(this).tooltip('dispose'); $.bc({ url: $this.attr('data-url'), cors: $this.attr('data-self') === 'false' }); listCacheUrl(); }); var $css = $('#dictCssDefine').dropdown('val'); });