This topic is locked

superscripts and subscripts etc

1/6/2016 6:08:28 PM
PHPRunner General questions
B
bioman author

Hi,

I am wondering if it is possible to allow for superscript and subscript fonts in my PHPRunner applications. I have teachers who would like to use these formats. For example, they would like to put 0 degrees Celsius into the database as 0°C. Notice the superscript. It seems the standard superscript and subscript shortcuts in MS Word don't work. How can this be done? Also, is there a way to format equations to look like equations or is this not possible in a database? Thanks,

Brett

Sergey Kornilov admin 1/6/2016
B
bioman author 1/6/2016

Thanks for the reply Sergey, but how would my users (who do not know anything about html) be able to put in a superscript or subscript? For example, if one of my users is a biology teacher and wants to type in CO2 (with a subscripted 2).

Thanks,

Brett



Check HTML <sup> tag:

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sup

Sergey Kornilov admin 1/7/2016

Well, you will have to teach you teachers then, provide some sort of cheat code on what kind of HTML tags they can use there. Probably you can find some sort of HTML Editor that comes with subscript/supercript buttons that make this task easier.

HJB 1/7/2016

Citing ex http://stackoverflow.com/questions/17683654/superscript-in-input-field-of-text-type
How about a plugin:
$.fn.superScript = function() {

var chars = '+−=()0123456789AaÆᴂɐɑɒBbcɕDdðEeƎəɛɜɜfGgɡɣhHɦIiɪɨᵻɩjJʝɟKklLʟᶅɭMmɱNnɴɲɳŋOoɔᴖᴗɵȢPpɸrRɹɻʁsʂʃTtƫUuᴜᴝʉɥɯɰʊvVʋʌwWxyzʐʑʒꝯᴥβγδθφχнნʕⵡ',

sup = '⁺⁻⁼⁽⁾⁰¹²³⁴⁵⁶⁷⁸⁹ᴬᵃᴭᵆᵄᵅᶛᴮᵇᶜᶝᴰᵈᶞᴱᵉᴲᵊᵋᶟᵌᶠᴳᵍᶢˠʰᴴʱᴵⁱᶦᶤᶧᶥʲᴶᶨᶡᴷᵏˡᴸᶫᶪᶩᴹᵐᶬᴺⁿᶰᶮᶯᵑᴼᵒᵓᵔᵕᶱᴽᴾᵖᶲʳᴿʴʵʶˢᶳᶴᵀᵗᶵᵁᵘᶸᵙᶶᶣᵚᶭᶷᵛⱽᶹᶺʷᵂˣʸᶻᶼᶽᶾꝰᵜᵝᵞᵟᶿᵠᵡᵸჼˤⵯ';
return this.each(function() {

this.value = this.value.replace(/<sup[^>]>(.?)<\/sup>/g, function(x) {

var str = '',

txt = $.trim($(x).unwrap().text());
for (var i=0; i<txt.length; i++) {

var n = chars.indexOf(txt[i]);

str += (n!=-1 ? sup[n] : txt[i]);

}

return str;

});

});

}
called like:

$('input').superScript();
unquote
Alternatively one of the EDITORS as seen under https://xlinesoft.com/phprunner/docs/rich_text_editor_plugins.htm cam join in.

B
bioman author 1/7/2016

Thanks walk2fly,

I think the rich text editor plugins are what I was looking for. I appreciate the help. It looks like all I need to do is enable it and make sure I have text area. I'll try it as soon as I can. Thanks,

Brett



Citing ex http://stackoverflow.com/questions/17683654/superscript-in-input-field-of-text-type
How about a plugin:
$.fn.superScript = function() {

var chars = '+−=()0123456789AaÆᴂɐɑɒBbcɕDdðEeƎəɛɜɜfGgɡɣhHɦIiɪɨᵻɩjJʝɟKklLʟᶅɭMmɱNnɴɲɳŋOoɔᴖᴗɵȢPpɸrRɹɻʁsʂʃTtƫUuᴜᴝʉɥɯɰʊvVʋʌwWxyzʐʑʒꝯᴥβγδθφχнნʕⵡ',

sup = '⁺⁻⁼⁽⁾⁰¹²³⁴⁵⁶⁷⁸⁹ᴬᵃᴭᵆᵄᵅᶛᴮᵇᶜᶝᴰᵈᶞᴱᵉᴲᵊᵋᶟᵌᶠᴳᵍᶢˠʰᴴʱᴵⁱᶦᶤᶧᶥʲᴶᶨᶡᴷᵏˡᴸᶫᶪᶩᴹᵐᶬᴺⁿᶰᶮᶯᵑᴼᵒᵓᵔᵕᶱᴽᴾᵖᶲʳᴿʴʵʶˢᶳᶴᵀᵗᶵᵁᵘᶸᵙᶶᶣᵚᶭᶷᵛⱽᶹᶺʷᵂˣʸᶻᶼᶽᶾꝰᵜᵝᵞᵟᶿᵠᵡᵸჼˤⵯ';
return this.each(function() {

this.value = this.value.replace(/<sup[^>]>(.?)<\/sup>/g, function(x) {

var str = '',

txt = $.trim($(x).unwrap().text());
for (var i=0; i<txt.length; i++) {

var n = chars.indexOf(txt[i]);

str += (n!=-1 ? sup[n] : txt[i]);

}

return str;

});

});

}
called like:

$('input').superScript();
unquote
Alternatively one of the EDITORS as seen under https://xlinesoft.com/phprunner/docs/rich_text_editor_plugins.htm cam join in.

HJB 1/7/2016

You as well as your customers can test the "CO²" and else issues under:
http://www.kevinroth.com/rte/demo.php
which is the BASIC editor shipped by default with PHPRunner whether or not they are satisfied with that very functionality.
P.S. Apart of usual signs and symbols available by keyboard strokes show your customers the SPECIAL CHARACTERS insertion feature by clicking the SECOND icon from the right in the upper menu.

It contains e.g. PROMILLE, Phi and more other useful characters or symbols to choose from the table. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=78527&image=1&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' />

B
bioman author 1/7/2016

Hi Walk2fly,

I am having a couple of problems with this approach and I was wondering if you might have solutions.

  1. The first problem is that the Basic editor that is part of PHPRunner doesn't seem to have superscript and subscript. Is there a way to add these?
  2. When saved in the database, it saves as code, but I am having users retrieve from the database with an external application. Is there some php code or something that can echo what is in the database as rich text rather than as code?
  3. I noticed some of the rich text editor features don't work at all in my application. I am thinking this is because my fields may be of the wrong type. What type of fields should I have to use the rich text editor best? I think I have VARCHAR right now. Should I change to something else (TEXT for example)? Thanks for your help. I appreciate it,

    Brett


    You as well as your customers can test the "CO²" and else issues under:
    http://www.kevinroth.com/rte/demo.php
    which is the BASIC editor shipped by default with PHPRunner whether or not they are satisfied with that very functionality.
    P.S. Apart of usual signs and symbols available by keyboard strokes show your customers the SPECIAL CHARACTERS insertion feature by clicking the SECOND icon from the right in the upper menu.

    It contains e.g. PROMILLE, Phi and more other useful characters or symbols to choose from the table. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=78528&image=1&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' />

HJB 1/8/2016

To 1) I cannot properly answer on that as it depends on how and whether the editor's programming code is supporting such issue or not. What I see in other EDITOR products like e.g. https://www.tinymce.com is that Subscript and Superscript icons can be added by some code injections into the upper menu, read e.g. http://wptavern.com/how-to-add-subscript-and-superscript-characters-in-wordpress (a recent publication informed that WORDPRESS had now been conquering more than 25% of worldwide page content, so, at least me is 100% sure that the PHPR developer team cannot afford to not at least look for a solution or comfortable workaround as the WORDPRESS worldwide market share of roughly 25% represents a quarter of mankind using the Internet for publications of all kind or say, on PHPRunner marketing, it is worth to invest some brainstorming).

To 2) On such wished PHP code I cannot assist. A question which needs to get answered by the forum admin.

To 3) In any case you need to MODIFY the table field from current VARCHAR to MEDIUMTEXT to get any of the editor's to work as wished.
P.S. Certainly as well no big deal to implmenet and taste other editors like e.g. http://nicedit.com/demos.php?demo=2 which are working under JS and are providing exactly what you need. Further, I saw that the BASIC editor which is shipped along with PHPRunner as well owns the feature to BUILD super- and subscript icons as per details seen under http://www.kevinroth.com/rte/usage.htm <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=78529&image=1&table=forumreplies' class='bbc_emoticon' alt='B)' />