MacBook, defective by design banner

title:
Put the knife down and take a green herb, dude.


descrip:

One feller's views on the state of everyday computer science & its application (and now, OTHER STUFF) who isn't rich enough to shell out for www.myfreakinfirst-andlast-name.com

Using 89% of the same design the blog had in 2001.

FOR ENTERTAINMENT PURPOSES ONLY!!!
Back-up your data and, when you bike, always wear white.

As an Amazon Associate, I earn from qualifying purchases. Affiliate links in green.

x

MarkUpDown is the best Markdown editor for professionals on Windows 10.

It includes two-pane live preview, in-app uploads to imgur for image hosting, and MultiMarkdown table support.

Features you won't find anywhere else include...

You've wasted more than $15 of your time looking for a great Markdown editor.

Stop looking. MarkUpDown is the app you're looking for.

Learn more or head over to the 'Store now!

Wednesday, November 30, 2011

As I'm sitting here rewatching Insomnia, I find myself wondering if anyone records the TV Channel. Interesting artifacts on that one.

Honestly, the TV Channel deciding to show "real" shows (and only two channels' worth of schedule at a time, which takes forever) is brilliant. I wanted to catch Insomnia, but also got stuck on Dharma and Greg  [sic] earlier this afternoon when I was just checking what's on...

Labels:


posted by ruffin at 11/30/2011 09:17:00 PM

But be prepared. Javascript keystrokes are insane. If anyone tells you that you can provide thick functionality in a browser, they're right, but there match a desktop app's ease when guiding user input? Impossible.

JavaScript - Detecting keystrokes:

Punctuation keys

I decided not to test the punctuation keys. I suspect that these keys are dependant not only on browser and operating system, but also on keyboard configuration and the official system language. I work on a Dutch Windows, but with a US 101 keyboard configuration, and I wouldn't be surprised if that matters a lot in punctuation keys experiments.

For instance, shift +, causes a < character to appear in my applications, but the ASCII value returned by my test script belongs to the ?. When I discovered that I decided not to risk my sanity by performing further punctuation character experiments. [emph mine -mfn]


Another favorite, this time for the number lock.

Chaos on Mac. Mozilla and Safari give 12, Opera 27.

Safari gives 63289 onkeypress.

Labels:


posted by ruffin at 11/30/2011 10:31:00 AM
Friday, November 25, 2011

I've been using Word Starter a lot recently. For some reason, it's all I've got at work, and it's also on the new HP subcompact (d1m) I finally received last week. It's not bad, and it even is nice enough to support the menu-based keyboard shortcuts I'm used to using. But when I tried to add a footnote -- I think that's Alt-I-N -- nothing happened. It sat around waiting for me to hit something after I. Perhaps I'm using Word 2000 shortcuts, or perhaps I just didn't remember correctly. But perhaps I can't add a footnote?

If you check the help to see how to add a footnote, Word Starter'll tell you that, sure enough, you can't add a footnote to a document.

Microsoft Word Starter 2010 is a simplified version of Word that comes pre-loaded on your computer. Word Starter includes features that are basic to creating and working with documents, but it does not include the rich set of features found in the full version of Word. This article lists the differences in features between Word Starter and the full version of Word.

If you find that you need a richer set of features than what Word Starter provides, you can easily upgrade from Word Starter to Word. On the Home tab, click Purchase to visit an online retailer, where you can purchase and download Office right away.


That's cute. Here's the footnote specific jive:

Footnotes and endnotes

Not available to create

If you open a document that contains footnotes or endnotes, you can click the footnote or endnote link to jump to the footnote or endnote. You can also cut, copy, or paste the footnote or endnote, and you can format the text.


Hrm. That seems weird. What if I want to move text that has a footnote by cutting and pasting? What if I want to duplicate text by copy and pasting? Does the footnote go away?

No, and that's how you add 'em. Highlight the footnote, copy, and paste in somewhere else. Now edit from the old footnote text to the new.

Of course, this requires that you have a doc to cut and paste from that already has a "donor" footnote. Hey, look! Here's one now! (Though always be wary of taking Word docs from strangers.)

It's an interesting move by Microsoft -- you're essentially giving Word away for free, except for those who don't like feeling constricted when they edit, in spite of the fact that pretty much everything is still there. Wonder how much we can thank OpenOffice for this?

Labels: ,


posted by ruffin at 11/25/2011 04:29:00 PM
Wednesday, November 23, 2011

I've got a web app that has a few buttons that I think are better handled purely within the browser, with no asp.net codebehind blind. So one is a "Save" button that includes... onclick="if (Page_ClientValidate()) document.forms[0].submit();"

Now I wrote that, but wondered what the heck Page_ClientValidate was as I looked back. There was no other Page_ClientValidate in the project or even the entire solution. Argh. It was pretty obviously running some Microsoft validation code, and I'm currently using plain jane ASP.NET validators on this page. So I figured MS had hidden the function on me somewhere

Sure enough. Here's what I suspect is the javascript file include with the function.

   1 <script src="/WebResource.axd?d=RqZmHVG6Bo97ETCETCETC&amp;t=634245046914809245" 
2 type="text/javascript"></script>
3 <script type="text/javascript">
4 //<![CDATA[

5 function WebForm_OnSubmit() {
6 if (typeof(ValidatorOnSubmit) == "function"
7 && ValidatorOnSubmit() == false) return false;
8 return true;
9 }
10 //]]>

11 </script>


And sure enough, in that page we find the function in question.

   1 function Page_ClientValidate(validationGroup) {
2 Page_InvalidControlToBeFocused = null;
3 if (typeof(Page_Validators) == "undefined") {
4 return true;
5 }
6 var i;
7 for (i = 0; i < Page_Validators.length; i++) {
8 ValidatorValidate(Page_Validators[i], validationGroup, null);
9 }
10 ValidatorUpdateIsValid();
11 ValidationSummaryOnSubmit(validationGroup);
12 Page_BlockSubmit = !Page_IsValid;
13 return Page_IsValid;
14 }


I don't know why I don't like the setup. I mean, ASP.NET either has to throw this stuff into your page, and there's already plenty of wacky javascript in there, or slap it into an include. They chose the second, and I'm often a little upset when they do the former. Go figure. I mean, heck, they even use human-readable var names to make it easy for you to figure out what they're doing. Just like any other lib (I'm looking at you, jQuery), there's going to be stuff you didn't write, you know?

I guess I just don't like all the overhead and the way their whitespace and code includes completely break with the way I do it. When I use jQuery, there are some includes and a few lines of code in a specialized format. I can still manage the way the code feels when you run through the logic and whitespace. With this auto-generated stuff, I can't as easily. I don't know.

Anyhow, that's where Page_ClientValidate is.

Labels:


posted by ruffin at 11/23/2011 02:28:00 PM

I love to comment code. Sometimes I think it's past the point of usefulness, where my code looks like it might be approaching half comments. That could be bad, but each time I come into code cold, after a break, I'm awfully glad the commenting is there. I hope it's at least half as helpful to others that use my jive.

But there is at least one place that lots of comments probably isn't helpful, for two reasons, and that's in code that's sent via network to your user. If it's a javascript include, comments are less useful. Unlike, well, most anything else, that compiles your code to some not exactly interpreted state, javascript sends EVERYTHING to your user.

I'll admit, I'm often a bad programmer, and leave everything in there, helping only those two want to prank my code or, more likely, myself when I want to remember what I did in a past project and don't have my codebase handy.

But ultimately comments are bad news in Javascript because 1.) you want to obfuscate how your code works in the wild and 2.) more bytes means more network traffic for your server to pump out means, ultimately, slower performance, even in the 2010s.

So the easy way out is to minimize your Javascript. It looks like The Right Way to do that is with Yahoo's YUI Compressor:

In terms of code minification, the most widely used tools to minify JavaScript code are Douglas Crockford's JSMIN, the Dojo compressor and Dean Edwards' Packer. Each of these tools, however, has drawbacks. JSMIN, for example, does not yield optimal savings (due to its simple algorithm, it must leave many line feed characters in the code in order not to introduce any new bugs).
...
The YUI Compressor is JavaScript minifier designed to be 100% safe and yield a higher compression ratio than most other tools. Tests on the YUI Library have shown savings of over 20% compared to JSMin (becoming 10% after HTTP compression).


Goodbye comments! And hello greater than average savings.

posted by ruffin at 11/23/2011 02:00:00 PM
Tuesday, November 22, 2011

Interesting. I'm seeing this too:

I believe I noticed that the "Enter key" functionality depends on the
presence of an in the form. I had a form where I
replaced it with a (to allow underlined letters) and the Enter key
stopped working there and then.


I was actually Googling up how to stop folks from being able to submit a form by pressing return in a textbox, but it looks like if you remove the Submit button (and/or turn it into a normal type="button" INPUT element), that already happens.

Interesting. Hope that's a crossbrowser solution. Hello, testing time.

posted by ruffin at 11/22/2011 08:35:00 AM

If your spam filter can't catch these, you're doing it wrong, okay? I've posted about this before, and it's about the fifth or sixth time I've had one get through. How does this happen? Add a hard-coded rule, for heaven's sake.

...
Return-Path:
Received: from p3plwbeout15-02.prod.phx3.secureserver.net (p3plsmtp15-02-2.prod.phx3.secureserver.net. [173.201.193.36])
by mx.google.com with SMTP id p1si11234722pbk.157.2011.11.21.19.30.25;
Mon, 21 Nov 2011 19:30:26 -0800 (PST)
Received-SPF: neutral (google.com: 173.201.193.36 is neither permitted nor denied by best guess record for domain of drnormsas@adedejisanniclothingline.com) client-ip=173.201.193.36;
...
From: "Gmail Team"
X-Sender: drnormsas@adedejisanniclothingline.com
To: membershipupgrade@gmail.com
Subject: ALERT : Gmail Member Warning
Date: Mon, 21 Nov 2011 20:30:24 -0700
Mime-Version: 1.0


Dear Account Users,

We regret to inform you that starting from 20th November 2011, Your Account will no longer allow you to send or welcome messages, files and pages due to malicious and spy wares activities detected on our old database system. To avoid this adverse effect on your Account, we want you to keep your Account content active and your data up to date on our new database system by providing us with your account information above correctly for proper confirmation.

Email Address:
Password:
Re-Type Password:
Full Names:
Date of Birth:
Occupation/Profession:
Country:

MEMBER-: Account owner that refuses to update his or her account within seven days of receiving this warning will lose his or her account permanently. your account need to be well checked and 100% verified so it will be ACTIVE and it will be UPGRADED automatically.


Member Verification & Upgrade Team. ยฉ2011


Labels:


posted by ruffin at 11/22/2011 06:37:00 AM
Monday, November 21, 2011

c# - JQuery UI Dialog with Asp .NET button postback - Stack Overflow:

$('#divname').parent().appendTo($("form:first"));


That was a pulling hair out situation.

Got more help (and fuller description of what was going on) here:

One of the first things you will notice when you try and use JQuery UI Dialog in ASP.Net page is it does not perform post backs from within the dialog window. This is because in a ASP.Net page there is only one form element and Jquery appends the dialog "div" outside of the form element.

posted by ruffin at 11/21/2011 03:38:00 PM
Wednesday, November 16, 2011

   1 //=======================================================================
2 // __ __ __ __ __ ___ __ ___ __
3 // | / \ / _` |__) | | \ / \ \ / |__ |__) |__| |__ /\ | \
4 //\__/ \__X \__> | \ | |__/ \__/ \/ |___ | \ | | |___ /~~\ |__/
5 //=======================================================================
6 var lastSel = -10;
7
8 // http://www.trirand.com/jqgridwiki/doku.php?id=wiki:events for events.
9 // http://www.ok-soft-gmbh.com/jqGrid/ActionButtons.htm for buttons inline
10 // http://stackoverflow.com/questions/5196387/jqgrid-editactioniconscolumn-events/5204793#5204793
11 // for description of above/formatter:actions
12 // http://www.trirand.com/jqgridwiki/doku.php?id=wiki:form_editing on editing and using add buttons, etc.
13 // http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_buttons straight custom buttons
14 $(function() {
15 $("#list").jqGrid({
16 url: '<%= ResolveUrl("~/secretLoc.aspx") %>?oper=DEMO_NAMES',
17 editurl: '<%= ResolveUrl("~/secretLoc.aspx") %>?oper=DEMO_NAME_EDIT',
18 datatype: 'json',
19 mtype: 'GET',
20 colNames: [ 'Edit', '+', 'Name Type', 'Prefix', 'First', 'Middle', 'Last', 'Suffix'],
21 colModel: [
22
23 {name:'act',index:'act',width:40,align:'center',sortable:false,formatter:'actions',
24 formatoptions:{
25 // we want use [Enter] key to save the row and [Esc] to cancel editing.
26 keys: true,
27 // user cannot delete aliases/names
28 delbutton : false,
29 onEdit:function(rowid) {
30 alert("in onEdit: rowid="+rowid+"\nWe don't need return anything");
31 },
32 onSuccess:function(jqXHR) {
33 // the function will be used as "succesfunc" parameter of editRow function
34 // (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing#editrow)
35 alert("in onSuccess used only for remote editing:"+
36 "\nresponseText="+jqXHR.responseText+
37 "\n\nWe can verify the server response and return false in case of"+
38 " error response. return true confirm that the response is successful");
39 // we can verify the server response and interpret it do as an error
40 // in the case we should return false. In the case onError will be called
41 return true;
42 },
43 onError:function(rowid, jqXHR, textStatus) {
44 // the function will be used as "errorfunc" parameter of editRow function
45 // (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing#editrow)
46 // and saveRow function
47 // (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing#saverow)
48 alert("in onError used only for remote editing:"+
49 "\nresponseText="+jqXHR.responseText+
50 "\nstatus="+jqXHR.status+
51 "\nstatusText"+jqXHR.statusText+
52 "\n\nWe don't need return anything");
53 },
54 afterSave:function(rowid) {
55 alert("in afterSave (Submit): rowid="+rowid
56 +"\nWe don't need return anything");
57 },
58 afterRestore:function(rowid) {
59 alert("in afterRestore (Cancel): rowid="+rowid
60 +"\nWe don't need return anything");
61 } //,
62 //delOptions: myDelOptions
63 }
64 },

65 { name: 'EDITME', key:true, index: 'EDITME', width: 12 },
66 { name: 'NAMETYPE', index: 'NAMETYPE', width: 65 },
67 { name: 'PREFIX', editable:true, index: 'PREFIX', edittype:'select',
68 editoptions:{value:"<%= helperClasses.utils.dataTable2JqGridEditoptions(dtNamePrefixes) %>"},
69 width: 80 },
70 { name: 'FNAME', editable:true, index: 'FNAME', width: 200 },
71 { name: 'MNAME', editable:true, index: 'MNAME', width: 300 },
72 { name: 'LNAME', editable:true, index: 'LNAME', width: 200 },
73 { name: 'SUFFIX', editable:true, index: 'SUFFIX', edittype:'select',
74 editoptions:{value:"<%= helperClasses.utils.dataTable2JqGridEditoptions(dtNameSuffixes) %>"},
75 width: 80 },
76 ],
77 pager: '#pager',
78 rowNum: 10,
79 rowList: [10, 20, 30],
80 sortname: 'p_name_prefix',
81 sortorder: 'desc',
82 viewrecords: true,
83 height: 230,
84 width: 890,
85 jsonReader: { repeatitems: false, id: "0" },
86 caption: 'All Names',
87 //afterShowForm:afterShowAdd,
88
89 onSelectRow: function(id){
90 if(id && id!==lastSel && lastSel != -10){
91 jQuery(this).restoreRow(lastSel);
92 lastSel=id;
93 }
94 jQuery(this).editRow(id, true);
95 }
96
97 }).navGrid('#pager',{edit:false,add:true,addtext:"Add New Name",
98 refresh:false,del:false,search:false
99 }).navButtonAdd('#pager',{
100 caption:"Add new name", onClickButton:function(){ helloWorld("1001") },
101 position:"first"
102 })
103
104 });

Labels: , ,


posted by ruffin at 11/16/2011 03:26:00 PM
Tuesday, November 15, 2011

Linux GUI Development: Monodevelop 2.6 review and screenshots ๏ฟฝ The Mac Daddy:
This blog is part of a series looking at programming tools on linux and covers MonoDevelop 2.6

MonoDevelop 2.6 is awesome I first tried MonoDevelop about a year ago and gave up quickly. It just wasnโ€™t usable, but these days itโ€™s a totally different story.


I've got to say that I've had a similar experience. Last time I tried Mono/MonoDevelop, it stunk. And I was largely using SharpDevelop for my C# play (from which MonoDevelop forked), so it wasn't simply disliking the IDE's setup. Now, it seems ready to do some work, and I'm going to try this morning.

It does seem to eat up the battery on OS X, but we'll see if I can't get a couple of hours. I've had to remove the Ajax Control Toolkit reference, which I was using for its pretty danged impressive ComboBox implementation, but that was my only change to get things running. Oh, that, and using ClearSelection on DropDownLists, as having a default selected and then filling the GUI with values later apparently clashes in Mono-land.

But it's otherwise pixel perfect so far. I'm using data serialized to XML already for testing, so there's no chance for a connection issue. We'll see.

posted by ruffin at 11/15/2011 07:55:00 AM
Monday, November 14, 2011

MonoDevelop WinForms? - Ubuntu Forums:

Re: MonoDevelop WinForms?
WinForms is the System.Windows.Forms namespace. MonoDevelop has no integrated support for designing GUIs with WinForms - instead, it has an integrated editor for GTK# GUIs. You can hand-write WinForms GUIs if you want to, though


Welp, that kinda stinks. I actually ordered a horrendously inexpensive, likely wholly underpowered laptop so that I could program ASP.NET on the go (well, and to have an inexpensive copy of Windows 7 handy), and I think MonoDevelop on OS X might make me think I was an idiot for doing that for ASP.NET, but now not so much for when I want to run Windows applications.

