Problem with "onlyto"
5 posters
Page 1 of 1
Problem with "onlyto"
Hi,
A month ago I wrote a topic "how to add bbcode" where I search for advance hide. So.
Today this code have got broken. Someone have a solution?
Code:
Screenshot of problem:

PS. if it will helps: I had change my forum design.
A month ago I wrote a topic "how to add bbcode" where I search for advance hide. So.
Today this code have got broken. Someone have a solution?
Code:
- Code:
/*
* Application: Create New BBCode Tags
* Date: 18/05/2018
* Version: 1.321052018
* Copyright (c) 2018 Daemon <help.forumotion.com>
* This work is free. You can redistribute it and/or modify it
*/
(function() {
BBParser = {
initialize: function() {
$(function() {
BBParser.setupBBParser();
});
},
add: [
/*
* Note: Add a comma at the end of each new entry
* '{option}' corresponds to the optional tag title, and '{content}' correspond to the text between the tags
*/
{
tag: 'success',
close: true,
replacement: '<div class="notice notice-success"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'warn',
close: true,
replacement: '<div class="notice notice-warn"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'info',
close: true,
replacement: '<div class="notice notice-info"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'alert',
close: true,
replacement: '<div class="notice notice-alert"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'onlyto',
close: true,
replacement: '<div class="onlyto">{content}</div>',
replace: function(option, content) {
var myArray = new Array();
// this will return an array with strings "1", "2", etc.
myArray = option.split(",").map(function(el) {
return el.trim();
});
if ($.inArray(_userdata.username, myArray) == -1 && _userdata.user_level != 1 && _userdata.user_level != 2 && _userdata.user_level != 3) {
return 'Only ' + myArray.join(", ").replace(/,([^,]*)$/, ' and $1', ' and $2', ' and $3') + ' can view this message';
return content;
}
}
}
// Note: Do not add a comma at the end of the last entry
],
// Do not change anything down
validateTag: function(a) {
if (!/^\w+$/.test(a)) throw new RangeError("You added an invalid tag: " + a);
},
replacers: function(a, b, c) {
return (a || "").replace(/{option}/g, b || "").replace(/{content}/g, c || "");
},
optionReg: /.*?=("|'|)(.*?)\1\]/,
parsedContent: function(a, b, c) {
return a.replace(c ? RegExp("(\\[" + b.tag + "[^\\]]*\\])([\\s\\S]*?)\\[/" + b.tag + "]", "g" + (b.insensitive ? "i" : "")) : RegExp("\\[" + b.tag + "[^\\]]*\\]", "g" + (b.insensitive ? "i" : "")), function(d, e, f) {
c || (e = d);
e = BBParser.optionReg.test(e) ? e.replace(BBParser.optionReg, "$2") : b.defaultOption;
if("undefined" !== typeof b.replace) {
d = c ? b.replace(e, f) : b.replace(e);
"string" === typeof d ? c ? f = d : e = d : d;
"object" === typeof d && (e = d.option || e, f = d.content || f);
}
return BBParser.replacers(b.replacement, e, f);
});
},
setupBBParser: function() {
var postBody = $(".postbody, .blog_message");
for (var i = 0, e;(e = postBody[i++]);) {
for (var j in BBParser.add) {
var item = BBParser.add[j];
// Validating tag
BBParser.validateTag(item.tag);
e.innerHTML = BBParser.parsedContent(e.innerHTML, item, item.close);
}
}
}
};
BBParser.initialize()
})();
Screenshot of problem:

PS. if it will helps: I had change my forum design.
Re: Problem with "onlyto"
Hey @Sn0w,
Welcome to Support Forumotion! Can you give access to a topic. It is in maintenance, the Forum.
- pedxz
Welcome to Support Forumotion! Can you give access to a topic. It is in maintenance, the Forum.
- pedxz
Re: Problem with "onlyto"
Yeah. I had Phpbb2, now modernbb.skouliki wrote:hello
did you change your version too?
Re: Problem with "onlyto"
Hello ^^
No warranty, but can you try that script ?
No warranty, but can you try that script ?
- Code:
/*
* Application: Create New BBCode Tags
* Date: 18/05/2018
* Version: 1.321052018
* Copyright (c) 2018 Daemon <help.forumotion.com>
* This work is free. You can redistribute it and/or modify it
*/
(function() {
BBParser = {
initialize: function() {
$(function() {
BBParser.setupBBParser();
});
},
add: [
/*
* Note: Add a comma at the end of each new entry
* '{option}' corresponds to the optional tag title, and '{content}' correspond to the text between the tags
*/
{
tag: 'success',
close: true,
replacement: '<div class="notice notice-success"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'warn',
close: true,
replacement: '<div class="notice notice-warn"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'info',
close: true,
replacement: '<div class="notice notice-info"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'alert',
close: true,
replacement: '<div class="notice notice-alert"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'onlyto',
close: true,
replacement: '<div class="onlyto">{content}</div>',
replace: function(option, content) {
var myArray = new Array();
// this will return an array with strings "1", "2", etc.
myArray = option.split(",").map(function(el) {
return el.trim();
});
if ($.inArray(_userdata.username, myArray) == -1 && _userdata.user_level != 1 && _userdata.user_level != 2 && _userdata.user_level != 3) {
return 'Only ' + myArray.join(", ").replace(/,([^,]*)$/, ' and $1', ' and $2', ' and $3') + ' can view this message';
return content;
}
}
}
// Note: Do not add a comma at the end of the last entry
],
// Do not change anything down
validateTag: function(a) {
if (!/^\w+$/.test(a)) throw new RangeError("You added an invalid tag: " + a);
},
replacers: function(a, b, c) {
return (a || "").replace(/{option}/g, b || "").replace(/{content}/g, c || "");
},
optionReg: /.*?=("|'|)(.*?)\1\]/,
parsedContent: function(a, b, c) {
return a.replace(c ? RegExp("(\\[" + b.tag + "[^\\]]*\\])([\\s\\S]*?)\\[/" + b.tag + "]", "g" + (b.insensitive ? "i" : "")) : RegExp("\\[" + b.tag + "[^\\]]*\\]", "g" + (b.insensitive ? "i" : "")), function(d, e, f) {
c || (e = d);
e = BBParser.optionReg.test(e) ? e.replace(BBParser.optionReg, "$2") : b.defaultOption;
if("undefined" !== typeof b.replace) {
d = c ? b.replace(e, f) : b.replace(e);
"string" === typeof d ? c ? f = d : e = d : d;
"object" === typeof d && (e = d.option || e, f = d.content || f);
}
return BBParser.replacers(b.replacement, e, f);
});
},
setupBBParser: function() {
var postBody = $("div.content");
for (var i = 0, e;(e = postBody[i++]);) {
for (var j in BBParser.add) {
var item = BBParser.add[j];
// Validating tag
BBParser.validateTag(item.tag);
e.innerHTML = BBParser.parsedContent(e.innerHTML, item, item.close);
}
}
}
};
BBParser.initialize()
})();
Re: Problem with "onlyto"
Sn0w wrote:Yeah. I had Phpbb2, now modernbb.skouliki wrote:hello
did you change your version too?
The codes are not for all versions
Each version haS different elements so when you change version you have to adjust all your codes
Re: Problem with "onlyto"
Unfortunately, It doesn't work.Neptune- wrote:Hello ^^
No warranty, but can you try that script ?
- Code:
/*
* Application: Create New BBCode Tags
* Date: 18/05/2018
* Version: 1.321052018
* Copyright (c) 2018 Daemon <help.forumotion.com>
* This work is free. You can redistribute it and/or modify it
*/
(function() {
BBParser = {
initialize: function() {
$(function() {
BBParser.setupBBParser();
});
},
add: [
/*
* Note: Add a comma at the end of each new entry
* '{option}' corresponds to the optional tag title, and '{content}' correspond to the text between the tags
*/
{
tag: 'success',
close: true,
replacement: '<div class="notice notice-success"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'warn',
close: true,
replacement: '<div class="notice notice-warn"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'info',
close: true,
replacement: '<div class="notice notice-info"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'alert',
close: true,
replacement: '<div class="notice notice-alert"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'onlyto',
close: true,
replacement: '<div class="onlyto">{content}</div>',
replace: function(option, content) {
var myArray = new Array();
// this will return an array with strings "1", "2", etc.
myArray = option.split(",").map(function(el) {
return el.trim();
});
if ($.inArray(_userdata.username, myArray) == -1 && _userdata.user_level != 1 && _userdata.user_level != 2 && _userdata.user_level != 3) {
return 'Only ' + myArray.join(", ").replace(/,([^,]*)$/, ' and $1', ' and $2', ' and $3') + ' can view this message';
return content;
}
}
}
// Note: Do not add a comma at the end of the last entry
],
// Do not change anything down
validateTag: function(a) {
if (!/^\w+$/.test(a)) throw new RangeError("You added an invalid tag: " + a);
},
replacers: function(a, b, c) {
return (a || "").replace(/{option}/g, b || "").replace(/{content}/g, c || "");
},
optionReg: /.*?=("|'|)(.*?)\1\]/,
parsedContent: function(a, b, c) {
return a.replace(c ? RegExp("(\\[" + b.tag + "[^\\]]*\\])([\\s\\S]*?)\\[/" + b.tag + "]", "g" + (b.insensitive ? "i" : "")) : RegExp("\\[" + b.tag + "[^\\]]*\\]", "g" + (b.insensitive ? "i" : "")), function(d, e, f) {
c || (e = d);
e = BBParser.optionReg.test(e) ? e.replace(BBParser.optionReg, "$2") : b.defaultOption;
if("undefined" !== typeof b.replace) {
d = c ? b.replace(e, f) : b.replace(e);
"string" === typeof d ? c ? f = d : e = d : d;
"object" === typeof d && (e = d.option || e, f = d.content || f);
}
return BBParser.replacers(b.replacement, e, f);
});
},
setupBBParser: function() {
var postBody = $("div.content");
for (var i = 0, e;(e = postBody[i++]);) {
for (var j in BBParser.add) {
var item = BBParser.add[j];
// Validating tag
BBParser.validateTag(item.tag);
e.innerHTML = BBParser.parsedContent(e.innerHTML, item, item.close);
}
}
}
};
BBParser.initialize()
})();
Oh, now I get it. The clue of problem is - how? It's possible to do it myself, if I didn't know any codes like java?skouliki wrote:Sn0w wrote:Yeah. I had Phpbb2, now modernbb.skouliki wrote:hello
did you change your version too?
The codes are not for all versions
Each version haS different elements so when you change version you have to adjust all your codes
Re: Problem with "onlyto"
our tutorials with codes have instructions for all versions
we cant modify a code that someone else has made you have to wait for that member
unless someone else can volunteer to help you
we cant modify a code that someone else has made you have to wait for that member
unless someone else can volunteer to help you
Re: Problem with "onlyto"
donepedxz wrote:Hey @Sn0w,
Welcome to Support Forumotion! Can you give access to a topic. It is in maintenance, the Forum.
- pedxz
Re: Problem with "onlyto"
Do you have a section where guests can post? If yes, please post the link to it.


Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
Re: Problem with "onlyto"
Sn0w wrote:Unfortunately, It doesn't work.
I just tried it to be sure
-> My code (with line 85 modified) perfectly works on modernBB
-> The original code (in first post) also works fine. (so i modified it for nothing

If you still have a problem, you should disable all your javascripts codes except this one
Re: Problem with "onlyto"
https://wonderful-world.forumpolish.com/t402-test#1281 here.SLGray wrote:Do you have a section where guests can post? If yes, please post the link to it.
I disabled all javascripts and forum has become empty. Same, when I aplicate code, which you sended in this topic.Neptune- wrote:Sn0w wrote:Unfortunately, It doesn't work.
I just tried it to be sure
-> My code (with line 85 modified) perfectly works on modernBB
-> The original code (in first post) also works fine. (so i modified it for nothing)
If you still have a problem, you should disable all your javascripts codes except this one
I think that my forum template is problem.
Re: Problem with "onlyto"
So you have heavy modified templates?


Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
Re: Problem with "onlyto"
Try this: force the default templates and see if the issue disappears.


Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
Re: Problem with "onlyto"
Doesn't work.SLGray wrote:Try this: force the default templates and see if the issue disappears.

Update: when I use [onlyto=NICKNAME] - It works, but when I use [onlyto] (without nickname) - Doesn't work.
Re: Problem with "onlyto"
Is that not what you want?


Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
Re: Problem with "onlyto"
Half by half. I would like to have [onlyto=] and [only to]. But if it's not possible, I'll be still satisfiable.SLGray wrote:Is that not what you want?
Re: Problem with "onlyto"
So you want 2 options that really have the same ID or name?


Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
Re: Problem with "onlyto"
Rather: [onlyto] - This content see only administrators, [onlyto=name] - content see administrator and user "name".SLGray wrote:So you want 2 options that really have the same ID or name?
Re: Problem with "onlyto"
So the error was from the code, not a conflict by a template or a script!
Try change your code to:
but I will quote @Daemon
Try change your code to:
- Code:
/*
* Application: Create New BBCode Tags
* Date: 18/05/2018
* Version: 1.321052018
* Copyright (c) 2018 Daemon <help.forumotion.com>
* This work is free. You can redistribute it and/or modify it
*/
(function() {
BBParser = {
initialize: function() {
$(function() {
BBParser.setupBBParser();
});
},
add: [
/*
* Note: Add a comma at the end of each new entry
* '{option}' corresponds to the optional tag title, and '{content}' correspond to the text between the tags
*/
{
tag: 'success',
close: true,
replacement: '<div class="notice notice-success"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'warn',
close: true,
replacement: '<div class="notice notice-warn"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'info',
close: true,
replacement: '<div class="notice notice-info"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'alert',
close: true,
replacement: '<div class="notice notice-alert"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'onlyto',
close: true,
replacement: '<div class="onlyto">{content}</div>',
replace: function(option, content) {
var myArray = new Array();
// this will return an array with strings "1", "2", etc.
if(option) {
myArray = option.split(",").map(function(el) {
return el.trim();
});
}
if ($.inArray(_userdata.username, myArray) == -1 && _userdata.user_level != 1 && _userdata.user_level != 2) {
return 'Only ' + ( myArray.length ? myArray.join(", ").replace(/,([^,]*)$/, ' and $1', ' and $2', ' and $3') : 'Administrator and Moderator' ) + ' can view this message';
return content;
} else if (_userdata.user_level !== 1 && _userdata.user_level !== 2) {
return content;
}
}
}
// Note: Do not add a comma at the end of the last entry
],
// Do not change anything down
validateTag: function(a) {
if (!/^\w+$/.test(a)) throw new RangeError("You added an invalid tag: " + a);
},
replacers: function(a, b, c) {
return (a || "").replace(/{option}/g, b || "").replace(/{content}/g, c || "");
},
optionReg: /.*?=("|'|)(.*?)\1\]/,
parsedContent: function(a, b, c) {
return a.replace(c ? RegExp("(\\[" + b.tag + "[^\\]]*\\])([\\s\\S]*?)\\[/" + b.tag + "]", "g" + (b.insensitive ? "i" : "")) : RegExp("\\[" + b.tag + "[^\\]]*\\]", "g" + (b.insensitive ? "i" : "")), function(d, e, f) {
c || (e = d);
e = BBParser.optionReg.test(e) ? e.replace(BBParser.optionReg, "$2") : b.defaultOption;
if("undefined" !== typeof b.replace) {
d = c ? b.replace(e, f) : b.replace(e);
"string" === typeof d ? c ? f = d : e = d : d;
"object" === typeof d && (e = d.option || e, f = d.content || f);
}
return BBParser.replacers(b.replacement, e, f);
});
},
setupBBParser: function() {
var postBody = $(".postbody, .blog_message");
for (var i = 0, e;(e = postBody[i++]);) {
for (var j in BBParser.add) {
var item = BBParser.add[j];
// Validating tag
BBParser.validateTag(item.tag);
e.innerHTML = BBParser.parsedContent(e.innerHTML, item, item.close);
}
}
}
};
BBParser.initialize();
})();
Re: Problem with "onlyto"
pedxz wrote:So the error was from the code, not a conflict by a template or a script!
Try change your code to:
- Code:
/*
* Application: Create New BBCode Tags
* Date: 18/05/2018
* Version: 1.321052018
* Copyright (c) 2018 Daemon <help.forumotion.com>
* This work is free. You can redistribute it and/or modify it
*/
(function() {
BBParser = {
initialize: function() {
$(function() {
BBParser.setupBBParser();
});
},
add: [
/*
* Note: Add a comma at the end of each new entry
* '{option}' corresponds to the optional tag title, and '{content}' correspond to the text between the tags
*/
{
tag: 'success',
close: true,
replacement: '<div class="notice notice-success"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'warn',
close: true,
replacement: '<div class="notice notice-warn"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'info',
close: true,
replacement: '<div class="notice notice-info"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'alert',
close: true,
replacement: '<div class="notice notice-alert"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'onlyto',
close: true,
replacement: '<div class="onlyto">{content}</div>',
replace: function(option, content) {
var myArray = new Array();
// this will return an array with strings "1", "2", etc.
if(option) {
myArray = option.split(",").map(function(el) {
return el.trim();
});
}
if ($.inArray(_userdata.username, myArray) == -1 && _userdata.user_level != 1 && _userdata.user_level != 2) {
return 'Only ' + ( myArray.length ? myArray.join(", ").replace(/,([^,]*)$/, ' and $1', ' and $2', ' and $3') : 'Administrator and Moderator' ) + ' can view this message';
return content;
} else if (_userdata.user_level !== 1 && _userdata.user_level !== 2) {
return content;
}
}
}
// Note: Do not add a comma at the end of the last entry
],
// Do not change anything down
validateTag: function(a) {
if (!/^\w+$/.test(a)) throw new RangeError("You added an invalid tag: " + a);
},
replacers: function(a, b, c) {
return (a || "").replace(/{option}/g, b || "").replace(/{content}/g, c || "");
},
optionReg: /.*?=("|'|)(.*?)\1\]/,
parsedContent: function(a, b, c) {
return a.replace(c ? RegExp("(\\[" + b.tag + "[^\\]]*\\])([\\s\\S]*?)\\[/" + b.tag + "]", "g" + (b.insensitive ? "i" : "")) : RegExp("\\[" + b.tag + "[^\\]]*\\]", "g" + (b.insensitive ? "i" : "")), function(d, e, f) {
c || (e = d);
e = BBParser.optionReg.test(e) ? e.replace(BBParser.optionReg, "$2") : b.defaultOption;
if("undefined" !== typeof b.replace) {
d = c ? b.replace(e, f) : b.replace(e);
"string" === typeof d ? c ? f = d : e = d : d;
"object" === typeof d && (e = d.option || e, f = d.content || f);
}
return BBParser.replacers(b.replacement, e, f);
});
},
setupBBParser: function() {
var postBody = $(".postbody, .blog_message");
for (var i = 0, e;(e = postBody[i++]);) {
for (var j in BBParser.add) {
var item = BBParser.add[j];
// Validating tag
BBParser.validateTag(item.tag);
e.innerHTML = BBParser.parsedContent(e.innerHTML, item, item.close);
}
}
}
};
BBParser.initialize();
})();but I will quote @Daemon
Omg, now It's work perfectly fine. Really thank you! You're my god.

Re: Problem with "onlyto"
Problem solved & topic archived.
|


Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.

» Another problem with "onlyto"...
» Link Color Problem / Titles Problem / and search problem
» Adding chatbox rules problem and background of announcements problem
» Founder: Kind of a password problem, mostly an e-mail problem
» Hierarchy problem + Whos online problem
» Link Color Problem / Titles Problem / and search problem
» Adding chatbox rules problem and background of announcements problem
» Founder: Kind of a password problem, mostly an e-mail problem
» Hierarchy problem + Whos online problem
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum