javascript - Simplify a working function to replace specific words? -
I have a word, when a few words are labeled to collapse (to accommodate different proposals) My work is working, but I think it can be made simple ... just not sure how I add more words here, repetition can be faster than hand, do I have an array long I can put words / short words and everything is the same Or I could feed some things? I could not work for Bela (though she is working on my project), but you can go here. thank you in advanced!
if ($ ('label'). Height ()> 20) {Warning ('Text wrapped'); Var numtext = $ ('label: contains ("number")) if numtext {numtext.each (function () ($ (this) .html ($ (this) .text (). Replace (' number ', '#'));});} Var pertext = $ ('label: contains (percent)} (pertext) {pertext.each (function () {$ (this) .html ($ (this) .text (); Substituted ('percent', '%'));});} var invtext = $ ('label: contains "(invoice) {invtext} {invtext.each (function () {$ (this ) .html ($ (this) .text (). Replace ('Invoice', 'In'));});} // etc ...} I'm thinking It is likely that the first step is to reduce the function ... now to feed long / short words in pairs.
if ($ ('label'). Height ( )> 32) {var Var label = "number"; var label = "#"; Var labelwop = $ ('label: (' + long + '' '' ') (labeled wipe) {labelwrap.each (function () {$ (this) .html ($ (this) .text ()., Less));}); }}
This is by far the most optimal way: < '' '' '' '' '' ',' Zodiac ':' Am ',' Shipping ':' Ship ',' Production ':' Prod ',' Allotted ' : 'Alok', 'complete': 'comp', 'manager': 'MGR' $ $ ('label'). Each (function () (if ($ (this) (word [i]) ({{ii]] {words for [i] (in different words) = Short_trans [word [i]];}} $ (This) .text (word zones (''));}});
We loop once for any label tag, Then check that height> 20 , then copy the text to each word and check if a smaller version is present, then if it is changed then
Comments
Post a Comment