Recent Posts
PAWN | 15 sec ago
None | 30 sec ago
None | 41 sec ago
None | 42 sec ago
Python | 1 min ago
C++ | 1 min ago
None | 1 min ago
Python | 1 min ago
None | 1 min ago
None | 1 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By Anonymous on the 3rd of Jan 2009 05:35:16 AM Download | Raw | Embed | Report
  1. import("storage");
  2. import("lib-json");
  3.  
  4. /* appjet:server */
  5.  
  6. var BOSS_KEY = "YOUR KEY";
  7. var postType = parseInt(request.params.isPost);
  8.  
  9. switch(postType){
  10.     case 0:
  11.         doMain();
  12.         break;
  13.     case 1:
  14.         doAjax();
  15.         break;
  16.     case 2:
  17.         getAutocomplete();
  18.         break;
  19.     default:
  20.         doMain();
  21.         break;
  22. }
  23.  
  24. function getAutocomplete(){
  25.     page.setMode("plain");
  26.    
  27.     var param = new String(request.params.jobField).toLowerCase();
  28.     var ap = storage.jobList;
  29.     var str = new String();
  30.     var matches = new Array();
  31.    
  32.     ap.forEach(function(e){
  33.         var title = new String(e.title).substring(0, param.length).toLowerCase();
  34.         if(title == param &&
  35.            matches.indexOf(e.title) == -1){
  36.             matches.push( e.title );
  37.         }
  38.     });
  39.    
  40.     matches.sort(
  41.             function(a, b){          
  42.                 if( a.length == b.length )
  43.                     return 0;
  44.                 return (a.length < b.length) ? -1 : 1;
  45.     });
  46.    
  47.     matches = matches.slice(0, 7);
  48.    
  49.     for(var i=0; i < matches.length; i++){
  50.         str += html(LI(matches[i]));
  51.     }
  52.    
  53.     print(UL(html(str)));
  54. }
  55.  
  56. function doAjax(){
  57.     // turn off the page formatting
  58.     page.setMode("plain");
  59.    
  60.     var searchFor = request.params.jobField;
  61.     var url = "http://boss.yahooapis.com/ysearch/web/v1/" + escape(searchFor) + "?appid=" + BOSS_KEY;
  62.     var response = wget(url);
  63.     var objData = JSON.parse(response);
  64.     var totalHits = objData["ysearchresponse"]["deephits"];
  65.    
  66.     var more = 0;
  67.     var closeJob;
  68.     var closeNum = -1;
  69.     var ap = storage.jobList;
  70.     var sum = 0;
  71.     var mean = 0;
  72.    
  73.     ap.forEach(function(e){
  74.        
  75.         if(e.score > totalHits){
  76.             more += 1;
  77.         }
  78.                
  79.         if(new String(e.title).toLowerCase() != new String(searchFor).toLowerCase()
  80.             && (closeNum < 0 || Math.abs(e.score-totalHits) < closeNum)){
  81.                 closeNum = Math.abs(e.score - totalHits);
  82.                 closeJob = e;
  83.         }
  84.        
  85.         sum += e.score;
  86.        
  87.     });
  88.    
  89.     mean = sum / ap.size();
  90.     sum = 0;
  91.    
  92.     ap.forEach(function(e){
  93.         sum += Math.pow((e.score - mean), 2);
  94.     });
  95.    
  96.     sum = sum * (1/ap.size());
  97.     sum = Math.sqrt(sum);
  98.    
  99.     var stdscore = Math.round( ((totalHits - mean) / sum) * 100 );
  100.     var arr = new Object();
  101.    
  102.     arr["stdScore"] = stdscore;
  103.     arr["closeJob"] = closeJob.title;
  104.     arr["more"] = Math.round((more / ap.size()) * 100);
  105.    
  106.     print(JSON.stringify(arr));
  107. }
  108.  
  109. // for the default main page
  110. function doMain(){
  111.    
  112.     var tryStr = "";
  113.     var ap = storage.jobList;
  114.     var sel = new Array();
  115.     var rand = 1 + (Math.random() * 5);
  116.    
  117.     ap.sort().skip(Math.random() * ap.size()).forEach(
  118.                                                         function(e){
  119.                                                             if(sel.length < 3)
  120.                                                                 sel.push(e.title);
  121.                                                             else
  122.                                                                 return false;
  123.                                                         } );
  124.    
  125.     tryStr = "Try: ";
  126.     for(var i=0; i < sel.length; i++){
  127.         tryStr += html(link("javascript:loadLink('" + sel[i] + "')", sel[i])) + "&nbsp&nbsp&nbsp";
  128.     }
  129.    
  130.     page.setTitle("Am I marginalized?");
  131.    
  132.     print(SCRIPT({src: "http://www.google.com/jsapi", type:"text/javascript", onload: "loadJS()"}));
  133.    
  134.     page.head.write(
  135.         SCRIPT({src: "http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js", type:"text/javascript"}) +
  136.         SCRIPT({src: "http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.2/scriptaculous.js", type:"text/javascript"})
  137.     );
  138.    
  139.     print(html("<div id='centerBox'>"));
  140.    
  141.     print( H1({id: "page-title"}, "Am I marginalized?"),
  142.                 P({id: "blurb"}, "Does your job feel meaningless? Praying for a layoff? \n Find out if your profession has been marginalized.")
  143.     );
  144.    
  145.     print( FORM({action:"/", method:"get", onsubmit: "javascript: return submitJob()"},
  146.                     SPAN({id: "job-label"}, "Job Title: "),
  147.                     INPUT({text:"text", name:"jobField", id: "jobField"}),
  148.                     INPUT({type:"hidden", name:"isPost", id: "isPost", value: "1"}),
  149.                     INPUT({type: "submit", value: "Submit"})
  150.                )
  151.     );
  152.    
  153.     print(DIV({id:"autocomplete_choices", 'class':"autocomplete"}));
  154.    
  155.     print(DIV({id:"space"}, P()));
  156.    
  157.     print(DIV({id:"ajax-result"}, html(tryStr)));
  158.    
  159.     print(DIV({id:"space"}, P()));
  160.    
  161.     print(DIV({id:"ajax-image"}));
  162.    
  163.     print(DIV({id:"space"}, P()));
  164.    
  165.     print(DIV({id:"bottom-div"}, link("http://shout.setfive.com", "setfive.com")));
  166.    
  167.     print(html("</div>"));
  168. }
  169.  
  170. /* appjet:client */
  171.  
  172. Event.observe(window, "load",
  173.               function(){
  174.                
  175.                 var hash = new String(window.location.hash).replace("#", "");
  176.                
  177.                 if(hash.length > 0){
  178.                     $('jobField').value = hash;
  179.                     submitJob();
  180.                 }
  181.                    
  182.                 new Ajax.Autocompleter("jobField", "autocomplete_choices", "?isPost=2");
  183.               }
  184. );
  185.  
  186. function loadJS(){
  187.     google.load("visualization", "1", {packages:["piechart"]});
  188. }
  189.  
  190.  
  191. function loadLink(str){
  192.     $('jobField').value = str;
  193.     submitJob();
  194. }
  195.  
  196. function submitJob(){
  197.    
  198.     $('autocomplete_choices').hide();
  199.     $('ajax-result').innerHTML = "Loading...";
  200.     $('ajax-image').innerHTML = "";
  201.    
  202.     window.location.hash = $F('jobField');
  203.    
  204.     new Ajax.Request("?isPost=1&jobField=" + escape($F('jobField')), {
  205.       method: 'get',
  206.       onSuccess: function(transport) {
  207.         var parts = new String(transport.responseText).evalJSON();
  208.        
  209.         $('ajax-result').innerHTML = parts.more + "% of careers are <span style='color: white'>more</span> important than yours! <br/>" +
  210.                                      "Society considers <span id='job-name'>" + parts.closeJob.toLowerCase() + "s</span> about as important as you.";
  211.              
  212.         var data = new google.visualization.DataTable();
  213.         data.addColumn('string', 'Breakdown');
  214.         data.addColumn('number', '% Marginalization');
  215.         data.addRows(2);
  216.         data.setValue(0, 0, 'Your Job');
  217.         data.setValue(0, 1, (100-parts.more));
  218.         data.setValue(1, 0, 'Everyone Else');
  219.         data.setValue(1, 1, parts.more);
  220.        
  221.         var chart = new google.visualization.PieChart(document.getElementById('ajax-image'));
  222.         chart.draw(data, {width: 400, height: 240, is3D: true, title: 'How important you are'});
  223.        
  224.       }
  225.     });
  226.  
  227.     return false;
  228. }
  229.  
  230. var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
  231. document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
  232. try {
  233. var pageTracker = _gat._getTracker("YOUR GA ID");
  234. pageTracker._trackPageview();
  235. } catch(err) {}
  236.  
  237.  
  238. /* appjet:css */
  239.  
  240. #job-name{
  241.     color: #ffffff;
  242. }
  243.  
  244. #ajax-result{
  245.     color: #ff4411;
  246.     font-size: 18px;
  247. }
  248.  
  249. #ajax-result a {
  250.     color: #ff4411;
  251. }
  252.  
  253. #page-title{
  254.     color: #ffffff;
  255.     font-family: Arial;
  256.     font-size: 42px;
  257. }
  258.  
  259. #blurb{
  260.     font-family: Arial;
  261.     font-size: 14px;
  262.     color: white;
  263. }
  264.  
  265. #centerBox{
  266.     margin-top: 100px;
  267.     text-align: center;
  268. }
  269.  
  270. #job-label{
  271.     font-size: 24px;
  272.     color: #0066bb;
  273. }
  274.  
  275. #bottom-div {
  276.     font-size: 12px;
  277. }
  278.  
  279. body{
  280.     background-color: #000000;
  281.     color: white;
  282. }
  283.  
  284. div.autocomplete {
  285.   position:absolute;
  286.   width:350px;
  287.   background-color:white;
  288.   border:1px solid #888;
  289.   margin:0;
  290.   padding:0;
  291.   color:black;
  292. }
  293. div.autocomplete ul {
  294.   list-style-type:none;
  295.   margin:0;
  296.   padding:0;
  297. }
  298. div.autocomplete ul li.selected { background-color: #ffb;}
  299.  
  300. div.autocomplete ul li {
  301.   font-size: 12px;
  302.   list-style-type:none;
  303.   display:block;
  304.   margin:0;
  305.   padding:2px;
  306.   height:32px;
  307.   cursor:pointer;
  308. }
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: