Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var cargo = {
- title: "I can post journals now",
- content: "Oh my gosh you guys, I made the hypest program ever. I'm gonna post pictures of my food and my cat and stuff. I hope you love it.",
- tags: ["These","tags","were","added","with","javascript"],
- ratings: ["all", "13+", "18+ nonsexual", "18+ sexual"],
- rating: 1,
- onlyFriends: true
- };
- var titlePort = function(x){
- console.log("title: " + x);
- var z = document.querySelector("input#journaltitle");
- z.value = x;
- };
- var contentPort = function(x){
- var z = document.querySelector("#submit-journal-content #submit-form .description #journaldesc");
- z.innerHTML = x;
- };
- var tagPort = function(x){
- //loop to pass through every tag
- var z = document.querySelector("#submit-journal-content #submit-form .tagging .listbuilder");
- var tagPadding = ['<li class="listbuilder-entry" unselectable="on"><span class="listbuilder-entry-text">','</span><a class="listbuilder-entry-remove" href="#" role="button" title="Remove sampletag from the list."></a>'];
- var package = "";
- for(var i = 0; i < x.length; i = i + 1)
- {
- package = tagPadding[0]+x[i]+tagPadding[1];
- console.log(package);
- z.innerHTML = z.innerHTML + package;
- }
- };
- var ratingsPort = function(x){
- //ratings function
- var z = document.querySelector("#submit-journal-content #submit-form .info #journalrating");
- switch (x) {
- case 1:
- //"13+" will be selected
- z.value = 20;
- break;
- case 2:
- //"18+ nonsexual" will be selected
- z.value = 30;
- break;
- case 3:
- //"18+ sexual" will be selected
- z.value = 40;
- break;
- default:
- //"all" will be selected
- z.value = 10;
- }
- };
- var onlyFriendsPort = function(x) {
- document.getElementById("submit-friends").checked = x;
- };
- titlePort(cargo.title);
- contentPort(cargo.content);
- tagPort(cargo.tags);
- //call ratings function
- ratingsPort(cargo.rating);
- onlyFriendsPort(cargo.onlyFriends);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement