text stringlengths 0 15.7k | source stringlengths 6 112 |
|---|---|
<style> | lns3.scpt |
textarea {width:96%;} | lns3.scpt |
</style> | lns3.scpt |
</head> | lns3.scpt |
<body style=\"" & bodyStyleCSS & "\">" & linefeed & HTMLBody & ¬ | lns3.scpt |
linefeed & "</body>" & linefeed & "</html>" | lns3.scpt |
set fileName to (do shell script "uuidgen") & ".html" | lns3.scpt |
set temporaryFolder to (path to temporary items folder from user domain) | lns3.scpt |
set targetFileHFSPath to (temporaryFolder as string) & fileName | lns3.scpt |
if my writeToFile(HTMLOutline, targetFileHFSPath, false) is true then | lns3.scpt |
set thisURL to the URL of disk item targetFileHFSPath | lns3.scpt |
set GoogleTranslateURL to ¬ | lns3.scpt |
"https://translate.google.com/#" & sourceLanguageID & ¬ | lns3.scpt |
"/" & destinationLanguageID & "/" | lns3.scpt |
set thisWindow to make new document with properties {URL:thisURL} | lns3.scpt |
make new tab with properties {URL:GoogleTranslateURL} | lns3.scpt |
on writeToFile(thisData, targetFile, appendData) | lns3.scpt |
set the targetFile to the targetFile as string | lns3.scpt |
set the openTargetFile to ¬ | lns3.scpt |
open for access file targetFile with write permission | lns3.scpt |
if appendData is false then set eof of the openTargetFile to 0 | lns3.scpt |
write thisData to the openTargetFile starting at eof as «class utf8» | lns3.scpt |
close access the openTargetFile | lns3.scpt |
on replaceText(sourceText, searchString, replacementString) | lns3.scpt |
set AppleScript's text item delimiters to the searchString | lns3.scpt |
set the itemList to every text item of sourceText | lns3.scpt |
set AppleScript's text item delimiters to the replacementString | lns3.scpt |
set sourceText to the itemList as string | lns3.scpt |
return sourceText | lns3.scpt |
on matchItemByIndexToCorrespondingList(itemToMatch, sourceList, matchingList) | lns3.scpt |
if length of sourceList is equal to length of matchingList then | lns3.scpt |
repeat with i from 1 to the count of sourceList | lns3.scpt |
if item i of sourceList is itemToMatch then | lns3.scpt |
return item i of matchingList | lns3.scpt |
end matchItemByIndexToCorrespondingList | lns3.scpt |
set KeynoteStatus to (exists document 1) | lns3.scpt |
if KeynoteStatus is false then "There is no document in Keynote." | lns3.scpt |
if not (exists document 1) then error "There is no document open in Safari." | lns3.scpt |
display dialog "This script will replace the presenter notes in the current Keynote document with the notes from this webpage." with icon 1 | lns3.scpt |
set pageSource to source of current tab of window 1 | lns3.scpt |
if pageSource contains "Page Generated for Translation" then | lns3.scpt |
set elementCount to ¬ | lns3.scpt |
(do JavaScript "document.getElementsByTagName('textarea').length;" in current tab of window 1) as integer | lns3.scpt |
set translatedNotes to {} | lns3.scpt |
repeat with i from 1 to elementCount | lns3.scpt |
set thisNote to ¬ | lns3.scpt |
(do JavaScript "document.getElementById('txtarea" & (i as string) & "').value;" in current tab of window 1) | lns3.scpt |
set the end of translatedNotes to thisNote | lns3.scpt |
display alert "INCORRECT PAGE" message "The current page was not generated by the translation script." | lns3.scpt |
display dialog "Notes extraction complete. Click “Continue” to switch to Keynote and replace the notes in the current document." buttons {"Cancel", "Continue"} default button 2 with icon 1 | lns3.scpt |
display alert "EXTRACTION ERROR" message errorMessage | lns3.scpt |
repeat with i from 1 to the count of translatedNotes | lns3.scpt |
set targetSlide to (first slide whose slide number is i) | lns3.scpt |
tell targetSlide | lns3.scpt |
set presenter notes to (item i of translatedNotes) | lns3.scpt |
display alert "ERROR" message errorMessage | lns3.scpt |
use framework "CoreGraphics" | lns3.scpt |
property targetMinimumDimension : 400 | lns3.scpt |
if (clipboard info for «class utf8») is not {} then | lns3.scpt |
set clipboardText to (get the clipboard as «class utf8») | lns3.scpt |
error "There is no text on the clipboard to convert into a QR code image." | lns3.scpt |
set theUUID to current application's NSUUID's UUID()'s UUIDString() | lns3.scpt |
set fileManager to current application's NSFileManager's defaultManager() | lns3.scpt |
set theURL to (fileManager's URLsForDirectory:(current application's NSPicturesDirectory) inDomains:(current application's NSUserDomainMask))'s firstObject() | lns3.scpt |
set the targetItemHFSPath to (theURL as string) & (theUUID as string) & ".jpg" | lns3.scpt |
set targetItemPOSIXPath to POSIX path of targetItemHFSPath | lns3.scpt |
set thisImageObject to my createFullSizeQRCodeImageObjectForString(clipboardText) | lns3.scpt |
my writeNSImageObjectToFileAsJPEG(thisImageObject, targetItemPOSIXPath, false) | lns3.scpt |
set the targetFile to targetItemHFSPath as alias | lns3.scpt |
if not (exists document 1) then | lns3.scpt |
set documentWidth to the width of it | lns3.scpt |
set documentHeight to the height of it | lns3.scpt |
tell current slide | lns3.scpt |
set thisImage to make new image with properties {file:targetFile, width:targetMinimumDimension, height:targetMinimumDimension} | lns3.scpt |
set the position of thisImage to {(documentWidth - targetMinimumDimension) div 2, (documentHeight - targetMinimumDimension) div 2} | lns3.scpt |
set thisPOSIXPath to current application's NSString's stringWithString:targetItemPOSIXPath | lns3.scpt |
set resultingURL to missing value | lns3.scpt |
set URLOfItemToTrash to (current application's |NSURL|'s fileURLWithPath:thisPOSIXPath) | lns3.scpt |
(fileManager's trashItemAtURL:URLOfItemToTrash resultingItemURL:resultingURL |error|:(missing value)) | lns3.scpt |
say "Done!" | lns3.scpt |
set spokenErrorTitle to "I was unable to complete your request: " | lns3.scpt |
set cfgutil to "/usr/bin/say" | lns3.scpt |
set theTask to (current application's NSTask's launchedTaskWithLaunchPath:cfgutil arguments:{(spokenErrorTitle & errorMessage)}) | lns3.scpt |
tell application (POSIX path of (path to frontmost application)) | lns3.scpt |
display alert "Unable to Complete Request:" message errorMessage buttons {"Cancel"} default button 1 | lns3.scpt |
on createFullSizeQRCodeImageObjectForString(thisString) | lns3.scpt |
set thisString to current application's NSString's stringWithString:thisString | lns3.scpt |
set thisData to thisString's dataUsingEncoding:(current application's NSUTF8StringEncoding) | lns3.scpt |
set anImageFilter to current application's CIFilter's filterWithName:"CIQRCodeGenerator" | lns3.scpt |
anImageFilter's setDefaults() | lns3.scpt |
anImageFilter's setValue:thisData forKey:"inputMessage" | lns3.scpt |
anImageFilter's setValue:"L" forKey:"inputCorrectionLevel" | lns3.scpt |
set baseImage to anImageFilter's outputImage() | lns3.scpt |
set aTransform to current application's CGAffineTransform's CGAffineTransformMakeScale(100.0, 100.0) | lns3.scpt |
set outputImage to baseImage's imageByApplyingTransform:aTransform | lns3.scpt |
set imageRepresentation to current application's NSCIImageRep's imageRepWithCIImage:outputImage | lns3.scpt |
set resultingImageObject to current application's NSImage's alloc()'s initWithSize:(imageRepresentation's |size|()) | lns3.scpt |
resultingImageObject's addRepresentation:imageRepresentation | lns3.scpt |
return resultingImageObject | lns3.scpt |
end createFullSizeQRCodeImageObjectForString | lns3.scpt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.