how to change Jscolor to remove hex - javascript

Hey if anybody knows http://jscolor.com/ I'm trying to have it in html without showing the hex code. I can't find where to hide the text in the long js file, any tips would be appreciated.

Use {valueElement:null}. Example:
<button
class="jscolor {valueElement:null,value:'66ccff'}">
</button>
More info:
http://jscolor.com/examples/#example-custom-look

Related

JavaScript unable to scroll <textarea> context while using NicEdit

I am a novice coder so I am having trouble getting this to work.
I have a javascript that scrolls the content of a <textarea> tag to bottom on button click, but when I add NicEdit plugin in it the script doesn't work.
I've already tried all the alternative ways to get it to work by creating external divs and wrappers but I'm sure it's coz of NicEdit.
Working Script Without NicEdit: http://jsfiddle.net/gab4qhc1
Not working script with NicEdit: http://jsfiddle.net/sgdLzjau
Kindly help me to get the script working along with nicedit.
Thanks
First of all, I would recommend you to use CKEditor or TinyMCE because nicEdit is not in active development (http://nicedit.com/docs.php).
Let's come to the problem, There was an error in console bkLib.domLoad[i] is not a function(I don't know what is bkLib) so what I did is, I removed that function and removed JS code
nicEditors.allTextAreas({buttonList : ['fontSize','bold','italic','underline','strikeThrough','subscript','superscript']});
from HTML file and added in the script file (I think it is good to separate JS and HTML code if possible) as following
HTML
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.0.js"></script>
<script src="http://js.nicedit.com/nicEdit-latest.js" type="text/javascript"></script>
<textarea id="textarea" cols=30 rows=5 >
Please presse enter Please presse enterPlease presse enter
Please presse enterPlease presse enterPlease presse enter
Please presse enterPlease presseenter
Please presse enterPlease presse enter
Please presse enter
</textarea>
<button id="button">click</button>
Script
$(document).ready(function(){
nicEditors.allTextAreas({buttonList : ['fontSize','bold','italic','underline','strikeThrough','subscript','superscript']});
$("#button").click(function(){
var textArea = $('.nicEdit-main');/*replace #textarea with .nicEdit-main*/
textArea.scrollTop( textArea[0].scrollHeight - textArea.height() );
});
});
(Not need to modify CSS)
Why #textarea selector is not working and .nicEdit-main is working
So, the reason behind this is every HTML based text editor use there own wrapper instead of textarea to make it more customizable like to apply bold, italic effects and in nicEdit they use a div with class nicEdit-main.
I hope this will help you to solve your problem. Happy Coding... :)

How to find the file that has a word i want to modify in HTML

I have been trying to modify some of part of HTML but I am stuck at this moment.
I am looking for a word, the file that includes the word that I want to modify or delete on HTML exactly.
please check following html code :
<input class="wSearchField no-filter" type="text"
data-class="no-filter: !#KEY_FEATURE.filter"
data-attr="placeholder: #KEY_LNG.Search;aria-label:#KEY_LNG.Search" data-value="KEY_SEARCH_TERM"
data-focus="#focusin_searchbox(true)"
data-blur="$sc.handleFocusOut('focusin_searchbox')|timeout:200"
data-keyup="$mc.newSearch(node.value, event.keyCode),$sc.handleKey(event)|debounce:150"
tabindex="7" placeholder="-Search-" aria-label="-Search-">
I want to modify right here placeholder="-Search-" (at the last line) as placeholder="-"
Which file does have the word "Search"? I am not able to find it out of many files.
Thanks have a great day
Do you mean this?
document.getElementsByTagName("input")[0].setAttribute("placeholder", "-");
https://codepen.io/anon/pen/wYVgmm
you can set by javascript
document.getElementsByClassName("wSearchField").placeholder = "Type name here..";
or you can try using jquery
$('.wSearchField').attr("placeholder", "Type your answer here");
Okay, i found the file related to that text. it's included on javascript file as a part of code.
Thank you guys

Trying to change value of Textarea (using Skulpt)

Okay, so I'm using Skulpt to program Python on a webpage.
I would like the text in the interpreter change once a button is clicked.
But no matter how I try, the code in the text area doesn't change.
However, if I 'alert' the value of the text area, it brings up the changed version, indicating that the button works.
I've also found this question:
Set value of textarea in jQuery
but nothing in here helped in my case :(
Here is how I try it:
<textarea id="theTextArea">print 'Hello World!'</textarea>
<div id="controls">
<button type="button" onclick="replaceCode()">Replace</button>
<button type="button" onclick="testAlert()">Alert Me</button>
</div>
<script>
function replaceCode(){
document.getElementById('theTextArea').value = "print 'Thats new code'";
};
function testAlert(){
alert(document.getElementById('theTextArea').value);
};
</script>
Also I've tried changing .innerHTML, .text and nothing actually replaced the text in the textarea.
If anyone thinks it could help, I could add the full HTML document with the whole Skulpt setup for online python interpreter, in case it somehow doesn't let me change the value of the textarea in a regular way. But I prefer not to have a wall of code for now if it's not needed for now.
You forgot brackets in your onclicks. You should use HTMLTextAreaElement.innerHTML to change the textarea's content
function replaceCode(){
document.getElementById('theTextArea').innerHTML = "print 'Thats new code'";
};
function testAlert(){
alert(document.getElementById('theTextArea').innerHTML);
};
<textarea id="theTextArea">print 'Hello World!'</textarea>
<div id="controls">
<button type="button" onclick="replaceCode()">Replace</button>
<button type="button" onclick="testAlert()">Alert Me</button>
</div>
So it turns out Skulpt was getting in my way of modifying python code on a button click. I needed to use a function which was defined probably in one of the imported documents which come with Skulpt. The function looks like this:
editor.setValue("print 'Thats new code'");
And then it actually changes in the textarea :)

Why doesn't my JavaScript statement change the background image properly?

I am trying to set a background Image of a div with this code .But it is not working. If i use backgroundColor instead then it works fine .
Can anyone tell me whats wrong with this .
Sorry for noob question.
<button onclick="document.getElementById('ab').style.backgroundImage='url("pexel.jpg")'">Click me</button>
Syntax error, see below
<button onclick="document.getElementById('ab').style.backgroundImage='url(pexel.jpg)'">Click me</button>
Use 'url(pexel.jpg)' instead of 'url("pexel.jpg")'
The quotes in the url() assignment are what's causing the issue.
You need to escape them correctly.
<button onclick="document.getElementById('ab').style.backgroundImage='url(\'pexel.jpg\')';">Click me</button>

Using Javascript to display an input (A number) from a user to a div

I have looked at the other questions that are asking similar things to this question however when I attempted to create my own I can't get it to work properly and i dont understand why. It's only very basic before I introduce it into a more complex system I just wanted to try and get the functionality done.
This is my HTML;
<div id="test2">
Please enter a number: <input type="number" id="RValue1">
<button id="test" onclick="R1Value()">Change Value</button>
</div>
<div id="ShowR1"></div>
And this is the JavaScript;
function R1Value() {
var t = document.getElementById("RValue1");
var div = document.getElementById('ShowR1');
div.innerHTML = t.value;
}
I have made this fiddle to save time and so you can have a look at it,
http://jsfiddle.net/2ufnK/52/
I can't see why this doesn't seem to work so if anyone can see why I would really appreciate it. Thanks.
Try it without the button:
Try out this: http://jsfiddle.net/2ufnK/56/
Type in the text, then you can just call the, ".value", method to get its text. Then everything else works the way you've written it.

Categories

Resources