Do anyone has the source caman js example on site? - camanjs

I am trying to create the functionality like this page url : http://camanjs.com/examples/ for image filters.
I have tried with this code.
var img_map = Caman("#test-canvas", "../images/test1_640.jpg");
//update brightness
function update_brightness(value){
//img_map.revert();
img_map.brightness(value).render();
}
//update contrast
function update_contrast(value){
//img_map.revert();
img_map.contrast(value).render();
}
The changes on image are not like the site i am refering.
The main issue is when i increase any control then it works fine. But when I try to decrease the control value then it does not work.
To control the value for brightness or contrast i have used "range" input.
<img id="test-image" src="../images/test1_640.jpg" />
<canvas id="test-canvas"></canvas>
brightness
<input onchange="update_brightness(this.value);" type ="range" min ="-100" max="100" step ="10" value ="0"/>
contrast
<input onchange="update_contrast(this.value);" type="range" min="-100" max="100" step="" value="0">

EDIT: I just compiled the coffeescript out to JavaScript and put it in a repo of my own for (hopefully) easier use:
https://github.com/nbieber/CamanJS-example
You can find the original source here: https://github.com/meltingice/CamanJS-Site/blob/master/_assets/javascripts/examples.js.coffee
It's in coffeescript, though.

You can add
this.revert(true);
in your update_brightness and update_contrast functions.
function update_brightness(value){
//img_map.revert();
this.revert(true);
img_map.brightness(value).render();
}

Related

JSTL loop through Array to NOT display content

I'd like to use an "Array" in JSTL that looks like this
<c:set var="hideMe" value="${['A','B','C','D']}" scope="application" />
I also have a global VAR called ${checkPageName} which has the name of the current page I am on in it, so I can check against it, as part of the logic (e.g. <c:if test="${checkPageName != hideMe}"> ... </c:if>)
The logic behind this is that if A, B, C or D exist then I will prevent a specific piece of information from being displayed to the user.
Does anyone know how I loop through a JSTL array?
The logic should then decide that if A, B, C or D DO NOT exist, then we display specific information to the user.
I have tried;
<c:forEach items="${hideMe}">
<c:set var="hide" value="true" />
</c:forEach>
<c:if test="${hide != 'true'}">
<div class="showMe">
<h1>Hello Sweetie</h1>
</div>
</c:if>
Could someone please point me in the right direction?
UPDATE: I have now fixed this myself using <c:forTokens>, see the solution below
So I figured it out in the end;
<c:set var="hideMe" value="false" />
<c:forTokens items="A,B,C,D" delims="," var="excludeDisplay">
<c:if test="${checkPageName == excludeDisplay}">
<c:set var="hideMe" value="true" />
</c:if>
</c:forTokens>
<c:if test="${hideMe == 'false}">
DO SOMETHING
</c:if>
checkPageName is a global variable I am checking against in my code to validate well, page names...
So I set a default VAR called hideMe with a value of false, I then use forTokens to create a VAR called excludeDisplay for values A, B, C or D.
I then check these values against my global variable and if they match overwrite the var hideMe with a value of true, this is then used to trigger the content I want to show. If the VAR is false show the content, if it is true, do nothing.
I hope this helps someone else, and I am happy to elaborate on some of the murkier points if anyone wants any more information...

sendKeys with p:calendar does not yield reliable results from one run to another

