Jump to content

beennn

Members
  • Posts

    117
  • Joined

  • Last visited

beennn's Achievements

Member

Member (2/7)

7

Reputation

  1. The results in the example above are stored in the array in the order that the response is received, not in the order that the requests are sent. So in the original post, where xhr[0] should equal 0.png, it's possible that 1.png is received before 0.png and so that is stored in xhr[0] instead.
  2. Thanks, wasn't the answer I was hoping for, but it got me on the right track. I ended up adding the responses to an array; when I had all the responses back, I sorted the array from 0 upwards and that fixed me problem. Alternatively, if I didn't need to set responseType, I could have just set async to false.
  3. I am trying to fetch some images from a server, however I need them to come back in the order requested. Currently, the below returns the images back in a seemingly random order, I guess which ever are finished first. How can I ensure I get the images back in the order they were requested? var xhr = [];for (i = 0; i < count; i++){ (function (i){ xhr[i] = new XMLHttpRequest(); xhr[i].open( "GET", url + dir + "/" + i.toString() + ".png", true ); xhr[i].responseType = "arraybuffer"; xhr[i].onreadystatechange = function () { if (xhr[i].readyState == 4 && xhr[i].status == 200) { var arrayBufferView = new Uint8Array( xhr[i].response ); var blob = new Blob( [ arrayBufferView ], { type: "image/png" } ); console.log("xhr: " + i + ".png"); } }; xhr[i].send(); })(i); } I want it to always output: xhr: 0.png xhr: 1.png xhr: 2.png I currently get a mixture of, and including the above: xhr: 0.png xhr: 2.png xhr: 1.png Or: xhr: 1.png xhr: 2.png xhr: 0.png
  4. I'm trying to convert: http://techslides.com/demos/image-video/create.html to work with images on a server. Currently the demo above uses local files: if(filesarr.length>0){ //loop through them and process for(i=0; i<filesarr.length; i++) { var file = filesarr[i]; if(file.type.match(/image.*/)){ process(file); } else { document.getElementById('status').innerHTML = "This file does not seem to be a image."; } } } else { document.getElementById('status').innerHTML = "Please select some images."; } I'm trying to fetch them from a server, so I have replaced the above with: for(i=0; i < 2; i++) { var url = "http://localhost/uploads/" + i.toString() + ".png"; var file = new Blob(); var xhr = new XMLHttpRequest(); xhr.open('GET', url, true); xhr.responseType = 'blob'; xhr.onload = function(e) { if (this.status == 200) { file = new Blob([this.response], {type: 'image/png'}); process(file); } }; xhr.send(); } Could someone tell me what I am doing wrong? I am not getting any errors so I have no idea. EDIT: I feel very silly, there is nothing wrong with the above. I was still checking against the size of filesarr further down the script.
  5. Is it possible to print an image (send it to a users printer) that is not on the current page? I have an application which uploads an image to a server, then a js function which currently opens the image alone in a new window, where I am then printing the image from. However instead of this, I would prefer the user stay on their current page, and have the print dialogue pop up there, rather than sending them to a new window with just an image. Any help or advice is much appreciated.
  6. Ah ok, I'll do that. Thank you both for the help.
  7. Is it not possible to achieve the desired result with a single div that's floating left?
  8. Currently I have: However, I'm after: Using: .expandable_window { float:left; margin-top: 20px; margin-bottom: 20px; margin-left:20px; max-width:46%; background: linear-gradient(white, c8c8c8); box-shadow: 10px 10px 5px #888888; } Any help is much appreciated.
  9. Thanks for this, looks like it could be - definitely a big help. I believe that method specifically only applies to MySQL databases though; not saying you can't achieve the same thing with other dbms's. I've managed to find what I was looking for, and they do compare to those seen on the wiki, just named differently. I'll post it here since I was unable to find it anywhere else. Full (Dense) Index Partial (Sparse) Index Partial Block Index Multi-level Index Partial Block: A partial index can be used to index blocks of data efficiently. The partial index contains the key value for the last record in each block. As a block is the smallest unit of data that may be read from the disc, the index will always read the minimum number of blocks. Multi Level: When the number of indexed values is large, the index will not fit in one block. Therefore, the contents of the index must be placed in two or more blocks As the number of blocks required to store the index grows, so searching the index becomes a major problem. In the same way that a data file takes a long time to search, a large index (occupying many blocks) will also take a long time to search. The solution to this problem is to create an index of an index. That is, the single index is split into a number of blocks and a new index is created that indexes each block. For example, to index a set of names we might split the name index between two blocks. All names beginning with ‘M’ or less are placed in block 1 and all names beginning with letters greater than ‘M’ are placed in block 2. A third block is created points to blocks 1 and 2. The indexed sequential file is a sequential file with a corresponding index.
  10. Types of Indexes: Full - examines all of the words in every stored document as it tries to match search criteria (text specified by a user). Partial - also known as filtered index is an index which has some condition applied to it so that it includes a subset of rows in the table. Partial-Blocked - ? Multi - ? Does anyone know any learning resources where I can read up on partial-blocked and multi indexes? I'm unable to find anything under these terms, perhaps they are known as something else? Also, how do these compare to types of index found here: http://en.wikipedia.org/wiki/Database_index#Types_of_indexes. I assume they are the same just named differently since the definitions are similar, though I'm not sure. If someone could help clarify some of this for me, I'd be very grateful. Any help would be much appreciated.
  11. I have several of the same floating div, and I'd like them to have an equal margin between themselves and other elements on the page, for example the header and footer (if there's a margin of 5px on the floating div, this stacks to 10px when touching the same div, however when hitting the header or footer, is only 5px). Is it in anyway possible to collapse a margin connected to a floating div? Currently I've just added and extra margin to the top and bottom of the footer/header to make the difference, but in the long run, if it's possible; it would be easier if there was a way to collapse them.
  12. My understanding is, collapsing margins on a floating div is not possible, is there a work around which can achieve the same effect?
  13. beennn

    Floating Divs

    Aah, thank you. The div which the content div was in had a margin which was causing it.
  14. beennn

    Floating Divs

    I'm having some trouble getting multiple divs floating next to each other. Here's what I have so far: .content { width:auto;max-width:100%;float:left;padding:15px;} which gives: However I'm aiming for: Any ideas?
  15. Here's what I've tried: <script> <? for ($i = 0; $i < sizeof($result_array); $i++) { ?> document.write('<? echo $i ?>'); <? } ?> </script> and <script> <? for ($i = 0; $i < sizeof($result_array); $i++) { ?> document.write('<? $i ?>'); <? } ?> </script> I've also tried just using JavaScript with the PHP variable embedded but still not luck. Any ideas? EDIT: Turns out I just needed to use <?php instead of <?
×
×
  • Create New...