Daily Archives

Articles indexed Friday June 8 2012

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

  • glTranslate, how exactly does it work?

    - by mykk
    I have some trouble understanding how does glTranslate work. At first I thought it would just simply add values to axis to do the transformation. However then I have created two objects that would load bitmaps, one has matrix set to GL_TEXTURE: public class Background { float[] vertices = new float[] { 0f, -1f, 0.0f, 4f, -1f, 0.0f, 0f, 1f, 0.0f, 4f, 1f, 0.0f }; .... private float backgroundScrolled = 0; public void scrollBackground(GL10 gl) { gl.glLoadIdentity(); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glTranslatef(0f, 0f, 0f); gl.glPushMatrix(); gl.glLoadIdentity(); gl.glMatrixMode(GL10.GL_TEXTURE); gl.glTranslatef(backgroundScrolled, 0.0f, 0.0f); gl.glPushMatrix(); this.draw(gl); gl.glPopMatrix(); backgroundScrolled += 0.01f; gl.glLoadIdentity(); } } and another to GL_MODELVIEW: public class Box { float[] vertices = new float[] { 0.5f, 0f, 0.0f, 1f, 0f, 0.0f, 0.5f, 0.5f, 0.0f, 1f, 0.5f, 0.0f }; .... private float boxScrolled = 0; public void scrollBackground(GL10 gl) { gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); gl.glTranslatef(0f, 0f, 0f); gl.glPushMatrix(); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); gl.glTranslatef(boxScrolled, 0.0f, 0.0f); gl.glPushMatrix(); this.draw(gl); gl.glPopMatrix(); boxScrolled+= 0.01f; gl.glLoadIdentity(); } } Now they are both drawn in Renderer.OnDraw. However background moves exactly 5 times faster. If I multiply boxScrolled by 5 they will be in sinc and will move together. If I modify backgrounds vertices to be float[] vertices = new float[] { 1f, -1f, 0.0f, 0f, -1f, 0.0f, 1f, 1f, 0.0f, 0f, 1f, 0.0f }; It will also be in sinc with the box. So, what is going under glTranslate?

    Read the article

  • Particle Effect Completion

    - by Siddharth
    In my game I use particle effect for various purposes. In that I detect the completion of the particle effect. Basically I want to do something after completion of the particle effect. But the problem is that I didn't able to find the particle effect completion. So any community member please help me. EDIT : I was creating particle effect using following code pointParticleEmtitter = new PointParticleEmitter(pX, pY); particleSystem = new ParticleSystem(pointParticleEmtitter, maxRate, minRate, maxParticles, mParticleTextureRegion.deepCopy()); particleSystem.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE); particleSystem.addParticleInitializer(new ColorInitializer(0f, 0f, 1f)); particleSystem.addParticleModifier(new AlphaModifier(1, 0, 0, 0.5f)); particleSystem.addParticleModifier(new ExpireModifier(0.5f)); gameObject.getScene().attachChild(particleSystem); Using above code the particle effect was started but when finished that I want to detect. After finishing effect I want to remove the object from the scene.

    Read the article

  • Android Game Development problem with Speed = Distance / Time

    - by Charlton Santana
    I have been coding speed for an object. I have made it so the object will move from one end of the screen to another at a speed depending on the screen size, at the monemt I have made it so it will take one second to pass the screen. So i have worked out the speed in code but when I go to assign the speed it tells me to force close and i do not understand why. Here is the code: MainGame Code: @Override protected void onDraw(Canvas canvas) { setBlockSpeed(getWidth()); } private int blockSpeed; private void setBlockSpeed(int screenWidth){ Log.d(TAG, "screenWidth " + screenWidth); blockSpeed = screenWidth / 100; // 100 is the FPS.. i want it to take 1 second to pass the screen Math.round(blockSpeed); // to make it a whole number block.speed = blockSpeed; // this is line 318!! if i put eg block.speed = 8; it still tells me to force close } Block.java Code: public int speed; public void draw(Canvas canvas) { canvas.drawBitmap(bitmap, x - (bitmap.getWidth() / 2), y - (bitmap.getHeight() / 2), null); if(dontmove == 0){ this.x -= speed; // if it was eg this.x -= 18; it would not have an error } } The exception 06-08 13:22:34.315: E/AndroidRuntime(2801): FATAL EXCEPTION: Thread-11 06-08 13:22:34.315: E/AndroidRuntime(2801): java.lang.NullPointerException 06-08 13:22:34.315: E/AndroidRuntime(2801): at com.charltonsantana.game.MainGame.setBlockSpeed(MainGame.java:318) 06-08 13:22:34.315: E/AndroidRuntime(2801): at com.charltonsantana.game.MainGame.onDraw(MainGame.java:351) 06-08 13:22:34.315: E/AndroidRuntime(2801): at com.charltonsantana.game.MainThread.run(MainThread.java:64)

    Read the article

  • NameValueCollection Issue In Proxy Generation

    - by N W. annor-adjei
    I have a proxy generation problem I am building my own customised XMLMembershipProvider in WCF. The code runs well in ASP.Net and am consuming the same code in WCF for silverlight, My class inherits the Membership provider hence have implemented all the MembershipProvider methods. Now, consumung this methods in WCF requires also the Initialize Method having NameValueCollection as passin parameter, which is the cause of the problem because WCF does not supporteCollection serialization. when the initialize method is marked as OperationContract, Proxy class does not get generated. I could have use Dictionary but that is impossible here bacause the base class's initialize method accepts two parameter one of which should be a NameValueCollection. If i don't mark the Initialize as OperationContract, the proxy class is generated with all the methods but i realized i still need the Initialize marked as Operation contract to start the provider. Has any one got any idea about the use of NameValueCollection in WCF and the work around this problem Thank you. Nicholas

    Read the article

  • Android: Expand ListView to fill space between two items

    - by BahaiResearch.com
    I have a ListView that is sandwiched between two buttons. The entire screen is in a ScrollView <Button android:text="Take a Picture" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/btnPicture" android:layout_marginRight="3dp" android:layout_marginLeft="3dp" android:layout_marginTop="5dp" android:textSize="25dp"/> <ListView android:minWidth="25px" android:minHeight="25px" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/lstPhotos" android:visibility="gone" /> <Button android:text="Location Type" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/btnLocationType" android:layout_marginRight="3dp" android:layout_marginLeft="3dp" android:layout_marginTop="5dp" android:textSize="25dp" /> As I add items to the listview in code, how can I get the listview to take up enough space to be visible. It does expand to show 1 item but after I add the second item it doesn't expand any more. You can see here after I added a second picture row to the listview, it's not visible.

    Read the article

  • editing a string using BufferedReader in Java

    - by pbs
    Exception handling aside, I'm using the following to input a line of text in Java: BufferedReader strin = new BufferedReader(new InputStreamReader(System.in)); String txt = null; txt = strin.readLine(); However, I want to be able to edit an existing string, so that if txt were initialized to "hello" instead of null, then the readLine() would have the "hello" text in the buffer for me to edit. I can't see how to do this. Any help would be appreciated.

    Read the article

  • Bash: Check if file was modified since used in script

    - by Thomas Münz
    I need to check in a script if a file was modified since I read it (another application can modify it in between). According to bash manual there is a "-N" test which should report if a file was modified since last read. I tried it in a small script but it seems like it doesn't work. #!/bin/bash file="test.txt" echo "test" > $file cat $file; if [ -N $file ]; then echo "modified since read"; else echo "not modified since read"; fi I also tried an alternative way by touching another file and using if [ "file1" -nt "file2 ]; but this works only on a seconds accuracy which may under rare conditions not be sufficient. Is there any other bash-inbuilt solution for this problem or I do really need to use diff or md5sum?

    Read the article

  • FxCop giving a warning on private constructor CA1823 and CA1053

    - by Luis Sánchez
    I have a class that looks like the following: Public Class Utilities Public Shared Function blah(userCode As String) As String 'doing some stuff End Function End Class I'm running FxCop 10 on it and it says: "Because type 'Utilities' contains only 'static' ( 'Shared' in Visual Basic) members, add a default private constructor to prevent the compiler from adding a default public constructor." Ok, you're right Mr. FxCop, I'll add a private constructor: Private Utilities() Now I'm having: "It appears that field 'Utilities.Utilities' is never used or is only ever assigned to. Use this field or remove it." Any ideas of what should I do to get rid of both warnings?

    Read the article

  • Why isn't this simple program working?

    - by user1445478
    I'm writing a very basic program that aims for the text view to display the phrase "Hello" after a button is pressed on the screen. However, I can't get this program to work; every time I run it, it says that the application has stopped unexpectedly. This is the program I wrote: public class EtudeActivityActivity extends Activity{ TextView tvResponse; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final TextView tvResponse = (TextView) findViewById (R.id.tvResponse); } public void updateTV(View v) { tvResponse.setText("Hello"); } } Also, I inserted an android:onClick = "updateTV" into my main.xml file for the button. Thanks for any help!

    Read the article

  • getURL, parsing web-site with german special characters

    - by Kay
    I am using getURL() and htmlParse() - how can I make web-site content with special characters to be displayed properly? library(RCurl); library(XML) script <- getURL("http://www.floraweb.de/pflanzenarten/foto.xsql?suchnr=814") doc <- htmlParse(script, encoding = "UTF-8") xpathSApply(doc, "//div[@id='content']//p", xmlValue)[2] [1] "Bellis perennis L., Gänseblümchen" # should say: [1] "Bellis perennis L., Gänseblümchen" > Sys.getlocale() [1] "LC_COLLATE=German_Austria.1252;LC_CTYPE=German_Austria.1252;LC_MONETARY=German_Austria.1252;LC_NUMERIC=C;LC_TIME=German_Austria.1252"

    Read the article

  • If I specify a System property multiple times when invoking JVM which value is used?

    - by RobV
    If I specify a system property multiple times when invoking the JVM which value will I actually get when I retrieve the property? e.g. java -Dprop=A -Dprop=B -jar my.jar What will be the result when I call System.getProperty("prop");? The Java documentation on this does not really tell me anything useful on this front. In my non-scientific testing on a couple of machines running different JVMs it seems like the last value is the one returned (which is actually the behavior I need) but I wondered if this behavior is actually defined officially anywhere or can it vary between JVMs?

    Read the article

  • Erlang bit indexing

    - by GTDev
    I am currently trying to learn erlang and what I am trying to do is to perform an operation on specific indices of an array stored in a bit array or int. If there is a 0 in a position, the index into the array at that position is not used. So envision the following: Example the array is: [1, 3, 5, 42, 23] My bit array is: 21 = 10101 in binary so I'm using indicies 1,3,5 so I'm calling a function on [1, 5, 23] my function is of the form my_function(Array, BitArray) -> SubArray = get_subarray_from_bitarray(Array, BitArray), process_subarray(SubArray). And I need help with the get_subarray_from_bitarray(). I know erlang has special syntax around bit strings (something like <<) so is there an efficient way of indexing into the bit array to get the indicies?

    Read the article

  • Grabbing rows from MySql where current date is in between start date and end date (Check if current date lies between start date and end date)

    - by Jordan Parker
    I'm trying to select from the database to get the "campaigns" that dates fall into the month. So far i've been successful in grabbing rows that starts or ends inside the current month. What I need to do now is select rows that start in one month and ends a few months down the line ( EG: It's the 3rd month in the year, and there's a "campaign" that runs from the 1st month until the 5th. other example There is a "campaign" that runs from 2012 until 2013 ) I'm hoping there is some way to select via MySql all rows in which a capaign may run. If not should I grab all data in the database and only show the ones that run via the current month. I have already made a function that displays all the days inbetween each date inside an array, which is called "dateRange". I've also created another which shows how many days the campaign runs for called "runTime". Select all (Obviously) $result = mysql_query("SELECT * FROM campaign"); Select Starting This Month $result = mysql_query("SELECT * FROM campaign WHERE YEAR( START ) = YEAR( CURDATE( ) ) AND MONTH( START ) = MONTH( CURDATE( ) )"); Select Ending This Month $result = mysql_query("SELECT * FROM campaign WHERE YEAR( END ) = YEAR( CURDATE( ) ) AND MONTH( END ) = MONTH( CURDATE( ) ) LIMIT 0 , 30"); Code sample while($row = mysql_fetch_array($result)) { $dateArray = dateRange($row['start'], $row['end']); echo "<h3>" . $row['campname'] . "</h3> Start " . $row['start'] . "<br /> End " . $row['end']; echo runTime($row['start'], $row['end']); print_r($dateArray); } In regards to the dates, MySql database only holds start date and end date of the campaign.

    Read the article

  • Android draw using SurfaceView and Thread

    - by Morten Høgseth
    I am trying to draw a ball to my screen using 3 classes. I have read a little about this and I found a code snippet that works using the 3 classes on one page, Playing with graphics in Android I altered the code so that I have a ball that is moving and shifts direction when hitting the wall like the picture below (this is using the code in the link). Now I like to separate the classes into 3 different pages for not making everything so crowded, everything is set up the same way. Here are the 3 classes I have. BallActivity.java Ball.java BallThread.java package com.brick.breaker; import android.app.Activity; import android.os.Bundle; import android.view.Window; import android.view.WindowManager; public class BallActivity extends Activity { private Ball ball; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); ball = new Ball(this); setContentView(ball); } @Override protected void onPause() { // TODO Auto-generated method stub super.onPause(); setContentView(null); ball = null; finish(); } } package com.brick.breaker; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.view.SurfaceHolder; import android.view.SurfaceView; public class Ball extends SurfaceView implements SurfaceHolder.Callback { private BallThread ballThread = null; private Bitmap bitmap; private float x, y; private float vx, vy; public Ball(Context context) { super(context); // TODO Auto-generated constructor stub bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ball); x = 50.0f; y = 50.0f; vx = 10.0f; vy = 10.0f; getHolder().addCallback(this); ballThread = new BallThread(getHolder(), this); } protected void onDraw(Canvas canvas) { update(canvas); canvas.drawBitmap(bitmap, x, y, null); } public void update(Canvas canvas) { checkCollisions(canvas); x += vx; y += vy; } public void checkCollisions(Canvas canvas) { if(x - vx < 0) { vx = Math.abs(vx); } else if(x + vx > canvas.getWidth() - getBitmapWidth()) { vx = -Math.abs(vx); } if(y - vy < 0) { vy = Math.abs(vy); } else if(y + vy > canvas.getHeight() - getBitmapHeight()) { vy = -Math.abs(vy); } } public int getBitmapWidth() { if(bitmap != null) { return bitmap.getWidth(); } else { return 0; } } public int getBitmapHeight() { if(bitmap != null) { return bitmap.getHeight(); } else { return 0; } } public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { // TODO Auto-generated method stub } public void surfaceCreated(SurfaceHolder holder) { // TODO Auto-generated method stub ballThread.setRunnable(true); ballThread.start(); } public void surfaceDestroyed(SurfaceHolder holder) { // TODO Auto-generated method stub boolean retry = true; ballThread.setRunnable(false); while(retry) { try { ballThread.join(); retry = false; } catch(InterruptedException ie) { //Try again and again and again } break; } ballThread = null; } } package com.brick.breaker; import android.graphics.Canvas; import android.view.SurfaceHolder; public class BallThread extends Thread { private SurfaceHolder sh; private Ball ball; private Canvas canvas; private boolean run = false; public BallThread(SurfaceHolder _holder,Ball _ball) { sh = _holder; ball = _ball; } public void setRunnable(boolean _run) { run = _run; } public void run() { while(run) { canvas = null; try { canvas = sh.lockCanvas(null); synchronized(sh) { ball.onDraw(canvas); } } finally { if(canvas != null) { sh.unlockCanvasAndPost(canvas); } } } } public Canvas getCanvas() { if(canvas != null) { return canvas; } else { return null; } } } Here is a picture that shows the outcome of these classes. I've tried to figure this out but since I am pretty new to Android development I thought I could ask for help. Does any one know what is causing the ball to be draw like that? The code is pretty much the same as the one in the link and I have tried to experiment to find a solution but no luck. Thx in advance for any help=)

    Read the article

  • ruby on rails has_many through relationship

    - by BennyB
    Hi i'm having a little trouble with a has_many through relationship for my app and was hoping to find some help. So i've got Users & Lectures. Lectures are created by one user but then other users can then "join" the Lectures that have been created. Users have their own profile feed of the Lectures they have created & also have a feed of Lectures friends have created. This question however is not about creating a lecture but rather "Joining" a lecture that has been created already. I've created a "lecturerelationships" model & controller to handle this relationship between Lectures & the Users who have Joined (which i call "actives"). Users also then MUST "Exit" the Lecture (either by clicking "Exit" or navigating to one of the header navigation links). I'm grateful if anyone can work through some of this with me... I've got: Users.rb model Lectures.rb model Users_controller Lectures_controller then the following model lecturerelationship.rb class lecturerelationship < ActiveRecord::Base attr_accessible :active_id, :joinedlecture_id belongs_to :active, :class_name => "User" belongs_to :joinedlecture, :class_name => "Lecture" validates :active_id, :presence => true validates :joinedlecture_id, :presence => true end lecturerelationships_controller.rb class LecturerelationshipsController < ApplicationController before_filter :signed_in_user def create @lecture = Lecture.find(params[:lecturerelationship][:joinedlecture_id]) current_user.join!(@lecture) redirect_to @lecture end def destroy @lecture = Lecturerelationship.find(params[:id]).joinedlecture current_user.exit!(@user) redirect_to @user end end Lectures that have been created (by friends) show up on a users feed in the following file _activity_item.html.erb <li id="<%= activity_item.id %>"> <%= link_to gravatar_for(activity_item.user, :size => 200), activity_item.user %><br clear="all"> <%= render :partial => 'shared/join', :locals => {:activity_item => activity_item} %> <span class="title"><%= link_to activity_item.title, lecture_url(activity_item) %></span><br clear="all"> <span class="user"> Joined by <%= link_to activity_item.user.name, activity_item.user %> </span><br clear="all"> <span class="timestamp"> <%= time_ago_in_words(activity_item.created_at) %> ago. </span> <% if current_user?(activity_item.user) %> <%= link_to "delete", activity_item, :method => :delete, :confirm => "Are you sure?", :title => activity_item.content %> <% end %> </li> Then you see I link to the the 'shared/join' partial above which can be seen in the file below _join.html.erb <%= form_for(current_user.lecturerelationships.build(:joinedlecture_id => activity_item.id)) do |f| %> <div> <%= f.hidden_field :joinedlecture_id %> </div> <%= f.submit "Join", :class => "btn btn-large btn-info" %> <% end %> Some more files that might be needed: config/routes.rb SampleApp::Application.routes.draw do resources :users do member do get :following, :followers, :joined_lectures end end resources :sessions, :only => [:new, :create, :destroy] resources :lectures, :only => [:create, :destroy, :show] resources :relationships, :only => [:create, :destroy] #for users following each other resources :lecturerelationships, :only => [:create, :destroy] #users joining existing lectures So what happens is the lecture comes in my activity_feed with a Join button option at the bottom...which should create a lecturerelationship of an "active" & "joinedlecture" (which obviously are supposed to be coming from the user & lecture classes. But the error i get when i click the join button is as follows: ActiveRecord::StatementInvalid in LecturerelationshipsController#create SQLite3::ConstraintException: constraint failed: INSERT INTO "lecturerelationships" ("active_id", "created_at", "joinedlecture_id", "updated_at") VALUES (?, ?, ?, ?) Also i've included my user model (seems the error is referring to it) user.rb class User < ActiveRecord::Base attr_accessible :email, :name, :password, :password_confirmation has_secure_password has_many :lectures, :dependent => :destroy has_many :lecturerelationships, :foreign_key => "active_id", :dependent => :destroy has_many :joined_lectures, :through => :lecturerelationships, :source => :joinedlecture before_save { |user| user.email = email.downcase } before_save :create_remember_token validates :name, :presence => true, :length => { :maximum => 50 } VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i validates :email, :presence => true, :format => { :with => VALID_EMAIL_REGEX }, :uniqueness => { :case_sensitive => false } validates :password, :presence => true, :length => { :minimum => 6 } validates :password_confirmation, :presence => true def activity # This feed is for "My Activity" - basically lectures i've started Lecture.where("user_id = ?", id) end def friendactivity Lecture.from_users_followed_by(self) end # lECTURE TO USER (JOINING) RELATIONSHIPS def joined?(selected_lecture) lecturerelationships.find_by_joinedlecture_id(selected_lecture.id) end def join!(selected_lecture) lecturerelationships.create!(:joinedlecture_id => selected_lecture.id) end def exit!(selected_lecture) lecturerelationships.find_by_joinedlecture_id(selected_lecture.id).destroy end end Thanks for any and all help - i'll be on here for a while so as mentioned i'd GREATLY appreciate someone who may have the time to work through my issues with me...

    Read the article

  • filling colors on a map - PHP

    - by jeremy
    I am trying to determine how to fill colors onto a map - such as the "Risk" board game map. I've done this before with HTML tables, by pulling an HTML color code from a SQL table and then just using it to fill the cell the color I want it. But for a non-square map, I'm not sure where to look. I have created a very simple two color map - its white with black borders. My desired result is having the 'regions' on the map shaded with a color, based on data in a sql table (just like the "fill" button in Paint). This looks like what I need: http://php.net/manual/en/function.imagefilltoborder.php and now.. how to define the borders... At the moment I have tried nothing, because the question was: how do I have PHP fill parts of an image? I have tried making an image in Paint, and then scratching my head wondering how to fill parts of it. Having stumbled upon a link, let me focus this a bit more: It appears that with imagefilltoborder that I can put an image on my server, perhaps one that looks like a black and white version of the RISK map - black borders and white everything else. Some questions: Is it correct that the 'border' variable should use the color of my border (whatever value black is) so that the code can "see" where the border is? Is it correct that I'll just need to figure out X,Y coords to begin the fill? Does this work if I have 10 different spots to fill on the map? Can I use varying colors from code or pulled from SQL to assign different colors to those 10 spots, and use 10 different X,Y coords to get them all?

    Read the article

  • Python - Is there a better/efficient way to find a node in tree?

    - by Sej P
    I have a node data structure defined as below and was not sure the find_matching_node method is pythonic or efficient. I am not well versed with generators but think there might be better solution using them. Any ideas? class HierarchyNode(): def __init__(self, nodeId): self.nodeId = nodeId self.children = {} # opted for dictionary to help reduce lookup time def addOrGetChild(self, childNode): return self.children.setdefault(childNode.nodeId,childNode) def find_matching_node(self, node): ''' look for the node in the immediate children of the current node. if not found recursively look for it in the children nodes until gone through all nodes ''' matching_node = self.children.get(node.nodeId) if matching_node: return matching_node else: for child in self.children.itervalues(): matching_node = child.find_matching_node(node) if matching_node: return matching_node return None

    Read the article

  • Change with jQuery a cell of a table created with JSF

    - by perissf
    From within a xhtml page created with JSF, I need to use JavaScript / jQuery for changing the content of a cell of a table. I know how to assign a unique id to the div containing the table, and to the tbody. I can also assign unique class names to the div itself and to the target column. The target row is identified by the data-rk attribute. <div id="tabForm:centerTabView:personsTable" class="ui-datatable ui-widget personsTable"> <table role="grid"> <tbody id="tabForm:centerTabView:personsTable_data" > <tr data-rk="2" > <td ... /> <td class="lastNameCol" role="gridcell"> <div> To Be Edited </div> </td> <td ... /> </tr> <tr ... /> </tbody> </table> </div> I have tried with many combinations of different jQuery selectors, but I am really lost. I need to search my target row and my target column inside that particular div or inside that particular table, because the xhtml page may contain other tables with different unique ids (and accidentally with the same row and column ids).

    Read the article

  • Entity Framework 1:1 Relationship Identity Colums

    - by Hupperware
    I cannot for the life of me get two separate tables to save with a relationship and two identity columns. I keep getting errors like A dependent property in a ReferentialConstraint is mapped to a store-generated column. Column: 'OlsTerminalId'. I can't imagine that this setup is abnormal. [DataContract] public class OlsData { private static readonly DateTime theUnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int OlsDataId { get; set; } [DataMember(Name = "id")] public int Id { get; set; } public DateTime Timestamp { get; set; } [DataMember(Name = "created")] [NotMapped] public double Created { get { return (Timestamp - theUnixEpoch).TotalMilliseconds; } set { Timestamp = theUnixEpoch.AddMilliseconds(value); } } [InverseProperty("OlsData")] [DataMember(Name = "terminal")] public virtual OlsTerminal OlsTerminal { get; set; } } [DataContract] public class OlsTerminal { [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int OlsTerminalId { get; set; } public int OlsDataId { get; set; } [DataMember(Name = "account")] [NotMapped] public virtual OlsAccount OlsAccount { get; set; } [DataMember(Name = "terminalId")] public string TerminalId { get; set; } [DataMember(Name = "merchantId")] public string MerchantId { get; set; } public virtual OlsData OlsData { get; set; } } public class OlsDataContext : DbContext { protected override void OnModelCreating(DbModelBuilder aModelBuilder) { aModelBuilder.Conventions.Remove<PluralizingTableNameConvention>(); } public OlsDataContext(string aConnectionString) : base(aConnectionString) {} public DbSet<OlsData> OlsData { get; set; } public DbSet<OlsTerminal> OlsTerminal { get; set; } public DbSet<OlsAccount> OlsAccount { get; set; } }

    Read the article

  • How to filter Backbone.js Collection and Rerender App View?

    - by Jeremy H.
    Is is a total Backbone.js noob question. I am working off of the ToDo Backbone.js example trying to build out a fairly simple single app interface. While the todo project is more about user input, this app is more about filtering the data based on the user options (click events). I am completely new to Backbone.js and Mongoose and have been unable to find a good example of what I am trying to do. I have been able to get my api to pull the data from the MongoDB collection and drop it into the Backbone.js collection which renders it in the app. What I cannot for the life of me figure out how to do is filter that data and re-render the app view. I am trying to filter by the "type" field in the document. Here is my script: (I am totally aware of some major refactoring needed, I am just rapid prototyping a concept.) $(function() { window.Job = Backbone.Model.extend({ idAttribute: "_id", defaults: function() { return { attachments: false } } }); window.JobsList = Backbone.Collection.extend({ model: Job, url: '/api/jobs', leads: function() { return this.filter(function(job){ return job.get('type') == "Lead"; }); } }); window.Jobs = new JobsList; window.JobView = Backbone.View.extend({ tagName: "div", className: "item", template: _.template($('#item-template').html()), initialize: function() { this.model.bind('change', this.render, this); this.model.bind('destroy', this.remove, this); }, render: function() { $(this.el).html(this.template(this.model.toJSON())); this.setText(); return this; }, setText: function() { var month=new Array(); month[0]="Jan"; month[1]="Feb"; month[2]="Mar"; month[3]="Apr"; month[4]="May"; month[5]="Jun"; month[6]="Jul"; month[7]="Aug"; month[8]="Sep"; month[9]="Oct"; month[10]="Nov"; month[11]="Dec"; var title = this.model.get('title'); var description = this.model.get('description'); var datemonth = this.model.get('datem'); var dateday = this.model.get('dated'); var jobtype = this.model.get('type'); var jobstatus = this.model.get('status'); var amount = this.model.get('amount'); var paymentstatus = this.model.get('paymentstatus') var type = this.$('.status .jobtype'); var status = this.$('.status .jobstatus'); this.$('.title a').text(title); this.$('.description').text(description); this.$('.date .month').text(month[datemonth]); this.$('.date .day').text(dateday); type.text(jobtype); status.text(jobstatus); if(amount > 0) this.$('.paymentamount').text(amount) if(paymentstatus) this.$('.paymentstatus').text(paymentstatus) if(jobstatus === 'New') { status.addClass('new'); } else if (jobstatus === 'Past Due') { status.addClass('pastdue') }; if(jobtype === 'Lead') { type.addClass('lead'); } else if (jobtype === '') { type.addClass(''); }; }, remove: function() { $(this.el).remove(); }, clear: function() { this.model.destroy(); } }); window.AppView = Backbone.View.extend({ el: $("#main"), events: { "click #leads .highlight" : "filterLeads" }, initialize: function() { Jobs.bind('add', this.addOne, this); Jobs.bind('reset', this.addAll, this); Jobs.bind('all', this.render, this); Jobs.fetch(); }, addOne: function(job) { var view = new JobView({model: job}); this.$("#activitystream").append(view.render().el); }, addAll: function() { Jobs.each(this.addOne); }, filterLeads: function() { // left here, this event fires but i need to figure out how to filter the activity list. } }); window.App = new AppView; });

    Read the article

  • Pass variable to Info Window in FusionTableLayer

    - by user1030205
    I am building a web application that includes a Google Map layered with data from a Google Fusion Table. I have defined the info window for the markers in the Fusion Table and all is rendering as expected, but I have one issue. I need to pass a session variable from my web application to be included in the links that are defined in the info window, but can't seem to find a way to do this. Below is the javascript I am currently using to render the map: var myOptions = { zoom: 10, mapTypeId: google.maps.MapTypeId.ROADMAP, center: new google.maps.LatLng( 40.4230,-98.7372) } map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); // Weather weatherLayer = new google.maps.weather.WeatherLayer({ temperatureUnits: google.maps.weather.TemperatureUnit.FAHRENHEIT }); weatherLayer.setMap(map); //Hobby Stores var storeLayer = new google.maps.FusionTablesLayer({ query: { select: "col2", from: "3991553" }, map: map, supressInfoWindows: true }); //Club Sites var siteLayer = new google.maps.FusionTablesLayer({ query: { select: "col13", from: "3855088" }, styles: [{ markerOptions: { iconName: "airports" }}], map: map, supressInfoWindows: true }); I'd like to be able to pass some type of parameter in the call to google.maps.FusionTableLayer that passes a value to be include in the info window, but can't find a way to do this. To view the actual page, visit www.dualrates.com. Enter your zipcode and select one of the airport markers to see the info window. You may have to zoom the map out to see an airfield.

    Read the article

  • atk4 advanced crud?

    - by thindery
    I have the following tables: -- ----------------------------------------------------- -- Table `product` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `product` ( `id` INT NOT NULL AUTO_INCREMENT , `productName` VARCHAR(255) NULL , `s7location` VARCHAR(255) NULL , PRIMARY KEY (`id`) ) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `pages` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `pages` ( `id` INT NOT NULL AUTO_INCREMENT , `productID` INT NULL , `pageName` VARCHAR(255) NOT NULL , `isBlank` TINYINT(1) NULL , `pageOrder` INT(11) NULL , `s7page` INT(11) NULL , PRIMARY KEY (`id`) , INDEX `productID` (`productID` ASC) , CONSTRAINT `productID` FOREIGN KEY (`productID` ) REFERENCES `product` (`id` ) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `field` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `field` ( `id` INT NOT NULL AUTO_INCREMENT , `pagesID` INT NULL , `fieldName` VARCHAR(255) NOT NULL , `fieldType` VARCHAR(255) NOT NULL , `fieldDefaultValue` VARCHAR(255) NULL , PRIMARY KEY (`id`) , INDEX `id` (`pagesID` ASC) , CONSTRAINT `pagesID` FOREIGN KEY (`pagesID` ) REFERENCES `pages` (`id` ) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; I have gotten CRUD to work on the 'product' table. //addproduct.php class page_addproduct extends Page { function init(){ parent::init(); $crud=$this->add('CRUD')->setModel('Product'); } } This works. but I need to get it so that when a new product is created it basically allows me to add new rows into the pages and field tables. For example, the products in the tables are a print product(like a greeting card) that has multiple pages to render. Page 1 may have 2 text fields that can be customized, page 2 may have 3 text fields, a slider to define text size, and a drop down list to pick a color, and page 3 may have five text fields that can all be customized. All three pages (and all form elements, 12 in this example) are associated with 1 product. So when I create the product, could i add a button to create a page for that product, then within the page i can add a button to add a new form element field? I'm still somewhat new to this, so my db structure may not be ideal. i'd appreciate any suggestions and feedback! Could someone point me toward some information, tutorials, documentation, ideas, suggestions, on how I can implement this?

    Read the article

  • Get element id on hover (or mouseover)

    - by Peter C
    Still getting to grips with jQuery and I am pleased to have got as far as I have, especially help from the posts in this forum. However, now got to a working function that does what I want, that is to create a radio group that looks like a button. It pulls data via json and loops through creating the radio buttons. I want to get the id of the radio buttons generated so that I can then parse through to the next step of the app but I can't get it to work. function FillDiv(groups, side) { var cnt = 1; var newClass = ''; var newType = ''; if (side == '#ck-button-left') { newClass = 'leftClass'; newType = 'radio' } else { newClass = 'rightClass'; newType = 'checkbox' } $.each(groups, function (index, groups) { $(side) .append( $(document.createElement('label')).attr({ id: cnt + 'lbl' }) ); $('#' + cnt + 'lbl') .append( $(document.createElement('input')).attr({ id: groups.GroupCode, type: newType, name: 'testGroup', class: newClass }) ); $('#' + groups.GroupCode).after ( $(document.createElement('span')).text(groups.GroupName).attr('class', 'leftSpan') ); $('#' + cnt + 'lbl').after($(document.createElement('br'))); cnt = cnt + 1; }); } Looking through various searched, it should work with something like... $('#leftSpan').mouseover(function () { $('#lblOutput').html(this.id); }); or, as I suspect, it is something to do with the nesting of the label/input that I need to reference the parent or child. Any pointers would be appreciated.

    Read the article

  • How to Add "Write a Review" / "Rate Us" Feature to My App?

    - by Ohad Regev
    I wish to add some sort of a "Write a Review" or "Rate Us" feature to my app so my customers can easily rate and review my app. Best practice I can think of is to have some sort of pop-up or open a UIWebView within my app so the user is not kicked off of my app while opening the App Store application as done in: [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms://itunes.com/apps/myAppName"]]; Does anyone knows of a way to do that?

    Read the article

  • Blogging After The Blog Boom

    - by Tim Murphy
    I have been blogging on Geeks With Blogs since 2005 and on other blogging sites before that.  In this age of Twitter, Facebook and G+ it feels like we are in the post-blog age and yet here I continue.  There are several reasons for this.  The first is that I still find it to be the best place for self publishing long form thought that won’t fit well on Twitter or Facebook.  Google+ allows for this type of content, but it suffers from the same scroll factor as the other social media platforms.  If you aren’t looking at the right moment you miss it.  On a blog I can put complete thoughts with examples and people can find what they want via key words or search engine. The second reason I blog is to have a place for me to put information I want to be able to reference back to later.  Although I use OneNote which is now accessible everywhere the blog gives me somewhere to refer co-workers and clients when I have solutions for problems I have previously solved. I know that other people use their blog as a resume builder, but that hasn’t been one of my primary concerns.  Don’t get me wrong.  Opportunities do come up because you put out well thought out, topical material.  That just isn’t one of my top motivators. I don’t always find the time to blog or even have anything to say lately, but I will continue to produce content for myself and others to learn from and hopefully enjoy. del.icio.us Tags: Blogging,Social Media

    Read the article

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