App-SocialCalc-Multiplayer

 view release on metacpan or  search on metacpan

socialcalc/simpleedit15.pl  view on Meta::CPAN


      default:
         result = SocialCalc.special_chars(valueformat+": "+displayvalue);
         break;
      }

   return '<img src="'+spreadsheet.imagePrefix+'sc-wikiflag.gif" alt="Wikitext" title="Wikitext">' + result;

   }

// Page link code

SocialCalc.Callbacks.MakePageLink = function(pagename, workspace, linktyle, valueformat) {

   var result = "";

   if (workspace) {
      result = "?&workspace=" + encodeURI(workspace) + "&pagename=" + encodeURI(pagename);
      }
   else {
      result = "?&pagename=" + encodeURI(pagename);
      }

   return result;

   }

// Additional formula functions

var funccache = {};
var functimer = null;
var funcquery = "";

SocialCalc.Formula.SocialtextFunction = function(fname, operand, foperand, sheet) {

   var value1, t;
   var scf = SocialCalc.Formula;

   var query = "a="+foperand.length;
   var num = 0;

   while (foperand.length > 0) {
      value1 = scf.OperandValueAndType(sheet, foperand);
      t = encodeURI(value1.type);
      num++;
      query += "&a"+num+"="+t+":"+encodeURI(value1.value);
      }

   if (funccache[query]) { // got this already
      t = funccache[query].indexOf(":");
      if (t) {
         scf.PushOperand(operand, funccache[query].substring(0,t), funccache[query].substring(t+1));
         }
      else {
         scf.PushOperand(operand, "t", "Server Error? "+funccache[query]);
         }
      return null;
      }


   scf.RemoteFunctionInfo.waitingForServer = "SOCIALTEXT"; // say what waiting for
   funcquery = query; // remember for setting when get it
   ajaxrequest2("", "&rpc=socialtext&"+query);
   return "Waiting for server"; // return an error for function
   }

// Add to function list
SocialCalc.Formula.FunctionList["SOCIALTEXT"] = [SocialCalc.Formula.SocialtextFunction, -1];


// define functions

function loadsheet(sheetname) {
addmsg("loadsheet:"+sheetname);
   return ajaxrequest("", "&loadsheet="+encodeURIComponent(sheetname));
   }

SocialCalc.RecalcInfo.LoadSheet = loadsheet;

// function 

var http_request;

function ajaxrequest(url, contents) {

   http_request = null;

   if (window.XMLHttpRequest) { // Mozilla, Safari,...
      http_request = new XMLHttpRequest();
      }
   else if (window.ActiveXObject) { // IE
      try {
         http_request = new ActiveXObject("Msxml2.XMLHTTP");
         }
      catch (e) {
         try {
            http_request = new ActiveXObject("Microsoft.XMLHTTP");
            }
         catch (e) {}
         }
      }
   if (!http_request) {
      alert('Giving up :( Cannot create an XMLHTTP instance');
      return false;
      }

   // Make the actual request

   http_request.onreadystatechange = alertContents;
   http_request.open('POST', document.URL, true); // async
   http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
   http_request.send(contents);

   return true;

   }

function alertContents() {

   var loadedstr = "";



( run in 2.388 seconds using v1.01-cache-2.11-cpan-b16cb0d3907 )