Advertisement
Xavion

Untitled

Feb 16th, 2013
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 10.45 KB | None | 0 0
  1.     <script type='text/javascript' src='http://ajax.aspnetcdn.com/ajax/knockout/knockout-2.2.1.js'></script>
  2.     <style>
  3.     body {
  4.         font-family: "arial";
  5.         font-size: 14;
  6.         color:#FFFFFF;
  7.     }
  8.     </style>
  9.     <!-- The HTML goes here -->
  10.     <div id="Test_Window" class="" style="position:relative; top:0px;; left:0px; width:500px; height:320px; background-color: #43423C;">
  11.     <p style="position:absolute; font-size: 8; left:7px; top: -6px;"><abbr title="Created and managed by Xavion. Created 6/2/13. Last updated 13/2/13.">CREDITS</abbr></p>
  12.     <div id="header" style="text-align: center; height:60px; margin-top:0px;">
  13.         <h4 style="margin-top:0px;">The all purpose spell for any situation<abbr title="Note: Usefulness not guaranteed."><sup style="font-size:8">*</sup></abbr>.</h4>
  14.     </div>
  15.     <form id="Fields" style="float:left; width:250px; height:100px; margin-top: -32px;">
  16.         <div style="display: table; float:left;">
  17.             <!-- The Spell Type Options. Vis:Always -->
  18.             <div id="Type" style="display: table-row; height:22px;" data-bind="visible: visType">
  19.                 <span style="display: table-cell; float:left; width:60px; margin-top:3px;">
  20.                     Type
  21.                 </span>
  22.                 <span style="display: table-cell; float:left;">
  23.                     <select style="width:100px;height:20px;" data-bind="options: availableTypes, value: chosenType"></select>
  24.                 </span>
  25.             </div>
  26.             <!-- The Elemental Options. Vis:Type==Elemental -->
  27.             <div id="Element" style="display: table-row; height:22px;" data-bind="visible: visElement">
  28.                 <span style="display: table-cell; float:left; width:60px; margin-top:3px;">
  29.                     Element
  30.                 </span>
  31.                 <span style="display: table-cell; float:left;">
  32.                     <select style="width:100px;height:20px;" data-bind="options: availableElements, value: chosenElement"></select>
  33.                 </span>
  34.             </div>
  35.             <div id="Form" style="display: table-row; height:22px;" data-bind="visible: visForm">
  36.                 <span style="display: table-cell; float:left; width:60px; margin-top:3px;">
  37.                     Form
  38.                 </span>
  39.                 <span style="display: table-cell; float:left;">
  40.                     <select style="width:100px;height:20px;" data-bind="options: availableForms, value: chosenForm"></select>
  41.                 </span>
  42.             </div>
  43.             <!-- The Illusion Options. Vis:Type==Illusion -->
  44.             <div id="Illusion" style="display: table-row; height:22px;" data-bind="visible: visIllusion">
  45.                 <span style="display: table-cell; float:left; width:60px; margin-top:3px;">
  46.                     Illusion
  47.                 </span>
  48.                 <span style="display: table-cell; float:left;">
  49.                     <select style="width:100px;height:20px;" data-bind="options: availableIllusions, value: chosenIllusion"></select>
  50.                 </span>
  51.             </div>
  52.             <!-- The Utility Options. Vis:Type==Utility -->
  53.             <div id="Utility" style="display: table-row; height:22px;" data-bind="visible: visUtility">
  54.                 <span style="display: table-cell; float:left; width:60px; margin-top:3px;">
  55.                     Utility
  56.                 </span>
  57.                 <span style="display: table-cell; float:left;">
  58.                     <select style="width:100px;height:20px;" data-bind="options: availableUtilities, value: chosenUtility"></select>
  59.                 </span>
  60.             </div>
  61.             <!-- Target Vis:Type is chosen -->
  62.             <div id="Target" style="display: table-row; height:22px;">
  63.                 <span style="display: table-cell; float:left; width:60px; margin-top:3px;">
  64.                     Target
  65.                 </span>
  66.                 <span style="display: table-cell; float:left;">
  67.                     <select style="width:100px;height:20px;" data-bind="options: availableTargets, value: chosenTarget"></select>
  68.                 </span>
  69.             </div>
  70.             <!-- Name Vis:Type is chosen -->
  71.             <div id="Name" style="display: table-row; height:22px;">
  72.                 <span style="display: table-cell; float:left; width:60px; margin-top:3px;">
  73.                     Name
  74.                 </span>
  75.                 <span style="display: table-cell; float:left; overflow:hidden; width:100px; height:20px; border: 1px solid #2C2C2C; background-color: #33322B; margin-top:1px;">
  76.                     <input style="padding: 5px; width:107px; height:37px; position:relative; top:-10px; margin-left:-3px; margin-top:1px; background: transparent; border-style: none; color:white;" data-bind="value: spellName, valueUpdate: 'afterkeydown'"></input>
  77.                 </span>
  78.             </div>
  79.         </div>
  80.         <div id="Power" style="float:right; width:90px; text-align:center;" data-bind='visible: numAttrVis(), style:{"marginTop":numAttrName()=="Power" ? "-110px" : "-87px"}'>
  81.             <span data-bind="text:numAttrName"></span>
  82.             <span style="float:right; overflow:hidden; width:50px; height:20px; border: 1px solid #2C2C2C; background-color: #33322B; margin-top:1px; margin-right:20px;">
  83.                 <input style="padding: 5px; width:57px; height:37px; position:relative; top:-10px; margin-left:-3px; margin-top:1px; background: transparent; border-style: none; color:white;" id="Power" data-bind="value: spellPower, valueUpdate: 'afterkeydown'"></input>
  84.             </span>
  85.         </div>
  86.     </form>
  87.     <div id="skillsDiv" style="float:left; margin-top: 10px; margin-left:10px; width:100px; height: 101px;">
  88.         <p style="margin-top:0px;">Required Skills</p>
  89.         <select id="skillsSelect" style="margin-top:-10px; width: 100px; height:80px;" id="skills" data-bind="options: requiredSkills, value: selectedSkill" size="2"></select>
  90.     </div>
  91.     <div id="reagentsDiv" style="float:left; margin-top: 10px; margin-left:10px; width:128px; height: 100px;">
  92.         <p style="margin-top:0px;">Required Reagents</p>
  93.         <select id="reagentsSelect"style="margin-top:-10px; width: 100px; height:80px;" id="reagents" data-bind="options: requiredReagents, value: selectedReagent" size="2"></select>
  94.     </div>
  95.     <div style="clear:both; margin-top:10px;">
  96.         <p style="margin-top:0px;">Code:</p>
  97.         <!--<div id="editor" style="margin-top:-10px; margin-left:2px; width:496px; height: 160px; border: 2px solid #4D4D4D;"></div>-->
  98.         <textarea id="code" style="margin-top:-10px; margin-left:2px; border: 4px solid gray; border-radius: 3px; width:496px; resize: none; height:160px;" data-bind="text: scriptCode"></textarea>
  99.     </div>
  100.  
  101.     <!-- The JavaScript goes here -->
  102.     <script>
  103.     //$(function(){Topia.showWindow("Omnispell");});
  104.     var skillPairs = {
  105.         "Pyromancy":["Element", "Fire"],
  106.         "Hydromancy":["Element", "Water"],
  107.         "Geomancy":["Element","Earth"],
  108.         "Aeromancy":["Element", "Air"],
  109.         "Illusion":["Type", "Illusion"],
  110.         "Teleportation":["Utility","Teleport"],
  111.         "Healing":["Utility", "Heal"]
  112.     };
  113.     var reagentPairs = {
  114.         "Brimstone":["Element", "Fire"],
  115.         "Teleport Rune":["Utility", "Teleport"],
  116.         "Wolf Figurine":["Illusion", "Wolf"],
  117.         "Dragon Statue":["Illusion", "Dragon"],
  118.         "Action Figure":["Illusion", "Human"],
  119.         "Heartwood":["Illusion", "Tree"]
  120.     };
  121.     function model() {
  122.         var self = this;
  123.         /*General*/
  124.         self.availableTypes = ko.observableArray(["Elemental", "Illusion", "Utility", "Summoning"]);
  125.         self.chosenType = ko.observable("Elemental");
  126.         self.availableElements = ko.observableArray(["Fire", "Water", "Earth", "Air"]);
  127.         self.chosenElement = ko.observable("Fire");
  128.         self.availableForms = ko.observableArray(["Shot", "Beam", "Wall", "Shockwave", "Aura", "Remote Bomb"]);
  129.         self.chosenForm = ko.observable("Shot");
  130.         self.availableUtilities = ko.observable(["Heal", "Teleport"])
  131.         self.chosenUtility = ko.observable("Heal");
  132.         self.availableIllusions = ko.observableArray(["Wolf", "Dragon", "Human", "Tree"]);
  133.         self.chosenIllusion = ko.observable("Wolf");
  134.         self.spellName = ko.observable("Awesome Spell");
  135.         self.spellPower = ko.observable(10);
  136.         self.codeHeight = ko.observable(160);
  137.         self.selectedReagent = ko.observable();
  138.         self.selectedSkill = ko.observable();
  139.         self.availableTargets = ko.observableArray(["Me", "Click", "Nearest Enemy", "Nearest Ally"]);
  140.         self.chosenTarget = ko.observable("Me");
  141.         /* Computed/Special */
  142.         self.numAttrName = ko.computed(function(){
  143.             switch (self.chosenType()) {
  144.                 case "Elemental":
  145.                     return "Power";
  146.                     break;
  147.                 case "Illusion":
  148.                     return "Duration";
  149.                     break;
  150.                 default:
  151.                     return "ERROR"
  152.                     break;
  153.             }
  154.         });
  155.         self.requiredSkills = ko.computed(function() {
  156.             var rSkills = [];
  157.             for (skill in skillPairs) {
  158.                 try {
  159.                     if (self["chosen"+skillPairs[skill][0]]() == skillPairs[skill][1] && self["vis"+skillPairs[skill][0]]()) {
  160.                         rSkills.push(skill);
  161.                     } else if (rSkills.indexOf(skill) != -1) {
  162.                         rSkills.splice(rSkills.indexOf(skill), 1);
  163.                     }
  164.                 } catch(err) {}
  165.             }
  166.             return rSkills;
  167.         });
  168.         self.requiredReagents = ko.computed(function() {
  169.             var rReagents = [];
  170.             for (reagent in reagentPairs) {
  171.                 try {
  172.                     if (self["chosen"+reagentPairs[reagent][0]]() == reagentPairs[reagent][1] && self["vis"+reagentPairs[reagent][0]]()) {
  173.                         rReagents.push(reagent);
  174.                     } else if (rReagents.indexOf(reagent) != -1) {
  175.                         rReagents.splice(rReagents.indexOf(reagent), 1);
  176.                     }
  177.                 } catch(err) {}
  178.             }
  179.             return rReagents;
  180.         });
  181.         /* Visibility*/
  182.         self.visElement  = ko.computed(function(){return self.chosenType() == "Elemental"});
  183.         self.visForm     = ko.computed(function(){return self.chosenType() == "Elemental"});
  184.         self.visUtility  = ko.computed(function(){return self.chosenType() == "Utility"});
  185.         self.visIllusion = ko.computed(function(){return self.chosenType() == "Illusion"});
  186.         self.visType     = ko.computed(function(){return true});
  187.         self.numAttrVis  = ko.computed(function(){
  188.             if (["Elemental","Illusion"].indexOf(self.chosenType()) != -1) {
  189.                 return true;
  190.             } else {
  191.                 return false;
  192.             }
  193.         });
  194.         /* The code*/
  195.         self.skillType = function(){
  196.  
  197.         };
  198.         self.targetCode = function(){
  199.  
  200.         };
  201.         self.scriptCode = ko.computed(function () {
  202.             var code = ["UsePower(function(power) {\n",
  203.                         "\tvar target = " + self.chosenTarget() + ";\n\n",
  204.                         "\tpower.Invoke(target, '" + self.chosenType().toLowerCase()/*self.skill_type()*/ + "', function(effect) {\n\n"];
  205.             switch (self.chosenType()) {
  206.                 case "Illusion":
  207.                     code.push(["\t\tif (target.race != '"+self.chosenIllusion().toLowerCase()+"') {\n",
  208.                               "\t\t\teffect.duration = "+self.spellPower()+";\n",
  209.                               "\t\t\ttarget.race = '"+self.chosenIllusion().toLowerCase()+"';\n",
  210.                               "\t\t}\n\n",
  211.                               "\t\teffect.FX(function(fx) {\n",
  212.                               "\t\t\tfx.animation = 'smoke';\n",
  213.                               "\t\t\tfx.x = target.x;\n",
  214.                               "\t\t\tfx.y = target.y;\n",
  215.                               "\t\t});\n"].join(""));
  216.                     break;
  217.                 default:
  218.                     code.push("//Only Illusion Spells are currently coded\n");
  219.                     break;
  220.             };
  221.             code.push("\t});\n});");
  222.             return code.join("");
  223.         });
  224.  
  225.         /* Subscribers */
  226.         self.scriptCode.subscribe(function(newValue) {
  227.             editor.setValue(newValue);
  228.             editor.getSession().selection.clearSelection();
  229.         });
  230.     }
  231.     </script>
  232. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement