Last active
December 30, 2016 00:28
-
-
Save marianomike/0798762a439cbaeaf3409e95ac63202a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function rgbToHex(r, g, b) { | |
return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1); | |
} | |
function colorFromString(value) { | |
var immutable = MSImmutableColor.colorWithSVGString_(value); | |
return MSColor.alloc().initWithImmutableObject_(immutable); | |
} | |
function alert(title, message){ | |
var app = [NSApplication sharedApplication]; | |
[app displayDialog:message withTitle:title]; | |
} | |
function checkIfExists(colorName, existingStyles){ | |
var existsArray = []; | |
for (var i = 0; i < existingStyles.length; i++){ | |
if(existingStyles[i] == colorName){ | |
existsArray.push(colorName); | |
} | |
} | |
if(existsArray.length > 0){ | |
return true; | |
}else{ | |
return false; | |
} | |
} | |
function createSelect(msg, items, selectedItemIndex){ | |
selectedItemIndex = selectedItemIndex || 0 | |
var accessory = NSComboBox.alloc().initWithFrame(NSMakeRect(0,0,200,25)) | |
accessory.addItemsWithObjectValues(items) | |
accessory.selectItemAtIndex(selectedItemIndex) | |
var alert = NSAlert.alloc().init() | |
alert.setMessageText(msg) | |
alert.addButtonWithTitle('OK') | |
alert.addButtonWithTitle('Cancel') | |
alert.setAccessoryView(accessory) | |
var responseCode = alert.runModal() | |
var sel = accessory.indexOfSelectedItem() | |
return [responseCode, sel] | |
} | |
function removeFileExtension(layerName){ | |
if([layerName containsString:@"."]){ | |
var nameArray = [layerName componentsSeparatedByString:@"."]; | |
var name = nameArray[0]; | |
return name; | |
}else{ | |
return layerName; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment