JSFiddle - React, Tailwind, and code Playground

by nate

JavaScript

(function(){ 
var 
beginRun = null,
stopper = null,
_Att = window.Att,
_$$ = window.$$,

Att = window.Att = window.$$ =  function( selector, context ) {
 return new Att.init( selector, context );
};


// This is essentially the main object below.
// Containing all of the code for the seperate areas of the attack.

Att = {

 init: function(selector, context){ 
  //alert(context);
  selector = selector || document; 
  
  if(typeof Att[selector]==='function'){   
   return Att[selector](context);
  }else{
   // Interpret other params to direct to function. 
  }
  
  
 },
 
 // Handles all of the functionality concerning the operation and showing of modal box's.
 
 modal: function() {
     return {
         activate: function(){
             alert("hey ive been alerted");
         }
     }
 },
 
 pagelife: function(context){
  
 }, 
 
 request: function(options){
  
  // To stop multi request cutomly force ajax to wait.
  if(!beginRun){
 
   var defaults = {
    extensions: '',
    theurl: 'ajax/attack.php',
    thetype: "POST",
    defaultdataType: "html",
    payload: '',
    beforeSend: 'reqBefore',
    error: 'requestError',
    complete: 'requestComplete',
    debug: false
   },
   
   options =  $.extend(defaults, options);
   
   $.ajax({
    url: options.theurl,
    type: options.thetype,
    beforeSend: Att[options.beforeSend],
    data: options.extensions,
    dataType: options.defaultdataType,
    success: function(data){
    
     // debug has been set
     
     if(options.debug){
      alert(data);
     }
     
     // handle some sort of success message
     
     if(typeof options.payload==='function'){
      options.payload(data);
     }
     
    },
    error: Att[options.error],
    complete: Att[options.complete]
   }); 
  
  }
 
 },
 
 // default beforeSend function
 reqBefore: function(XMLHttpRequest){
  beginRun = true;
 },
 
 // default ajax error handling var.
 requestError: function(xhr,textStatus,errorThrown){
  //alert(xhr.statusText);
...