ClockInfo.com
Commentary about clock repair and clock history (with some tidbits on web site development)

ClockInfo.com

Ajax In Place Autocomplete Editor for CakePHP

July 29, 2007 . by Bill

The Scriptaculous InPlaceEditor and Autocompleter are very useful, and I needed a combination of them: when you click on a field to edit it, the Autocompleter comes up with a list of options, then after you choose an option and click “ok”, the ID of the selected element is sent to the server and the new text is sent back for display.

Here is the code used in my view:

// data to be displayed for editing
$fk_data = $input_data[$ForeignModelName][$foreign_column_name];

$editor_data =
“<td $display_style>\n
<div id=\”{$ModelName}_{$ForeignModelName}_
{$foreign_column_name}_{$rowId}\”>$fk_data</div>\n
<div id=\”{$ModelName}_{$ForeignModelName}_
{$foreign_column_name}_{$rowId}_ac_choices\”
class=\”autocomplete\”
style=\”opacity: 1; display: none;\”>
</div>
<script type=\”text/javascript\”>
var editor=new Ajax.InPlaceEditor(
‘{$ModelName}_{$ForeignModelName}_
{$foreign_column_name}_{$rowId}’,
‘/devadmin/{$controllerName}/editInPlaceDropDown/{$ForeignModelName}/
{$foreign_column_name}/{$ModelName}/{$fieldName}/{$rowId}’,
{cols: $size,
callback:function(form,value){
var request=\”value=\”+id;
return request;
}
}
);
Object.extend(editor, {
_createEditField: editor.createEditField,
createEditField: function() {
this._createEditField();
new Ajax.Autocompleter(
this.editField,
‘{$ModelName}_{$ForeignModelName}_
{$foreign_column_name}_{$rowId}_ac_choices’,
‘/devadmin/{$controllerName}/autocomplete/{$ForeignModelName}/
{$foreign_column_name}’,
{paramName: ‘q’ ,minChars: 2, frequency: 0.2,
afterUpdateElement: function(txt, li)
{
id = li.id.replace(’auto_’,”);
}
});}
});
</script>
</td>\n”;

$output .= $editor_data;

Here is the function editInPlaceDropDown, which is located in appController.php. It receives the ID of the row being edited as part of the URL, and receives the new value as the request variable ‘value’.

function editInPlaceDropDown($ForeignModelName, $foreign_column_name, $ModelName, $col_name, $rowId)
{

$ForeignModelName = text_input_filter($ForeignModelName);
$foreign_column_name = text_input_filter($foreign_column_name);
$ModelName = text_input_filter($ModelName);
$column_name = text_input_filter($col_name);
$rowId = integer_input_filter($rowId);
$value = integer_input_filter($_REQUEST['value']);

$this->layout = ‘ajax’;

if (!$this->RequestHandler->isAjax()) {
return true;
}

$this->$ModelName->id = $rowId;

$this->$ModelName->saveField($column_name, $value, true);

$new_value = $this->$ModelName->find(”$rowId = $ModelName.id”);

$new_value = $new_value[$ForeignModelName][$foreign_column_name];

$this->set(’new_value’, $new_value);
$this->render(’../common/ajax_update_field’);
}

Here is the autocomplete function, located in appController.php. It receives parameter “q” and returns the selection list, in the format documented in the comment.

function autocomplete($ForeignModelName, $foreign_column_name)
{

$ForeignModelName = text_input_filter($ForeignModelName);
$foreign_column_name = text_input_filter($foreign_column_name);

$this->layout = ‘ajax’;

if (!$this->RequestHandler->isAjax()) {
return true;
}

$text = text_input_filter($_REQUEST['q']);

$text = strtolower($text);
$data = $this->$ForeignModelName->findall(”lower($foreign_column_name) LIKE ‘%$text%’”, ”, “$ForeignModelName.$foreign_column_name ASC”);

$new_value = “<ul>\n”;
foreach ($data as $row=>$value) {
$new_value .= “<li id=\”auto_{$value[$ForeignModelName]['id']}\”>
{$value[$ForeignModelName][$foreign_column_name]}</li>\n”;
}
$new_value .= “</ul>\n”;

/*Sample output:
“<ul>
<li id=\”auto_12\”>Hi Bill</li>
<li id=\”auto_3\”>Hi Hairy!</li>
<li id=\”auto_5\”>Hi Holly</li>
<li id=\”auto_14\”>Hi Lovey</li>
</ul>”; */

$this->set(’new_value’, $new_value);
$this->render(’../common/ajax_update_field’);
}

