HTA: Predefined message in textarea on click? - textarea

I'm trying to build an HTA app with a textarea box with pre-defined text:
<textarea name="Box1" rows=3 cols=75>Use this area for inputs that require multiple lines of text.
This is an example of pre-defined text.</textarea>
Which works. However, I'm also adding a reset button that clears some of the input boxes and textareas:
Sub ResetSub
Value5.Focus
Value5.Value = "Reset successful"
Box1.Value = "Use this area for inputs that require multiple lines of text.
This is an example of pre-defined text."
End Sub
<input id=runbutton type="button" value="Reset" onClick="ResetSub">
Loading the HTA I get an "Unterminated string constant" error because Box1.Value doesn't have quotes at the end of the line. Does anyone know how I can fix this? NOTE: I can't reload the entire page because I also need to retain data from other text boxes. Thanks for the tips!

You can include a newline like so:
Box1.Value = "Use this area for inputs that require multiple lines of text." & chr(13) & "This is an example of pre-defined text."

Related

how to add hyperlink to text in dart

I am trying to add an anchor tag to the message I want to display but I am getting an error message. Am I not doing this right?
String browserRequirementsUrl = "https://test.testing.com";
var someText = new ParagraphElement()
..innerHtml = "Link can be found <a href=${url}>here</a>[1].";
But I get an error message saying
html_dart2js.dart:3614 Removing disallowed attribute <A href="https://test.testing.com">
Any suggestions, how I can do this?
By default in dart:html, for security purposes, this is disallowed.
You can use the .setInnerHtml method:
..setInnerHtml("Link can be found...", treeSanitizer: NodeTreeSanitizer.trusted);
Note that this can potentially be insecure (i.e. inject <script> tags and such), so you can always create a custom sanitizer or validator to only allow a subset of HTML tags (such as <a>).

Is there material input type number in angular 2 dart

I was tring to use material component in angular 2 dart as a number input:
<material-input type="number"></material-input>
but it behaves like a normal input. In docs it sais it supports type "number". Am i doing anything wrong? Or isn't number type implemented yet?
Thank you for any suggestions.
I can share my personal experiment trying to have a number (integer) input. It does not work perfectly on all browsers but I wanted to have the proper keyboard shown on Android and iOS. What I did was forcing the type on the inner input element programmatically. It seems that on Firefox it does not prevent entering text but does display a message ("Please enter a number"). It does not handle decimal neither (i.e. it does expect an integer)
initInputNumber(MaterialInputComponent inputComponent) {
inputComponent.type = "number";
InputElement inputElement = inputComponent.inputEl.nativeElement;
inputElement.type = "number";
// http://stackoverflow.com/questions/6178556/phone-numeric-keyboard-for-text-input
// As of mid-2015, I believe this is the best solution:
// <input type="number" pattern="[0-9]*" inputmode="numeric">
inputElement.attributes["inputmode"] = "numeric";
inputElement.pattern = "[0-9]*"; // this and only this works 0-9
}
I don't know if that's the best solution but I find it hard to have a complete cross-browser solution
I think you need to set an errorMsg
<material-input type="number" errorMsg="That's not a number"></material-input>
This line https://github.com/dart-lang/angular2_components/blob/a0eff879a6cb347b8beb95ed758c02c6dd9dfaa0/lib/src/components/material_input/material_input.dart#L232 seems to indicate that type="tel" and type="number" are set to text for the internal input element, while this line https://github.com/dart-lang/angular2_components/blob/a0eff879a6cb347b8beb95ed758c02c6dd9dfaa0/lib/src/components/material_input/material_input.dart#L61 says that errorMsg is used when and invalid number is entered when type="number".

google translator toolkit - how to exclude portions of the text from being processed

