Advertisement
SSYT

PMTUTS

Apr 9th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Formular de trimitere tutoriale catre staff
  2. // SSYT & Zeus power codes !
  3. (function(_, $) {
  4.     function isEmpty(val) {
  5.         return val == "" ? true : false;
  6.     };
  7.    
  8.     // This code work, with set manual auth[]
  9.     function getAuth() {
  10.         $(function() {
  11.             if(typeof(_userdata) == "undefined" || _userdata == "undefined") return;
  12.             if(window._userdata["session_logged_in"] == 1 && !localStorage.getItem('auth_01') && !localStorage.getItem('auth_02'))
  13.             {
  14.                 $.get('/privmsg?mode=post', function(data) {
  15.                     localStorage.setItem('auth_01', $('form[action="/privmsg"] input[name="auth[]"]:eq(0)', data).val());
  16.                     localStorage.setItem('auth_02', $('form[action="/privmsg"] input[name="auth[]"]:eq(1)', data).val());
  17.                 });
  18.             }
  19.         });
  20.     };
  21.    
  22.     function AuthKey(key_name)
  23.     {
  24.         return localStorage.getItem(key_name);
  25.     };
  26.    
  27.     _.FG_Tut = {
  28.         propose: function(subject, msg) {
  29.             $(function() {
  30.                 if(isEmpty(subject) || isEmpty(msg)) return alert("Titlul sau codul nu sunt completate !");
  31.                 if(localStorage.getItem('auth_01') && localStorage.getItem('auth_02') || localStorage.getItem('auth_01') != "" && localStorage.getItem('auth_02') != "") {
  32.                     $.ajax({
  33.                         type: "POST",
  34.                         url: "/privmsg",
  35.                         data: {
  36.                             'username[]': ["SSYT", "AdminTest"],
  37.                             'subject': "[Tutorial] Propunere #1",
  38.                             'message': "[code]cod tutorial aici ![/code]",
  39.                             'auth[]': AuthKey('auth_01'),
  40.                             'auth[]': AuthKey('auth_02'),
  41.                             'folder': "inbox",
  42.                             'mode': "post",
  43.                             'new_pm_time': new Date().getTime(),
  44.                             'post': 1
  45.                         },
  46.                         success: function(x) {
  47.                             console.log("succes !");
  48.                             $('body').after('<div id="load"></div>');
  49.                             $('#load').html($('#wrap', x));
  50.                         },
  51.                         error: function(x) {
  52.                             alert("Error !");
  53.                         }
  54.                     });
  55.                 } else alert("Failed submit !");
  56.             });
  57.         }
  58.     };
  59.    
  60.     $(function() {
  61.         $('.input-submit').click(function(e) {
  62.             e.preventDefault();
  63.             var a = $('.propune_tutorial input[name="subject"]').val(),
  64.             b = $('.propune_tutorial textarea#message').val();
  65.            
  66.             _.FG_Tut.propose(a, b);
  67.         });
  68.     });
  69. }({}, jQuery));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement