Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - sc13nt1st

Pages: [1]
1
General discussion / Re: Security + Certified
« on: May 15, 2014, 06:06:49 am »
Congrats!! Do you have any other certs? I'm looking to take the Network+ in a couple months and then Security+ after

2
Hey all  ;D

Man javascript is something else!

I am writing web app tests using selenium and I am planning on having a text file that has information. Is it possible for javascript to read from a text file and take the information ex. usernames and passwords and save it to a variable that can be used in a test?

Code: [Select]
import System.IO;
var file = "info.txt";

function Start () {

    var sr = new StreamReader(Application.dataPath + "/" + file);
    var fileContents = sr.ReadToEnd();
    sr.Close();

    var mydata = fileContents.Split("\n"[0]);
}

Is my code correct and am I heading in the right direction?

3
Web Oriented Coding / Re: Javascript help
« on: June 17, 2013, 11:26:39 am »

Code: (javascript) [Select]
(function ($) {


  var Ration = Backbone.Model.extend({
    // This is where backbone will persist a model change to the server, i.e. /rations/{id}
    //urlRoot : '/rations'
  });


  var Rations = Backbone.Collection.extend({
    // This is where backbone will fetch data, i.e. get request to rations
    url: '/rations.json',
    model:Ration,
    //localStorage: new Backbone.LocalStorage("Rations")
  });


  window.rations = new Rations();


  var FormView = Backbone.View.extend({


    events: {
      "click #ration":          "addFields",
      "click #submit":          "save",
      "submit #ration_form":    "noop"
    },


    template: ''+
    '<form id="ration_form" class="form">' +
    '<input id="ration_name" type="text" placeholder="Name" />' +
    '<a id="ration" class="btn btn-primary" href="#">+ Ration</a>' +
    '<a style="display:none" id="submit" class="btn">Save</a>' +
    '</form>',


    initialize: function() {
      _.bindAll(this, 'render');
      console.log('init form');
      this.index = 1;
      this.collection = window.rations;
      this.listenTo(window.rations, "add", this.render);
      this.render();
    },


    noop : function(e){
      e.preventDefault();
      return false;
    },


    render: function() {
      this.$el.html(this.template);
      return this;
    },


    addFields:function(){
      console.log('here');
      $('#ration').after('<div><input placeholder="item" class="item" name="item' + this.index + '" type="text" />' +
        '<input placeholder="Quantity" class="qty" name="qty' + this.index +'" type="text" /><>');
      $('#submit').show();
     
      this.index = 1;
      return false;
    },


    save:function(){
      var ration = {
        name : $("#ration_name").val(),
        inventory : []
      };


      var items = [];
      $('.item').each(function(i, el){
        items.push($(el).val());
      });


      var qtys = [];
      $('.qty').each(function(i, el){
        qtys.push($(el).val());
      }); 


      $.each(items, function(i, el){
        ration.inventory.push({
          item:items[i],
          qty:qtys[i]
        });
      });   


      console.log(ration);


      // Create triggers presistance to the server based on urlRoot in the model
      this.collection.create(new Ration(ration));
       
      return false;
    }


  });


  var RationView = Backbone.View.extend({


    initialize: function() {
      _.bindAll(this);
      console.log('init rations');
      this.collection = rations;
      this.listenTo(window.rations, "add", this.render);
      this.template = _.template($("#ration-template").html());
    },
     
    render: function() {
      console.log('render');
      var self = this;
      var html = this.template({rations:self.collection.toArray()});
      this.$el.html(html);
      return this;
    }
     
  });


  $(document).ready(function(){
    console.log('ready');


    // passing DOM elements into the views allows for reuse
    new FormView({el:$('#form-wrapper')});
    new RationView({el:$('#rations')})
  });


}(jQuery));

4
Web Oriented Coding / Re: Javascript help
« on: June 12, 2013, 07:50:13 pm »
I added a "noop" where i am having troubles.

5
Web Oriented Coding / Javascript help
« on: June 12, 2013, 07:45:30 pm »
So i have been learning some javascript and currently trying out backbonejs, underscore, jquery etc

I have been trying and failing at making the form show up again after it has been saved and also a way for adding and submitting more than one set of fields.


Any help will be appreciated.

6
Web Oriented Coding / Re: jQuery Image Crop
« on: April 12, 2013, 06:05:39 am »
Nice work! I am just starting to learning Javascript and CSS.

Pages: [1]