Daily Archives

Articles indexed Monday March 29 2010

Page 3/123 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • problem getting info from a cookie with javascript

    - by Jason
    I am having an issue with my cookies and I can't figure it out. Basically I have it set up so it checks for the cookie to see if the user is logged in, and then displays either a welcome message or a login link. It works - except that instead of returning the persons name in the welcome message it just is blank where the name should be. The cookie is there, with all the appropriate info.. not sure what I am doing wrong. var itm = new Array(); itm[0] = findCookie("ui"); if (itm[0] == null) { document.write("<h2><a href='logreg.html'>Log In or Sign Up</a></h2>"); } else { var c1 = itm[0].indexOf(","); var c2 = itm[0].indexOf(",",c1); var c3 = itm[0].indexOf(",",c2); var gname = itm[0].substring(c2,c3); document.write("<h2>Welcome "+gname+"!</h2>"); } The findCookie function is.. function findCookie(val){ var cookie = null; var findVal = val + "="; var dc = document.cookie; if (dc.length > 0) { var start = dc.indexOf(findVal); if (start >= 0) { start += findVal.length; lastVal = dc.indexOf(";", start); if (lastVal == -1) { lastVal = dc.length; } cookie = (dc.substring(start, lastVal)); } else { return cookie; } } return cookie; }

    Read the article

  • Access variables from a number of sources

    - by mac_55
    I'm creating my first game, and I've currently set up a 'GameState' class, to store player health etc. inside. This class is currently instantiated from the AppDelegate as I need to access it from all over my game. This is fine. For each class I'm working in, I can access the app delegate, and then find the GameState object... however, it seems very messy. I'm tempted to find a way (I'm still a newbie) to define the GameState instance as being some sort of global variable so that I can access it from all over with ease... but my little bit of reading on variable scope makes me uneasy about doing this, even if I knew how. Any ideas of the best way to define and access this class? It'll be used for everything from player health, to items they've found, any personalisation etc. Thanks!

    Read the article

  • Measuring text with sizeWithFont returns height one line too short

    - by Mac
    In an iPhone app I'm working on, I'm trying to get a UILabel to dynamically adjust its size based on its content. To do so, I'm using NSString's sizeWithFont:constrainedToSize method to measure the height of the text when constrained to a given width, and then set the UILabel to that width and the returned height. The problem however, is that roughly half the time sizeWithFont is returning a height for the text that is one line too short. This happens mostly with long strings (a couple of hundred characters), but also very occasionally with shorter strings (less than one hundred). For reference, my code looks like the following (textLabel is the UILabel in question and is a member variable, TEXT_WIDTH is the desired label width): - (void) setLabelText:(NSString*) text { CGSize bounds = CGSizeMake(TEXT_WIDTH, CGFLOAT_MAX); int textHeight = [text sizeWithFont:textLabel constrainedToSize:bounds lineBreakMode:UILineBreakModeWordWrap].height; CGRect newFrame = CGRectMake(0, 0, TEXT_WIDTH, textHeight); [textLabel setFrame:newFrame]; } Just to be clear, I don't believe the issue is with the UILabel, as I've manually inspected the value being returned by sizeWithFont and can confirm that the number being returned for the height is too small on the occasions when the label is also too small.

    Read the article

  • edmx - The operation could not be completed - After adding Inheritance

    - by vdh_ant
    Hey guys I have an edmx model which I have draged 2 tables onto - One called 'File' and the other 'ApplicaitonFile'. These two tables have a 1 to 1 relationship in the database. If I stop here everything works fine. But in my model, I want 'ApplicaitonFile' to inherit from 'File'. So I delete the 1 to 1 relationship then configure 'ApplicaitonFile' from 'File' and then remove the FileId from 'ApplicaitonFile' which was the primary key. (Note I am following the instructions from here). If I leave the model open at this point everything is fine, but as soon as I close it, if I try and reopen it again I get the following error "The operation could not be completed". I have been searching for a solution and found this - http://stackoverflow.com/questions/944050/entity-model-does-not-load but as far as I can tell I don't have a duplicate InheritanceConnectors (although I don't know exactly what I'm looking for but I can't see anything out of the ordinary - like 2 connectors with the same name) and the relationship I originally have is a 1 to 1 not a 1 to 0..1 Any ideas???

    Read the article

  • Using excel as UI without VB

    - by 01
    I think every business person would like to have excel UI, however they are forced into using web applications that sometimes look like really bad excel. Are there any frameworks that help build excel ui without VB? I dont mean framework like POI or JExcel that allows you to generate excel reports.

    Read the article

  • PHP preg_replace - Don't match within h1 tags

    - by James
    Hi there. I am using preg_replace to add a link to keywords if they are found within a long HTML string. I don't want to add a link if the keyword is found within h1 tags or strong tags. The below regex nearly works and basically says (I think): If the keyword is not immediately wrapped by either a h1 tag or a strong tag then replace with the keyword that was matched, as a bolded link to google. $result = preg_replace('%(?!<h1>)(?!<strong>)\b(bobs widgets)\b(?!<\/strong>)(?!<\/h1>)%i','<a href="http://www.google.com"><strong>$1</strong></a>', $result, -1); (the reason I don't want to match if in strong tags is because I am recursing through a lot of keywords so don't want to link an already linked keyword on subsequent passes) the above works fine and won't match: <h1>bobs widgets</h1> It will however match the keyword in the following text, because the h1 tag isn't immediately either side of the keyword: <h1>Here are bobs widgets for sale</h1> I need to make the spaces either side optional and have tried adding \s* but that doesn't get me anywhere. I'd be very grateful for a push in the right direction here.

    Read the article

  • Pros and Cons of C vs C++ programming

    - by Mohit Deshpande
    I am trying to decide on whether I should learn C or C++. I come from a very object-oriented background of java and C#. I have heard that C++ is more object-oriented than C, BUT I have also heard that a C program compiles and runs faster than a C++ program. Please help me get the facts straight by giving pros and cons of BOTH points of views. (Points of views being C over C++, or C++ over C)

    Read the article

  • Find cosine similarity in R

    - by Derek
    I'm wondering if there is a built in function in R that can find the cosine similarity (or cosine distance) between two arrays? Currently, I implemented my own function, but I can't help but think that R should already come with one :) Thanks, Derek

    Read the article

  • PowerBuilder Plug-in Architecture

    - by Adam Hawkes
    PowerBuilder seems to have some support for plug-ins since version 10. However, I can't find any documentation nor tutorials about this. The only hints I can manage are by examining the COM objects inside the existing DLLs. It doesn't help much, but I'm a novice at COM development. A very cursory example of how to do something would be awesome.

    Read the article

  • jQuery UI autocomplete combobox in a modal dialog

    - by Daveo
    I want to use a autocomplete combobox http://jqueryui.com/demos/autocomplete/#combobox within a modal dialog. However whenever I click on the down arrow (of the combobox) it causes a refresh that results in my modal window closing. How do I stop the refresh from occuring? (I am still new to jQuery) I am using UI 1.8 and jQuery 1.4.1.

    Read the article

  • Live Messenger Programming - video

    - by NicoJuicy
    I have checked the possibilities of msn live sdk, i haven't come across a possiblity to add video options to a "bot". How would i implement this? I want to stream video's directly to a user's msn (multiple video's) ... Would this be possible?

    Read the article

  • Using a Javascript Variable & Sending to JSON

    - by D Franks
    Hello all! I'm trying to take a URL's hash value, send it through a function, turn that value into an object, but ultimately send the value to JSON. I have the following setup: function content(cur){ var mycur = $H(cur); var pars = "p="+mycur.toJSON(); new Ajax.Updater('my_box', 'test.php', { parameters: pars }); } function update(){ if(window.location.hash.length > 0){ content(window.location.hash.substr(1)); // Everything after the '#' } } var curHashVal = window.location.hash; window.onload = function(){ setInterval(function(){ if(curHashVal != window.location.hash){ update(); curHashVal = window.location.hash; } },1); } But for some reason, I can't seem to get the right JSON output. It will either return as a very large object (1:"{",2:"k") or not return at all. I doubt that it is impossible to accomplish, but I've exhausted most of the ways I can think of. Other ways I've tried were "{" + cur + "}" as well as cur.toObject(), however, none seemed to get the job done. Thanks for the help!

    Read the article

  • Best choice for off-site backup: dd vs tar

    - by plok
    I have two 1TB single-partition hard disks configured as RAID1, of which I would like to make an off-site backup on a third disk, which I am still to buy. The idea is to store the backup at a relative's house, considerably far away from my place, in the hope that all the information will be safe in the case of a global thermonuclear apocalypse. Of course, this backup would be well encrypted. What I still have to decide is whether I am going to simply tar the entire partition or, instead, use dd to create an image of the disks. Is there any non-trivial difference between these two approaches that I could be overlooking? This off-site backup would be updated no more than two or three times a year, in the best of the cases, so performance should not be a factor to be pondered at all. What, and why, would you use if you were me? dd, tar, or a third option?

    Read the article

  • Lightweight PHP5 based template class/system

    - by Wizzard
    Hi there. Looking at using a template system for a new project, it's only a small site and don't want to use the overhead and 'complexity' of smarty. I don't really like template systems that force you to make use of another language just to make it easier for designers (apparently). Something like this http://www.namepros.com/code/517342-php5-template-class.html is what Im looking at but something which is a bit more robust and proven.

    Read the article

  • input box height issues

    - by Steven Xu
    I'm trying to set an input box with a specific internal height, and I'm running into issues: font-size: 12px; line-height: 12px; height: 12px; display: block; padding: 5px; Is a sample of what I put in inline styles or stylesheets. I would expect the input box value to be visible at full height, but the inner height of the input box ends up being really small, and it always seems to follow the form: actual inner height = css height - 2*border width - 2*padding Funny, because I swear I've done this before without issue. What am I missing?

    Read the article

  • C#, finding the largest prime factor of a number

    - by Juan
    Hello! I am new at programming and I am practicing my C# programming skills. My application is meant to find the largest prime factor of a number entered by the user. But my application is not returning the right answer and I dont really know where the problem is. Can you please help me? using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Console.WriteLine("Calcular máximo factor primo de n. De 60 es 5."); Console.Write("Escriba un numero: "); long num = Convert.ToInt64(Console.ReadLine()); long mfp = maxfactor(num); Console.WriteLine("El maximo factor primo es: " + num); Console.Read(); } static private long maxfactor (long n) { long m=1 ; bool en= false; for (long k = n / 2; !en && k > 1; k--) { if (n % k == 0 && primo(k)) { m = k; en = true; } } return m; } static private bool primo(long x) { bool sp = true; for (long i = 2; i <= x / 2; i++) { if (x % i == 0) sp = false; } return sp; } } }

    Read the article

  • Dynamic gridview columns event problem

    - by ropstah
    Hi, i have a GridView (selectable) in which I want to generate a dynamic GridView in a new row BELOW the selected row. I can add the row and gridview dynamically in the Gridview1 PreRender event. I need to use this event because: _OnDataBound is not called on every postback (same for _OnRowDataBound) _OnInit is not possible because the 'Inner table' for the Gridview is added after Init _OnLoad is not possible because the 'selected' row is not selected yet. I can add the columns to the dynamic GridView based on my ITemplate class. But now the button events won't fire.... Any suggestions? The dynamic adding of the gridview: Private Sub GridView1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.PreRender Dim g As GridView = sender g.DataBind() If g.SelectedRow IsNot Nothing AndAlso g.Controls.Count &gt; 0 Then Dim t As Table = g.Controls(0) Dim r As New GridViewRow(-1, -1, DataControlRowType.DataRow, DataControlRowState.Normal) Dim c As New TableCell Dim visibleColumnCount As Integer = 0 For Each d As DataControlField In g.Columns If d.Visible Then visibleColumnCount += 1 End If Next c.ColumnSpan = visibleColumnCount Dim ph As New PlaceHolder ph.Controls.Add(CreateStockGrid(g.SelectedDataKey.Value)) c.Controls.Add(ph) r.Cells.Add(c) t.Rows.AddAt(g.SelectedRow.RowIndex + 2, r) End If End Sub Private Function CreateStockGrid(ByVal PnmAutoKey As String) As GridView Dim col As Interfaces.esColumnMetadata Dim coll As New BLL.ViewStmCollection Dim entity As New BLL.ViewStm Dim query As BLL.ViewStmQuery = coll.Query Me._gridStock.AutoGenerateColumns = False Dim buttonf As New TemplateField() buttonf.ItemTemplate = New QuantityTemplateField(ListItemType.Item, "", "Button") buttonf.HeaderTemplate = New QuantityTemplateField(ListItemType.Header, "", "Button") buttonf.EditItemTemplate = New QuantityTemplateField(ListItemType.EditItem, "", "Button") Me._gridStock.Columns.Add(buttonf) For Each col In coll.es.Meta.Columns Dim headerf As New QuantityTemplateField(ListItemType.Header, col.PropertyName, col.Type.Name) Dim itemf As New QuantityTemplateField(ListItemType.Item, col.PropertyName, col.Type.Name) Dim editf As New QuantityTemplateField(ListItemType.EditItem, col.PropertyName, col.Type.Name) Dim f As New TemplateField() f.HeaderTemplate = headerf f.ItemTemplate = itemf f.EditItemTemplate = editf Me._gridStock.Columns.Add(f) Next query.Where(query.PnmAutoKey.Equal(PnmAutoKey)) coll.LoadAll() Me._gridStock.ID = "gvChild" Me._gridStock.DataSource = coll AddHandler Me._gridStock.RowCommand, AddressOf Me.gv_RowCommand Me._gridStock.DataBind() Return Me._gridStock End Function The ITemplate class: Public Class QuantityTemplateField : Implements ITemplate Private _itemType As ListItemType Private _fieldName As String Private _infoType As String Public Sub New(ByVal ItemType As ListItemType, ByVal FieldName As String, ByVal InfoType As String) Me._itemType = ItemType Me._fieldName = FieldName Me._infoType = InfoType End Sub Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) Implements System.Web.UI.ITemplate.InstantiateIn Select Case Me._itemType Case ListItemType.Header Dim l As New Literal l.Text = "&lt;b&gt;" & Me._fieldName & "</b>" container.Controls.Add(l) Case ListItemType.Item Select Case Me._infoType Case "Button" Dim ib As New Button() Dim eb As New Button() ib.ID = "InsertButton" eb.ID = "EditButton" ib.Text = "Insert" eb.Text = "Edit" ib.CommandName = "Edit" eb.CommandName = "Edit" AddHandler ib.Click, AddressOf Me.InsertButton_OnClick AddHandler eb.Click, AddressOf Me.EditButton_OnClick container.Controls.Add(ib) container.Controls.Add(eb) Case Else Dim l As New Label l.ID = Me._fieldName l.Text = "" AddHandler l.DataBinding, AddressOf Me.OnDataBinding container.Controls.Add(l) End Select Case ListItemType.EditItem Select Case Me._infoType Case "Button" Dim b As New Button b.ID = "UpdateButton" b.Text = "Update" b.CommandName = "Update" b.OnClientClick = "return confirm('Sure?')" container.Controls.Add(b) Case Else Dim t As New TextBox t.ID = Me._fieldName AddHandler t.DataBinding, AddressOf Me.OnDataBinding container.Controls.Add(t) End Select End Select End Sub Private Sub InsertButton_OnClick(ByVal sender As Object, ByVal e As EventArgs) Console.WriteLine("insert click") End Sub Private Sub EditButton_OnClick(ByVal sender As Object, ByVal e As EventArgs) Console.WriteLine("edit click") End Sub Private Sub OnDataBinding(ByVal sender As Object, ByVal e As EventArgs) Dim boundValue As Object = Nothing Dim ctrl As Control = sender Dim dataItemContainer As IDataItemContainer = ctrl.NamingContainer boundValue = DataBinder.Eval(dataItemContainer.DataItem, Me._fieldName) Select Case Me._itemType Case ListItemType.Item Dim fieldLiteral As Label = sender fieldLiteral.Text = boundValue.ToString() Case ListItemType.EditItem Dim fieldTextbox As TextBox = sender fieldTextbox.Text = boundValue.ToString() End Select End Sub End Class

    Read the article

  • book style website, how to have different links on each page?

    - by dean nolan
    I am creating a website that is to have a book style layout. So you turn the pages and they fold over. I have this working in JQuery for images. What I am looking to do is have clickable links on the pages so that I can jump to a page further in the "book" or even to another site. Does anyone know the best way to go about this or have any examples to help out? Thanks

    Read the article

  • In XSLT is it possible to use the value of an xpath expression in a call to a template using an par

    - by Cell
    I am performing an xsl transform and in it I call a template with a param using the following code <xsl:call-template name="GenerateColumns"> <xsl:with-param name="curRow" select="$curRow"/> <xsl:with-param name="curCol" select="$curCol + 1"/> </xsl:call-template> This calls a template function which outputs part of a table element in HTML. The curRow and curCol are used to determine which row and column we are in the table. gbl_maxCols is set to the number of columns in an html table <xsl:template name="GenerateColumns"> <xsl:when test="$curCol &lt;= $gbl_maxCols"> <td> <xsl:attribute="colspan"> <xsl:value-of select="/page/column/@skipColumns"/> </xsl:attribute> </xsl:when> </xsl:template> The result of this function is a set of td elements, however some of these elements (those with a skipColumn attribute greater than 1 span more than 1 column, I need to skip this many columns with the next call to generateColumns. this works just like I would expect in the case where I simply increment the curCol param but I have a case where I need to use the value from the xml attribute skipColumns in the math to calculate the value for curCol. In the above case I iterate through all the columns and this works for the majority of my use cases. However in same cases I need to skip over some of the columns and need to pass in that value from the xml attribute to calculate how many columns I need to skip. My naive first attempt was something like this <xsl:call-template name="GenerateColumns"> <xsl:with-param name="curRow" select="$curRow"/> <xsl:with-param name="curCol" select="$curCol + /page/column/@skipColumns"/> </xsl:call-template> But unforutnately this does not seem to work. Is there any way to use an attribute from an xml page in the calculation for the value of a param in xsl. My xml page is something like this (edited heavily since the xml file is rather large) <page> <column name="blank" skipColumns="1"/> <column name="blank" skipColumns="1"/> <column name="test" skipColumns="3"/> <column name="blank" skipColumns="1"/> <column name="test2" skipColumns="6"/> </page> after all of this I would like to have a set of td elements like the following <td></td><td></td><td colSpan="3"></td><td></td><td colSpan="6"></td> if I just iterate through the columns I instead end up with something like this which gives me more td elements than I should have <td></td><td></td><td colSpan="3"></td><td></td><td colSpan="6"></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td> Edited to provide more information

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >