Code written in JavaScript

Simple FOR Loop

Posted by Shane Griffiths 3 months ago
var hour;
var ampm;
		
for (hour=1; hour<24; hour++)
{
	if (hour < 12) {ampm="am"}
	if (hour >= 12) {amppm="pm"}

	if (hour < 13)
	{
		document.write(hour + ampm)
	}
	else
	{
		document.write((hour-12) + ampm)
	}
		
	document.write("
"); }
Language JavaScript / Tagged with for loop, javascript

A nice simple jquery logger

jQuery.fn.log = function (msg) {
  console.log("%s: %o", msg, this);
  return this;
};
Language JavaScript / Tagged with jquery, logging

Image Resizer for Adobe Photoshop CS2

Posted by gara mond about 1 year ago
/*
resizer.jsx for Adobe Photoshop CS2

WARNING: this script changes documents that will be processed.
         so be sure to duplicate documents before script runs.

this script resizes images storing in given number of pixel.
smaller images than given number won't be resized.
all images will be changed into RGB color mode.

last update: 2006-10-26
*/

preferences.rulerUnits = Units.PIXELS;

cutVal = 960;
fileType = "*.psd";

folderObj = Folder.selectDialog("select folder");

if(folderObj != null) {
	inputFileType = prompt("input file type like '*.psd'", fileType);
	if(inputFileType != null) { fileType = inputFileType; }
	
	inputCutVal = prompt("input length (pixel)", cutVal);
	if(inputCutVal != null) { cutVal = eval(inputCutVal); }
	
	fileList = folderObj.getFiles(fileType);
	
	for(i = 0; i < fileList.length; i++) {
		open(fileList[i]);
		
		if(activeDocument.width.value > cutVal || activeDocument.height.value > cutVal) {
			if(activeDocument.width.value > activeDocument.height.value) {
				activeDocument.resizeImage(
					cutVal,
					(cutVal / activeDocument.width.value) * activeDocument.height.value,
					72,
					ResampleMethod.BICUBICSHARPER
					);
			} else {
				activeDocument.resizeImage(
					(cutVal / activeDocument.height.value) * activeDocument.width.value,
					cutVal,
					72,
					ResampleMethod.BICUBICSHARPER
					);
			}
		}
		
		activeDocument.changeMode(ChangeMode.RGB);
		
		activeDocument.close(SaveOptions.SAVECHANGES);
	}
}
Language JavaScript / Tagged with photoshop