Search the Community
Showing results for tags 'reference'.
-
I'm trying to build a simulator to let users train with. It's a good bit of code at the moment so hopefully this isn't too much for someone to look at right now. Basically, it's Windows in a web page. http://tomsfreelance.com/windows_virtual_security/ Current Behavior: When opening two "Outlook" windows, changing the folder in the first window changes the second windows outlook. Desired Behavior: The folders should be specific to the window. Steps to Reproduce: Double click on "Outlook", doubleclick the title bar to take it out of full screen, then open another Outlook window. Next, click on a folder in the first window. Note that the folder changes in the second window. I know the code below is a lot, so if anyone is willing to view the actual site posted above and try and debug what is happening instead I'd appreciate it very much. (Need a second set of eyes on this, because mine aren't finding it.) The entire code can be seen at http://tomsfreelance.com/windows_virtual_security/js/desktop.js The outlook object is created via a function call: function outlook() { var params = { ... menu : ..., messages : ..., panes : ..., functions : { selectFolder : function(that, folder) { //that.aliases['Folder->' + folder].block.css("background-color", "#EEEEEE"); //that.count = 0; //setInterval(function() { that.titleBarContainer.text(++that.count); }, 1000); console.log(that); var that = that; // Set title that.aliases['Current Folder'].block.text(folder); var subPanes = []; // Get messages if (that.options.params.messages[folder]) { for (var i in that.options.params.messages[folder]) { // Rebuild sub pane object. subPanes.push([{ css : { }, "class" : "outlook_preview", text : that.options.params.messages[folder][i].Subject, resizable : false, height : "22px" }]); } } that.aliases['Folder Messages'].block.empty(); var parentPane = $('<table class="child_pane"></table>').appendTo(that.aliases['Folder Messages'].block); that.buildPanes(parentPane, subPanes); } .......... } } }; return params; } And new windows are spawned via function create_window(parameters) { var param = parameters; var window = $('<div></div>').prependTo('body'); window.window({ params : param }); $('#start_menu').hide(); } The random variable reassignments is me trying to break the reference since I have no clue why / where it is happening... (var param = parameters) The "selectFolder" function is called from the Window jQuery widget I created: $(function( $, undefined ) { $.widget("ui.window", $.ui.mouse, { self : this, ..., _create : function() { console.log(this); this.createWindow(); var that = this; $('html').click(function() { $('.menu').hide(); }); }, createWindow : function() { ... // Content panes this.buildPanes(this.panesBlock, this.options.params.panes); this.scalePanes(); ... }, buildPanes : function(paneBlock, panes) { var pane = null; var that = this; for (var i in panes) { this.paneRows++; var rowPane = $('<tr></tr>').appendTo(paneBlock); for (var h in panes[i]) { panes[i][h].block = $('<td class="pane"></td>').appendTo(rowPane); ... if (pane.subPanes) { var parentPane = $('<table class="child_pane"></table>').appendTo(panes[i][h].block); that.buildPanes(parentPane, pane.subPanes); } if (pane.alias) { that.aliases[pane.alias] = pane; } ... if (pane.onClick) { that.onClick(that, pane); } if (pane.onLoad) { that.onLoad(that, pane); } } } }, onClick : function(that, pane) { pane.block.on("click", function() { pane.onClick(that, pane.id); }); }, onLoad : function(that, pane) { var pane = pane; var that = that; pane.onLoad(that, pane.id); }, scalePanes : function(addHeight) { var pane = null; var contentHeight = this.element.outerHeight() - (this.titleBar.outerHeight() + this.menuBar.outerHeight() + this.statusBar.outerHeight()); if (this.element.hasClass("windowed")) contentHeight -= 4; var contentWidth = this.contentBox.outerWidth(); if (addHeight) contentHeight += addHeight; console.log(contentHeight); this.panesBlock.outerHeight(contentHeight); /* for (var i in this.options.params.panes) { pane = this.options.params.panes[i]; if (pane.height) { pane.block.outerHeight(contentHeight * (pane.height / 100)); } if (pane.width) { pane.block.outerWidth(contentWidth * (pane.width / 100)); } } */ }, closeWindow : function() { this.element.remove(); } }); });
-
i have a foreach statement which looks like this foreach(static::$_components as &$field){ ..some code } in "some code" i sometimes add more components to "static::$_components" member if the insertion happens not at the final iteration it works, and the foreach detect & use the last insertion. but if the insertion happens at the last iteration the foreach statement breaks(ends) without detecting & using the last insertion there is any workaround for this issue beside using for loops and count(array). i prefer using foreach due to performance demands for($iterator = 0, $field = ''; null != ($field = empty(static::$_components[$iterator]) ? null : static::$_components[$iterator]); $iterator++){ ...some code } consumes a lot of memory and proccessing time using for($iterator = 0; $iterator < count(static::$_components); $iterator++){ ...some code } is even worse Thanks in advance