Does anybody know whether there is a possiblity to exclude portions of a text from being processed by the google translator toolkit?
A great advantage of this tool is that it suggests the translations of sentences which have already been translated in another context. However, if any additional footnote and/or remark has been added to the text, it won't be recognized as a match. I am looking for a possibility to enclose such text in "brackets" within which it will be ignored.
For example, the following two strings should be recognized as identical:
"This is one continuous sentence."
"This is {this text will be ignored}one continuous sentence."
and be translated i.e. into German as:
"Dies ist ein zusammenhängender Satz."
"Dies is {this text will be ignored}ein zusammenhängender Satz."
If neccessary I could number such insertions and place their content into additional paragraphs like:
"This is one continuous sentence."
"This is {1}one continuous sentence."
"{1 this text will be ignored}
thanks a lot in advance,
Marcel
Quoting from the Google Translate FAQ ...
How do I tell Cloud Translation API to NOT translate something?
You can use the following HTML tags:
<span translate="no"> </span>
<span class="notranslate"> </span>
This functionality requires the source text to be submitted in HTML.
If it's "not working for you" a likely reason is that you requested TEXT translation not HTML translation. If you only want TEXT translation then wrapper your plan text in HTML tags (with <span> tags as above) and then unwrap after translation.
Add a span tag with a class of 'skiptranslate' to the bits that you do not want to be translated, like this:
"This is <span class="skiptranslate">this text will be ignored</span> one continuous sentence."
The "skiptranslate" class didn't work for me in the po files I submitted to gtt. Gtt continued to translate everything. I noticed that gtt does not translate anything inside an href attribute, so what I did was to pre-process my .po file (using a "copy" grunt task) by changing {{my_expr}} type strings to <a href='{{my_expr}}/> strings, then changing them back to {{my_expr}} after the gtt translation (using another "copy" grunt task).
I'm not sure how this affects the semantics of the translation, but at least the resulting translation doesn't break my templating code.
Here is my grunt copy task config showing the regular expressions I used:
copy: {
fixupPoFileForTranslation: {
src: [], // Fill in src and dest!
dest: '',
options : {
process: function (content, srcpath) {
return content.replace(/"Go page"/g, '"Go"')
// Change handlebars {{<name>}} to <a ref='<name>'/> to stop
// machine translation from translating them.
return content.replace(/(\{\{[a-zA-Z_\$].*?\}\})/g, '<a href=\'$1\'/>')
// Same thing for our js .format {0}, {1}, ...
.replace(/(\{\d*?\})/g, '<a href=\'$1\'/>');
}
}
},
fixupPoFileForMerge: {
src: [],
dest: '',
options : {
process: function (content, srcpath) {
// Restore <a href=... back to {{<name>}}
return content..replace(/<a href='(\{\{[a-zA-Z_\$].*?\}\})'(\/>|)/gi, '$1')
// Same thing for {0} constructs
.replace(/<a href=' *(\{.\d?\})('\/>|)/gi, '$1');
}
}
}
}

Line Breaks not working in Textarea Output

line breaks or pharagraph not working in textarea output? for example i am using enter for pharagraph in textarea but not working in output? How can i do that?
$("#submit-code").click(function() {
$("div.output").html($(".support-answer-textarea").val());
}).next().click(function () {
$(".support-answer-textarea").val($("div.output").html());
});
.support-answer-textarea{width:100%;min-height:300px;margin:0 0 50px 0;padding:20px 50px;border-top:1px solid #deddd9;border-bottom:1px solid #deddd9;border-left:none;border-right:none;box-sizing:border-box;letter-spacing:-1px;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<textarea id="support-answer-textarea" class="support-answer-textarea" placeholder="Destek Konusunu Cevapla!"></textarea>
<button type="submit" id="submit-code" class="btn btn-success">Submit Your Code</button>
<div class="output"></div>
The best and easy way to fix line breaks on the output use these simple css:
.support-answer-textarea {
white-space: pre-wrap;
}
When you hit enter in a <textarea>, you're adding a new line character \n to the text which is considered a white space character in HTML. HTML generally converts the sequence of all white spaces to a single space. This means that if you enter a single or a dozen of whitespace characters (space, new line character or tab) in a row, the only effect in resulting HTML is just a single space.
Now the solution. You can substitute the new line character (\n) to <br> or <p> tag using replace() method.
$("#submit-code").click(function() {
$("div.output").html($(".support-answer-textarea").val().replace(/\n/g, "<br>"));
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<textarea id="support-answer-textarea" class="support-answer-textarea"></textarea>
<button type="submit" id="submit-code">Submit Your Code</button>
<div class="output"></div>
for me, I had a e.preventDefault() for only Enter keypress on a parent element, this prevents a new line from adding.
If you are capturing an input from a textarea, sending it via ajax (saving to database, e.g. mysql) and then want to display the result in a textarea (e.g. by echoing via php), use the following three steps in your JS:
#get value of textarea
var textarea_value = $('#id_of_your_textarea').val();
#replace line break with line break input
var textarea_with_break = textarea_value.replace(/(\r\n|\n|\r)/gm, '
');
#url encode the value so that you can send it via ajax
var textarea_encoded = encodeURIComponent(textarea_with_break);
#now send via ajax
You can also perform all of the above in one line. I did it in three with separate variables for easier readability.
Hope it helps.
Posting this here as it took me about an hour to figure this out, fumbling together the solutions from the answers below (see for more details):
The .val() of a textarea doesn't take new lines into account
New line in text area
URL Encode a string in jQuery for an AJAX request

Automatic redirect when selecting 3rd dropdown in a form?

I have 3 typeahead fields:
They are as follows:
Country: |___________|
State: |___________|
City: |___________|
Here is the code for the second typeahead field (the rest are similar):
<input type="text" class="span3" style="margin: 0 auto;"
data-provide="typeahead" data-items="4"
data-source="["Alabama","Alaska",
<many more US states>
,"Wyoming"]">
Now ... I need both typeahead fields to look like dropdowns which can be achieved by following instructions here.. no problem.
https://github.com/danielfarrell/bootstrap-combobox
http://dl.dropbox.com/u/21368/bootstrap-combobox/index.html
The question I'm asking pertains to the "Last Option" below:
Note: I am building this in Rails, so ruby code would be nice...
Placeholder Case:
I need each of the drop down lists to have a default placeholder text which is grayed out.
eg:
Country: |_USA_______|
State: |_IOWA______|
City: |_DES MOINES____|
Missing Value Case:
If the user types in a City value that does not exist in the autocomplete, I want to show them a dropdown with a link..
eg: User types in "yahoo" in City field. This should result in the output "That city does not exist, click here to search for it"
Clicking on the above text should redirect me to Google.com
Error Case:
If nothing is selected in the first field (country).. the second field should have a default value in the dropdown: "Please select a Country to begin"
Last Option:
upon successful selection of a City, eg: San Francisco ... I want to make a redirect to a new html file like "mysite.com/datastore/calsan.html" (first three letters from each selection in lowercase appended together)
this final html file will be pre-generated and will have relevant statistics and fun facts about the city "San Francisco"... I'll also have fun facts for other cities pregenerated in the datastore folder.
See my snippets below
Placeholder case
<script type="text/javascript">
$(document).ready(function(){
$('.combobox').combobox({placeholder: "Type Something.."});
});
</script>
Last Option
<script type="text/javascript">
$('.combobox').change(function(){
if($(this).val().length > 0){
var fileName = $(this).val().substr(0,3); // this is for getting the first 3 characters, apply the same logic wherever necessary
window.location("/datastrore/" + fileName + ".html");
}
})
</script>
Last Option
There seems to be a simple way to do this with inline javascript and option value. I think I will be using this simpler way..
http://webdesign.about.com/od/javascript/f/blfaqddredirect.htm
Placeholder Case and All other Cases
http://harvesthq.github.com/chosen/
The above library solves all my issues and is very powerful! Its not for bootstrap but I don't mind until bootstrap has a comparable option.

Resources