I am using selenium to fill a p:calendar field. Instead of using the date picker, I send the keys to the field directly.
webDriver.findElement(By.id("theId").sendKeys("06031984");
Before and after this, I am interacting with various other elements on the page. With each run, I am getting different values appearing in my date input field - and rarely are these the correct ones:
40.60.3198
98.40.6031
06.03.1984 <- Correct
The order of the keys seems to be shifted, probably by the ajax calls in the p:calendar:
<p:calendar id="theId" styleClass="date-input"
binding="#{date}" navigator="true"
value="#{aView.date}"
validator="dateValidator"
yearRange="#{validatorService.dateRange}"
pattern="dd.MM.yyyy" mask="99.99.9999" readonlyInput="false"
readonly="false" required="true" showOn="button"
requiredMessage="#{i18n['aMsg']}"
locale="de">
<p:ajax event="dateSelect"
update="many elements"
oncomplete="updateTabbing();" />
<p:ajax event="change"
update="many elements"
oncomplete="updateTabbing();" />
</p:calendar>
Is there a way to ensure the correct value ends up in the field ?
So far I find working with Selenium (and a JSF page) to be a bit of a hassle.
We can try adding some wait and send tab key
or injecting java script for the value would Solve this problem
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("document.getElementsByid('theId').value = '06.03.1984';");
Please let me know if its solving the problem.

bootsfaces selectMultiMenu don't show selected values

I want to pre-charge a selectMultiMenu with values I already have in the application.
For example:
<b:panelGrid colSpans="2,2,8">
<h:outputLabel value="Traffic light color" />
<b:selectMultiMenu value="#{semaphoreBean.color}" >
<f:selectItems value="#{semaphoreBean.colors}" var="c" itemValue="#{c}" itemLabel="#{c}"/>
</b:selectMultiMenu>
</b:panelGrid>
if var color = "green, red" before than I load the page, I don't see in my selectMultiMenu 2 items selected.
¿What do I have to do to pre-load that field with those values?
Maybe that's because of the space between the entries. I take it you've take the example from our showcase. So I've added this line to our showcase, and it works like charm:
private String color = "green,red";
Finally I found out data format was wrong so I fix it and works.
Thank you for helping.

How to upload a file using VBA (input file)

I have this CSV file that it need to be uploaded in a WebSite , but this website have an input type file.
I know its pretty impossible because i spent like three weeks loking for an answer,i found another way to upload the file WITHOUT USING THE INPUT TYPE FILE* so i was wondering if anyone found a solution to my probleme
This is what i have :
This is my firt attempt like any average personne using VBA :
Set UploadCSV = IEDoc.getElementById("namecsv")
UploadCSV.Value = "something\toto.csv"
This is my input type file:
<input name="filename" class="text align_center" id="nomfichiercsv" type="file" size="24" accept="text/html,text/plain" value=""/>
Thank's
I tried the SendKeys function no luck
Like mentioned you can do this in an Eclipse project using the Java Selenium driver. Afterwards part of the code could look like this;
driver.findElement(By.id("nomfichiercsv")).sendKeys(UploadCSV);
driver.findElement(By.id("submit")).click();
In VBA, you can use the below code after you have identified the element:
driver.FindElementById("Id of the element").SendKeys ("path to the input file")
If the frame changes when you are trying to upload the file, you will need to switch to the new frame.
If Id is not present for the element, use other Web Element selector methods.

Using Perl to get Checked and put VALUE in an array

I'm new to Perl and trying to check to see if a series of checkboxs on an HTML page are checked or not. Each checkbox has a different numeric value I want to add to an array in Perl. I keep getting an undef value. I've combed the web for a reason this is not working and finally broken down to ask for help. For now I just want to display the values retrieved in my log. I'm expecting to see (1, 2) in my results when the checkbox is checked. Can anyone see anything wrong with the code below or offer a suggestion as to why I'm getting an "undefined" array? Is there a way to test for connection to the checkbox in question from Perl?
HTML:
<input type="checkbox" name="Shipping" id="checkFXG" value="1" enabled />
<input type="checkbox" name="Shipping" id="checkFX2" value="2" enabled />
PERL:
use CGI;
...
sub updateShipping;
my $p;
my $self = shift;
my $cgi;
my $sIDquery = CGI->new;
my $param = $sIDquery->Vars;
my #sID = $param->{'Shipping'}; # Grab VALUE from checkbox
my $sID;
foreach $sID(#sID) { # Loop through array displaying each Shipping ID
warn "**** sID : [$sID]";
}
}
To get multiple parameters with the same name, don't use the Vars method, do:
my #values = $sIDquery->param('Shipping');
There are very few cases where you'd ever want to use Vars. It is especially unlikely to do what you want for parameters that may not be present (such as checkboxes) or may have more than one value.

Resources