luceos I thank you for your very detailed help article
I edit the js or css content in the vendor extension: Everything is fine
But I run "editor update", I'll start from the beginning...
It would be better if you made the modifications in your own installation using the Extend.php root directory <<< Điều này tôi nhờ bạn thêm mã dưới sau:
###Extensions: first-visit-indexpage
js: justoverclockl/first-visit-indexpage/blob/main/js/src/forum/index.js
/*
* This file is part of justoverclock/first-visit-indexpage.
*
* Copyright (c) 2021 Marco Colia.
* https://flarum.it
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
import { extend } from 'flarum/common/extend';
import app from 'flarum/forum/app';
import FirstVisitIndexPage from './components/FirstVisitIndexPage';
import Page from 'flarum/common/components/Page';
app.initializers.add('justoverclock/first-visit-indexpage', () => {
app.routes.FirstVisitIndexPage = {
path: '/forum-rules',
component: FirstVisitIndexPage,
};
extend(Page.prototype, 'oninit', function () {
const User = app.session.user;
const baseUrl = app.forum.attribute('baseUrl');
if (User) {
function redirect() {
var thecookie = readCookie('doRedirect');
if (!thecookie) {
location.href = baseUrl + '/forum-rules';
}
}
function createCookie(name, value, days) {
if (days) {
var date = new Date();
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
var expires = '; expires=' + date.toGMTString();
} else var expires = '';
document.cookie = name + '=' + value + expires + '; path=/';
}
function readCookie(name) {
var nameEQ = name + '=';
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) === ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
}
return null;
}
window.onload = function () {
redirect();
createCookie('doRedirect', 'true', '9999');
};
}
});
});
My edit:
/*
* This file is part of justoverclock/first-visit-indexpage.
*
* Copyright (c) 2021 Marco Colia.
* https://flarum.it
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
import { extend } from 'flarum/common/extend';
import app from 'flarum/forum/app';
import FirstVisitIndexPage from './components/FirstVisitIndexPage';
import Page from 'flarum/common/components/Page';
app.initializers.add('justoverclock/first-visit-indexpage', () => {
app.routes.FirstVisitIndexPage = {
path: '/forum-rules',
component: FirstVisitIndexPage,
};
extend(Page.prototype, 'oninit', function () {
const User = app.session.user;
const baseUrl = app.forum.attribute('baseUrl');
if (User) {
function redirect() {
var thecookie = readCookie('doRedirect');
if (!thecookie) {
location.href = baseUrl + '/forum-rules';
}
}
function createCookie(name, value, days) {
if (days) {
var date = new Date();
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
var expires = '; expires=' + date.toGMTString();
} else var expires = '';
document.cookie = name + '=' + value + expires + '; path=/';
}
function readCookie(name) {
var nameEQ = name + '=';
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) === ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
}
return null;
}
window.onload = function () {
//redirect();
/*createCookie('doRedirect', 'true', '9999');*/
if ($('#acceptRules').length == 1) {
$('#acceptRules').on('click', function (e) {
e.preventDefault();
e.stopPropagation();
var checkBox = document.getElementById("agreeRules");
if (checkBox.checked == true){
createCookie('doRedirect', 'true', '9999');
return true;
} else {
//redirect();
return false;
}
return false;
});
} else {
var thecookie = readCookie('doRedirect');
if (!thecookie) {
location.href = baseUrl + '/forum-rules';
//return false;
}
}
};
}
});
});
The old and new js content files have different code snippets:
/redirect();
createCookie('doRedirect', 'true', '9999');/
window.onload = function () {
/*redirect();
createCookie('doRedirect', 'true', '9999');*/
if ($('#acceptRules').length == 1) {
$('#acceptRules').on('click', function (e) {
e.preventDefault();
e.stopPropagation();
var checkBox = document.getElementById("agreeRules");
if (checkBox.checked == true){
createCookie('doRedirect', 'true', '9999');
return true;
} else {
//redirect();
return false;
}
return false;
});
} else {
var thecookie = readCookie('doRedirect');
if (!thecookie) {
location.href = baseUrl + '/forum-rules';
//return false;
}
}
};
I want to edit the above paragraph in exten.php, this file is completely new to me. I do not know how?
Looking forward to your help
Thank you very much