Added option, cached thesaurus, some cleanup #4

Merged
merged 5 commits into from Feb 2, 2013

Conversation

Projects
None yet
2 participants
Contributor

ultimatedelman commented Jan 31, 2013

I added a few options, namely the option to change the ajax call method. This was one problem I had getting this to work initially, as my backend does not allow POSTs on .json files, so I had to override my $.ajaxSetup() to get this working. Now it defaults to 'GET' with the option to override (although I can't see anyone overriding a GET).

I also noticed that the thesaurus was being called every time in a loop for getting sentences. This was resulting in an AJAX call every time the loop was run, which was slowing down page load a lot for a large number of blocks. I simply cached the thesaurus and removed the methods that spliced out paragraphs. I felt that the integrity of the randomness of the sentences/paragraphs/etc was less important for prototyping than the performance of this plugin, as it is, after all, just for prototyping.

I tried to conform to your coding conventions as much as I could and only touched things that I played with for my own need, so I didn't get through the whole codebase. I hope you like my changes!

ultimatedelman added some commits Jan 31, 2013

added options (but not yet implementation) for providing a callback a…
…fter all operations are complete and for overriding the default ajax type. modernized thesaurus ajax call
cached thesaurus to prevent multiple ajax calls, removed splicing of …
…thesaurus so that future 'reset' calls to thesaurus are unnecessary. i decided to do this because after all, this is a prototyping library, so i feel that speed and performance is much more important than ensuring the integrity of the randomness of sentences. also implemented callback after all operations are complete
stripped out callback because it's not necessary, as everything is sy…
…nchronous. was initially added when I thought I could make it asynchronous, but I realize now it's not necessary :)
Owner

ndreckshage commented Jan 31, 2013

this is great. ajax change is good idea. i noticed the multiple request problem (#2) and have it fixed in current version that im working on. im actually restructuring the whole thesaurus method a bit, and going to be loading the content via jsonp apis (from random text generators with apis, for true random content), and then leave backup option to use local custom lorem ipsum library.

ive got a bit of work to do the way im setting up the next version, and ill merge these changes into mine.

Contributor

ultimatedelman commented Jan 31, 2013

sweet! glad i could help... this plugin has been super useful for my current project while we're in the prototyping phase. you and i both should thank html5weekly :)

Owner

ndreckshage commented Feb 2, 2013

just pushed my main changes, but gonna sort through these tomorrow and see what i can merge in.

@ndreckshage ndreckshage merged commit 91bca1d into ndreckshage:master Feb 2, 2013

Owner

ndreckshage commented Feb 2, 2013

a lot of our changes were similar -- tough part when working on a single file rather than a codebase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment