|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
<select id="mySel" class="select2">
<option></option>
<option value="NEW">Add new type</option>
<option>Car</option>
<option>BUS</option>
<option>TWO</option>
<option>THREE</option>
</select>
<pre>$(function () {
$(".select2")
.select2({
placeholder: 'Select type',
width: '50%',
minimumResultsForSearch: Infinity
})
.on('select2:close', function() {
var el = $(this);
if(el.val()==="NEW") {
var newval = prompt("Enter new value: ");
if(newval !== null) {
el.append('<option>'+newval+'</option>')
.val(newval);
}
}
});
});</pre>
|
|
|
|
|
Hi there,
I have created a random password and intend to send this password to the user's email. So that they can type in the password, to log into my course and at the same time use it as a verification.
Below is my random password code.
var passwordChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#@!%&()/";
var otp = Array(6).fill(passwordChars).map(function(x) {
return x[Math.floor(Math.random() * x.length)]
}).join('');
var player = GetPlayer();
player.SetVar("NewOTP",otp);
let's say the random code is O#bD3f
The text message in the email will be
Please key in the password O#bD3f
How to include NewOTP in to the text message.
Please help
Thanks.
|
|
|
|
|
freezers wrote: How to include NewOTP in to the text message. What is NewOTP? And why can't you add it to the email?
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
I have already done it...thanks.
|
|
|
|
|
string emailBody = string.Format("Please key in the password {0}", otp);
|
|
|
|
|
|
<pre><pre lang="Javascript">function registerHandlers() {
var as = document.getElementsByTagName('a');
for (var i = 0; i < as.length; i++) {
as[i].onclick = function() {
alert(i);
return true;
}
}
}</pre><pre>
And HTML:
In my life, I used the following web search engines:<br/>
<a href="//www.yahoo.com">Yahoo!</a><br/>
<a href="//www.altavista.com">AltaVista</a><br/>
<a href="//www.google.com">Google</a><br/>
|
|
|
|
|
|
Other option for scripting with onclick functionality
<pre> function registerHandlers() {
var as = document.getElementsByTagName('a');
for (var i = 0; i < as.length; i++) {
as[i].addEventListener('onclick', function() {
alert(i);
return true;
});
}
}
//Call Function Here on window load
window.addEventListener('load', function() {
registerHandlers();
});</pre>
|
|
|
|
|
Hi,
Quick question. Using Java Script to display dynamic htmlpages.
Question on how to make all the fields in a row high lighted in red based on a condition instead of doing each field.
Code below is what we are doing currently to set color for some fields based on condition.
But with a new condition all fields have to be highlighted in Red.
How to do it. There are around 20 fields in the row to conditionally highlight in red.
if (field.entered == 1 && field.pcnt_staged != '100%') {
fldText += '' + field.shipto + '';
}else{
fldText += '' + field.shipto + '';
}
thanks
|
|
|
|
|
To highlight a row of what? What I mean by this is that it depends on how you setup the HTML. If you setup HTML that can be modified in a 1 liner in JavaScript and CSS, then my example would work easy. It really depends on how you designed the HTML.
I would imagine that you just create a class in CSS to create the visual effect you need, then add that class to each element that needs to be highlighted.
These elements could have a master element wrapper, in which you would add a new CSS visual effect, that would highlight all the child elements.
<div class="wrapper">
<div class="element">1</div>
<div class="element">2</div>
</div>
Something like this would add the class. Not tested, just off the top of my head
if (field.entered == 1 && field.pcnt_staged != '100%') {
let wrapper = document.getElementByClassName('wrapper');
if (wrapper) {
wrapper.classList.add('red-all');
}
}
<div class="wrapper red-all">
<div class="element">1</div>
<div class="element">2</div>
</div>
In css I think it would be, master element select all child divs within the master.
.red-all > .element {
color: red;
}
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
thanks for the input.
we are building in a html table and display the results.
var fldText = "There are 10-15 fields in the tables.
So need to highlight all these 15 fields conditionally.
|
|
|
|
|
|
Hello,
I'm looking into taking a course and on the precourse material the question ask...
function NumberFour(value){
let greaterThanFive = false;
// In this exercise, you will be given a variable, it will be called: value
// You will also be given a variable named: greaterThanFive
// Using an 'if' statement check to see if the value is greater than 5. If it is, re-assign greaterThanFive the boolean true.
// Please write your answer in the line above.
return greaterThanFive;
}
How would I know if the value is greater than 5? Is this a trick question... would someone please explain.
Thanks
|
|
|
|
|
Quote: How would I know if the value is greater than 5? Really?
That is the purpose of the course, and the author would have explained the operators and language structure to perform this operation. I recommend taking the course, and also exploring JavaScript language, you can start at MDN; JavaScript | MDN.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
I am working on a cep html panels extension and I am facing this known "thorn" of asynchronous code!!! I know that the most secure way is to use promises and async/await, but my problem is that I can't really understand how I can suit my code to promises and async/await. I believe an example based on my code would really help me.
Here is a small example of my code...
JS FILE CODE:
(function()
{
'use strict';
const csInterface = new CSInterface();
const extensionId = csInterface.getExtensionID();
let psDocumentsLength;
function init()
{
themeManager.init();
$(document).ready(function()
{
setTimeout(function(){check_PSDocumentsLength();
setTimeout(function(){reclaim_PSDocumentsLength();
}, 100);
}, 100);
});
};
function check_PSDocumentsLength()
{
var chosenFunction = 'checkDocumentsLength()';
csInterface.evalScript(chosenFunction, function(result)
{
psDocumentsLength = result;
});
};
function reclaim_PSDocumentsLength()
{
if(psDocumentsLength < 1)
{
alert('There is no opened document!!!');
csInterface.closeExtension()
};
};
init();
}()); JSX CODE:
function checkDocumentsLength()
{
return documents.length;
};
As you can see, in order to avoid the phenomenon of asynchronous code, I am using nested setTimeout(s). Is there anyone who can explain to me how I can do the same thing but using promises and async/await?
Thank you in advance!!!
|
|
|
|
|
Promises really are not that hard. They basically allow you to dynamically attach callbacks to an object, which are execute when you designate within the promise function.
In your case it would look something like this:
function init()
{
themeManager.init();
$(document).ready(function()
{
var promise = new Promise((resolve, reject) => {
try {
var chosenFunction = 'checkDocumentsLength()';
csInterface.evalScript(chosenFunction, function(result)
{
resolve(result < 1);
});
} catch(ex) {
reject(ex);
} finally {
csInterface.closeExtension();
}
}
promise.then(function(value){
if(!value){
alert('There is no opened document!!!');
}
});
promise.catch(function(error){
console.error('checkPSDocument error: ' + error);
});
});
}
"Never attribute to malice that which can be explained by stupidity."
- Hanlon's Razor
|
|
|
|
|
Try something like this:
(async function(){
'use strict';
const csInterface = new CSInterface();
const extensionId = csInterface.getExtensionID();
const runEvalScript = (script) => new Promise(resolve => csInterface.evalScript(script, resolve));
const waitForDom = () => new Promise($);
themeManager.init();
await waitForDom();
var psDocumentsLength = await runEvalScript('checkDocumentsLength()');
if (psDocumentsLength < 1) {
alert('There is no opened document!!!');
csInterface.closeExtension();
}
})(); NB: async functions[^] are not supported in Internet Explorer. Neither are arrow functions[^] or promises[^].
let and const [^] are supported in IE11.
If you need to support IE at all, you'll need to use a "transpiler" to convert your code to ES5.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Dear All,
How do i get the client's windows login name in java based web application.
|
|
|
|
|
There may be some hacks out there, but unless you're on a domain, that should not be possible and would be considered a security risc.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Have your Java-based web app send a current user object to the client, where it can be interpreted by your JS...?
Not 100% sure what you are asking here.
"Never attribute to malice that which can be explained by stupidity."
- Hanlon's Razor
|
|
|
|
|
Hi,
I have an intranet application in which i should be able to get the client machines windows user login. usually our staff login by their employee Id, if i could be able to get the login id based on that i will display the menu list(access control). this functionality i am trying to avoid login phase for intranet application.
|
|
|
|
|
If you're in an Active Directory environment and your users are on Windows computers, you can use Windows Authentication in IIS in order to automatically use their currently logged in claims principal. I don't know the interface for Java, but I'm sure there is one, and it's trivial using asp.net.
"Never attribute to malice that which can be explained by stupidity."
- Hanlon's Razor
|
|
|
|
|
Dear
Nathan Minier ,
Thank you so much.
|
|
|
|
|
// ------- Please begin your work below this line: -------
function exerciseOne(){
// In this exercise, write a simple 'for loop' that starts the variable 'i' at 0 and
// increases i until it reaches 6.
// Fill in the blanks in the parentheses, and then console.log(i) inside of the for loop
(;;)
for(let i=0; i < 7; i++){
console.log("This is i:",i);
}
console.log(str);
// Please write your answer in the line above.
}
}
function exerciseTwo(){
let count = 0;
// In this exercise write your own for loop (you can look at the syntax above).
// It should loop 10 times.
// You are given a variable called: count .
// For each loop reassign count to the current value of count + 1 .
for (var i = 0; i < 10; i++) {
count ++;
}
//Please write your answer in the line above.
return count;
}
//Assignment 13 exercise 1 is showing correct but 2 is undefined
function ClassOne(name, pw, mail){
// Exercise One: In this exercise you will be creating your own class!
// You are currently in the class, you are given three strings, name, pw, and mail.
// You need to create three properties on this class.
// Those properties are: 'username', 'password', and 'email'
// Set the value of username to name,
// Set the value of password to pw,
// Set the value of email to mail
this.username = name;
this.password = pw;
this.email = mail;
}
// Note: Remember you DO NOT need to return anything in a class!
function ClassTwo(name, pw, mail){
// Exercise Two: Now that you have created your own class,
// you will create a class with a method on it.
// In this class create 4 properties: username, password, email, and checkPassword.
// Set the value of username to name,
// Set the value of password to pw,
// Set the value of email to mail
// Set the value of checkPassword to a function.
// The checkPassword function takes a string as it's only argument.
// Using the 'this' keyword check to see if the password on the class is the same as
// the string being passed in as the parameter. Return true or false.
this.username = name;
this.password = pw;
this.email = mail;
this.checkPassword = function(){}
if (this.checkPassword === pw){
return true;
}
}
|
|
|
|