trigger file upload dialog using javascript/jquery

You mean something like this? http://jsfiddle.net/CSvjw/ $(‘input[type=text]’).click(function() { $(‘input[type=file]’).trigger(‘click’); }); $(‘input[type=file]’).change(function() { $(‘input[type=text]’).val($(this).val()); }); Note, though, that the value given by the file input is fake for security reasons. If you want to just have the file name show up, you can cut out the slashes. Here’s an example of how to do it using … Read more

Measuring text width/height without rendering

Please check this. is a solution using canvas function get_tex_width(txt, font) { this.element = document.createElement(‘canvas’); this.context = this.element.getContext(“2d”); this.context.font = font; return this.context.measureText(txt).width; } alert(‘Calculated width ‘ + get_tex_width(“Hello World”, “30px Arial”)); alert(“Span text width “+$(“span”).width()); Demo using EDIT The solution using canvas is not the best, each browser deal different canvas size. Here is … Read more

How do I keep whitespace formatting using PHP/HTML?

use the <pre> tag (pre formatted), that will use a mono spaced font (for your art) and keep all the white space <pre> text goes here and here and here and here Some out here ▄ ▄█▄ █▄ ▄ ▄█▀█▓ ▄▓▀▀█▀ ▀▀▀█▓▀▀ ▀▀ ▄█▀█▓▀▀▀▀▀▓▄▀██▀▀ ██ ██ ▀██▄▄ ▄█ ▀ ░▒ ░▒ ██ ██ ▄█▄ █▀ … Read more

How can I calculate the difference between two times that are in 24 hour format?

You can just subtract the hours right away doing it this way var valuestart = $(“select[name=”timestart”]”).val(); var valuestop = $(“select[name=”timestop”]”).val(); //create date format var timeStart = new Date(“01/01/2007 ” + valuestart).getHours(); var timeEnd = new Date(“01/01/2007 ” + valuestop).getHours(); var hourDiff = timeEnd – timeStart; Here’s the working fiddle http://jsfiddle.net/VnwF7/4/ UPDATE – to calculate if … Read more

How do I open a URL from C++?

Your question may mean two different things: 1.) Open a web page with a browser. #include <windows.h> #include <shellapi.h> … ShellExecute(0, 0, L”http://www.google.com”, 0, 0 , SW_SHOW ); This should work, it opens the file with the associated program. Should open the browser, which is usually the default web browser. 2.) Get the code of … Read more

Create links in HTML canvas

There is no easy way. You will have to draw the link text onto the canvas and then check for mouseclicks. Here is a demo html page: <html> <head> <script type=”text/javascript”> var canvas = document.getElementById(“myCanvas”); var ctx; var linkText=”https://stackoverflow.com”; var linkX=5; var linkY=15; var linkHeight=10; var linkWidth; var inLink = false; // draw the balls … Read more

Set rowSpan or colSpan of a child of a GridLayout programmatically?

GridLayout gridLayout = (GridLayout)findViewById(R.id.tableGrid); gridLayout.removeAllViews(); int total = 12; int column = 5; int row = total / column; gridLayout.setColumnCount(column); gridLayout.setRowCount(row + 1); for(int i =0, c = 0, r = 0; i < total; i++, c++) { if(c == column) { c = 0; r++; } ImageView oImageView = new ImageView(this); oImageView.setImageResource(R.drawable.ic_launcher); GridLayout.LayoutParams param … Read more