mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-06 05:50:11 +02:00
refactor: cleanup
remove test page, remove dupe functions in utils.common
This commit is contained in:
@@ -22,7 +22,7 @@ define('admin/appearance/customise', ['admin/settings', 'ace/ace'], function (Se
|
||||
};
|
||||
|
||||
function initACE(aceElementId, mode, holder) {
|
||||
var editorEl = ace.edit(aceElementId, {
|
||||
const editorEl = ace.edit(aceElementId, {
|
||||
mode: 'ace/mode/' + mode,
|
||||
theme: 'ace/theme/twilight',
|
||||
maxLines: 30,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const hooks = require('./modules/hooks');
|
||||
const hooks = require('hooks');
|
||||
const { render } = require('./widgets');
|
||||
|
||||
window.ajaxify = window.ajaxify || {};
|
||||
@@ -326,6 +326,7 @@ ajaxify.widgets = { render: render };
|
||||
|
||||
ajaxify.loadScript = function (tpl_url, callback) {
|
||||
let location = !app.inAdmin ? 'forum/' : '';
|
||||
|
||||
if (tpl_url.startsWith('admin')) {
|
||||
location = '';
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ app.currentRoom = null;
|
||||
app.widgets = {};
|
||||
app.flags = {};
|
||||
|
||||
|
||||
(function () {
|
||||
let appLoaded = false;
|
||||
const isTouchDevice = utils.isTouchDevice();
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
import 'jquery-ui/ui/widgets/datepicker';
|
||||
import Sortable from 'sortablejs';
|
||||
import semver from 'semver';
|
||||
import * as autocomplete from 'autocomplete';
|
||||
// we are using browser colorpicker
|
||||
// import { enable as colorpickerEnable } from '../admin/modules/colorpicker';
|
||||
import * as api from 'api';
|
||||
import * as alerts from 'alerts';
|
||||
|
||||
export function init() {
|
||||
console.log('should be true semver.gt("1.1.1", "1.0.0")', semver.gt('1.1.1', '1.0.0'));
|
||||
$('#change-skin').val(config.bootswatchSkin);
|
||||
|
||||
$('#inputTags').tagsinput({
|
||||
confirmKeys: [13, 44],
|
||||
trimValue: true,
|
||||
});
|
||||
|
||||
$('#inputBirthday').datepicker({
|
||||
changeMonth: true,
|
||||
changeYear: true,
|
||||
yearRange: '1900:-5y',
|
||||
defaultDate: '-13y',
|
||||
});
|
||||
|
||||
$('#change-language').on('click', function () {
|
||||
config.userLang = 'tr';
|
||||
var languageCode = utils.userLangToTimeagoCode(config.userLang);
|
||||
import(/* webpackChunkName: "timeago/[request]" */ 'timeago/locales/jquery.timeago.' + languageCode).then(function () {
|
||||
overrides.overrideTimeago();
|
||||
ajaxify.refresh();
|
||||
});
|
||||
});
|
||||
|
||||
// colorpickerEnable($('#colorpicker'));
|
||||
|
||||
autocomplete.user($('#autocomplete'));
|
||||
|
||||
Sortable.create($('#sortable-list')[0], {});
|
||||
|
||||
var data = $('#form-serialize').serializeObject();
|
||||
$('#json-form-data').text(JSON.stringify(data, null, 2));
|
||||
|
||||
$('#form-deserialize').deserialize({
|
||||
foo: [1, 2],
|
||||
moo: 'it works',
|
||||
});
|
||||
|
||||
$('#change-skin').change(async function () {
|
||||
var newSkin = $(this).val();
|
||||
api.put(`/users/${app.user.uid}/settings`, {
|
||||
settings: {
|
||||
postsPerPage: 20,
|
||||
topicsPerPage: 20,
|
||||
bootswatchSkin: newSkin,
|
||||
}
|
||||
}).then((newSettings) => {
|
||||
config.bootswatchSkin = newSkin;
|
||||
reskin(newSkin);
|
||||
}).catch(alerts.error);
|
||||
});
|
||||
|
||||
// copied from account/settings
|
||||
async function reskin(skinName) {
|
||||
const clientEl = Array.prototype.filter.call(document.querySelectorAll('link[rel="stylesheet"]'), function (el) {
|
||||
return el.href.indexOf(config.relative_path + '/assets/client') !== -1;
|
||||
})[0] || null;
|
||||
if (!clientEl) {
|
||||
return;
|
||||
}
|
||||
|
||||
const currentSkinClassName = $('body').attr('class').split(/\s+/).filter(function (className) {
|
||||
return className.startsWith('skin-');
|
||||
});
|
||||
if (!currentSkinClassName[0]) {
|
||||
return;
|
||||
}
|
||||
let currentSkin = currentSkinClassName[0].slice(5);
|
||||
currentSkin = currentSkin !== 'noskin' ? currentSkin : '';
|
||||
|
||||
// Stop execution if skin didn't change
|
||||
if (skinName === currentSkin) {
|
||||
return;
|
||||
}
|
||||
|
||||
const linkEl = document.createElement('link');
|
||||
linkEl.rel = 'stylesheet';
|
||||
linkEl.type = 'text/css';
|
||||
linkEl.href = config.relative_path + '/assets/client' + (skinName ? '-' + skinName : '') + '.css';
|
||||
linkEl.onload = function () {
|
||||
clientEl.parentNode.removeChild(clientEl);
|
||||
|
||||
// Update body class with proper skin name
|
||||
$('body').removeClass(currentSkinClassName.join(' '));
|
||||
$('body').addClass('skin-' + (skinName || 'noskin'));
|
||||
};
|
||||
|
||||
document.head.appendChild(linkEl);
|
||||
}
|
||||
}
|
||||
|
||||
const testPage = { init };
|
||||
export default testPage;
|
||||
@@ -448,14 +448,6 @@ const utils = {
|
||||
return !utils.isAbsoluteUrl(url);
|
||||
},
|
||||
|
||||
makeNumbersHumanReadable: function (elements) {
|
||||
elements.each(function () {
|
||||
$(this)
|
||||
.html(utils.makeNumberHumanReadable($(this).attr('title')))
|
||||
.removeClass('hidden');
|
||||
});
|
||||
},
|
||||
|
||||
makeNumberHumanReadable: function (num) {
|
||||
const n = parseInt(num, 10);
|
||||
if (!n) {
|
||||
@@ -469,14 +461,6 @@ const utils = {
|
||||
return n;
|
||||
},
|
||||
|
||||
addCommasToNumbers: function (elements) {
|
||||
elements.each(function (index, element) {
|
||||
$(element)
|
||||
.html(utils.addCommas($(element).html()))
|
||||
.removeClass('hidden');
|
||||
});
|
||||
},
|
||||
|
||||
// takes a string like 1000 and returns 1,000
|
||||
addCommas: function (text) {
|
||||
return String(text).replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,');
|
||||
|
||||
@@ -14,7 +14,6 @@ const minifier = require('./minifier');
|
||||
|
||||
const JS = module.exports;
|
||||
|
||||
|
||||
JS.scripts = {
|
||||
base: [
|
||||
'node_modules/@adactive/bootstrap-tagsinput/src/bootstrap-tagsinput.js',
|
||||
|
||||
@@ -13,16 +13,6 @@ module.exports = function (app) {
|
||||
res.redirect(404);
|
||||
});
|
||||
|
||||
// const { setupPageRoute } = require('./helpers');
|
||||
// setupPageRoute(app, '/debug/test', middleware, [], async (req, res) => {
|
||||
// // res.redirect(404);
|
||||
// const meta = require('../meta');
|
||||
// res.render('test', {
|
||||
// now: new Date().toISOString(),
|
||||
// skins: [{ name: 'no-skin', value: '' }].concat(meta.css.supportedSkins.map(s => ({ name: s, value: s }))),
|
||||
// });
|
||||
// });
|
||||
|
||||
// Redoc
|
||||
router.get('/spec/:type', async (req, res, next) => {
|
||||
const types = ['read', 'write'];
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
<label>Tags Input</label>
|
||||
<input id="inputTags" class="form-control" value="" placeholder="">
|
||||
<hr/>
|
||||
|
||||
<label>Birthday</label>
|
||||
<input id="inputBirthday" class="form-control" value="" placeholder="mm/dd/yyyy">
|
||||
<hr/>
|
||||
|
||||
<label>Auto complete</label>
|
||||
<input id="autocomplete" class="form-control">
|
||||
<hr/>
|
||||
|
||||
<label>Color Picker</label>
|
||||
<input id="colorpicker" type="color" class="form-control">
|
||||
<hr/>
|
||||
|
||||
<label>Timeago</label>
|
||||
<div>
|
||||
<label>Language is [[language:name]]</label>
|
||||
<br/>
|
||||
<span id="timeago" class="timeago" title="{now}"></span>
|
||||
<button id="change-language" type="button" class="btn btn-primary">Change Language</button>
|
||||
</div>
|
||||
<hr/>
|
||||
|
||||
<label>Change Skin</label>
|
||||
<select id="change-skin" class="form-control">
|
||||
{{{each skins}}}
|
||||
<option value="{skins.value}">{skins.name}</option>
|
||||
{{{end}}}
|
||||
</select>
|
||||
<hr/>
|
||||
|
||||
<label>Sortable</label>
|
||||
<div>
|
||||
<ul id="sortable-list">
|
||||
<li>Item 1</li>
|
||||
<li>Item 2</li>
|
||||
<li>Item 3</li>
|
||||
</ul>
|
||||
</div>
|
||||
<hr/>
|
||||
|
||||
<label>Form Serialize</label>
|
||||
<form id="form-serialize">
|
||||
<input name="a" value="1">
|
||||
<input name="a" value="2">
|
||||
<input name="bar" value="test">
|
||||
</form>
|
||||
<pre id="json-form-data"></pre>
|
||||
<hr/>
|
||||
|
||||
<label>Form Deserialize</label>
|
||||
<form id="form-deserialize">
|
||||
<input name="foo" value="">
|
||||
<input name="foo" value="">
|
||||
<input name="moo" value="">
|
||||
</form>
|
||||
<hr/>
|
||||
Reference in New Issue
Block a user