(A laptop just for Windows? RLY? I seriously considered the MacBook Air and $130 for Windows 7, but I couldn't justify the extra price. And there are times I've got to get out of the home office and run to Starbucks to keep programming, so mobility is relatively important. And, finally, I had Boot Camp on my MacBook, which doubles as my primary OS X box, before, but it wasn't particularly wieldy. I often like to boot into OS X, and being a hard reboot away was simply too far. Another laptop "needed". There's just nothing good under $400. We'll see if that AMD E-450 is any good, though CPU Benchmarks tells me probably not (compare to my Core 2 Duo and Athlon X4. Ouch.))

That said, the Windows.Forms project does run with MonoDevelop/Mono without any tinkering, which is quite impressive. Obviously GTK look and feel, but it runs! Much more robust/mature than the last time I fooled around with this, iirc.

Labels: ,


posted by ruffin at 11/14/2011 11:33:00 AM
Sunday, November 13, 2011

My iPod touch (8 gigs) was pretty much full, and one of the worst culprits was the Apps section. It was well over two gigs. But when I added up all the sizes reported in iTunes, it wasn't close. I didn't have more than a gig of apps on there.

Long story short, after removing lots of apps I thought might have been hiding how much space they were taking (Kindle, my Gmail account in Mail, etc), I finally figured out it was Al Gore's Our Choice app. It was taking up about a gig all by itself, though it only reported about 60 megs [sic!].

It must be downloading tons of stuff in the background though I can never remember it not showing something when I was outside of WiFi range. Perhaps it was uncompressing files to show them and never recompressing, perhaps even doing it again with each view.

Strange. But that explained the lack o' space. And when you're shooting more pictures and movies because of how awsomez!11! iCloud's photo stream is, well, choo needs cho space.

Labels: ,


posted by ruffin at 11/13/2011 06:01:00 PM
Thursday, November 10, 2011

An Introduction to JavaScript Object Notation (JSON) in JavaScript and .NET:

* Jayrock is open-source, making it possible to extend or customize as needed.
...
* ... While ASP.NET AJAX includes some support for creating and parsing JSON text, its primary purpose is to offer a rich platform for building end-to-end Ajax-style web applications in ASP.NET. The extra bells and whistles can be distracting when your main focus is JSON.


That's the kind of attitude I like to see. So much stuff is overkill, like XML for AJAX.

EDIT: Also good -- The comments in json2.js, a reference impl for JSON here.

// Due to a specification blunder in ECMAScript, typeof null is 'object',
// so watch out for that case.

Labels:


posted by ruffin at 11/10/2011 08:31:00 AM
Wednesday, November 09, 2011

System.Diagnostics.Debugger.Break();

Enjoy.

Labels:


posted by ruffin at 11/09/2011 09:40:00 AM
Sunday, November 06, 2011

I've been impressed to find that my iPod touch has been synchronizing over WiFi when I start iTunes now, which is admittedly pretty neat. The more transparent the content loading process, the better -- and here, that's "Better as in magical" better.

Was looking to see where the magic was with my pictures, though, and things took a dive. I'd just gotten an extended battery for my Android phone that required a replacement phone back to cover the battery on steroids, and the back I received had much of its matte finish sluff off in the packaging. I took a picture to email the merchant with my iPod touch, and went to my Mac, ready to email it.

It's nowhere. I have Lion, but never upgraded iPhoto to match, so no Photo Stream there. Nor is Photo Stream automatically synchronizing with my Pictures folder.

But guess what? It is syncing with Windows Vista for free.

How To Get iCloud's Photo Stream Working On A PC:

I find it interesting that Windows users can get this utility for free. Whereas on the Mac, in order to get iCloud syncing you have to upgrade to OS X Lion, which costs $30. One of the few times PCs get the advantage over Macs with iDevices.


Yep, not just Lion, but also iPhoto for $15 more. So that's $45 to use Photo Stream on my Mac, $0 on Windows.

I recently defended Apple to someone who asked why they had to upgrade everything to the latest version to have it all work like this...

I think this way of doing business (having a very small set of supported devices and software) fairly obviously allows Apple to offer better integration and fancier features. And the market seems to respond to it.


But it still makes you wonder when Windows users come out ahead at times. (I believe the last time I posted about it was when a version of iTunes worked with a much older Windows computer than Mac.)

posted by ruffin at 11/06/2011 09:29:00 AM
Friday, November 04, 2011

Every so often I talk myself out of believing I know which JOIN I want to use in SQL-land. "LEFT OUTER doesn't mean "OUTER" from the point of view of the LEFT table does it? There's no way. It's the entire LEFT table's OUTERness. Right? Yes. Right? Well, try it. But it's a compound statement. I don't really want to write a stupid trial statement, do I? I know this. It's all of the LEFT."

"Right?"

This visual review is great. LEFT OUTER JOIN is exactly what I thought it was. (Thanks Denny Green):

Left outer join produces a complete set of records from Table A, with the matching records (where available) in Table B. If there is no match, the right side will contain null.



And continue... That'll last me another year or so.

Labels:


posted by ruffin at 11/04/2011 11:10:00 AM
Thursday, November 03, 2011

Codige follows. This is the first "seems to work" version. The Microsoft AJAX Control Toolkit ComboBox does a good job of providing almost identical functionality, but doesn't always show the "select"/dropdown portion of the pair.


   1 var gintStart = 0;
2 var gintEnd = 0;
3 var gstrLastVal = "";
4
5
6 function findMatch() {
7 frm1 = document.forms[0];
8 intMatch = -1;
9 txtLoc = frm1.elements['txtLoc'];
10 lstLoc = frm1.elements['<%=lstLocs.ClientID%>'];
11
12 var strCurText = txtLoc.value;
13 if (strCurText.length <= gstrLastVal.length) {
14 // ignore all this; allow deletes gracefully
15 } else {
16 //if ( gstrLastVal.length >= 2
17 //&& (0 != txtLoc.value.indexOf(gstrLastVal)) ) {
18 // gets rid of any hanging on autofilled text
19
20
21 if (0 != txtLoc.value.toUpperCase().indexOf(gstrLastVal.toUpperCase())) {
22 // txtLoc.value.slice(0, gstrLastVal.length - 1);
23 // then again let them do what they want. Don't try to overcomplete
24
25 } else {
26 if (txtLoc.value.length > 0) {
27 // go backwards to grab the first match
28 for (var i = lstLoc.options.length - 1; i >= 0; i--) {
29
30 var strOptTxt = lstLoc.options[i].text.toUpperCase();
31
32 if (0 == strOptTxt.indexOf(txtLoc.value.toUpperCase())) {
33 intMatch = i;
34 }
35 }
36
37 if (-1 != intMatch) {
38 lstLoc.options[intMatch].selected = true;
39
40 txtLoc.value = lstLoc.options[intMatch].text;
41 gintStart = strCurText.length;
42 gintEnd = txtLoc.value.length;
43 // (kinda ruining the whitespace to reduce width for blog)
44 //createSelection(txtLoc,strCurText.length,txtLoc.value.length);
45 // it looks like this tries to set the selection while focus is
46 // still going to another control, blowing up the selection.
47 // thus the delay tactics.
48 // unsuccessful delay tactics commented, below.
49 //backdoorSelection();
50 //setTimeout("createSelection(txtLoc,strCurText.length,txtLoc.value.length)",100);
51 //setTimeout("createSelection(txtLoc,4,9)",100);
52 setTimeout("backdoorSelection()", 30);
53 } else {
54 // no match. Deselect anything selected
55 lstLoc.selectedIndex = -1;
56 }
57 }
58 }
59 }
60 gstrLastVal = strCurText;
61 }
62
63 function backdoorSelection() {
64 createSelection(document.forms[0].elements['txtLoc'], gintStart, gintEnd);
65 }
66
67 function createSelection(field, start, end) {
68 if (field.createTextRange) {
69 var selRange = field.createTextRange();
70 selRange.collapse(true);
71 selRange.moveStart('character', start);
72 selRange.moveEnd('character', end);
73 selRange.select();
74 } else if (field.setSelectionRange) {
75 field.setSelectionRange(start, end);
76 } else if (field.selectionStart) {
77 field.selectionStart = start;
78 field.selectionEnd = end;
79 }
80 field.focus();
81 }

Labels: , ,


posted by ruffin at 11/03/2011 08:27:00 AM

<< Older | Newer >>


Support freedom
All posts can be accessed here:


Just the last year o' posts:

URLs I want to remember:
* Atari 2600 programming on your Mac
* joel on software (tip pt)
* Professional links: resume, github, paltry StackOverflow * Regular Expression Introduction (copy)
* The hex editor whose name I forget
* JSONLint to pretty-ify JSON
* Using CommonDialog in VB 6 * Free zip utils
* git repo mapped drive setup * Regex Tester
* Read the bits about the zone * Find column in sql server db by name
* Giant ASCII Textifier in Stick Figures (in Ivrit) * Quick intro to Javascript
* Don't [over-]sweat "micro-optimization" * Parsing str's in VB6
* .ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture); (src) * Break on a Lenovo T430: Fn+Alt+B
email if ya gotta, RSS if ya wanna RSS, (?_?), ยข, & ? if you're keypadless


Powered by Blogger etree.org Curmudgeon Gamer badge
The postings on this site are [usually] my own and do not necessarily reflect the views of any employer, past or present, or other entity.