Why could an extra back-slash appears in javascript in outsystems? - javascript

we use the autocomplete component from RichWidgets and we get extra back-slash in the javascript which causes a bug in the autocomplete.
autocomplete JavaScript code tries to split the bulk of rows into items in the autocomplete list but the extra back-slash interrupt the split (js method from functioning well.
although we use the same component in another module (where it works perfectly without the extra back-slash) referencing to same RichWidgets but we still
update:
this is only when we use Arabic language, it works fine in english.

Without more context, it's difficult to answer, but if it only happens with the AR locale then it might be the case that there are translations defined for those strings that are causing the issue.
Check if setting the behavior of those strings to not translate makes any difference.

Related

Javascript for replacing $ with $$ or $latex

I do know good HTML and some PHP, but not at all javascript, so I need some help with this question please. I have a wordpress site the uses math equations together with Simple Matjax plugin for rendering the math from latex. There are many worpress plugins for latex some of them faster, some of them slower.
I tried to find a faster plugin to replace Simple Mathjax, but every other plugin use a different math "quotation" than that I am using $...$
So I need a javascript that either replaces the $...$ with $$...$$ or first $ with $latex (or whatever start and end sequence I might need for a specific plugin). I guess this is simple, but as I was saying, I do not know javascript at all. Thank you.
PS. There is one replacement WP Quick Latex but when I install it it block the access to my homepage (all other pages are rendered and displayed, except my homepage, page 2, page 3,...that contain excertpts). Any suggestions? Edit: Quicklatex uses shortcodes [latexpage]. If one enables it sitewide on the homepage it has to work on all equations, Thus the wating time for loading the homepage increases significantly.
The javascript function for string replacement is
replace("string to replace", "new string")
I think you should do something like this:
var string = "$"; // <-- this is where you enter the string you want to replace
var new_replaced_string = string.replace("$", "$latex");
Hope this helps.

Jquery image bookmarklet not working in Django

Im working through Django By Example and in one chapter a Jquery bookmarklet is built within a Django app so that a user can easily save jpg images from a website into their user profile area within the Django app.
Im not an experienced JS or Jquery programmer but I did some JS some years back and can read the code however the tutorial does give exact instructions on what to do which I have followed and although I have managed to get the bookmarklet button to appear in my bookmarks bar in Chrome, nothing happens when I click it when browsing a webpage with jpg images.
This is my local Django dashboard where the bookmarklet button is added to the bookmarks bar and this part works fine
and this is what it should look like when clicked on, this is the part where nothing happens for me
these are the relevant js files
https://github.com/davejonesbkk/bookmarks/blob/master/images/templates/bookmarklet_launcher.js
https://github.com/davejonesbkk/bookmarks/blob/master/images/static/js/bookmarklet.js
the only thing I can see that is different with these compared to the files that came with the book is the indentation is a bit off but for some reason the indentation does seem to have changed a bit when I uploaded to Git and they dont look like that locally. Is indentation important in JS?
I followed the same book with the same examples but didn't had any trouble. Make sure your dashboard.html file is referring to the correct javascript file. If nothing works try to add the bookmark manually, you can see how that's done over here http://www.howtogeek.com/189358/beginner-geek-how-to-use-bookmarklets-on-any-device/ it'll sure to work.
And answer to your last question, Indentation is not as important in JavaScript as it's in Python, as python doesn't use any curly braces "{}" or semi-colons ";". But you can write your entire javascript code in a single line and it'll work because your using curly braces everywhere to tell which line of code ends where.
I agree with all the above. In addition, the following:
Error I noticed in the book:
In bookmarklet-launcher.js the js function being called from bookmarklet.js is called myBookmarklet(), however there is no function called this way in bookmarklet.js. So, you may want to use the same name in both js files.
Practically speaking however, the bookmarklet will always work because, not finding a myBookmarklet function in memory, bookmarklet-launcher.js appends the bookmarklet.js script to the body element and, being bookmarklet.js a self-invoking function, its content executed (without the need it to being called). There are some additional interesting technicalities here (the key function in bookmarklet.js is not self invoking but it will anyway be always called because of the script checking whether jQuery is present...) but ok, this is more relevant for those busy with the mentioned book (Django 2 by example).
Check whether bookmarkled, once you click on it, is added to the
current webpage:
2.1. Open devtools (F12 on Chrome) and check e.g. in the html head element whether you find the newly added link element containing the css attribute and/or in the body element whether you find the script element containing the reference to the bookmarklet.js file.
2.2. Alternative: Add an alert message on top of the bookmarklet.js script so that it will be launched if it is correctly loaded. Example:
(function(){
alert('bookmarkled loaded!');
var jquery_version =...
Make sure you're trying to use it on a HTTP site only. Since you're serving from same protocol. HTTPS site would always tell say: There is a problem loadingbyour jquery. That's how I solved mine.
dude.I have solved the problems I met like you.
The most important thing is that noticing the syntax error(without warnings),mainly caused by ignoring blank.
for example, in the line:
jQuery('#bookmarklet .images').append('<img src="'+image_url+'"/>');
between #bookmarklet and .images should lie a blank space,because of jquery syntax rules(meaning to search tag with id of bookmarklet and search tag with class equaling images within result previously).
Another two places worth notice are codes containing #bookmarklet .images a and #bookmarklet #close,requiring blank spaces between filter condition.
That's where I found I made mistaks mainly after studying syntax of jquery.
You'd better compare your codes with codes already loaded up to github by someone to make sure there are no more little errors(such as spelling).

How to refer to Presentation Variable in JavaScript?

I'm on OBIEE 11g. I am trying to create a printer-friendly dashboard that shows in the footer how the dashboard was prompted on each page. I don't want to use the filter object because it is query specific and I have multiple queries per dashboard.
I've assigned all prompts with a presentation variable and I've referred to the presentation variables in the footer. I now am almost where I want to be. I would now just like to use javascript logic (supported in footer section) so that all blank prompts are filtered out.
Is it possible to refer to a presentation variable in JS? If so, how should I build the syntax?
UPDATE: The use of JS was not needed. There is a feature on the syntax of the Presentation Variable code that allows you to enter how you display nulls. The basic code format is this: #{var_name}. Adding an extra set of curly brackets activates the ability to modify the default display. #{var_name}{} displays the blank that I was looking for instead of the variable name I had before.
The use of JS was not needed. There is a feature on the syntax of the Presentation Variable code that allows you to enter how you display nulls. The basic code format is this: #{var_name}. Adding an extra set of curly brackets activates the ability to modify the default display. #{var_name}{} displays the blank that I was looking for instead of the variable name I had before.
I'm not sure if you can reference a presentation variable from JS, and I think that's still an interesting question.
However, a more scalable/supportable solution might be to use the built in functionality – which I think could meet your requirement.
You could either make a new Analysis and drop in as many columns as you have presentation variables, and change the column formula for each in turn to reference your presentation variables. I'm not sure how you'd display that though.
Alternatively, I would probably do it in a Narrative view, where you can reference the presentation variables directly and possibly format it a little better.
Inspiration from Nico Gerard.

jQuery adding unwanted characters to string?

I'm using a jQuery to add localised currency signs to a page. Seemingly an innocent and straightforward procedure:
$('.currency').text( userCurrency() )
However, if the currency string is £, instead the output is £.
I've got no idea what might be causing it, as I cannot recreate the issue in jsFiddle.
It doesn't happen in firefox, ie or safari, only chrome.
By setting a breakpoint at the function call it is possible to see that the text is not actually visible (or loaded?) in the browser (even though the code is only run after the window has loaded).
I understand I'm not giving you much to work with, and I'm sorry - this is a very bizarre issue indeed.
Has anyone out there encountered anything similar, maybe someone has ideas how I can go about troubleshooting?
This is due to the different encodings used. Make sure all documents use the utf-8 encoding, along with setting the meta tag for utf-8. But also as in Qambar Raza's answer mentions you should probably use the html entity of certain characters instead of the actual character.
You need to use this in your of the HTML page:
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
It basically sets the content type of your page to ('utf-8') encoding meaning it can support the character set for currency.
Also, make sure you use HTML entities like:
£ for £
i.e your function userCurrency() should return html entities (e.g £) rather than a direct symbol. You can find more details about this topic on the following link:
http://webdesign.about.com/od/localization/l/blhtmlcodes-cur.htm

How to use Dojo Dijit select without tables?

I'm working on some project that uses Dojo dijit.form.Select, that produce some really strange HTML. It's replace standard browser select with table, tr, td and other crap that made it slow (a lot of unnecessary elements), inaccessible (select by letter doesn't work) and very hard to style.
Is there any why to tell Dojo to switch into standards mode?
You probably want to override the template (you can check in dijit/form/template/select.html)
You'll need to override it, but keep the attachpoint and vars I guess.
I'd recommend checking that and if the original Select.js writes hard coded html which would mean you would also have to override these functions.
In any case, this does not seem like a simple switch off property.
In the end you might want to simply call a normal select and handle it with a custom made controller widget...

Categories

Resources