The first <div> displays the text to be edited. The second <div> is used to display the drop down option list (by autocompleter). It has an initial style to not be visible.

The basic operation is this: Moving the cursor over the text field with the ajax InPlaceEditor causes it to be highlighted in yellow. Clicking on it changes it to an input form and activates the ajax autocomplete, via the object.extend, which causes inPlaceEditor’s internal function createEditField to be overridden by the one we define here (thanks to reference 1 for this approach!). The autocompleter sends parameter q, containing the text that has been typed into the input field, to the autocomplete function on the server; which returns the option choices in the following format:

<ul>
<li id=\”auto_12\”>Hi Bill</li>
<li id=\”auto_3\”>Hi Hairy!</li>
<li id=\”auto_5\”>Hi Holly</li>
<li id=\”auto_14\”>Hi Lovey</li>
</ul>

The afterUpdateElement function called by autoComplete gets the ID of the selected <li>. When “ok” is clicked, the callback function in inPlaceEditor sends a parameter in the form of value=ID to the editInPlaceDropDown function on the server, which saves the field in the database, then reads the new text value and returns it to the inPlaceEditor for display.

Many thanks to the following sources for their help:

  1. inplaceeditor + autocompleter on Ruby on Rails: Spinoffs
  2. Ajax Autocomplete With Scriptaculous by MetaPundit
  3. Extending Prototype.js by Elf M. Sternberg
  4. Ajax.In Place Editor on Scriptaculous Wiki
  5. Ajax.Autocompleter on Scriptaculous Wiki
  6. Ajax.In Place Collection Editor on Scriptaculous Wiki

Putting an American Antique Clock in Beat

. by Bill

A pendulum clock is out of beat when the ticking does not sound even (or more precisely, when the left tick and the right tick do not occur at the same angle of the pendulum from its point of rest). A clock that is slightly out of beat may run; if the beat error is severe, the clock will be unreliable or may not run for more than a few seconds.

Note: You can put a clock in beat by tilting it to the left or right until the ticking sounds even. If it looks too much off level to suit you, follow the instructions below.

These directions apply to American antique clocks of the “Connecticut” type such as Sessions, Ingraham, Gilbert, Seth Thomas, Waterbury, New Haven, etc., having an easy to bend crutch made of brass wire. The same principle applies to other clocks, but on some clocks the crutch is wide and hard to bend, on French clocks the escapement is delicate and you must be very careful, many modern clocks have a slip clutch for beat adjustment, some modern clocks (especially grandfather clocks) have automatic beat setting, and many precision clocks such as Vienna regulators (and some grandfather clocks) have a beat setting screw near the TOP of the pendulum.

American Strip Verge Escapement

Wall Clock: Clock should be leveled and fastened to wall at both top and bottom so it stays in place. Remove the hands and dial.

Shelf or Mantel Clock with pendulum in front: Place the clock on a level surface and remove the hands and dial.

Mantel Clock with rear pendulum: Place the clock on a level surface with the back facing you, and open the back door.

Refer to the View A and View B in the illustration above and follow the steps below to put the clock in beat.

  1. Move pendulum to the left or right until the escape wheel escapes from one pallet to the other. Release pendulum and see if clock keeps running for several seconds.
  2. Stop pendulum, and move it in the other direction until escape wheel escapes. Release pendulum and see if clock keeps running for several seconds.
  3. If the clock keeps running when started from both the left and right sides (or nearly so) clock is in beat.
  4. If the clock keeps running only when started from the left, slightly bend the verge wire to the right, as shown by the arrow in view A. To bend the verge wire, grasp it in needle nose pliers (or your fingers) about 1/3 of the way down from the verge, and bend the free end slightly with your fingers.
  5. If the clock keeps running only when started from the right, slightly bend the verge wire to the left, as shown by the arrow in view B. To bend the verge wire, grasp it in needle nose pliers (or your fingers) about 1/3 of the way down from the verge, and bend the free end slightly with your fingers.

Repeat steps 1) through 5) until the ticking sounds even. You can make the most precise beat determination when the pendulum is taking the minimum possible swing that will make the clock tick on both the left and right pendulum swing. A larger swing may mask beat errors.

Note: it is better to use a wire bender (a small metal rod with a slot in it) instead of pliers, but the pliers will suffice if you are careful.

Troubleshooting: Make sure the pendulum rod is not touching the front or back of the crutch loop - bend the crutch wire if necessary. Make sure the sides of the crutch loop are parallel and that there is slight clearance between the pendulum rod and the sides of the crutch loop.

When I was a youngster I experimented and learned how to put a clock in beat, and can do it almost without thinking. In the instructions above, I have tried to put my procedure into words and drawings suitable for the clock owner with some mechanical know-how. Please feel free to make a comment on how to make the instructions more clear!


Things to check when repairing an antique American clock movement

July 25, 2007 . by Bill

Here are some things I check or do when repairing an antique American clock movement of the open spring type.

  • Check wear on time and strike mainwheel teeth and record on log sheet.
  • If mainspring arbor hooks have high backs, file down the backside to make it easier to unhook the inner end of the mainspring in the future.
  • Check ratchets and clicks - do any repairs necessary. File burrs off bottom of clicks. Tighten or replace click rivets if necessary. Make sure click springs are secure. Be wary of round brass wire click springs such as used in Sessions clocks. If you have any doubt about their reliability, replace with click springs made of round spring steel wire.
  • Check motion work and clean its pivots.
  • Chamfer ends of pin that holds center wheel hand set tension spring.
  • Check lantern pinions - make a list of those needing new wires or wires reversed. Check for loose holes in shrouds that might let the wires fall out.
  • Check pivot holes - make a list of ones to bush.
  • Check pivots - make a list of those to turn down and polish or just polish.
  • Check for “tunneled” pivot holes - where pivot is too short for the hole. Deepen oil sinks so pivot protrudes past oil sink. Seth Thomas #124 movements and many German movement have this problem.
  • Check pins: warning, lock, lift, etc for tightness.
  • Check pins in plates for tightness and smoothness.
  • Check for verge wear. Slight wear in a verge can be left alone, especially a deadbeat verge. If you decide to move the escape wheel to engage with an unworn verge surface, do it now, before pivot work.
  • Repair pinions first, then do pivot work, then bushing work.
  • Use a smoothing broach to polish any pivot holes not bushed. Polish large pivot holes with leather strip.
  • Test each wheel pair for proper depth and proper pivot hole fit by putting each wheel pair between the plates. With your fingers on each end of the driven wheel for pressure, turn the driving wheel and feel how smoothly it turns the driven wheel. If the wheel depth is way off, you can feel it in this way.
  • Assemble all wheels between the plates and tighten the pillar nuts and/or screws. Check sideshakes, endshakes and free rotation of wheels. Then install the verge and check and ajust the escapement.
  • Check suspension spring - if it is merely dimpled to prevent it from sliding through the suspension post, punch a small hole (use an old staking tool) and insert flat brass wire. (Use #22 soft brass wire, flatten it slightly, bend it partly, insert in hole, comlete the bend and hammer it slightly.)
  • Smooth and polish suspension rod where the crutch embraces it (take off enough metal to remove the worn spot).
  • Polish the pallets if necessary. Install verge, test and adjust escapement. Check crutch to make sure it fits tightly into the verge. Check and adjust crutch loop.
  • Clean pivots of strike lever arbors, smooth end of count hook, smooth lifting surfaces. Replace the leather in the strike hammer if it is hard or worn down close to the metal.
  • After assembly, push mainspring loop ends toward back plate so mainspring won’t rub on mainwheel.

400 Day Clock Suspension Units

July 15, 2007 . by Bill

Installing a new suspension spring is a delicate operation, especially with the miniature clocks, which use a very thin spring. Another problem is making the spring the correct length and getting the fork and lower block in the proper location. It is easier to install a complete suspension unit, which is a pre-assembled unit containing the spring, top block, fork and bottom block. For many clocks, you will need the Horolovar 400 Day Clock Repair Guide to determine the correct suspension unit.

The following list gives the suspension unit id number for the Schatz clocks:

  • Schatz Standard model 49: Unit6789,
  • Schatz Miniature model 53: Unit 10A,
  • Schatz 1000 Day model 54: Unit 10B,
  • Schatz midget, model JUM/7: Unit 10C.

If you run a clock repair shop, I recommend that you buy suspension units from your regular clock part supplier.

I am not a clock parts supplier and don’t intend to compete with those in the clock parts business. As a service to the individual who wants to buy a suspension unit, you may buy them from me, under the following terms:

  1. Shipping to the USA and Canada only,
  2. The unit MAY NOT be returned after its package has been opened,
  3. Be aware that the clock may need more work beyond installing a suspension unit, so I do not guarantee that a new unit will make your clock work. If you need your 400 day clock repaired, see my Bill’s Clockworks web site,
  4. Each suspension unit is $34, plus a fee of $8.00 for shipping and handling for the entire order in the USA ($10 for shipping outside the USA),
  5. Please send a note with your name, address, e-mail address, the id number of the suspension unit you want, and your payment by check or money order in US Dollars to:

Bill’s Clockworks
8 W. Columbia Street
Flora, IN 46929

I will send the unit as soon as possible after receiving your check.


Seth Thomas Mantel Clock Glass Sizes

July 13, 2007 . by Bill

Seth Thomas “Woodbury” Chiming tambour mantel clock, catalog no. 1302, model E899-259 (dated 3-11-77 has Hermle movement): 5 3/4 inch convex glass lens

Seth Thomas Medbury - 5W Chiming tambour mantel clock (uses #124 movement, dated 50-05): 6 7/8 inch convex glass lens

Note: I do not sell clock parts - this information is being provided as a service. To buy clock parts, visit the clock parts suppliers listed in the links in the sidebar.


400 Day Clock Suspension Spring Sizes

July 9, 2007 . by Bill

A company called Horolovar makes suspension springs for 400 day clocks. Various thicknesses are available. If the spring is too thick the clock will gain time, and if too thin it will lose time

Suspension Spring Thickness for Schatz 400 Day and 1000 Day Clocks

Schatz clocks have a model number inside a circle on the back plate (49, 53, 54 or JUM/7). The other numbers on the back of a Schatz clock are the date code (month and year). Here are the suspension spring thicknesses for Schatz 400 day and 1000 day clocks:

  • Schatz standard size clock (49 on back plate): .004 inch
  • Schatz miniature (53 on back plate): .0023 inch
  • Schatz 1000 day clock (54 on back plate): .0024 inch
  • Schatz midget 400 day clock (JUM/7 on back plate): .0022 inch

Suspension Spring Thickness for Kundo 400 Day Clocks

  • Kundo full sized clock (about 12″ tall): .0032 inch
  • Kundo miniature clock (about 9″ tall, including the oval base model): .0023 inch
  • Kundo midget (similar to the miniature but the anchor pin has an offset bend and makes contact with the fork slightly behind the back plate): .0022 inch

For other clocks, you will need the Horolovar 400 Day Clock Repair Guide to determine the proper spring thickness. Note: measuring the old spring’s thickness is not a reliable method, as the spring may not be a Horolovar brand spring. The Repair Guide and suspension springs are available from Norkro.com and other clock parts suppliers.

The thicknesses given above are for genuine Horolovar suspension springs, which most clock suppliers sell. You may want to ask to be sure you are getting Horolovar suspension springs.


WordPress Permalink Format

July 6, 2007 . by Admin

Today I changed my WordPress permalink format to /posts/post_id

At first, I used the default date format /year/month/day/post_name but then decided that dates were not useful information in the URL.

Next I tried /category/post_name, but the URLs were just too long to look “pretty”. (And I thought that if I ever re-named a post, the URL would change. I learned that this is not necessarily the case, as the post_name in the URL is actually the “slug”, which does not change when the post name changes, but can be changed manually if desired).

Then I used /category/post_id, which seemed very good, until I realized that If I ever reorganize my categories, the permalinks will change, leading to bad links. As the blog grows, I can foresee the categories changing. For example, if one category gets many, many entries, it could make sense to divide it into sub-categories.

Finally (I hope its final!), I changed the permalink format to /posts/post_id, which I believe will actually result in permanent permalinks. The post_id will never change, even if the post’s date, name or category is changed. Having the word “posts” in the URL is a good idea, so there will be no confusion with the URL for your “pages” such as “About” which do not have any prefix in the URL (for example the URL for my “About” page is http://clockinfo.com/about, but a typical URL for a post is http://clockinfo.com/posts/18).

There is lots of debate over whether keywords in the URL help with search engine indexing. In my opinion, the content of a web page should matter to the search engine, not the URL, otherwise people could use all kinds of spam words in the URL to make a web page rank better. I will take my chance with short, simple permalinks and see what happens.

I hope now that I can leave my permalink format alone, so that the Google indexing will stabilize. If you think that I am making a big mistake (or agree with me), please comment!

(Note: don’t change your permalink format if your site has been active for a while unless you install a plugin to redirect old URLs to new URLs. This blog is just a few weeks old so I felt free to make changes.)


CakePHP - Do not name a table “models”!

July 5, 2007 . by Bill

I’m making a clock model database. Naturally enough, I named one of my tables “models”. Using CakePHP, I could enter data into the table, but neither data validation nor table associations would work. I renamed the table to “item” and everything is fine. Likewise, I suppose, a table should not be named “views” or “controllers”. I wonder what other names will not work.


« Previous Entries