Conditions | 1 |
Paths | 1 |
Total Lines | 59 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | /*jslint |
||
271 | Markers.createMarkerDiv = function (id) { |
||
272 | 'use strict'; |
||
273 | |||
274 | var alpha = id2alpha(id), |
||
275 | iconw = 33, |
||
276 | iconh = 37, |
||
277 | offsetx = (id % 26) * iconw, |
||
278 | offsety = Math.floor(id / 26) * iconh; |
||
279 | |||
280 | return "<div id=\"dyn" + id + "\">" + |
||
281 | "<table class=\"markerview\" style=\"width: 100%; vertical-align: middle;\">\n" + |
||
282 | " <tr>\n" + |
||
283 | " <td rowspan=\"3\" style=\"vertical-align: top\">\n" + |
||
284 | " <span style=\"width:" + iconw + "px; height:" + iconh + "px; float: left; display: block; background-image: url(img/markers.png); background-repeat: no-repeat; background-position: -" + offsetx + "px -" + offsety + "px;\"> </span>\n" + |
||
285 | " </td>\n" + |
||
286 | " <td style=\"text-align: center\"><i class=\"fa fa-map-marker\"></i></td>\n" + |
||
287 | " <td id=\"view_name" + alpha + "\" colspan=\"2\">marker</td>\n" + |
||
288 | " </tr>\n" + |
||
289 | " <tr>\n" + |
||
290 | " <td style=\"text-align: center\"><i class=\"fa fa-globe\"></i></td>\n" + |
||
291 | " <td id=\"view_coordinates" + alpha + "\" colspan=\"2\">N 48° 00.123 E 007° 51.456</td>\n" + |
||
292 | " </tr>\n" + |
||
293 | " <tr>\n" + |
||
294 | " <td style=\"text-align: center\"><i class=\"fa fa-circle-o\"></i></td>\n" + |
||
295 | " <td id=\"view_circle" + alpha + "\">16100 m</td>\n" + |
||
296 | " <td>\n" + |
||
297 | " <div class=\"btn-group\" style=\"padding-bottom: 2px; padding-top: 2px; float: right\">\n" + |
||
298 | " <button class=\"my-button btn btn-mini btn-warning\" data-i18n=\"[title]sidebar.markers.edit_marker\" type=\"button\" onclick=\"Marker.enterEditMode(" + id + ");\"><i class=\"fa fa-edit\"></i></button>\n" + |
||
299 | " <button class=\"my-button btn btn-mini btn-danger\" data-i18n=\"[title]sidebar.markers.delete_marker\" type=\"button\" onClick=\"Markers.removeById(" + id + ");\"><i class=\"fa fa-trash-o\"></i></button>\n" + |
||
300 | " <button class=\"my-button btn btn-mini btn-info\" data-i18n=\"[title]sidebar.markers.move_to\" type=\"button\" onClick=\"Markers.goto(" + id + ");\"><i class=\"fa fa-search\"></i></button>\n" + |
||
301 | " <button class=\"my-button btn btn-mini btn-warning\" data-i18n=\"[title]sidebar.markers.center\" type=\"button\" onClick=\"Markers.center(" + id + ");\"><i class=\"fa fa-crosshairs\"></i></button>\n" + |
||
302 | " <button class=\"my-button btn btn-mini btn-success\" data-i18n=\"[title]sidebar.markers.project\" type=\"button\" onClick=\"projectFromMarker(" + id + ");\"><i class=\"fa fa-location-arrow\"></i></button>\n" + |
||
303 | " </div>\n" + |
||
304 | " </td>\n" + |
||
305 | " </tr>\n" + |
||
306 | "</table>\n" + |
||
307 | "<table class=\"markeredit\" style=\"display: none; width: 100%; vertical-align: middle;\">\n" + |
||
308 | " <tr>\n" + |
||
309 | " <td rowspan=\"4\" style=\"vertical-align: top\"><span style=\"width:" + iconw + "px; height:" + iconh + "px; float: left; display: block; background-image: url(img/markers.png); background-repeat: no-repeat; background-position: -" + offsetx + "px -" + offsety + "px;\"> </span>\n" + |
||
310 | " <td style=\"text-align: center; vertical-align: middle;\"><i class=\"icon-map-marker\"></i></td>\n" + |
||
311 | " <td><input data-i18n=\"[title]sidebar.markers.name;[placeholder]sidebar.markers.name_placeholder\" class=\"edit_name form-control input-block-level\" type=\"text\" style=\"margin-bottom: 0px;\" value=\"n/a\" /></td>\n" + |
||
312 | " </tr>\n" + |
||
313 | " <tr>\n" + |
||
314 | " <td style=\"text-align: center; vertical-align: middle;\"><i class=\"icon-globe\"></i></td>\n" + |
||
315 | " <td><input id=\"edit_coordinates" + alpha + "\" data-i18n=\"[title]sidebar.markers.coordinates;[placeholder]sidebar.markers.coordinates_placeholder\" class=\"form-control input-block-level\" type=\"text\" style=\"margin-bottom: 0px;\" value=\"n/a\" /></td>\n" + |
||
316 | " </tr>\n" + |
||
317 | " <tr>\n" + |
||
318 | " <td style=\"text-align: center; vertical-align: middle;\"><i class=\"icon-circle-blank\"></i></td>\n" + |
||
319 | " <td><input id=\"edit_circle" + alpha + "\" data-i18n=\"[title]sidebar.markers.radius;[placeholder]sidebar.markers.radius_placeholder\" class=\"form-control input-block-level\" type=\"text\" style=\"margin-bottom: 0px;\" value=\"n/a\" /></td>\n" + |
||
320 | " </tr>\n" + |
||
321 | " <tr>\n" + |
||
322 | " <td colspan=\"2\" style=\"text-align: right\">\n" + |
||
323 | " <button class=\"btn btn-small btn-primary\" type=\"button\" onclick=\"Markers.leaveEditMode(" + id + ", true);\" data-i18n=\"dialog.ok\">OK</button>\n" + |
||
324 | " <button class=\"btn btn-small\" type=\"button\" onclick=\"Marker.leaveEditMode(" + id + ", false);\" data-i18n=\"dialog.cancel\">CANCEL</button>\n" + |
||
325 | " </td>\n" + |
||
326 | " </tr>\n" + |
||
327 | "</table>" + |
||
328 | "</div>"; |
||
329 | }; |
||
330 | |||
389 |