I would like to put a clock on my webpage which should show time and a timer for a particular interval.
Could you please suggest me some open source javascript to do that??
I tried unsuccessfully searching web for flash one's.
Please help.
Thanks,
Mahesh
There is JavaScript function called SetInterval that allows you to pass a callback to be executed on a specified interval of time. You can use it in order to repeat a given action over a period of time. Here is an example:
<script type="text/javascript">
function doSomething() {
alert('yahoo');
}
setInterval(doSomething, 500);
</script>
This will alert 'yahoo' оn every 500 miliseconds.
As for the clock, I suggest that you take a look at the following link
Related
Can someone help me, I want to add time and date to an app without the user having to insert this.
I have figured out how to fix the Date, but not the time.
Can anyone help me ?
Loading a text widget automatically on page refresh
Well, I'm kind of new to appmaker so this isn't necessarily the easiest way to to it. But this works. I added a new text widget named todaysDate to the screen as shown below:
Then I went into clientside script and added this code in ready function.
$(function(){
google.script.run
.withSuccessHandler(upDateToDaysDate)
.getTodaysDate();//this code
google.script.run
.withSuccessHandler(upDateLastRecipient)
.getLastEmailRecipient();//this was already there
});
And I added this function above it because it appears that functions have to be defined before they are used.
function upDateToDaysDate(s){
app.pages.Email.descendants.TodaysDate.value=s;
}
And then in server script I added this function:
function getTodaysDate(){
return Utilities.formatDate(new Date(),Session.getScriptTimeZone(),"E MMM d, yyyy");//for time just add HH:mm:ss to the format parameter
}
When you load the page or preview, the the ready function will call the server script and it will return todays date and upDateTodaysDate() will load it into the todaysDate text widget.
How can I let the user know when they are getting a hot code push?
At the moment the screen will go blank during the push, and the user will feel it's rather weird. I want to reassure them the app is updating.
Is there a hook or something which I can use?
Here's the shortest solution I've found so far that doesn't require external packages:
var ALERT_DELAY = 3000;
var needToShowAlert = true;
Reload._onMigrate(function (retry) {
if (needToShowAlert) {
console.log('going to reload in 3 seconds...');
needToShowAlert = false;
_.delay(retry, ALERT_DELAY);
return [false];
} else {
return [true];
}
});
You can just copy that into the client code of your app and change two things:
Replace the console.log with an alert modal or something informing the user that the screen is about to reload.
Replace ALERT_DELAY with some number of milliseconds that you think are appropriate for the user to read the modal from (1).
Other notes
I'd recommend watching this video on Evented Mind, which explains what's going on in a little more detail.
You can also read the comments in the reload source for further enlightenment.
I can image more complex reload logic, especially around deciding when to allow a reload. Also see this pacakge for one possible implementation.
You could send something on Meteor.startup() in your client-side code. I personally use Bert to toast messages.
I'm developing a web-application in which I have a constant stream of data that is being received every 5 seconds or so in a java servlet (being read from a file written by another application). I want to push this data onto an html page and get it read in javascript so I can graph it in the d3 library.
At the moment I'm using a javascript function that calls the 'doGet' function of the servlet every 5 seconds. I'm worried this is creating a lot of overhead, or that it could be performed more efficiently.
I know it's also possible to run "response.setIntHeader("Refresh", 5);" from the servlet.
Are there any other better ways?
Thanks in advance for the help!
Short polling is currently probably the most common approach to solving the problem you describe
If you can cope with a few seconds lag in notification, then short polling is really simple, here is a basic example:
On page load, call this in your JS:
setInterval(checkFor, 30000);
The above will call a function checkFor() every 30 seconds (obviously, you can change the 30 seconds to any length of time - just adjust the 30000 in the above line according to how regular you want users to be updated).
Then, in your checkForNotifications function, just make an ajax call to your server asking if there are any updates - if the server says yes, then just display the alert using JS, if not (which will be most of the time most likely) then do nothing:
function checkFor(){
$.ajax({
url: "your/server/url",
type: "POST",
success: function( notification ) {
//Check if any notifications are returned - if so then display alert
},
error: function(data){
//handle any error
}
});
}
when I run the code, the thread process before the response.write !! why and how to make them in order ?
insertUser.ExecuteNonQuery()
con.Close()
Response.Write("Done successfully ...")
Thread.Sleep(4000)
Response.Redirect("Default.aspx")
A response is a one-time thing in a web application. You can't "respond a little, do something else, and respond some more." This is especially true when you consider something like Response.Redirect() which modifies the headers of the response. (Essentially, Response.Redirect() will entirely "clobber" any content that you've added to the response so that the user will never see it.)
It looks like what you're trying to do here is:
Show the user a message.
Wait a few seconds.
Send the user to another page.
There are a couple of standard ways to accomplish this. You can either respond with a page that includes step 1 which, in client-side code, performs steps 2 and 3 or you can perform step 3 in server-side code and on the second page perform step 1 (and possibly two, hiding the message after a few seconds).
For example, let's say you want to show the message on Page A, wait a few seconds, then send the user to Page B. Then in Page A you might include something like this:
<script type="text/javascript">
$(function() {
$('#dialog-message').dialog({
modal: true,
buttons: {
Ok: function() {
$(this).dialog('close');
}
},
close: function() {
window.location.href='Default.aspx';
}
});
});
</script>
<div id="dialog-message">Done successfully ...</div>
Using jQuery, what this does is show the user a dialog (using the jQuery UI Dialog) with the intended message, and when the user closes the dialog it then performs the redirect.
You can do it using client side functionality in your code
plese refer following link
http://social.msdn.microsoft.com/Forums/da/sharepointdevelopmentprevious/thread/087c6b95-fe8d-48ea-85e6-b7fbcb777a5c
Web Response will get on the page only after the complete processing of webrequest,ie you can see response after the excution of code completly.So your code is excuting correct order.You can test it by insert Response.End() methord as shown below
insertUser.ExecuteNonQuery()
con.Close()
Response.Write("Done successfully ...")
Response.End();
Thread.Sleep(4000)
Response.Redirect("Default.aspx")
I need to create an control in asp.net mvc that allows the user to select a time that is anywhere between 7am and 7pm with quarter hour segments. i.e. The user could select:
7:00am
7:15am
7:30am
7:45am
8:00am
8:15am
....
....
7:00pm
Currently ive got a dropdown that comprises of a select list with entries for every single time slot. Just wondering if anyone knows a cleaner and or better UI experience for the user.
Thanks in advance
I suggest you looking into a JQuery addon: Timepicker.
It is easy to set up, simple in use, and it looks great.
For easy access put this code into your Layout view in the section:
<script type="text/javascript">
$(function() {
$('.timepicker').live('mousedown', function () {
$(this).timepicker({
stepMinute: 15,
hourMin: 7,
hourMax: 19
});
});
});
</script>
In your view have something like this:
#Html.TextBoxFor(m => m.Time, new { #class = #"timepicker" })
Another JQuery option is Timepickr. I don't like it as much as the first one, but it still is a good option.
The Telerik DateTime Picker can handle this. It defaults to an interval every half-hour, but you can configure it to display any interval you want, such as your 15 minutes. It integrates with their date picker, in case you want a combined datetime picker.
It is a drop-down list, like yours, but they tend to have a lot of whiz-bang chrome on their stuff, so you might be able to configure it in other display formats.
I believe the Telerik MVC controls are free to download and use, but you have to pay if you want support.