private void SendInternal(string httpMethod, string type, JsString url, object data, JsAction<object, JsString, jqXHR> success, JsAction<JsError, JsString, jqXHR> failed) { url = addTimeToUrl(url); JsObject headers = new JsObject(); AjaxSettings ajaxSettings = new AjaxSettings { type = httpMethod, dataType = type, data = data, url = jsUtils.inst.getLocation() + "/" + url, headers = headers, success = delegate(object o, JsString s, jqXHR arg3) { success(o, s, arg3); }, error = delegate(jqXHR xhr, JsString s, JsError arg3) { failed(arg3, s, xhr); } }; bool isString = data.As<JsObject>()["toLowerCase"] != null; if (isString) { ajaxSettings.processData = true; ajaxSettings.contentType = (type.As<JsString>().toLowerCase() == "xml") ? "application/xml" : "application/json"; } jQuery.ajax( ajaxSettings); }
public void addView(JsString url, object viewData) { if (!hasView(url)) { //this is one point that I conced we should consider making async var content = contentParser.parse( contentLoader.synchronousFragmentLoad( url ) ); var div = new HtmlDivElement(); var fragment = jQueryContext.J( div ); fragment.hide(); fragment.html( content ); fragment.css( "width", "100%" ); fragment.css( "height", "100%" ); fragment.css( "position", "absolute" ); fragment.css( "top", "0" ); fragment.css( "left", "0" ); var mediatorCapturer = new MediatorCapturer(); domWalker.walkDomFragment( div, mediatorCapturer ); rootElement.append( div ); views[ url ] = fragment; mediators[ url ] = mediatorCapturer.mediator; } selectView( url, viewData ); }
public override JsArray<Translation> synchronousTranslate(JsString domain, JsArray<JsString> keys) { if (HtmlContext.window.console != null) { HtmlContext.console.log("Requested to translate: " + domain + " " + keys); } return new JsArray<Translation>(); }
public TypeDefinition resolveClassName(JsString qualifiedClassName) { dynamic type = findDefinition(qualifiedClassName); if (type == null) { JsString classDefinition = loader.loadClass(qualifiedClassName); //Before we load it into memory, check on the super class and see if we need to load *that* //into memory. We may *NOT* have an inherit if we dont inherit from anything, that is just fine resolveParentClassFromDefinition(qualifiedClassName,classDefinition); //Load the newly found class memory addDefinition(classDefinition); //Get a reference to the newly added type type = findDefinition(qualifiedClassName); if (type == null) { //This alert shouldnt be here, we should figure out a way to get it to the UI level HtmlContext.alert(qualifiedClassName + " does not contain required injection information "); throw new JsError(qualifiedClassName + " does not contain required injection information "); } var td = new TypeDefinition(type); if (!td.builtIn) { //Finally, resolve any classes it references in its own code execution resolveClassDependencies(td); } } return new TypeDefinition(type); }
public JsString parse( JsString content ) { //We need to get rid of the body element and maybe choose to do away with other things like script var bodyRegex = new JsRegExp(@"(</?)body", "gi"); var sanitizedContent = content.replace(bodyRegex,"$1div"); return sanitizedContent; }
public void Querystring(JsString qs = null) { // optionally pass a querystring to parse this.parameters = new JsObject<JsString>(); JsCode("this.get = Querystring_get"); if (qs == null) qs = location.search.Substring(1, location.search.length); if (qs.length == 0) return; // Turn <plus> back to <space> // See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1 qs = qs.Replace(new JsRegExp("\\+", "g"), " "); JsArray<JsString> args = qs.Split('&'); // parse out name/value pairs separated via & // split out each name=value pair for (int i = 0; i < args.length; i++) { JsString value; JsArray<JsString> pair = args[i].Split('='); JsString name = Unescape(pair[0]); if (pair.length == 2) value = Unescape(pair[1]); else value = name; this.parameters[name] = value; } }
public override void injectPotentialNode(JsString id, object node) { //Ugly hack for the moment, figure out a better way to handle by checking the identity... somehow... of this class dynamic behavior = node; if (_mediator == null && behavior.setViewData != null) { _mediator = behavior; } }
public void addView(JsString url) { if (hasView(url)) { selectView( url ); } else { addView(url, null); } }
public JsString getCachedHtmlForUri(JsString key) { if (ContentCache.htmlMergedFiles[key] != null) { return ContentCache.htmlMergedFiles[key]; } return null; }
public override JsArray<Translation> synchronousTranslate(JsString domain, JsArray<JsString> keys) { if (!fileLoaded) { makeSynchronousRequest( url ); } return provideTranslations(domain, keys); }
JsString Querystring_get(JsString key, JsString default_) { // This silly looking line changes UNDEFINED to NULL if (default_ == null) default_ = null; JsString value = this.parameters[key]; if (value == null) value = default_; return value; }
public InjectionClassBuilder buildChildClassBuilder(InjectionClassBuilder classBuilder, HtmlElement element, JsString contextClassName) { var module = (GuiceModule)classBuilder.buildClass(contextClassName); var injector = (ChildInjector)classBuilder.buildClass("guice.ChildInjector"); var guiceJs = new GuiceJs(); guiceJs.configureInjector(injector, module); //Setup a new InjectionClassBuilder return (InjectionClassBuilder)injector.getInstance(typeof(InjectionClassBuilder)); }
public void injectPotentialNode( JsString id, object node) { //if we ever want to throw an error because of a duplicate id injection, this is the place to do it //right now first one in wins if (viableInjectionPoints[id] != null) { JsContext.delete( viableInjectionPoints[ id ] ); dynamic instance = this; instance[ id ] = node; } }
/* statMobi Analytics */ /// <summary> /// This sample function records an event ID, as well as an optional /// set of name/value pairs as a query string to the statMobi Analytics /// logs. /// </summary> /// <param name="eventID"></param> /// <param name="queryString"></param> public static void AddAnalyticsDataPoint(JsString eventID, JsString queryString) { try { if (queryString == null) { queryString = ""; } Xdk.analytics.LogPageEvent("/application/" + eventID + ".event", queryString, "", GetPost.GET, 0, "index.html"); } catch (JsError e) { } }
public void addBehaviorEntry(JsString cssClassName, JsString behaviorType, JsString className ) { StyleExtensionMapEntry attributes = hashMap[cssClassName]; if (attributes == null) { attributes = new StyleExtensionMapEntry(); hashMap[cssClassName] = attributes; } attributes.addExtensionType(behaviorType, className); }
public bool hasView(JsString url) { jQuery fragment = null; var allFragments = decoratedNode.children(); if ( allFragments.length > 0 ) { fragment = allFragments.find("[data-url='" + url + "']"); } return ((fragment != null) && fragment.length>0); }
public void addCSSEntry(JsString cssSelector, JsString extensionType, JsString extensionValue ) { StyleExtensionMapEntry attributes = hashMap[cssSelector]; if (attributes == null) { attributes = new StyleExtensionMapEntry(); hashMap[cssSelector] = attributes; } attributes.addExtensionType(extensionType, extensionValue); }
public virtual void injectPotentialNode( JsString id, object node) { //by default dont inject if we dont have an id... we would have no way to reference it //if we ever want to throw an error because of a duplicate id injection, this is the place to do it //right now first one in wins if ((id != null) && (viableInjectionPoints != null ) && (viableInjectionPoints[id] != null)) { JsContext.delete( viableInjectionPoints[ id ] ); dynamic instance = this; instance[ id ] = node; } }
public static JsString addTimeToUrl(JsString url) { if (-1 == url.indexOf("?")) { url += "?" + "time=" + (new JsDate()).getTime(); } else { url += "&" + "time=" + (new JsDate()).getTime(); } return url; }
public static void PrependToLog(HtmlElement log, JsString message) { HtmlDivElement child = new HtmlDivElement(); child.innerHTML = message; if (log.firstChild == null) { log.AppendChild(child); } else { log.InsertBefore(child, log.firstChild); } }
public JsString synchronousLoad(JsString fragmentURL) { //We need to check to see if we already have this content. If we do not, then we need to load it now and insert it into the DOM var request = new XMLHttpRequest(); request.open("GET", fragmentURL, false); request.send(""); if (request.status == 404) { throw new JsError("Cannot continue, missing required content " + fragmentURL); } return request.responseText; }
public void SendGet(string type, JsString url, JsAction<object, JsString, jqXHR> success, JsAction<JsError, JsString, jqXHR> failed) { url = addTimeToUrl(url); JsObject headers = new JsObject(); jQuery.ajax(new AjaxSettings { type = "GET", dataType = type, url = jsUtils.inst.getLocation() + "/" + url, headers = headers, success = delegate(object o, JsString s, jqXHR arg3) { success(o, s, arg3); }, error = delegate(jqXHR xhr, JsString s, JsError arg3) { failed(arg3, s, xhr); } }); }
public override JsArray<Translation> synchronousTranslate(JsString domain, JsArray<JsString> keys) { var domainKeys = translations[domain]; var response = new JsArray<Translation>(); if ( domainKeys != null ) { for ( var i=0; i<keys.length;i++) { var translation = new Translation(); translation.key = keys[i]; translation.value = domainKeys[keys[i]]; response.push(translation); } } return response; }
public override void translate(JsString domain, JsArray<JsString> keys) { if (!fileLoaded) { makeAsynchronousRequest(url, delegate() { //The data is back, translate JsArray<Translation> translations = provideTranslations(domain, keys); if (translationResult != null ) { translationResult(domain, translations); } } ); } else { //We already have the file, so just translate JsArray<Translation> translations = provideTranslations(domain, keys); if (translationResult != null) { translationResult(domain, translations); } } }
public AbstractBehavior buildBehavior(InjectionClassBuilder classBuilder, HtmlElement element, JsString behaviorClassName ) { AbstractBehavior behavior = null; var resolution = classResolver.resolveClassName(behaviorClassName); if ( resolution.builtIn ) { /** If we have a type which was not created via Randori, we send it out to get created. In this way * we dont worry about injection data and we allow for any crazy creation mechanism the client can * consider **/ behavior = externalBehaviorFactory.createExternalBehavior(element, behaviorClassName, resolution.type); } else { behavior = (AbstractBehavior)classBuilder.buildClass(behaviorClassName); behavior.provideDecoratedElement(element); } return behavior; }
public static void Show(JsString strPrompt, JsString strTitle, JsString strOKPrompt, JsString strCancelPrompt, JsString OKFunction, JsString CancelFunction) { //Defaults if (strPrompt == null) { strPrompt = "Would you like to confirm or cancel this action?"; } if (strTitle == null) { strTitle = "Confirmation"; } if (strOKPrompt == null) { strOKPrompt = "Confirm"; } if (strCancelPrompt == null) { strCancelPrompt = "Cancel"; } //create the hidden DIV to hold the confirmation box on load if (divConfirmationBox == null) { divConfirmationBox = new HtmlDivElement(); divConfirmationBox.id = "divConfirmatonPopup"; divConfirmationBox.style.display = "none"; divConfirmationBox.style.backgroundColor = "#333"; divConfirmationBox.style.textAlign = "center"; divConfirmationBox.style.position = "absolute"; divConfirmationBox.style.width = "1px"; divConfirmationBox.style.height = "1px"; divConfirmationBox.style.top = "312px"; divConfirmationBox.style.left = "84px"; divConfirmationBox.style.opacity = ".8"; divConfirmationBox.style.border = "solid 3px #aaa"; divConfirmationBox.style.fontSize = "24px"; divConfirmationBox.style.overflow = "hidden"; // divConfirmationBox.style.borderRadius = "30px"; divConfirmationBox.SetAttribute("style", "border-radius:30px"); HtmlBodyElement.GetByTagName()[0].AppendChild(divConfirmationBox); } //set the confirmation box actions confirmationBox_OKCall = OKFunction; confirmationBox_CancelCall = CancelFunction; JsString tmpPopupHTML = "<table width='600' height='400'><tr><td colspan='2' valign='top'><span style='font-size:32pt;font-weight:bold;'>" + strTitle + "</span></td></tr><tr><td colspan='2' valign='middle'>" + strPrompt + "</td></tr>"; tmpPopupHTML += "<tr><td valign='bottom' align='middle' width='50%' ontouchstart='eval(confirmationBox_OKCall);confirmationBox_hide();' ><div style='border-radius:30px;opacity:.95;border: solid 3px #aaa;background-color:#000;width:250px;font-size:28pt;font-weight:bold;padding-top:30px;padding-bottom:30px;margin-bottom:15px;'>" + strOKPrompt + "</div></td>"; tmpPopupHTML += "<td valign='bottom' align='middle' width='50%' ontouchstart='eval(confirmationBox_CancelCall);confirmationBox_hide();'><div style='border-radius:30px;opacity:.95;border: solid 3px #aaa;background-color:#000;width:250px;font-size:28pt;font-weight:bold;padding-top:30px;padding-bottom:30px;margin-bottom:15px;'>" + strCancelPrompt + "</div></td></tr></table>"; HtmlDivElement.GetById("divConfirmatonPopup").innerHTML = tmpPopupHTML; HtmlDivElement.GetById("divConfirmatonPopup").style.width = "600px"; HtmlDivElement.GetById("divConfirmatonPopup").style.height = "400px"; HtmlDivElement.GetById("divConfirmatonPopup").style.display = "block"; }
public virtual string loadClass( JsString qualifiedClassName ) { JsRegExp classNameRegex = new JsRegExp("\\.", "g"); var potentialURL = qualifiedClassName.replace(classNameRegex, "/"); potentialURL = dynamicClassBaseUrl + potentialURL; potentialURL += ".js"; xmlHttpRequest.open("GET", potentialURL, false); xmlHttpRequest.send(""); //Todo Need to handle other status than just 404 if (xmlHttpRequest.status == 404) { //Todo This alert shouldnt be here, we should figure out a way to get it to the UI level HtmlContext.alert("Required Class " + qualifiedClassName + " cannot be loaded."); throw new JsError("Cannot continue, missing required class " + qualifiedClassName); } return ( xmlHttpRequest.responseText + "\n//@ sourceURL=" + potentialURL ); }
public JsString synchronousFragmentLoad(JsString fragmentURL) { //We need to check to see if we already have this content. If we do not, then we need to load it now and insert it into the DOM var cachedContent = contentCache.getCachedHtmlForUri(fragmentURL); if (cachedContent != null) { return cachedContent; } //Else load it now xmlHttpRequest.open( "GET", fragmentURL, false ); xmlHttpRequest.send( "" ); if ( xmlHttpRequest.status == 404 ) { throw new JsError("Cannot continue, missing required content " + fragmentURL); } return xmlHttpRequest.responseText; }
public void selectByURL(JsString url) { JsArray dataRef = data; dynamic item; for (int i = 0; i < dataRef.length; i++) { item = dataRef[i]; if (item.url == url) { if (selectedIndex != i) { selectedIndex = i; } break; } } }
private void addDefinition( JsString definitionText ) { JsContext.JsCode(@" var globalEval = (function () { var isIndirectEvalGlobal = (function (original, Object) { try { // Does `Object` resolve to a local variable, or to a global, built-in `Object`, // reference to which we passed as a first argument? return (1, eval)('Object') === original; } catch (err) { // if indirect eval errors out (as allowed per ES3), then just bail out with `false` return false; } })(Object, 123); if (isIndirectEvalGlobal) { // if indirect eval executes code globally, use it return function (expression) { return (1, eval)(expression); }; } else if (typeof window.execScript !== 'undefined') { // if `window.execScript exists`, use it return function (expression) { return window.execScript(expression); }; } // otherwise, globalEval is `undefined` since nothing is returned })(); globalEval(definitionText); "); }
/// <summary> /// Writes the number of times that the line of code where count was called was executed. The optional argument title will print a message in addition to the number of the count. /// </summary> /// <param name="title"></param> public static void count(JsString title) { }
/// <summary> /// Turns off the JavaScript profiler and prints its report. /// </summary> /// <param name="title"></param> public static void profileEnd(JsString title) { }
public Element GetElementById(JsString elementId) { return(default(Element)); }
/// <summary> /// Gets the menu picker associated with the passed field /// </summary> /// <param name="item"><p>The field identifier ('before', 'after', 'on')</p> /// </param> /// <returns> /// <span><see cref="Object">Object</see></span><div><p>The menu picker</p> /// </div> /// </returns> public object getPicker(JsString item) { return(null); }
/// <summary> /// Given a shortcode, returns true or false if the it is in a valid format. /// </summary> /// <param name="shortcode">the short code to validate</param> /// <returns>Boolean</returns> public static bool isValidShortCode(JsString shortcode) { return(false); }
public void SetUri(JsString uri) { }
public void SetPaint(SvgPaintType paintType, JsString uri, JsString rgbColor, JsString iccColor) { }
static SharpKit.NodeJs.http.Utils require(JsString className) { return(null); }
/// <summary> /// A synchronous output function. Will block the process and output string immediately to stderr. /// <example> /// <code> /// require('util').debug('message on stderr'); /// </code> /// </example> /// </summary> /// <param name="str"></param> /// <returns></returns> public JsString debug(JsString str) { return(null); }
/// <summary> /// Returns a formatted string using the first argument as a printf-like format. /// </summary> /// <param name="format">The format argument is a string that contains zero or more placeholders. Each placeholder is replaced with the converted value from its corresponding argument. Supported placeholders are: /// <list type="bullet"> /// %s - String. /// %d - Number (both integer and float). /// %j - JSON. /// % - single percent sign ('%'). This does not consume an argument.</param> /// </list> /// <param name="strings"></param> /// <returns>Returns a formatted string using the first argument as a printf-like format.</returns> /// If the placeholder does not have a corresponding argument, the placeholder is not replaced. ///<example> ///<code> /// util.format('%s:%s', 'foo'); // 'foo:%s' ///</code> /// If there are more arguments than placeholders, the extra arguments are converted to strings with util.inspect() and these strings are concatenated, delimited by a space. /// <code> /// util.format('%s:%s', 'foo', 'bar', 'baz'); /// 'foo:bar baz' /// </code> /// If the first argument is not a format string then util.format() returns a string that is the concatenation of all its arguments separated by spaces. Each argument is converted to a string with util.inspect(). /// <code> /// util.format(1, 2, 3); // '1 2 3' /// </code> /// </example> public JsString format(JsString format, params JsString[] strings) { return(null); }
/// <summary> /// Output with timestamp on stdout. /// <example> /// <code>require('util').log('Timestamped message.');</code> /// </example> /// </summary> /// <param name="str"></param> /// <returns></returns> public JsString log(JsString str) { return(null); }
protected FunctionInstance( Engine engine, JsString name) : this(engine, name, FunctionThisMode.Global, ObjectClass.Function) { }
public NodeList GetElementsByTagNameNS(JsString namespaceURI, JsString localName) { return(default(NodeList)); }
public IDBOpenDBRequest Open(JsString name) { return(default(IDBOpenDBRequest)); }
/// <summary> /// Create a new PatternLayout /// </summary> /// <param name="pattern">The conversion pattern string to use</param> public PatternLayout(JsString pattern) { }
public object buildClass(JsString className) { TypeDefinition type = classResolver.resolveClassName(className); return(injector.getInstance(type)); }
public bool hasView(JsString url) { return(views[url] != null); }
/// <summary> /// Given a phone number, returns true or false if the phone number is in a valid format. /// </summary> /// <param name="phone">the phone number to validate</param> /// <returns>Boolean</returns> public static bool isValidPhoneNumber(JsString phone) { return(false); }
/// <summary> /// Given a phone number, returns the phone number with all characters, other than numbers, stripped /// </summary> /// <param name="phone">he phone number to normalize</param> /// <returns>the normalized phone number</returns> public static JsString normalizePhoneNumber(JsString phone) { return(null); }
/// <summary> /// This helper routine will return a properly formatted URL to the SDK routine which will provide the source content (image, text, etc) for the specified message number and part. /// </summary> /// <param name="messageId">The message id of the message</param> /// <param name="partNumber">The part number to retrieve</param> /// <returns>The source URL which returns the content of the message part along with appropriate content headers.</returns> public static JsString getContentSrc(JsString messageId, JsString partNumber) { return(null); }
protected static void postMessage(object message, JsString targetOrigin, MessagePort[] ports) { }
/// <summary> /// Aligns this floating Component to the specified element ... /// </summary> public Ext.Component alignTo(object element, JsString position, JsArray offsets = null) { return(null); }
/// <summary> /// Given an email, returns true or false if the it is in a valid format. /// </summary> /// <param name="email">the email to validate</param> /// <returns>Boolean</returns> public static bool isValidEmail(JsString email) { return(false); }
public void selectView(JsString url) { selectView(url, null); }
public void ResolveLocalFileSystemUrl(JsString url, EntryCallback successCallback, FileErrorCallback errorCallback = null) { }
public NodeList GetElementsByClassName(JsString className) { return(default(NodeList)); }
public new void RemoveEventListener(JsString type, EventListener listener, bool useCapture = false) { }
/// <summary> /// Stops a timer created by a call to console.time(name) and writes the time elapsed. /// </summary> /// <param name="name"></param> public static void timeEnd(JsString name) { }
/// <summary> /// Get and return the date menu picker value /// </summary> /// <param name="item"><p>The field identifier ('before', 'after', 'on')</p> /// </param> /// <returns> /// <span><see cref="Date">Date</see></span><div><p>Gets the current selected value of the date field</p> /// </div> /// </returns> public JsDate getFieldValue(JsString item) { return(null); }
public NodeList GetElementsByTagName(JsString tagName) { return(default(NodeList)); }