Daily Archives

Articles indexed Thursday January 6 2011

Page 11/36 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • Does heavy library and snippet codes usage make you a bad programmer?

    - by Henrik P.
    Overall I'm in programming for about 8 years now and it seems to me that I'm relying more and more on open source libraries and snippets (damn you GitHub!) to "get the job done". I know that in time I could write me own implementation but I like to focus on the overall design. Is this normal (non cooperate environment)? Does it make you a bad programmer if "programming" is nothing more than cluing different libraries together. Feels like it. I know about "don't reinvent the wheel" but what happens when you don't invent a single wheel anymore. What's your take on this?

    Read the article

  • Best strategy (tried and tested) for using Box2D in a real-time multiplayer game?

    - by Simon Grey
    I am currently tackling real-time multiplayer physics updates for a game engine I am writing. My question is how best to use Box2D for networked physics. If I run the simulation on the server, should I send position, velocity etc to every client on every tick? Should I send it every few ticks? Maybe there is another way that I am missing? How has this problem been solved using Box2D before? Anyone with some ideas would be greatly appreciated!

    Read the article

  • Inheritance using prototype / "new"

    - by mikkol
    Hi I'm new in Javascript OO and want to know more about about inheritance. Hope you can provide some advice! I see this great post: How to "properly" create a custom object in JavaScript? which talks about how a class is inherited as I see in other websites, ex.: function man(x) { this.x = x; this.y = 2; } man.prototype.name = "man"; man.prototype.two = function() { this.y = "two"; } function shawn() { man.apply(this, arguments); }; shawn.prototype = new man; The above post claims that in order not to call "man"'s constructor while inheriting, one can use a helper like this instead: function subclassOf(base) { _subclassOf.prototype= base.prototype; return new _subclassOf(); } function _subclassOf() {}; shawn.prototype = subclassOf(man); While I understand its intention, I don't see why we can't call shawn.prototype = man.prototype; I see it works exactly the same. Or is there something I'm missing? Thanks in advance!

    Read the article

  • What HTTP error code should I use for unauthorised access to a protected image?

    - by Bala Clark
    I am writing a web application that has secure images uploaded by users. These images are only available to the owner when logged in. I am wondering what the best HTTP error code to throw in the case of unauthorised access? Would a 404 not found, or a 403 unauthorised be better? I am leaning towards the 403, but would it be better to hide the fact that the resource exists to unauthorised users be better?

    Read the article

  • Distributing WPF apps to a legacy user base: How seamless is it?

    - by Christian Nunciato
    I'm considering developing a WPF application, to be hosted by a legacy Windows app (C++), and I'm trying to get a better sense of how feasible it'll be to do so, given the broad user base I'm targeting. Knowing WPF targets .NET 3.5, I'm looking for some insight as to what the field looks like right now -- who's already got the runtime, whether it's distributed by Windows Update, if so, how (e.g., as an optional or required download, to which operating systems, etc.), whether XP pre-XP2 supports it (and how), and so on. The current version's got many thousands of users, using all manner of Windows operating systems, and while I'd very much like to leverage WPF to breathe some life into their user experience, I want to make sure I'm not shutting anyone out by doing so, or burdening them with a download they might have to do manually. I realize most, or all, of this information's out there already, in various places, but I figured I'd ask here first, since I'm sure some of you've probably already gone down this road and have valuable experiences to share. Thanks in advance!

    Read the article

  • EndOfStreamException caused by spammer (c#/asp.net)

    - by maxp
    I have a contact page on my site that seems to have been latched on to by a spammer. The error itself is: System.IO.EndOfStreamException: Unable to read beyond the end of the stream. at System.IO.BinaryReader.ReadByte() at System.Web.UI.ObjectStateFormatter.DeserializeIndexedString(SerializerBinaryReader reader, Byte token) at System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) Google turns up little. I assume they are submitting an invalid viewstate, but the exception has no line number so im stumped.

    Read the article

  • Developing and deploying games for Windows, Mac (& Linux)

    - by nornagon
    I want to write games that run on all the major platforms. I also want people to be able to play them by downloading a file and double clicking it. That means a single .exe/.app file. I'm happy to use OpenGL directly for graphics. What I don't know how to do is show a window, handle mouse/keyboard input and play sounds in a cross-platform manner. I don't really mind what the underlying language is, as long as it isn't C++ or Java. C#, Ruby or Python would be preferable, in that order :) Please, SO, save me from having to write Flash games!

    Read the article

  • Object model design choice

    - by spinon
    I am currently working on a ASP.NET MVC reporting application using C#. This is a redesign from a PHP application that was just initially thrown together and is now starting to gain some more traction. SowWe are in the process of reworking the backend to have a more OO approach. One of the descisions I am currently wrestling with is how to structure the domain objects. Since 95% of the site is readonly I am not sure if the typical approaches are practical. Should I create domain objects for the primary pieces of the application (ticket, assignment, assignee) and then create static methods off of these areas to pull the reporting data? Or should I just skip that part and create the chart data classes and have some get method off of these classes? It's not a real big application and currenlty I am the only one developing on it. But I feel torn as to which approach. I feel that the first one is the better choice but maybe overkill given that the majority of uses is for aggregate reporting. Anybody have some good insight on why I should go one way or another?

    Read the article

  • How to force a node inside tiny mce ?

    - by KutePHP
    Hi All, I'm using tiny mce for my project and want to validate the node inside the tiny mce. On click of a text element, let's say a paragraph with some id, I load editor for the element. But, sometimes if user replaces the whole content, the node and its HTML is lost. I want to retain this node and only the content is removed. The node can be a paragraph or heading or ul or ol. EDIT : I'm providing dummy text such as "Lorem epsum .....". User will be removing this dummy text and add his content. How can I accomplish this ?

    Read the article

  • WPF DataGrid Vs Windows Forms DataGridView

    - by Mrk Mnl
    I have experience in WPF and Windows Forms, however have only used the Windows Forms DataGridView and not the WPF DataGrid (which was only included in .Net 4 or could be added to .Net 3.5 from Codeplex, I understand). I am about to devlop an app using one of these controls heavily for large amounts of data and have read performance is an issue with the WPF DataGrid so I may stick to the Windows Forms DataGridView.. Is this the case? I do not want to use a 3rd party control. Does the Windows Forms DataGridView offer significant performance over the WPF DataGrid for large amounts of data? If I were to use WPF I would prefer to use .Net 3.5S SP1, unless the DataGrid in the .Net 4 is significantly better? Also I want to use ADO with DataTable's which I feel is better suited to Windows Forms..

    Read the article

  • how to Calling JavaScript in a WebBrowser control from C# in such a situation

    - by weahappy
    sorry, my poor English,my question is as following: Calling JavaScript in a WebBrowser control from C# in ordinary way: JavaScript function showMe() { ... } C# webBrowser1.Document.InvokeScript("showMe"); that is ok! but how to call in such situation: html: <a href="javascript:void(0);" onclick="App.followcancel('1880161672',this,'0','A','B');return false;">hello</a> c#: webBrowser1.Document.InvokeScript(????????) I don't know how to write the correct paremeter to achieve the onclick's javascript anyone help me,thanks a lot

    Read the article

  • How to check using a script if project is opened in XCode?

    - by delirus
    Hi, I'd like to introduce build number feature for my iPhone project and increase it automatically with every commit to my git repo. I plan to do it using Apple's agvtool, which recommends that project is not opened in XCode at the time So my questions are: 1) So far I know that I need to make an executable script from .git/hooks/pre-commit.sample. How to do the scripting to check if certain project is opened in XCode? 2) pre-commit.sh will be executed upon calling git commit with no args, so whenever someone will commit with -a option, I won't have my build number updated. Is there any way to workaround this? Cheers

    Read the article

  • Customized listfield with image displaying from a url

    - by arunabha
    I am displaying a customized list field with text on the right side and image on the left side.The image comes from a URL dynamically.Initially i am placing a blank image on the left of the list field,then call URLBitmapField class's setURL method,which actually does the processing and places the processed image on top of the blank image.The image gets displayed on the list field,but to see that processed image i need to press any key or click on the list field items.I want the processed image to be displayed automatically in the list field after the processing.Can anyone tell me where i am getting wrong? import java.util.Vector; import net.rim.device.api.system.Bitmap; import net.rim.device.api.system.Display; import net.rim.device.api.ui.ContextMenu; import net.rim.device.api.ui.DrawStyle; import net.rim.device.api.ui.Field; import net.rim.device.api.ui.Font; import net.rim.device.api.ui.Graphics; import net.rim.device.api.ui.Manager; import net.rim.device.api.ui.MenuItem; import net.rim.device.api.ui.UiApplication; import net.rim.device.api.ui.component.BitmapField; import net.rim.device.api.ui.component.Dialog; import net.rim.device.api.ui.component.LabelField; import net.rim.device.api.ui.component.ListField; import net.rim.device.api.ui.component.ListFieldCallback; import net.rim.device.api.ui.component.NullField; import net.rim.device.api.ui.container.FullScreen; import net.rim.device.api.ui.container.MainScreen; import net.rim.device.api.ui.container.VerticalFieldManager; import net.rim.device.api.util.Arrays; import net.rim.device.api.ui.component.ListField; public class TaskListField extends UiApplication { // statics // ------------------------------------------------------------------ public static void main(String[] args) { TaskListField theApp = new TaskListField(); theApp.enterEventDispatcher(); } public TaskListField() { pushScreen(new TaskList()); } } class TaskList extends MainScreen implements ListFieldCallback { private Vector rows; private Bitmap p1; private Bitmap p2; private Bitmap p3; String Task; ListField listnew = new ListField(); private VerticalFieldManager metadataVFM; TableRowManager row; public TaskList() { super(); URLBitmapField artistImgField; listnew.setRowHeight(80); listnew.setCallback(this); rows = new Vector(); for (int x = 0; x <3; x++) { row = new TableRowManager(); artistImgField = new URLBitmapField(Bitmap .getBitmapResource("res/images/bg.jpg")); row.add(artistImgField); String photoURL = "someimagefrmurl.jpg"; Log.info(photoURL); // strip white spaces in the url, which is causing the // images to not display properly for (int i = 0; i < photoURL.length(); i++) { if (photoURL.charAt(i) == ' ') { photoURL = photoURL.substring(0, i) + "%20" + photoURL.substring(i + 1, photoURL.length()); } } Log.info("Processed URL: " + photoURL); artistImgField.setURL(photoURL); LabelField task = new LabelField("Display"); row.add(task); LabelField task1 = new LabelField( "Now Playing" + String.valueOf(x)); Font myFont = Font.getDefault().derive(Font.PLAIN, 12); task1.setFont(myFont); row.add(task1); rows.addElement(row); } listnew.setSize(rows.size()); this.add(listnew); //listnew.invalidate(); } // ListFieldCallback Implementation public void drawListRow(ListField listField, Graphics g, int index, int y, int width) { TableRowManager rowManager = (TableRowManager) rows.elementAt(index); rowManager.drawRow(g, 0, y, width, listnew.getRowHeight()); } protected void drawFocus(Graphics graphics, boolean on) { } private class TableRowManager extends Manager { public TableRowManager() { super(0); } // Causes the fields within this row manager to be layed out then // painted. public void drawRow(Graphics g, int x, int y, int width, int height) { // Arrange the cell fields within this row manager. layout(width, height); // Place this row manager within its enclosing list. setPosition(x, y); // Apply a translating/clipping transformation to the graphics // context so that this row paints in the right area. g.pushRegion(getExtent()); // Paint this manager's controlled fields. subpaint(g); g.setColor(0x00CACACA); g.drawLine(0, 0, getPreferredWidth(), 0); // Restore the graphics context. g.popContext(); } // Arrages this manager's controlled fields from left to right within // the enclosing table's columns. protected void sublayout(int width, int height) { // set the size and position of each field. int fontHeight = Font.getDefault().getHeight(); int preferredWidth = getPreferredWidth(); // start with the Bitmap Field of the priority icon Field field = getField(0); layoutChild(field, 146,80); setPositionChild(field, 0, 0); // set the task name label field field = getField(1); layoutChild(field, preferredWidth - 16, fontHeight + 1); setPositionChild(field, 149, 3); // set the list name label field field = getField(2); layoutChild(field, 150, fontHeight + 1); setPositionChild(field, 149, fontHeight + 6); setExtent(360, 480); } // The preferred width of a row is defined by the list renderer. public int getPreferredWidth() { return listnew.getWidth(); } // The preferred height of a row is the "row height" as defined in the // enclosing list. public int getPreferredHeight() { return listnew.getRowHeight(); } } public Object get(ListField listField, int index) { // TODO Auto-generated method stub return null; } public int getPreferredWidth(ListField listField) { return 0; } public int indexOfList(ListField listField, String prefix, int start) { // TODO Auto-generated method stub return 0; } }

    Read the article

  • Textmate, open file at Caret

    - by amjags
    I bet this is really obvious but I can't find how to open the linked file that the Caret is currently on in Textmate. For example in the likes of Dreamweaver you can click in the index.html portion of <a href"index.html" hit cmd-D and it opens this file in a new tab. Is this possible? Would also be good to do this with <img src="image.jpg" to open the file directly into Photoshop. Solved! Solution for Patrick below. I used a modified version of Daustin777's example above to create a Command called OpenatCaret. The command is: open "$TM_PROJECT_DIRECTORY"/"$TM_SELECTED_TEXT" I then extended this by installing a macro which allowed you to select a path between double quotes but not including the quotes. I got this from the macromates board here. http://lists.macromates.com/textmate/2009-June/028965.html To wrap them both together I put my cursor in a path and recorded a new macro where I run the "Select within double quotes" macro and then the OpenatCaret command. I then named this OpenProjectFileAtCaret and bound this macro to cmd-D. Works a treat and is used all the time. Just make sure you have the correct default apps setup for each file type you are opening eg. Textmate for php, asp, html and it will open them in a new tab.

    Read the article

  • Screen recorder for tracking back your steps while debugging?

    - by hstoerr
    I am wondering whether there is a screen recorder that is usable for checking what exactly you did a couple of minutes ago while debugging, or just checking what value for a variable was displayed the last time you hit that breakpoint etc. (Of course this latter question would be something terrific for an IDE to implement, but I've never seen something like that so far. :-) For this you would need a screen recorder that could record all day and preferably automatically delete the recording the recording that is, say, older than an hour. Probably the recording format should be something that is good for screen recording instead of natural scenes. Do you know a screen recorder like that or at least one that comes close?

    Read the article

  • RESTful web service, PUTting an unnamed resource?

    - by James L
    I have a back-end service that creates unique identifiers for resources. The general idea is that resources are saved and versioned, so you can perform: GET http://service/sales/targets/7818181919/latest or GET http://service/sales/targets/7818181919/4 for version 4, and so on. My question is about the most correct way to upload these resources in the first place. How about: PUT http://service/sales/targets/ returning 303 See other /service/sales/targets/ It seems a little wrong as you should PUT and GET from exactly the same place using a resource-oriented interface, but I can't think of a better option. Any ideas?

    Read the article

  • Simple question about the lunarlander example.

    - by Smills
    I am basing my game off the lunarlander example. This is the run loop I am using (very similar to what is used in lunarlander). I am getting considerable performance issues associated with my drawing, even if I draw almost nothing. I noticed the below method. Why is the canvas being created and set to null each cycle? @Override public void run() { while (mRun) { Canvas c = null; try { c = mSurfaceHolder.lockCanvas();//null synchronized (mSurfaceHolder) { updatePhysics(); doDraw(c); } } finally { // do this in a finally so that if an exception is thrown // during the above, we don't leave the Surface in an // inconsistent state if (c != null) { mSurfaceHolder.unlockCanvasAndPost(c); } } } } Most of the times I have read anything about canvases it is more along the lines of: mField = new Bitmap(...dimensions...); Canvas c = new Canvas(mField); My question is: why is Google's example done that way (null canvas), what are the benefits of this, and is there a faster way to do it?

    Read the article

  • jQuery load() problem with html that contain jQuery plugin

    - by Victorgalaxy
    FYI, here is my code: [index.html] <script type="text/javascript" src="js/script.js"></script> [script.js] $(document).ready(function() { $('#buttonEphone').click(function() { $('#apDiv2').load("ePhone.html, #content"); }); }); "ePhone.html" contain some lightbox effect. (making use of code below) [ePhone.html] <script type="text/javascript" src="js/prototype.lite.js"></script> <script type="text/javascript" src="js/moo.fx.js"></script> <script type="text/javascript" src="js/litebox-1.0.js"></script> The Litebox plugin also required to add onload="initLightbox()" within the BODY tag of ePhone.html. From the above code, I can load ePhone.html's content(#content div) to my (apDiv2) of my index.html. However, the lightbox effect is no longer work. I've also try loading the whole html instead of only #content: $('#apDiv2').load('ePhone.html'); but it still doesn't work. Please help, thx

    Read the article

  • JBoss envers and huge audit tables

    - by LeChe
    All, I am auditing my JEE application with JBoss Evers and the nature of my application causes the audit table to grow very fast. The historic data is queried infrequently and access time is not really an issue, apart from the data from the last week. This data IS queried frequently and access needs to be fast. Ideally, I would split the data and distribute it over two tables, with the older data in compressed format. Unfortunately, Envers does not allow spreading data over multiple tables as far as I can tell from the docs. Does somebody have any idea what would be the best way to achieve this (if possible while still using Envers)? Cheers, LeChe

    Read the article

  • Bound a treeview control to user-defined complex type using EF 4

    - by GIbboK
    Hi, I use Asp.net, SQL 2008 and EF 4. I need display hierarchy data in a treeview control, Data is stored in a DB that use HierarchyId. Unfortunately, EF4 doesn't support HierarchyId. So in this case, I thought to have a stored procedure that deals with my hierarchy and return a result set back to EF that EF4 can turn into a collection of user-defined complex type that can then be bound directly to the treeview control. I imported a SPROC in EF 4 using Import Function and now I have a Complex DataType called: CategoryHierarchy_Result An image of my Model: Here some data from the Complex Type (in a GridView for example GridView1.DataSource = context.CategoryHierarchy(1);): My questions is: How to display my data from my Complex Type in a TreeView Control, showing a Tree structure that respect CategoryNodeString? I am a beginner an I never use TreeView before, any help or resource would be appreciated! Thanks!. Here some useful resource: http://www.robbagby.com/entity-framework/entity-framework-modeling-action-stored-procedures/

    Read the article

  • SQL Server: Cross-tabulation, please help

    - by user335160
    I want to achieve the results shown in the attached image. The table structure and data are: Table relationship: Facility Limit -> one to many -> Facility Sub Limit Tables structure and data Facility Limit Id OverallIBLimitId Product Type 1 1 RPA 2 1 CG 3 2 RPA 4 3 CG Facility Sub Limit Id FacilityLimitId Sub-Limit Type Amount Tenor Status Status Date 1 1 RPA at max 2,000,0000.00 2 months Approved January 5, 2011 2 1 Oil 3,000,0000.00 3 yrs Approved January 5, 2011 3 2 CG at minor 4,000,0000.00 1 yr Approved January 5, 2011 4 2 CG at max 5,000,0000.00 6 months Approved January 5, 2011 5 2 Flood Component 1 5,000,0000.00 6 months Approved January 5, 2011 6 2 Flood Component 2 6,000,0000.00 3 yrs Approved January 5, 2011 7 3 RPA at minor 1,000,0000.00 6 months Approved January 5, 2011 8 4 One-Off 1,000,0000.00 6 months Approved January 5, 2011

    Read the article

  • Use fileupload as template field in a details view

    - by MyHeadHurts
    I have an admin page where a user will select a document path and add that path to a certain column of a database. I am using a fileupload on the page where they can find the document and copy the path and then paste it into the details view. However, I want to skip this step and I want them to select a document and automatically make the path show up in the details view. <asp:FileUpload ID="FileUpload1" runat="server" Visible="False" Width="384px" /><br /> <br /> <div> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <ContentTemplate> <center> <asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateRows="False" DataKeyNames="ID" DataSourceID="SqlDataSource1" Height="128px" Width="544px" Visible="False" OnModeChanged="Button2_Click" CellPadding="4" ForeColor="#333333" GridLines="None" > <Fields> <asp:BoundField DataField="Order" HeaderText="Order" SortExpression="Order" /> <asp:BoundField DataField="Department" HeaderText="Department" SortExpression="Department"/> <asp:BoundField DataField="DOC_Type" HeaderText="DOC_Type" SortExpression="DOC_Type" /> <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" /> <asp:BoundField DataField="Revision" HeaderText="Revision" SortExpression="Revision" /> <asp:BoundField DataField="DOC" HeaderText="DOC" SortExpression="DOC" /> <asp:BoundField DataField="Active" HeaderText="Active" SortExpression="Active" /> <asp:BoundField DataField="Rev_Date" HeaderText="Rev_Date" SortExpression="Rev_Date" /> <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" Visible="False" /> <asp:CommandField ShowInsertButton="True" /> </Fields> <FooterStyle BackColor="#5D7B9D" BorderStyle="None" Font-Bold="True" ForeColor="White" /> <CommandRowStyle BackColor="#E2DED6" BorderStyle="None" Font-Bold="True" /> <RowStyle BackColor="#F7F6F3" BorderStyle="None" ForeColor="#333333" /> <FieldHeaderStyle BackColor="#E9ECF1" BorderStyle="None" Font-Bold="True" /> <EmptyDataRowStyle BorderStyle="None" /> <PagerStyle BackColor="#284775" BorderStyle="None" ForeColor="White" HorizontalAlign="Center" /> <HeaderStyle BackColor="#5D7B9D" BorderStyle="None" Font-Bold="True" ForeColor="White" /> <InsertRowStyle BorderStyle="None" /> <EditRowStyle BackColor="#999999" BorderStyle="None" /> <AlternatingRowStyle BackColor="White" BorderStyle="None" ForeColor="#284775" /> </asp:DetailsView> &nbsp; <br /> I need to get the fileupload1 into the DOC contenttemplate area so instead of showing an empty textbox it will show just a textbox it will show the fileupload

    Read the article

  • Error in asp.net C#

    - by Ishan
    How to pass Editor1 as Parameter: In my aspx.cs i am giving a call to a function which is in .cs file for the same project, as follows: protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e) { DropDown abs = new DropDown(); abs.dd(this.DropDownList2, this.DropDownList3); } .CS file code public void dd(DropDownList DropDownList2, DropDownList DropDownList3) { //My code which contains DropDownList2 DropDownList3 and Editor1 } The error that i am getting is: Error 1 The name 'Editor1' does not exist in the current context The way i have passed DropDownList2 and DropDownList3 i am not able to pass Editor1(It is an ajax control). How do i pass it?

    Read the article

  • JQuery and the multiple date selector

    - by David Carter
    Overview I recently needed to build a web page that would allow a user to capture some information and most importantly select multiple dates. This functionality was core to the application and hence had to be easy and quick to do. This is a public facing website so it had to be intuitive and very responsive. On the face of it it didn't seem too hard, I know enough juery to know what it is capable of and I was pretty sure that there would be some plugins that would help speed things along the way. I'm using ASP.Net MVC for this project as I really like the control that it gives you over the generated html and javascript. After years of Web Forms development it makes me feel like a web developer again and puts a smile on my face, that can only be a good thing!   The Calendar The first item that I needed on this page was a calender and I wanted the ability to: have the calendar be always visible select/deselect multiple dates at the same time bind to the select/deselect event so that I could update a seperate listing of the selected dates allow the user to move to another month and still have the calender remember any dates in the previous month I was hoping that there was a jQuery plugin that would meet my requirements and luckily there was! The jQuery datepicker does everything I want and there is quite a bit of documentation on how to use it. It makes use of a javascript date library date.js which I had not come across before but has a number of very useful date utilities that I have used elsewhere in the project. As you can see from the image there still needs to be some styling done! But there will be plenty of time for that later. The calendar clearly shows which dates the user has selected in red and i also make use of an unordered list to show the the selected dates so the user can always clearly see what has been selected even if they move to another month on the calendar. The javascript code that is responsible for listening to events on the calendar and synchronising the list look as follows: <script type="text/javascript">     $(function () {         $('.datepicker').datePicker({ inline: true, selectMultiple: true })         .bind(             'dateSelected',             function (e, selectedDate, $td, state) {                                 var dateInMillisecs = selectedDate.valueOf();                 if (state) { //adding a date                     var newDate = new Date(selectedDate);                     //insert the new item into the correct place in the list                     var listitems = $('#dateList').children('li').get();                     var liToAdd = "<li id='" + dateInMillisecs + "' >" + newDate.toString('ddd dd MMM yyyy') + "</li>";                     var targetIndex = -1;                     for (var i = 0; i < listitems.length; i++) {                         if (dateInMillisecs <= listitems[i].id) {                             targetIndex = i;                             break;                         }                     }                     if (targetIndex < 0) {                         $('#dateList').append(liToAdd);                     }                     else {                         $($('#dateList').children("li")[targetIndex]).before(liToAdd);                     }                 }                 else {//removing a date                     $('ul #' + dateInMillisecs).remove();                 }             }         )     }); When a date is selected on the calendar a function is called with a number of parameters passed to it. The ones I am particularly interested in are selectedDate and state. State tells me whether the user has selected or deselected the date passed in the selectedDate parameter. The <ul> that I am using to show the date has an id of dateList and this is what I will be adding and removing <li> items from. To make things a little more logical for the user I decided that the date should be sorted in chronological order, this means that each time a new date is selected it need to be placed in the correct position in the list. One way to do this would be just to append a new <li> to the list and then sort the whole list. However the approach I took was to get an array of all the items in the list var listitems = ('#dateList').children('li').get(); and then check the value of each item in the array against my new date and as soon as I found the case where the new date was less than the current item remember that position in the list as this is where I would insert it later. To make this work easily I decided to store a numeric representation of each date in the list in the id attribute of each <li> element. Fortunately javascript natively stores dates as the number of milliseconds since 1 Jan 1970. var dateInMillisecs = selectedDate.valueOf(); Please note that this is the value of the date in UTC! I always like to store dates in UTC as I learnt a long time ago that it saves a lot of refactoring at a later date... When I convert the dates back to their original back on the server I will need the UTC offset that was used when calculating the dates, this and how to actually serialise the dates and get them posted back will be the subject of another post.

    Read the article

  • IIS6 cannot start additional processes when page request is called from other than localhost

    - by awe
    I have a web application dll that is running under iis6. This is starting a number of processes to be able to handle more than one request at the time. This is working perfect in a numbers of installations. In this particular installation, it runs perfectly when initialized by a call in IE on the server using http://localhost/apppath . The problem is when the processes are from another location, i.e. another computer on the same network initialising the call throught http://servername/apppath . In this case, the initial dll running under iis is executing (proved by logging), but it fails to initialize the additional processes. If the additional processes are already initialized by a call from localhost, it also works when called from another machine (in this case, it is just attached to the existing processes).

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >