Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- yourworldoftext.com/applescript
- -- Instructions: Run script. After the beep, the clipboard has specially formatted javascript.
- -- paste the contents of the clipboard into a javascript console and run.
- set epoch_time to do shell script ("date +%s") as number 20
- set output_array to ""
- set number_of_slices to 0
- set cell_x_width to 7
- set cell_y_width to 15
- set slice_partition to 128 * 1
- set skip_number to 0
- property big_x_start : 0
- property small_x_start : 0
- property big_y_start : 0
- property small_y_start : 0
- set big_x to big_x_start
- set small_x to small_x_start
- set big_y to big_y_start
- set small_y to small_y_start
- set page to "" as string
- set theFile to choose file with prompt "Select a text file:"
- set theFileReference to open for access theFile
- set theFileContents to read theFileReference
- close access theFileReference
- set total_length to length of theFileContents
- display dialog ("Length of text: " & total_length & " characters" & "
- " & theFileContents)
- display dialog "X tile" default answer big_x_start
- set big_x_start to text returned of result
- display dialog "Y tile" default answer big_y_start
- set big_y_start to text returned of result
- set big_x to big_x_start
- set big_y to big_y_start
- set output_array to output_array & "arr = ["
- repeat with i from 1 to total_length
- set char to character i of theFileContents
- if char = "
- " then
- set big_x to big_x_start
- set small_x to small_x_start
- if small_y = 7 then
- set big_y to big_y + 1
- set small_y to 0
- else
- set small_y to small_y + 1
- end if
- else
- if char = "\\" then
- set char to "\\\\"
- end if
- if char = "\"" then
- set char to "\\\""
- end if
- set output_array to output_array & translate_character(big_x, big_y, small_x, small_y, epoch_time, char)
- if small_x = 15 then
- set big_x to big_x + 1
- set small_x to 0
- else
- set small_x to small_x + 1
- end if
- end if
- end repeat
- set output_array to output_array & "];"
- set output_array to output_array & "
- "
- set number_of_edits to round total_length / slice_partition rounding up
- repeat with i from 1 to number_of_edits
- set start_slice to 0 + slice_partition * (i - 1)
- set end_slice to slice_partition + slice_partition * (i - 1)
- set output_array to output_array & specifiy_edits(start_slice, end_slice, page)
- end repeat
- set the clipboard to output_array
- beep
- to specifiy_edits(start_slice, end_slice, page)
- return "setTimeout(function() { jQuery.post(window.location.pathname, {edits: arr.slice(" & start_slice & ", " & end_slice & ")}, YourWorld.editsDone, 'json') }, 10*" & start_slice & ");
- "
- end specifiy_edits
- to translate_character(big_x, big_y, small_x, small_y, time, next_character)
- return "[" & big_y & ", " & big_x & ", " & small_y & ", " & small_x & ", " & time & "000" & ", " & "\"" & next_character & "\"" & "], "
- end translate_character
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement