Created
July 26, 2013 15:01
-
-
Save nau/6089585 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.jscala._ | |
object JScalaExample { | |
def main(args: Array[String]) { | |
val js = javascript { | |
window.setTimeout(() => { | |
val r = new RegExp("d.*", "g") | |
def func(i: String) = r.exec(i) | |
val list = document.getElementById("myList2") | |
val map = collection.mutable.Map[String, String]() | |
if (typeof(map) == "string") { | |
for (idx <- 0 until list.attributes.length) { | |
val attr = list.attributes.item(idx).asInstanceOf[Attribute] | |
map(attr.name) = func(attr.textContent).asInstanceOf[String] | |
} | |
} else { | |
val obj = new { | |
val field = 1 | |
def func2(i: Int) = "string" | |
} | |
val links = Array("https://github.com/nau/scala") | |
for (link <- links) { | |
include("var raw = 'JavaScript'") | |
console.log(link + obj.func2(obj.field)) | |
} | |
window.location.href = links(0).replace("scala", "jscala") | |
} | |
}, 1000) | |
} | |
println(js.asString) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment